提交 | 用户 | 时间
|
e57a89
|
1 |
package com.jcdm.main.da.paramCollection.service.impl; |
懒 |
2 |
|
6a462f
|
3 |
import cn.hutool.core.collection.CollUtil; |
b64ed2
|
4 |
import cn.hutool.core.date.DateUtil; |
237733
|
5 |
import cn.hutool.core.util.ObjectUtil; |
6a462f
|
6 |
import cn.hutool.core.util.StrUtil; |
8f0f8d
|
7 |
import cn.hutool.db.Db; |
6a462f
|
8 |
import cn.hutool.http.HttpRequest; |
W |
9 |
import cn.hutool.http.HttpResponse; |
|
10 |
import cn.hutool.json.JSONUtil; |
7bee80
|
11 |
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
0ce25f
|
12 |
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
237733
|
13 |
import com.jcdm.common.core.domain.AjaxResult; |
e57a89
|
14 |
import com.jcdm.common.utils.DateUtils; |
a60fef
|
15 |
import com.jcdm.common.utils.StringUtils; |
7bee80
|
16 |
import com.jcdm.main.bs.formula.service.IBsFormulaInfoService; |
懒 |
17 |
import com.jcdm.main.bs.formula.service.impl.BsFormulaInfoServiceImpl; |
b77c7b
|
18 |
import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
懒 |
19 |
import com.jcdm.main.bs.formulaChild.mapper.BsFormulaChildInfoMapper; |
7bee80
|
20 |
import com.jcdm.main.bs.formulaChild.service.IBsFormulaChildInfoService; |
6a462f
|
21 |
import com.jcdm.main.constant.Constants; |
b64ed2
|
22 |
import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
懒 |
23 |
import com.jcdm.main.da.collectionParamConf.mapper.DaCollectionParamConfMapper; |
5966d6
|
24 |
import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
e57a89
|
25 |
import com.jcdm.main.da.paramCollection.domain.DaParamCollection; |
懒 |
26 |
import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper; |
|
27 |
import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; |
32483a
|
28 |
import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; |
懒 |
29 |
import com.jcdm.main.da.passingStationCollection.mapper.DaPassingStationCollectionMapper; |
|
30 |
import com.jcdm.main.da.passingStationCollection.service.IDaPassingStationCollectionService; |
054a69
|
31 |
import com.jcdm.main.plcserver.sub.OPCUaSubscription; |
237733
|
32 |
import com.jcdm.main.restful.factoryMes.service.RestfulService; |
6a462f
|
33 |
import com.jcdm.main.restful.qingYan.doman.ChildVO; |
W |
34 |
import com.jcdm.main.restful.qingYan.doman.ParentVO; |
32483a
|
35 |
import com.kangaroohy.milo.model.ReadWriteEntity; |
懒 |
36 |
import com.kangaroohy.milo.service.MiloService; |
054a69
|
37 |
import org.apache.ibatis.session.ExecutorType; |
懒 |
38 |
import org.apache.ibatis.session.SqlSession; |
|
39 |
import org.apache.ibatis.session.SqlSessionFactory; |
e57a89
|
40 |
import org.springframework.beans.factory.annotation.Autowired; |
5966d6
|
41 |
import org.springframework.security.core.parameters.P; |
e57a89
|
42 |
import org.springframework.stereotype.Service; |
懒 |
43 |
|
054a69
|
44 |
import javax.annotation.Resource; |
5966d6
|
45 |
import java.text.SimpleDateFormat; |
A |
46 |
import java.time.Instant; |
b64ed2
|
47 |
import java.util.*; |
6a462f
|
48 |
import java.util.stream.Collectors; |
e57a89
|
49 |
|
懒 |
50 |
/** |
|
51 |
* 设备产品过程参数采集Service业务层处理 |
|
52 |
* |
|
53 |
* @author yyt |
|
54 |
* @date 2023-12-13 |
|
55 |
*/ |
|
56 |
@Service |
0ce25f
|
57 |
public class DaParamCollectionServiceImpl extends ServiceImpl<DaParamCollectionMapper,DaParamCollection> implements IDaParamCollectionService |
e57a89
|
58 |
{ |
懒 |
59 |
@Autowired |
|
60 |
private DaParamCollectionMapper daParamCollectionMapper; |
b64ed2
|
61 |
|
懒 |
62 |
@Autowired |
|
63 |
private DaCollectionParamConfMapper daCollectionParamConfMapper; |
b77c7b
|
64 |
|
懒 |
65 |
@Autowired |
|
66 |
private BsFormulaChildInfoMapper bsFormulaChildInfoMapper; |
7bee80
|
67 |
|
懒 |
68 |
@Autowired |
|
69 |
private IBsFormulaChildInfoService bsFormulaChildInfoService; |
32483a
|
70 |
|
懒 |
71 |
@Autowired |
|
72 |
private MiloService miloService; |
|
73 |
|
|
74 |
@Autowired |
|
75 |
private DaPassingStationCollectionMapper daPassingStationCollectionMapper; |
e57a89
|
76 |
|
054a69
|
77 |
@Resource |
懒 |
78 |
private SqlSessionFactory sqlSessionFactory; |
|
79 |
|
ddb300
|
80 |
@Autowired |
A |
81 |
private IDaParamCollectionService daParamCollectionService; |
5966d6
|
82 |
|
A |
83 |
@Autowired |
|
84 |
private IDaCollectionParamConfService daCollectionParamConfService; |
237733
|
85 |
|
A |
86 |
public SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
ddb300
|
87 |
|
e57a89
|
88 |
/** |
懒 |
89 |
* 查询设备产品过程参数采集 |
|
90 |
* |
|
91 |
* @param id 设备产品过程参数采集主键 |
|
92 |
* @return 设备产品过程参数采集 |
|
93 |
*/ |
|
94 |
@Override |
|
95 |
public DaParamCollection selectDaParamCollectionById(Long id) |
|
96 |
{ |
|
97 |
return daParamCollectionMapper.selectDaParamCollectionById(id); |
|
98 |
} |
|
99 |
|
|
100 |
/** |
|
101 |
* 查询设备产品过程参数采集列表 |
|
102 |
* |
|
103 |
* @param daParamCollection 设备产品过程参数采集 |
|
104 |
* @return 设备产品过程参数采集 |
|
105 |
*/ |
|
106 |
@Override |
|
107 |
public List<DaParamCollection> selectDaParamCollectionList(DaParamCollection daParamCollection) |
|
108 |
{ |
|
109 |
return daParamCollectionMapper.selectDaParamCollectionList(daParamCollection); |
054a69
|
110 |
} |
懒 |
111 |
|
|
112 |
@Override |
|
113 |
public void saveBeachDaParamCollection(List<DaParamCollection> list) { |
|
114 |
// ExecutorType.SIMPLE: 这个执行器类型不做特殊的事情。它为每个语句的执行创建一个新的预处理语句。 |
|
115 |
// ExecutorType.REUSE: 这个执行器类型会复用预处理语句。 |
|
116 |
// ExecutorType.BATCH: 这个执行器会批量执行所有更新语句,如果 SELECT 在它们中间执行还会标定它们是 必须的,来保证一个简单并易于理解的行为。 |
|
117 |
|
|
118 |
// 关闭session的自动提交 |
|
119 |
SqlSession sqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false); |
|
120 |
try { |
|
121 |
DaParamCollectionMapper userMapper = sqlSession.getMapper(DaParamCollectionMapper.class); |
|
122 |
list.stream().forEach(DaParamCollection -> userMapper.insertDaParamCollection(DaParamCollection)); |
|
123 |
// 提交数据 |
|
124 |
sqlSession.commit(); |
|
125 |
sqlSession.rollback(); |
|
126 |
} catch (Exception e) { |
|
127 |
sqlSession.rollback(); |
|
128 |
} finally { |
|
129 |
sqlSession.close(); |
|
130 |
} |
e57a89
|
131 |
} |
懒 |
132 |
|
|
133 |
/** |
|
134 |
* 新增设备产品过程参数采集 |
|
135 |
* |
|
136 |
* @param daParamCollection 设备产品过程参数采集 |
|
137 |
* @return 结果 |
|
138 |
*/ |
|
139 |
@Override |
|
140 |
public int insertDaParamCollection(DaParamCollection daParamCollection) |
|
141 |
{ |
|
142 |
daParamCollection.setCreateTime(DateUtils.getNowDate()); |
|
143 |
return daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
|
144 |
} |
|
145 |
|
|
146 |
/** |
|
147 |
* 修改设备产品过程参数采集 |
|
148 |
* |
|
149 |
* @param daParamCollection 设备产品过程参数采集 |
|
150 |
* @return 结果 |
|
151 |
*/ |
|
152 |
@Override |
|
153 |
public int updateDaParamCollection(DaParamCollection daParamCollection) |
|
154 |
{ |
|
155 |
daParamCollection.setUpdateTime(DateUtils.getNowDate()); |
|
156 |
return daParamCollectionMapper.updateDaParamCollection(daParamCollection); |
|
157 |
} |
|
158 |
|
|
159 |
/** |
|
160 |
* 批量删除设备产品过程参数采集 |
|
161 |
* |
|
162 |
* @param ids 需要删除的设备产品过程参数采集主键 |
|
163 |
* @return 结果 |
|
164 |
*/ |
|
165 |
@Override |
|
166 |
public int deleteDaParamCollectionByIds(Long[] ids) |
|
167 |
{ |
|
168 |
return daParamCollectionMapper.deleteDaParamCollectionByIds(ids); |
|
169 |
} |
|
170 |
|
|
171 |
/** |
|
172 |
* 删除设备产品过程参数采集信息 |
|
173 |
* |
|
174 |
* @param id 设备产品过程参数采集主键 |
|
175 |
* @return 结果 |
|
176 |
*/ |
|
177 |
@Override |
|
178 |
public int deleteDaParamCollectionById(Long id) |
|
179 |
{ |
|
180 |
return daParamCollectionMapper.deleteDaParamCollectionById(id); |
|
181 |
} |
b64ed2
|
182 |
|
懒 |
183 |
@Override |
|
184 |
public void addBasicParameters(DaParamCollection daParamCollection) { |
|
185 |
// 假设这是从数据库或其他地方获取的参数数据 |
|
186 |
Map<String, String> map = new HashMap<>(); |
|
187 |
map.put("GC", "南浔工厂"); |
|
188 |
map.put("CXBH", "Pack线"); |
|
189 |
map.put("SBBH", "设备001"); |
|
190 |
map.put("YGBH", "员工001"); |
|
191 |
map.put("GDBH", daParamCollection.getWorkOrderNo()); |
|
192 |
map.put("CPXH", daParamCollection.getModel()); |
|
193 |
map.put("INT", DateUtil.formatDateTime(new Date())); |
|
194 |
|
|
195 |
map.forEach((key, value) -> { |
|
196 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
197 |
daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
|
198 |
daCollectionParamConf.setCollectParameterId(key); |
|
199 |
List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
|
200 |
DaParamCollection saveData = new DaParamCollection(); |
|
201 |
saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
202 |
saveData.setProductCode(daParamCollection.getProductCode()); |
|
203 |
saveData.setLocationCode(daParamCollection.getLocationCode()); |
3c2299
|
204 |
saveData.setSfcCode(daParamCollection.getProductBarcode()); |
b64ed2
|
205 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
懒 |
206 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
207 |
saveData.setCollectionTime(new Date()); |
|
208 |
saveData.setParamValue(value); |
|
209 |
daParamCollectionMapper.insertDaParamCollection(saveData); |
|
210 |
}); |
|
211 |
} |
49c784
|
212 |
|
懒 |
213 |
@Override |
|
214 |
public void addTighteningParameters(DaParamCollection daParamCollection) { |
b77c7b
|
215 |
String paramCode = daParamCollection.getParamCode(); |
a60fef
|
216 |
String tightenData = daParamCollection.getTightenTheArray(); |
A |
217 |
if(StringUtils.isNotBlank(paramCode)&&StringUtils.isNotBlank(tightenData)){ |
|
218 |
tightenData = tightenData.replace("[", "").replace("]", "").replace(" ", ""); |
|
219 |
String[] tightenDataParts = tightenData.split(","); |
|
220 |
String[] paramCodeParts = paramCode.split(","); |
|
221 |
for (int i = 0; i < paramCodeParts.length; i++) { |
|
222 |
daParamCollection.setParamValue(tightenDataParts[i]); |
|
223 |
daParamCollection.setParamCode(paramCodeParts[i]); |
|
224 |
daParamCollection.setCollectionTime(new Date()); |
|
225 |
daParamCollection.setSfcCode(daParamCollection.getProductBarcode()); |
|
226 |
daParamCollectionMapper.insertDaParamCollection(daParamCollection); |
|
227 |
} |
b77c7b
|
228 |
} |
49c784
|
229 |
} |
32483a
|
230 |
|
懒 |
231 |
@Override |
|
232 |
public void saveCampaignTimeParameters(DaParamCollection daParamCollection) { |
7bee80
|
233 |
List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() |
懒 |
234 |
.eq(BsFormulaChildInfo::getProcessesCode, daParamCollection.getLocationCode()) |
|
235 |
.eq(BsFormulaChildInfo::getSpareField4, "1") |
|
236 |
); |
237733
|
237 |
if(StringUtils.isNotBlank(list.get(0).getResults())){ |
A |
238 |
if(!list.get(0).getResults().equals("OK")){ |
|
239 |
try { |
|
240 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); |
|
241 |
} catch (Exception e) { |
|
242 |
throw new RuntimeException(e); |
|
243 |
} |
|
244 |
return; |
|
245 |
} |
|
246 |
}else { |
7bee80
|
247 |
try { |
懒 |
248 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); |
|
249 |
} catch (Exception e) { |
|
250 |
throw new RuntimeException(e); |
|
251 |
} |
|
252 |
return; |
|
253 |
} |
32483a
|
254 |
BsFormulaChildInfo bsFormulaChildInfo = new BsFormulaChildInfo(); |
懒 |
255 |
bsFormulaChildInfo.setProcessesCode(daParamCollection.getLocationCode()); |
|
256 |
bsFormulaChildInfo.setProductCode(daParamCollection.getProductCode()); |
|
257 |
bsFormulaChildInfo.setSpareField4("1"); |
|
258 |
List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo); |
|
259 |
String result = bsFormulaChildInfos.get(0).getResults(); |
|
260 |
if(result != null && !result.isEmpty()){ |
|
261 |
try { |
|
262 |
//过站参数采集记录出站时间 |
|
263 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
264 |
daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
|
265 |
daCollectionParamConf.setCollectParameterId("OUTT"); |
|
266 |
List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
|
267 |
DaParamCollection saveData = new DaParamCollection(); |
|
268 |
saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
269 |
saveData.setProductCode(daParamCollection.getProductCode()); |
|
270 |
saveData.setLocationCode(daParamCollection.getLocationCode()); |
|
271 |
saveData.setSfcCode(daParamCollection.getProductBarcode()); |
|
272 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
|
273 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
274 |
saveData.setCollectionTime(new Date()); |
|
275 |
saveData.setParamValue(DateUtil.formatDateTime(new Date())); |
|
276 |
daParamCollectionMapper.insertDaParamCollection(saveData); |
|
277 |
|
|
278 |
//更新过站记录表出站时间 |
|
279 |
DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
|
280 |
daPassingStationCollection.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
1df825
|
281 |
daPassingStationCollection.setLocationCode(daParamCollection.getLocationCode()); |
32483a
|
282 |
List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); |
懒 |
283 |
daPassingStationCollections.get(0).setOutboundTime(new Date()); |
|
284 |
int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
|
285 |
|
8f0f8d
|
286 |
// OPCUaSubscription.SaveParamData(daParamCollection.getProductBarcode(),"OP",daParamCollection.getLocationCode(),daParamCollection.getWorkOrderNo(),daParamCollection.getProductCode()); |
054a69
|
287 |
|
32483a
|
288 |
//给opc发21 |
7bee80
|
289 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); |
237733
|
290 |
if(daParamCollection.getLocationCode().equals("OP240")){ |
A |
291 |
RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(),"OP230",format.format(new Date())); |
|
292 |
} |
32483a
|
293 |
} catch (Exception e) { |
懒 |
294 |
throw new RuntimeException(e); |
|
295 |
} |
|
296 |
} |
|
297 |
} |
8f0f8d
|
298 |
|
懒 |
299 |
@Override |
|
300 |
public void insertBatch(List<DaParamCollection> confList){ |
|
301 |
try{ |
|
302 |
this.saveBatch(confList); |
|
303 |
}catch (Exception e){ |
|
304 |
return; |
|
305 |
} |
|
306 |
|
|
307 |
} |
ddb300
|
308 |
|
A |
309 |
@Override |
|
310 |
public void replaceAssemblyCode(DaParamCollection daParamCollection) { |
|
311 |
List<DaParamCollection> list = daParamCollectionService.list(new LambdaQueryWrapper<DaParamCollection>() |
2c7661
|
312 |
.eq(DaParamCollection::getSfcCode, daParamCollection.getYzSfcCode()) |
ddb300
|
313 |
); |
A |
314 |
if(list.size() > 0){ |
|
315 |
for (DaParamCollection paramCollection : list) { |
2c7661
|
316 |
paramCollection.setSfcCode(daParamCollection.getSfcCode()); |
ddb300
|
317 |
daParamCollectionService.saveOrUpdate(paramCollection); |
A |
318 |
} |
|
319 |
} |
|
320 |
|
|
321 |
} |
4a5f2a
|
322 |
|
A |
323 |
@Override |
|
324 |
public void yzAddBasicParameters(DaParamCollection daParamCollection) { |
|
325 |
// 假设这是从数据库或其他地方获取的参数数据 |
|
326 |
Map<String, String> map = new HashMap<>(); |
|
327 |
// map.put("GC", "南浔工厂"); |
|
328 |
// map.put("CXBH", "Pack线"); |
|
329 |
// map.put("SBBH", "设备001"); |
|
330 |
// map.put("YGBH", "员工001"); |
|
331 |
// map.put("GDBH", daParamCollection.getWorkOrderNo()); |
|
332 |
// map.put("CPXH", daParamCollection.getModel()); |
|
333 |
map.put("INT", DateUtil.formatDateTime(new Date())); |
|
334 |
|
|
335 |
map.forEach((key, value) -> { |
|
336 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
337 |
daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
|
338 |
daCollectionParamConf.setCollectParameterId(key); |
|
339 |
List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
|
340 |
DaParamCollection saveData = new DaParamCollection(); |
|
341 |
saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
342 |
saveData.setProductCode(daParamCollection.getProductCode()); |
|
343 |
saveData.setLocationCode(daParamCollection.getLocationCode()); |
|
344 |
saveData.setSfcCode(daParamCollection.getProductBarcode()); |
|
345 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
|
346 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
347 |
saveData.setCollectionTime(new Date()); |
|
348 |
saveData.setParamValue(value); |
|
349 |
daParamCollectionMapper.insertDaParamCollection(saveData); |
|
350 |
}); |
|
351 |
} |
1c84ae
|
352 |
|
A |
353 |
@Override |
|
354 |
public void jrmSaveCampaignTimeParameters(DaParamCollection daParamCollection) { |
|
355 |
DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); |
|
356 |
daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); |
|
357 |
daCollectionParamConf.setCollectParameterId("OUTT"); |
|
358 |
List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); |
|
359 |
DaParamCollection saveData = new DaParamCollection(); |
|
360 |
saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
361 |
saveData.setProductCode(daParamCollection.getProductCode()); |
|
362 |
saveData.setLocationCode(daParamCollection.getLocationCode()); |
|
363 |
saveData.setSfcCode(daParamCollection.getProductBarcode()); |
|
364 |
saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); |
|
365 |
saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); |
|
366 |
saveData.setCollectionTime(new Date()); |
|
367 |
saveData.setParamValue(DateUtil.formatDateTime(new Date())); |
|
368 |
daParamCollectionMapper.insertDaParamCollection(saveData); |
|
369 |
|
|
370 |
//更新过站记录表出站时间 |
|
371 |
DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); |
|
372 |
daPassingStationCollection.setWorkOrderNo(daParamCollection.getWorkOrderNo()); |
|
373 |
daPassingStationCollection.setLocationCode(daParamCollection.getLocationCode()); |
|
374 |
List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); |
|
375 |
daPassingStationCollections.get(0).setOutboundTime(new Date()); |
|
376 |
int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); |
|
377 |
|
|
378 |
// OPCUaSubscription.SaveParamData(daParamCollection.getProductBarcode(),"OP",daParamCollection.getLocationCode(),daParamCollection.getWorkOrderNo(),daParamCollection.getProductCode()); |
|
379 |
|
|
380 |
//给opc发21 |
|
381 |
try { |
|
382 |
// miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); |
1ccd69
|
383 |
String strA = daParamCollection.getLocationCode(); |
1c84ae
|
384 |
miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+strA+".RecordDataDone").value(21).build()); |
A |
385 |
} catch (Exception e) { |
|
386 |
throw new RuntimeException(e); |
|
387 |
} |
|
388 |
} |
6a462f
|
389 |
|
W |
390 |
|
|
391 |
public void sendToFactoryMes(String stationCode,String productNum ){ |
a846f2
|
392 |
// String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
A |
393 |
String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
6a462f
|
394 |
ParentVO vo =new ParentVO(); |
W |
395 |
List<ChildVO> checkList = new ArrayList<>(); |
|
396 |
List<DaParamCollection> list = this.list(new LambdaQueryWrapper<DaParamCollection>() |
|
397 |
.eq(DaParamCollection::getSfcCode, productNum) |
|
398 |
.eq(DaParamCollection::getLocationCode, stationCode)); |
|
399 |
vo.setTotalResult("1"); |
|
400 |
String string = new Random(10).toString(); |
|
401 |
vo.setRecordId(string); |
|
402 |
vo.setProductNum(productNum); |
|
403 |
vo.setSiteCode("3983"); |
|
404 |
vo.setStationCode(stationCode); |
|
405 |
if (CollUtil.isNotEmpty(list)){ |
|
406 |
List<DaParamCollection> collect = list.stream().filter(x -> Constants.NG.equals(x.getParamValue())).collect(Collectors.toList()); |
|
407 |
if (CollUtil.isNotEmpty(collect)){ |
|
408 |
vo.setTotalResult("0"); |
|
409 |
} |
|
410 |
List<BsFormulaChildInfo> bsFormulaChildInfoList = bsFormulaChildInfoService.list(); |
|
411 |
for (DaParamCollection daParamCollection : list) { |
|
412 |
ChildVO childVO = new ChildVO(); |
|
413 |
childVO.setItemCode(daParamCollection.getParamCode()); |
|
414 |
String time = daParamCollection.getCollectionTime() != null ? daParamCollection.getCollectionTime().toString() : ""; |
|
415 |
childVO.setCheckResult("1"); |
|
416 |
if (StrUtil.isNotBlank(daParamCollection.getParamValue())){ |
|
417 |
if (Constants.NG.equals(daParamCollection.getParamValue())){ |
|
418 |
childVO.setCheckResult("0"); |
|
419 |
} |
|
420 |
} |
|
421 |
childVO.setCheckTime(time); |
|
422 |
childVO.setItemValue(daParamCollection.getParamValue()); |
|
423 |
childVO.setItemType("3"); |
|
424 |
childVO.setItemText(daParamCollection.getParamName()); |
|
425 |
if (StrUtil.isNotBlank(daParamCollection.getParamCode())){ |
|
426 |
List<BsFormulaChildInfo> collect1 = bsFormulaChildInfoList.stream().filter(x -> daParamCollection.getParamCode().equals(x.getParamCode())).collect(Collectors.toList()); |
|
427 |
if (CollUtil.isNotEmpty(collect1)){ |
|
428 |
BsFormulaChildInfo bsFormulaChildInfo = collect1.get(0); |
|
429 |
childVO.setItemType(bsFormulaChildInfo.getOperationType()); |
|
430 |
} |
|
431 |
} |
|
432 |
|
|
433 |
checkList.add(childVO); |
|
434 |
} |
|
435 |
} |
|
436 |
vo.setCheckList(checkList); |
|
437 |
HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(vo)).execute(); |
|
438 |
|
|
439 |
} |
5966d6
|
440 |
|
A |
441 |
@Override |
|
442 |
public void pushGeelycvMesFeedback(String packID, String stationCode) { |
|
443 |
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
a846f2
|
444 |
// String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
A |
445 |
String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback"; |
5966d6
|
446 |
String totalResult = "0"; |
A |
447 |
List<DaParamCollection> paramList = daParamCollectionService.list(new LambdaQueryWrapper<DaParamCollection>().eq(DaParamCollection::getSfcCode, packID).eq(DaParamCollection::getLocationCode, stationCode)); |
|
448 |
if(paramList.size() > 0){ |
|
449 |
ParentVO parentVO = new ParentVO(); |
|
450 |
parentVO.setSiteCode("3983"); |
|
451 |
parentVO.setRecordId(String.valueOf(Instant.now().toEpochMilli())); |
|
452 |
parentVO.setStationCode(stationCode); |
|
453 |
parentVO.setProductNum(packID); |
|
454 |
parentVO.setTotalResult("1"); |
|
455 |
List<ChildVO> listChildVo = new ArrayList<>(); |
|
456 |
|
|
457 |
for (DaParamCollection daParamCollection : paramList) { |
|
458 |
ChildVO childVO = new ChildVO(); |
|
459 |
childVO.setItemCode(daParamCollection.getParamCode()); |
|
460 |
BsFormulaChildInfo childOne = bsFormulaChildInfoService.getOne(new LambdaQueryWrapper<BsFormulaChildInfo>().eq(BsFormulaChildInfo::getParamCode, daParamCollection.getParamCode())); |
|
461 |
DaCollectionParamConf paramConfOne = daCollectionParamConfService.getOne(new LambdaQueryWrapper<DaCollectionParamConf>().eq(DaCollectionParamConf::getCollectParameterId, daParamCollection.getParamCode())); |
237733
|
462 |
// if(childOne!=null){ |
A |
463 |
// String operationType = childOne.getOperationType(); |
|
464 |
// if(operationType.equals("1")){ |
|
465 |
// childVO.setItemType("2"); |
|
466 |
// }else if(operationType.equals("2")){ |
|
467 |
// childVO.setItemType("1"); |
|
468 |
// } |
|
469 |
// }else { |
|
470 |
// childVO.setItemType("3"); |
|
471 |
// } |
5966d6
|
472 |
if(paramConfOne!=null){ |
237733
|
473 |
childVO.setItemType(paramConfOne.getSpareField1()); |
5966d6
|
474 |
childVO.setItemText(paramConfOne.getCollectParameterName()); |
A |
475 |
}else { |
237733
|
476 |
childVO.setItemType("3"); |
5966d6
|
477 |
childVO.setItemText(""); |
A |
478 |
} |
|
479 |
childVO.setItemValue(daParamCollection.getParamValue()); |
|
480 |
|
|
481 |
if(daParamCollection.getParamValue().equals("1")){ |
|
482 |
childVO.setCheckResult("1"); |
|
483 |
}else if(daParamCollection.getParamValue().equals("2")){ |
|
484 |
childVO.setCheckResult("0"); |
|
485 |
parentVO.setTotalResult("0"); |
|
486 |
totalResult = "1"; |
|
487 |
}else { |
|
488 |
childVO.setCheckResult("1"); |
|
489 |
} |
|
490 |
childVO.setCheckTime(format.format(daParamCollection.getCollectionTime())); |
|
491 |
listChildVo.add(childVO); |
|
492 |
} |
|
493 |
parentVO.setCheckList(listChildVo); |
|
494 |
HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute(); |
|
495 |
System.out.println(execute.body()); |
|
496 |
System.out.println("-----------------------"+totalResult); |
|
497 |
} |
|
498 |
|
|
499 |
} |
616f98
|
500 |
|
237733
|
501 |
@Override |
A |
502 |
public AjaxResult checkRecordDataDone(DaParamCollection daParamCollection) { |
|
503 |
String result = ""; |
|
504 |
try { |
|
505 |
Object recordDataDone = miloService.readFromOpcUa("PACK" + "." + daParamCollection.getLocationCode() + ".RecordDataDone").getValue(); |
|
506 |
if(ObjectUtil.isNotNull(recordDataDone)){ |
|
507 |
result = recordDataDone.toString(); |
|
508 |
} |
|
509 |
} catch (Exception e) { |
|
510 |
throw new RuntimeException(e); |
|
511 |
} |
|
512 |
return AjaxResult.success(result); |
|
513 |
} |
|
514 |
|
e57a89
|
515 |
} |