提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.channel.opcua.controller.admin; |
H |
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; |
a6de49
|
6 |
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
H |
7 |
import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; |
aecc49
|
8 |
import com.iailab.module.data.channel.opcua.vo.OpcUaTagPageReqVO; |
L |
9 |
import com.iailab.module.data.channel.opcua.vo.OpcUaTagRespVO; |
a6de49
|
10 |
import org.springframework.web.bind.annotation.*; |
H |
11 |
|
aecc49
|
12 |
import javax.annotation.Resource; |
L |
13 |
import javax.validation.Valid; |
|
14 |
import java.util.Date; |
a6de49
|
15 |
import java.util.UUID; |
aecc49
|
16 |
|
L |
17 |
import static com.iailab.framework.common.pojo.CommonResult.success; |
a6de49
|
18 |
|
H |
19 |
/** |
|
20 |
* 操作opcua tag配置 |
aecc49
|
21 |
* @author lirm |
L |
22 |
* @Description |
|
23 |
* @createTime 2024年08月26日 |
a6de49
|
24 |
*/ |
H |
25 |
@RestController |
|
26 |
@RequestMapping("/data/channel/opcua/tag") |
|
27 |
public class ChannelOPCUATagController { |
|
28 |
@Resource |
|
29 |
private ChannelOPCUATagService channelOpcuaTagService; |
|
30 |
|
aecc49
|
31 |
@GetMapping("page") |
L |
32 |
public CommonResult<PageResult<OpcUaTagRespVO>> list(@Valid OpcUaTagPageReqVO reqVO) { |
|
33 |
PageResult<ChannelOPCUATagEntity> page = channelOpcuaTagService.queryPage(reqVO); |
|
34 |
return success(BeanUtils.toBean(page, OpcUaTagRespVO.class)); |
a6de49
|
35 |
} |
aecc49
|
36 |
|
a6de49
|
37 |
@GetMapping("/info/{id}") |
aecc49
|
38 |
public CommonResult<ChannelOPCUATagEntity> info(@PathVariable("id") String id) { |
L |
39 |
ChannelOPCUATagEntity info = channelOpcuaTagService.info(id); |
|
40 |
return success(info); |
a6de49
|
41 |
} |
aecc49
|
42 |
|
a6de49
|
43 |
@PostMapping("/add") |
aecc49
|
44 |
public CommonResult<Boolean> add(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { |
L |
45 |
String id = UUID.randomUUID().toString(); |
|
46 |
channelOPCUATagEntity.setId(id); |
|
47 |
channelOPCUATagEntity.setCreateTime(new Date()); |
|
48 |
channelOpcuaTagService.add(channelOPCUATagEntity); |
|
49 |
return success(true); |
a6de49
|
50 |
} |
H |
51 |
|
aecc49
|
52 |
@PutMapping("/update") |
L |
53 |
public CommonResult<Boolean> update(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { |
|
54 |
channelOPCUATagEntity.setUpdateTime(new Date()); |
a6de49
|
55 |
channelOpcuaTagService.update(channelOPCUATagEntity); |
aecc49
|
56 |
return success(true); |
a6de49
|
57 |
} |
H |
58 |
|
aecc49
|
59 |
@DeleteMapping("/delete") |
L |
60 |
public CommonResult<Boolean> delete(@RequestParam("id") String id) { |
a6de49
|
61 |
channelOpcuaTagService.delete(id); |
aecc49
|
62 |
return success(true); |
a6de49
|
63 |
} |
H |
64 |
|
aecc49
|
65 |
// @PostMapping("/import/{device}") |
L |
66 |
// public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) { |
|
67 |
// try { |
|
68 |
// if (file.isEmpty()) { |
|
69 |
// throw new RRException("上传文件不能为空"); |
|
70 |
// } |
|
71 |
// channelOpcuaTagService.importTag(device, file); |
|
72 |
// } catch (Exception ex) { |
|
73 |
// return R.error(ex.getMessage()); |
|
74 |
// } |
|
75 |
// return R.ok(); |
|
76 |
// } |
a6de49
|
77 |
} |