提交 | 用户 | 时间
|
a477ef
|
1 |
package com.iailab.module.data.channel.opcda.controller.admin; |
9d7e02
|
2 |
|
aecc49
|
3 |
import com.iailab.framework.common.pojo.CommonResult; |
L |
4 |
import com.iailab.framework.common.pojo.PageResult; |
|
5 |
import com.iailab.framework.common.util.object.BeanUtils; |
9d7e02
|
6 |
import com.iailab.module.data.channel.opcda.entity.ChannelOPCDATagEntity; |
潘 |
7 |
import com.iailab.module.data.channel.opcda.service.ChannelOPCDATagService; |
aecc49
|
8 |
import com.iailab.module.data.channel.opcda.vo.OpcDaTagPageReqVO; |
L |
9 |
import com.iailab.module.data.channel.opcda.vo.OpcDaTagRespVO; |
9d7e02
|
10 |
import com.iailab.module.data.common.exception.RRException; |
潘 |
11 |
import org.springframework.beans.factory.annotation.Autowired; |
a477ef
|
12 |
import org.springframework.security.access.prepost.PreAuthorize; |
9d7e02
|
13 |
import org.springframework.web.bind.annotation.*; |
潘 |
14 |
import org.springframework.web.multipart.MultipartFile; |
|
15 |
|
aecc49
|
16 |
import javax.validation.Valid; |
L |
17 |
import java.util.Date; |
9d7e02
|
18 |
import java.util.UUID; |
aecc49
|
19 |
|
L |
20 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
9d7e02
|
21 |
|
潘 |
22 |
/** |
|
23 |
* 操作OPCDA tag配置 |
aecc49
|
24 |
* @author lirm |
L |
25 |
* @Description |
|
26 |
* @createTime 2024年08月26日 |
9d7e02
|
27 |
*/ |
潘 |
28 |
@RestController |
aecc49
|
29 |
@RequestMapping("/data/channel/opcda/tag") |
9d7e02
|
30 |
public class ChannelOPCDATagController { |
潘 |
31 |
@Autowired |
|
32 |
private ChannelOPCDATagService channelOPCDATagService; |
a477ef
|
33 |
|
潘 |
34 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") |
aecc49
|
35 |
@GetMapping("page") |
L |
36 |
public CommonResult<PageResult<OpcDaTagRespVO>> list(@Valid OpcDaTagPageReqVO reqVO) { |
|
37 |
PageResult<ChannelOPCDATagEntity> page = channelOPCDATagService.queryPage(reqVO); |
|
38 |
return success(BeanUtils.toBean(page, OpcDaTagRespVO.class)); |
9d7e02
|
39 |
} |
aecc49
|
40 |
|
a477ef
|
41 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:query')") |
9d7e02
|
42 |
@GetMapping("/info/{id}") |
aecc49
|
43 |
public CommonResult<ChannelOPCDATagEntity> info(@PathVariable("id") String id) { |
L |
44 |
ChannelOPCDATagEntity info = channelOPCDATagService.info(id); |
|
45 |
return success(info); |
9d7e02
|
46 |
} |
aecc49
|
47 |
|
a477ef
|
48 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:create')") |
潘 |
49 |
@PostMapping("/create") |
|
50 |
public CommonResult<Boolean> create(@RequestBody ChannelOPCDATagEntity channelOPCDATagEntity) { |
aecc49
|
51 |
String id = UUID.randomUUID().toString(); |
L |
52 |
channelOPCDATagEntity.setId(id); |
|
53 |
channelOPCDATagEntity.setCreateTime(new Date()); |
|
54 |
channelOPCDATagService.add(channelOPCDATagEntity); |
|
55 |
return success(true); |
9d7e02
|
56 |
} |
潘 |
57 |
|
a477ef
|
58 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:update')") |
aecc49
|
59 |
@PutMapping("/update") |
L |
60 |
public CommonResult<Boolean> update(@RequestBody ChannelOPCDATagEntity channelOPCDATagEntity) { |
|
61 |
channelOPCDATagEntity.setUpdateTime(new Date()); |
9d7e02
|
62 |
channelOPCDATagService.update(channelOPCDATagEntity); |
aecc49
|
63 |
return success(true); |
9d7e02
|
64 |
} |
潘 |
65 |
|
a477ef
|
66 |
@PreAuthorize("@ss.hasPermission('data:channel-opcua:delete')") |
aecc49
|
67 |
@DeleteMapping("/delete") |
L |
68 |
public CommonResult<Boolean> delete(@RequestParam("id") String id) { |
9d7e02
|
69 |
channelOPCDATagService.delete(id); |
aecc49
|
70 |
return success(true); |
9d7e02
|
71 |
} |
a477ef
|
72 |
|
9d7e02
|
73 |
@PostMapping("/import/{serverId}") |
aecc49
|
74 |
public CommonResult<String> importTag(@PathVariable("serverId") String serverId, @RequestParam("file") MultipartFile file) { |
9d7e02
|
75 |
try { |
潘 |
76 |
if (file.isEmpty()) { |
|
77 |
throw new RRException("上传文件不能为空"); |
|
78 |
} |
|
79 |
channelOPCDATagService.importTag(serverId, file); |
|
80 |
} catch (Exception ex) { |
aecc49
|
81 |
ex.getMessage(); |
9d7e02
|
82 |
} |
aecc49
|
83 |
return success("上传成功"); |
9d7e02
|
84 |
} |
潘 |
85 |
} |