提交 | 用户 | 时间
|
a6de49
|
1 |
package com.iailab.module.data.channel.opcua.controller.admin; |
H |
2 |
|
4a47e4
|
3 |
import cn.hutool.core.codec.Base64; |
a6de49
|
4 |
import com.iailab.module.data.common.exception.RRException; |
H |
5 |
import com.iailab.module.data.common.utils.PageUtils; |
|
6 |
import com.iailab.module.data.common.utils.R; |
|
7 |
import com.iailab.module.data.channel.opcua.entity.ChannelOPCUATagEntity; |
|
8 |
import com.iailab.module.data.channel.opcua.service.ChannelOPCUATagService; |
|
9 |
import javax.annotation.Resource; |
|
10 |
import org.springframework.web.bind.annotation.*; |
|
11 |
import org.springframework.web.multipart.MultipartFile; |
|
12 |
|
|
13 |
import java.util.Map; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
/** |
|
17 |
* 操作opcua tag配置 |
|
18 |
* |
|
19 |
* @author DongYukun |
|
20 |
* @createTime 2023年05月6日 17:44:00 |
|
21 |
*/ |
|
22 |
@RestController |
|
23 |
@RequestMapping("/data/channel/opcua/tag") |
|
24 |
public class ChannelOPCUATagController { |
|
25 |
@Resource |
|
26 |
private ChannelOPCUATagService channelOpcuaTagService; |
|
27 |
/** |
|
28 |
* 分页查询tag |
|
29 |
* |
|
30 |
* @param params |
|
31 |
*/ |
|
32 |
@GetMapping("/list") |
|
33 |
public R tagList(@RequestParam Map<String, Object> params){ |
|
34 |
PageUtils page = channelOpcuaTagService.queryPage(params); |
|
35 |
|
|
36 |
return R.ok().put("page", page); |
|
37 |
} |
|
38 |
/** |
|
39 |
* 根据id查询tag详情 |
|
40 |
* |
|
41 |
* @param id |
|
42 |
*/ |
|
43 |
@GetMapping("/info/{id}") |
|
44 |
public R tagInfo(@PathVariable("id") String id){ |
4a47e4
|
45 |
ChannelOPCUATagEntity info= channelOpcuaTagService.info(Base64.decodeStr(id)); |
a6de49
|
46 |
return R.ok().put("data", info); |
H |
47 |
} |
|
48 |
/** |
|
49 |
* 添加tag |
|
50 |
* |
|
51 |
* @param entity |
|
52 |
*/ |
|
53 |
@PostMapping("/add") |
|
54 |
public R tagAdd(@RequestBody ChannelOPCUATagEntity entity){ |
|
55 |
entity.setId(UUID.randomUUID().toString()); |
|
56 |
channelOpcuaTagService.add(entity); |
|
57 |
return R.ok(); |
|
58 |
} |
|
59 |
|
|
60 |
/** |
|
61 |
* 修改tag |
|
62 |
* |
|
63 |
* @param channelOPCUATagEntity |
|
64 |
*/ |
|
65 |
@PostMapping("/update") |
|
66 |
public R tagUpdate(@RequestBody ChannelOPCUATagEntity channelOPCUATagEntity) { |
|
67 |
channelOpcuaTagService.update(channelOPCUATagEntity); |
|
68 |
return R.ok(); |
|
69 |
} |
|
70 |
|
|
71 |
/** |
|
72 |
* 删除tag |
|
73 |
* @param params |
|
74 |
* |
|
75 |
*/ |
|
76 |
@PostMapping("/delete") |
|
77 |
public R tagDelete(@RequestBody Map<String, Object> params) { |
|
78 |
String id = (String)params.get("id"); |
|
79 |
channelOpcuaTagService.delete(id); |
|
80 |
return R.ok(); |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* 导入 |
|
85 |
* |
|
86 |
* @param device |
|
87 |
* @param file |
|
88 |
* @return |
|
89 |
*/ |
|
90 |
@PostMapping("/import/{device}") |
|
91 |
public R importTag(@PathVariable("device") String device, @RequestParam("file") MultipartFile file) { |
|
92 |
try { |
|
93 |
if (file.isEmpty()) { |
|
94 |
throw new RRException("上传文件不能为空"); |
|
95 |
} |
|
96 |
channelOpcuaTagService.importTag(device, file); |
|
97 |
} catch (Exception ex) { |
|
98 |
return R.error(ex.getMessage()); |
|
99 |
} |
|
100 |
return R.ok(); |
|
101 |
} |
|
102 |
} |