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