yyt
2024-06-26 0cceb649e1dc443c2a91d26d81eacb0867c96db3
提交 | 用户 | 时间
0cceb6 1 package com.jcdm.main.da.opcuaconfig.controller;
Y 2
3 import java.util.List;
4 import javax.servlet.http.HttpServletResponse;
5
6 import com.jcdm.main.da.opcuaconfig.client.ClientHandler;
7 import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig;
8 import com.jcdm.main.da.opcuaconfig.domain.NodeEntity;
9 import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService;
10 import org.springframework.security.access.prepost.PreAuthorize;
11 import org.springframework.beans.factory.annotation.Autowired;
12 import org.springframework.web.bind.annotation.GetMapping;
13 import org.springframework.web.bind.annotation.PostMapping;
14 import org.springframework.web.bind.annotation.PutMapping;
15 import org.springframework.web.bind.annotation.DeleteMapping;
16 import org.springframework.web.bind.annotation.PathVariable;
17 import org.springframework.web.bind.annotation.RequestBody;
18 import org.springframework.web.bind.annotation.RequestMapping;
19 import org.springframework.web.bind.annotation.RestController;
20 import com.jcdm.common.annotation.Log;
21 import com.jcdm.common.core.controller.BaseController;
22 import com.jcdm.common.core.domain.AjaxResult;
23 import com.jcdm.common.enums.BusinessType;
24 import com.jcdm.common.utils.poi.ExcelUtil;
25 import com.jcdm.common.core.page.TableDataInfo;
26
27 /**
28  * 交互信号配置Controller
29  * 
30  * @author yyt
31  * @date 2024-01-23
32  */
33 @RestController
34 @RequestMapping("/da/opcuaconfig")
35 public class DaOpcuaConfigController extends BaseController
36 {
37     @Autowired
38     private IDaOpcuaConfigService daOpcuaConfigService;
39
40     /**
41      * 查询交互信号配置列表
42      */
43     @PreAuthorize("@ss.hasPermi('da:opcuaconfig:list')")
44     @GetMapping("/list")
45     public TableDataInfo list(DaOpcuaConfig daOpcuaConfig)
46     {
47         startPage();
48         List<DaOpcuaConfig> list = daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig);
49         return getDataTable(list);
50     }
51
52     /**
53      * 导出交互信号配置列表
54      */
55     @PreAuthorize("@ss.hasPermi('da:opcuaconfig:export')")
56     @Log(title = "交互信号配置", businessType = BusinessType.EXPORT)
57     @PostMapping("/export")
58     public void export(HttpServletResponse response, DaOpcuaConfig daOpcuaConfig)
59     {
60         List<DaOpcuaConfig> list = daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig);
61         ExcelUtil<DaOpcuaConfig> util = new ExcelUtil<DaOpcuaConfig>(DaOpcuaConfig.class);
62         util.exportExcel(response, list, "交互信号配置数据");
63     }
64
65     /**
66      * 获取交互信号配置详细信息
67      */
68     @PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')")
69     @GetMapping(value = "/{id}")
70     public AjaxResult getInfo(@PathVariable("id") Long id)
71     {
72         return success(daOpcuaConfigService.selectDaOpcuaConfigById(id));
73     }
74
75     /**
76      * 新增交互信号配置
77      */
78     @PreAuthorize("@ss.hasPermi('da:opcuaconfig:add')")
79     @Log(title = "交互信号配置", businessType = BusinessType.INSERT)
80     @PostMapping
81     public AjaxResult add(@RequestBody DaOpcuaConfig daOpcuaConfig)
82     {
83         return toAjax(daOpcuaConfigService.insertDaOpcuaConfig(daOpcuaConfig));
84     }
85
86     /**
87      * 修改交互信号配置
88      */
89     @PreAuthorize("@ss.hasPermi('da:opcuaconfig:edit')")
90     @Log(title = "交互信号配置", businessType = BusinessType.UPDATE)
91     @PutMapping
92     public AjaxResult edit(@RequestBody DaOpcuaConfig daOpcuaConfig)
93     {
94         return toAjax(daOpcuaConfigService.updateDaOpcuaConfig(daOpcuaConfig));
95     }
96
97     /**
98      * 删除交互信号配置
99      */
100     @PreAuthorize("@ss.hasPermi('da:opcuaconfig:remove')")
101     @Log(title = "交互信号配置", businessType = BusinessType.DELETE)
102     @DeleteMapping("/{ids}")
103     public AjaxResult remove(@PathVariable Long[] ids)
104     {
105         return toAjax(daOpcuaConfigService.deleteDaOpcuaConfigByIds(ids));
106     }
107
108     /**
109      * 获取交互信号配置详细信息
110      */
111     @PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')")
112     @GetMapping(value = "/SNCode/{SNCode}/{locationCode}")
113     public AjaxResult setSNCode(@PathVariable("SNCode") String SNCode,@PathVariable("locationCode") String locationCode) {
114         NodeEntity node= NodeEntity.builder().index(2).identifier("CFL4CVT"+"."+locationCode+".MesSNCode").value(SNCode).type("string").build();
115         Boolean out= null;
116         try {
117             out = ClientHandler.write(node);
118         } catch (Exception e) {
119             throw new RuntimeException(e);
120         }
121
122         return toAjax(out);
123     }
124 }