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