提交 | 用户 | 时间
|
e4c3b0
|
1 |
package com.jcdm.main.da.opcuaconfig.controller; |
Y |
2 |
|
054abe
|
3 |
import java.util.List; |
5030f3
|
4 |
import java.util.stream.Collectors; |
dd4482
|
5 |
import javax.annotation.Resource; |
054abe
|
6 |
import javax.servlet.http.HttpServletResponse; |
Y |
7 |
|
5030f3
|
8 |
import cn.hutool.core.collection.CollUtil; |
054abe
|
9 |
import com.jcdm.main.da.opcuaconfig.domain.DaOpcuaConfig; |
0b1422
|
10 |
import com.jcdm.main.da.opcuaconfig.domain.NodeEntity; |
054abe
|
11 |
import com.jcdm.main.da.opcuaconfig.service.IDaOpcuaConfigService; |
04b8ef
|
12 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
Y |
13 |
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
|
14 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
dd4482
|
15 |
import com.jcdm.main.da.tileMatchCollection.domain.DaTileMatchCollection; |
Y |
16 |
import com.jcdm.main.da.tileMatchCollection.service.IDaTileMatchCollectionService; |
5030f3
|
17 |
import com.jcdm.main.da.tileMatchMiddleware.domain.DaTileMatchMiddleware; |
Y |
18 |
import com.jcdm.main.da.tileMatchMiddleware.service.IDaTileMatchMiddlewareService; |
|
19 |
import com.jcdm.main.da.tileMatchRules.domain.DaTileMatchRules; |
|
20 |
import com.jcdm.main.da.tileMatchRules.service.IDaTileMatchRulesService; |
d4f437
|
21 |
import com.jcdm.main.plcserver.sub.OPCUaSubscription; |
Y |
22 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
054abe
|
23 |
import org.springframework.security.access.prepost.PreAuthorize; |
Y |
24 |
import org.springframework.beans.factory.annotation.Autowired; |
|
25 |
import org.springframework.web.bind.annotation.GetMapping; |
|
26 |
import org.springframework.web.bind.annotation.PostMapping; |
|
27 |
import org.springframework.web.bind.annotation.PutMapping; |
|
28 |
import org.springframework.web.bind.annotation.DeleteMapping; |
|
29 |
import org.springframework.web.bind.annotation.PathVariable; |
|
30 |
import org.springframework.web.bind.annotation.RequestBody; |
|
31 |
import org.springframework.web.bind.annotation.RequestMapping; |
|
32 |
import org.springframework.web.bind.annotation.RestController; |
e4c3b0
|
33 |
import com.jcdm.common.annotation.Log; |
Y |
34 |
import com.jcdm.common.core.controller.BaseController; |
|
35 |
import com.jcdm.common.core.domain.AjaxResult; |
|
36 |
import com.jcdm.common.enums.BusinessType; |
|
37 |
import com.jcdm.common.utils.poi.ExcelUtil; |
054abe
|
38 |
import com.jcdm.common.core.page.TableDataInfo; |
e4c3b0
|
39 |
|
04b8ef
|
40 |
import static com.jcdm.main.plcserver.sub.OPCUaSubscription.miloService; |
Y |
41 |
|
e4c3b0
|
42 |
/** |
054abe
|
43 |
* 交互信号配置Controller |
e4c3b0
|
44 |
* |
Y |
45 |
* @author yyt |
28cd73
|
46 |
* @date 2024-01-23 |
e4c3b0
|
47 |
*/ |
Y |
48 |
@RestController |
|
49 |
@RequestMapping("/da/opcuaconfig") |
|
50 |
public class DaOpcuaConfigController extends BaseController |
|
51 |
{ |
|
52 |
@Autowired |
|
53 |
private IDaOpcuaConfigService daOpcuaConfigService; |
5030f3
|
54 |
@Autowired |
04b8ef
|
55 |
private IDaParamCollectionService daParamCollectionService; |
5030f3
|
56 |
@Autowired |
Y |
57 |
private IDaTileMatchRulesService daTileMatchRulesService; |
|
58 |
@Autowired |
|
59 |
private IDaTileMatchMiddlewareService daTileMatchMiddlewareService; |
dd4482
|
60 |
@Resource |
Y |
61 |
private IDaTileMatchCollectionService daTileMatchCollectionService; |
e4c3b0
|
62 |
|
Y |
63 |
/** |
054abe
|
64 |
* 查询交互信号配置列表 |
e4c3b0
|
65 |
*/ |
Y |
66 |
@PreAuthorize("@ss.hasPermi('da:opcuaconfig:list')") |
|
67 |
@GetMapping("/list") |
|
68 |
public TableDataInfo list(DaOpcuaConfig daOpcuaConfig) |
|
69 |
{ |
|
70 |
startPage(); |
|
71 |
List<DaOpcuaConfig> list = daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig); |
|
72 |
return getDataTable(list); |
|
73 |
} |
|
74 |
|
|
75 |
/** |
054abe
|
76 |
* 导出交互信号配置列表 |
e4c3b0
|
77 |
*/ |
Y |
78 |
@PreAuthorize("@ss.hasPermi('da:opcuaconfig:export')") |
054abe
|
79 |
@Log(title = "交互信号配置", businessType = BusinessType.EXPORT) |
e4c3b0
|
80 |
@PostMapping("/export") |
Y |
81 |
public void export(HttpServletResponse response, DaOpcuaConfig daOpcuaConfig) |
|
82 |
{ |
|
83 |
List<DaOpcuaConfig> list = daOpcuaConfigService.selectDaOpcuaConfigList(daOpcuaConfig); |
|
84 |
ExcelUtil<DaOpcuaConfig> util = new ExcelUtil<DaOpcuaConfig>(DaOpcuaConfig.class); |
054abe
|
85 |
util.exportExcel(response, list, "交互信号配置数据"); |
e4c3b0
|
86 |
} |
Y |
87 |
|
|
88 |
/** |
054abe
|
89 |
* 获取交互信号配置详细信息 |
e4c3b0
|
90 |
*/ |
Y |
91 |
@PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')") |
|
92 |
@GetMapping(value = "/{id}") |
|
93 |
public AjaxResult getInfo(@PathVariable("id") Long id) |
|
94 |
{ |
|
95 |
return success(daOpcuaConfigService.selectDaOpcuaConfigById(id)); |
|
96 |
} |
|
97 |
|
|
98 |
/** |
054abe
|
99 |
* 新增交互信号配置 |
e4c3b0
|
100 |
*/ |
Y |
101 |
@PreAuthorize("@ss.hasPermi('da:opcuaconfig:add')") |
054abe
|
102 |
@Log(title = "交互信号配置", businessType = BusinessType.INSERT) |
e4c3b0
|
103 |
@PostMapping |
Y |
104 |
public AjaxResult add(@RequestBody DaOpcuaConfig daOpcuaConfig) |
|
105 |
{ |
|
106 |
return toAjax(daOpcuaConfigService.insertDaOpcuaConfig(daOpcuaConfig)); |
|
107 |
} |
|
108 |
|
|
109 |
/** |
054abe
|
110 |
* 修改交互信号配置 |
e4c3b0
|
111 |
*/ |
Y |
112 |
@PreAuthorize("@ss.hasPermi('da:opcuaconfig:edit')") |
054abe
|
113 |
@Log(title = "交互信号配置", businessType = BusinessType.UPDATE) |
e4c3b0
|
114 |
@PutMapping |
Y |
115 |
public AjaxResult edit(@RequestBody DaOpcuaConfig daOpcuaConfig) |
|
116 |
{ |
|
117 |
return toAjax(daOpcuaConfigService.updateDaOpcuaConfig(daOpcuaConfig)); |
|
118 |
} |
|
119 |
|
|
120 |
/** |
054abe
|
121 |
* 删除交互信号配置 |
e4c3b0
|
122 |
*/ |
Y |
123 |
@PreAuthorize("@ss.hasPermi('da:opcuaconfig:remove')") |
054abe
|
124 |
@Log(title = "交互信号配置", businessType = BusinessType.DELETE) |
e4c3b0
|
125 |
@DeleteMapping("/{ids}") |
Y |
126 |
public AjaxResult remove(@PathVariable Long[] ids) |
|
127 |
{ |
|
128 |
return toAjax(daOpcuaConfigService.deleteDaOpcuaConfigByIds(ids)); |
|
129 |
} |
0b1422
|
130 |
|
Y |
131 |
/** |
|
132 |
* 获取交互信号配置详细信息 |
|
133 |
*/ |
|
134 |
@PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')") |
|
135 |
@GetMapping(value = "/SNCode/{SNCode}/{locationCode}") |
|
136 |
public AjaxResult setSNCode(@PathVariable("SNCode") String SNCode,@PathVariable("locationCode") String locationCode) { |
d4f437
|
137 |
ReadWriteEntity entity = new ReadWriteEntity("CFL4HX."+locationCode+".SNCode", SNCode); |
Y |
138 |
Boolean out= true; |
0b1422
|
139 |
try { |
04b8ef
|
140 |
miloService.writeToOpcUa(entity);//写SN |
Y |
141 |
} catch (Exception e) { |
|
142 |
throw new RuntimeException(e); |
|
143 |
} |
|
144 |
return toAjax(out); |
|
145 |
} |
|
146 |
|
|
147 |
/** |
|
148 |
* 配瓦扫码 |
|
149 |
*/ |
|
150 |
@PreAuthorize("@ss.hasPermi('da:opcuaconfig:query')") |
5030f3
|
151 |
@GetMapping(value = "/barcode1") |
Y |
152 |
public DaParamCollection setBarcode1(String barcode,String locationCode) { |
|
153 |
Boolean out = true; |
|
154 |
DaParamCollection xParamCollection = null; |
04b8ef
|
155 |
try { |
5030f3
|
156 |
Object SNCodeObject = miloService.readFromOpcUa("CFL4HX." + locationCode + ".Code1").getValue(); |
Y |
157 |
if (null == SNCodeObject) { |
|
158 |
SNCodeObject = miloService.readFromOpcUa("CFL4HX." + locationCode + ".Code").getValue(); |
04b8ef
|
159 |
} |
5030f3
|
160 |
if (null != SNCodeObject) { |
04b8ef
|
161 |
String SNCode = SNCodeObject.toString(); |
Y |
162 |
//插入数据 |
|
163 |
DaParamCollection saveData = new DaParamCollection(); |
|
164 |
saveData.setSfcCode(SNCode); |
|
165 |
saveData.setParamValue(barcode); |
|
166 |
saveData.setLocationCode(locationCode); |
1c7036
|
167 |
saveData.setParamCode("CZM"); |
5030f3
|
168 |
saveData.setParamName("曲轴"); |
04b8ef
|
169 |
daParamCollectionService.insertDaParamCollection(saveData); |
5030f3
|
170 |
|
dd4482
|
171 |
DaTileMatchCollection MatchCollection = new DaTileMatchCollection(); |
Y |
172 |
MatchCollection.setSfcCode(SNCode); |
|
173 |
MatchCollection.setParamValue(barcode); |
|
174 |
MatchCollection.setLocationCode(locationCode); |
|
175 |
MatchCollection.setParamCode("CZM"); |
|
176 |
MatchCollection.setParamName("曲轴"); |
|
177 |
daTileMatchCollectionService.insertDaTileMatchCollection(MatchCollection); |
|
178 |
|
5030f3
|
179 |
DaTileMatchRules TileMatchRules = new DaTileMatchRules(); |
Y |
180 |
TileMatchRules.setProductSeries("380Y"); |
|
181 |
TileMatchRules.setScanObject1("连杆"); |
|
182 |
TileMatchRules.setScanObject2("曲轴"); |
|
183 |
daTileMatchRulesService.selectDaTileMatchRulesList(TileMatchRules); |
|
184 |
|
|
185 |
for (int i = 1; i <= 3; i++) { |
|
186 |
DaTileMatchMiddleware TileMatchMiddleware = new DaTileMatchMiddleware(); |
|
187 |
TileMatchMiddleware.setSfcCode(SNCode); |
|
188 |
TileMatchMiddleware.setCrankshaftNo(barcode); |
|
189 |
TileMatchMiddleware.setCylinder((long) i); |
|
190 |
TileMatchMiddleware.setState(1L); |
|
191 |
daTileMatchMiddlewareService.insertDaTileMatchMiddleware(TileMatchMiddleware); |
|
192 |
} |
|
193 |
|
|
194 |
DaParamCollection ParamCollection = new DaParamCollection(); |
|
195 |
ParamCollection.setSfcCode(SNCode); |
|
196 |
ParamCollection.setParamName("箱体"); |
|
197 |
List<DaParamCollection> DaParamCollectionlist = daParamCollectionService.selectDaParamCollectionList(ParamCollection); |
|
198 |
List<DaParamCollection> XTParamCollection = DaParamCollectionlist.stream().filter(x -> "箱体".equals(x.getParamName())).collect(Collectors.toList()); |
|
199 |
if (CollUtil.isNotEmpty(XTParamCollection)) { |
|
200 |
xParamCollection = XTParamCollection.get(0); |
|
201 |
} |
04b8ef
|
202 |
} |
0b1422
|
203 |
} catch (Exception e) { |
Y |
204 |
throw new RuntimeException(e); |
|
205 |
} |
5030f3
|
206 |
return xParamCollection; |
0b1422
|
207 |
} |
e4c3b0
|
208 |
} |