| | |
| | | import cn.hutool.http.HttpResponse; |
| | | import cn.hutool.json.JSONUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.jcdm.common.core.domain.AjaxResult; |
| | | import com.jcdm.framework.websocket.WebSocketUsers; |
| | | import com.jcdm.main.bs.formulaChild.domain.BsFormulaChildInfo; |
| | | import com.jcdm.main.constant.Constants; |
| | | import com.jcdm.main.da.collectionParamConf.domain.DaCollectionParamConf; |
| | | import com.jcdm.main.da.collectionParamConf.service.IDaCollectionParamConfService; |
| | |
| | | } |
| | | }else if (Constants.RECORD_SN.equals(tab)){//æ±ä¸å模ç»ç 请9 |
| | | if (Constants.ONE.equals(valueString)){ |
| | | /*if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device) ){*/ |
| | | if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device) ){ |
| | | //æ¥è¯¢è¦ç产çå·¥å |
| | | List<OmProductionOrdeInfo> orderList = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>() |
| | | .eq(OmProductionOrdeInfo::getOrderStatus, Constants.ONE));//å·¥åç¶æ |
| | |
| | | Long id = orderList.get(0).getId(); |
| | | String productNum = orderList.get(0).getProductNum();//模ç»ç |
| | | //ä¸å产å模ç»ç |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build()); |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_ModuleCode").value(productNum).build()); |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_WorkOrderNumber").value(productNum).build()); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MES_ProductType").value(productNum).build()); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build()); |
| | | |
| | | //æ´æ°å·¥åç¶æ为æ§è¡ä¸ |
| | |
| | | }else{ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(2).build());//没æè¦ç产çå·¥å |
| | | } |
| | | /* }*/ |
| | | } |
| | | } |
| | | }else if (Constants.RECORD_DATA.equals(tab)){//åºå
¥ç« |
| | | if (Constants.ONE.equals(valueString)){//å
¥ç« |
| | |
| | | if (Constants.OP030.equals(device)){ |
| | | //åé¦çµè¯ocvæ£æµç»æ |
| | | boolean b = true;//OCVResultFeedBack(thoroughfare, device); |
| | | |
| | | //å个çµè¯çç¶æ |
| | | if (b){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); |
| | | log.info("åå
¥å°å·¥ä½{}çRecordDataDoneæ°æ®ï¼{}",device,11); |
| | |
| | | //å段010-065段 |
| | | if (Constants.OP010.equals(device)){ |
| | | //010å·¥ä½æ è¿ç«è®°å½ï¼åªç»æ¾è¡ä¿¡å· |
| | | /*List<SendFactoryMes> collect = sendFactoryMesList.stream().filter(x -> device.equals(x.getLocationCode())).collect(Collectors.toList()); |
| | | if (CollUtil.isNotEmpty(collect)){ |
| | | for (SendFactoryMes sendFactoryMes : collect) { |
| | | ChildVO childVO = new ChildVO(); |
| | | childVO.setItemCode(sendFactoryMes.getItemCode()); |
| | | childVO.setItemText(sendFactoryMes.getItemText()); |
| | | childVO.setItemType(sendFactoryMes.getItemType()); |
| | | } |
| | | }*/ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
| | | log.info("åå
¥å°å·¥ä½{}çRecordDataDoneæ°æ®ï¼{}",device,21); |
| | | }else if (Constants.OP020_OP065.contains(device)){ |
| | |
| | | result = 23; |
| | | }else{ |
| | | result = savePassingStation(thoroughfare, device,cellCodeList);//ä¿åè¿ç« |
| | | if(result==21) { |
| | | if(result == 21) { |
| | | result = saveParamCollection(thoroughfare, device,cellCodeList);//ä¿ååæ°ï¼åéå·¥åMES |
| | | } |
| | | } |
| | |
| | | log.info("åå
¥å°å·¥ä½{}çRecordDataDoneæ°æ®ï¼{}",device,result); |
| | | } else if (Constants.OP100_1.equals(device) || Constants.OP100_2.equals(device)){ |
| | | |
| | | |
| | | //ä¸çº¿æ¥å·¥ |
| | | |
| | | WebSocketUsers.sendMessageToUserByText(map.get(device), "END"); |
| | | } else { |
| | | //2:åç¥MESå·¥ä½å·¥ä½å®æï¼è¯·æ±è®°å½å·¥ä½æ°æ® |
| | | //ä¿ååæ°ééè®°å½ |
| | | saveParamPassingData(device,thoroughfare); |
| | | //ä¿åè¿ç«è®°å½ |
| | | DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
| | | Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
| | | String moduleCode = null; |
| | | if (ObjectUtil.isNotNull(value1)){ |
| | | moduleCode = value1.toString(); |
| | | log.info("读åå·¥ä½{}çModuleCodeæ°æ®ï¼{}",device,moduleCode); |
| | | } |
| | | passingStationCollection.setSfcCode(moduleCode); |
| | | passingStationCollection.setLocationCode(device); |
| | | passingStationCollection.setInboundTime(new Date()); |
| | | String stationStatus = Constants.PASS; |
| | | ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus"); |
| | | if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
| | | String string = stationStatusRead.getValue().toString(); |
| | | if (Constants.TWO.equals(string)){ |
| | | stationStatus = Constants.UN_PASS; |
| | | Integer result = 21; |
| | | Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
| | | if (ObjectUtil.isNull(modulCodeObjcet) && modulCodeObjcet.toString().trim().isEmpty()){ |
| | | result = 23; |
| | | }else{ |
| | | String moduleCode = modulCodeObjcet.toString(); |
| | | result = savePassingStation(thoroughfare, device,moduleCode);//ä¿åè¿ç« |
| | | if(result == 21) { |
| | | result = saveParamCollection(thoroughfare, device,moduleCode);//ä¿ååæ°ï¼åéå·¥åMES |
| | | } |
| | | } |
| | | passingStationCollection.setOutRsSign(stationStatus); |
| | | passingStationCollection.setCreateTime(new Date()); |
| | | daPassingStationCollectionService.save(passingStationCollection); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); |
| | | log.info("åå
¥å°å·¥ä½{}çRecordDataDoneæ°æ®ï¼{}",device,21); |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); |
| | | log.info("åå
¥å°å·¥ä½{}çRecordDataDoneæ°æ®ï¼{}",device,result); |
| | | } |
| | | } |
| | | } /*else if (Constants.RECORD_CHECK_CODE_1.equals(tab)) { |
| | |
| | | */ |
| | | private static List<String> readCellCodeList(String thoroughfare, String device){ |
| | | List<String> cellCodeList = new ArrayList<>(); |
| | | Map map = new HashMap(); |
| | | //çµè¯ç å°å |
| | | List<String> readList = new ArrayList<>(); |
| | | readList.add(thoroughfare + "." + device +".CellCode_1"); |
| | |
| | | try { |
| | | List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList);//çµè¯ç |
| | | for (ReadWriteEntity readWriteEntity : readWriteEntityList) { |
| | | if (ObjectUtil.isNotNull(readWriteEntity.getValue())){ |
| | | if(!"".equals(readWriteEntity.getValue().toString().trim())){ |
| | | cellCodeList.add(readWriteEntity.getValue().toString());//å°è£
çµè¯ç |
| | | } |
| | | |
| | | if (ObjectUtil.isNotNull(readWriteEntity.getValue()) && !"".equals(readWriteEntity.getValue().toString().trim())){ |
| | | cellCodeList.add(readWriteEntity.getValue().toString());//å°è£
çµè¯ç |
| | | }else{ |
| | | cellCodeList.add("");//å°è£
çµè¯ç |
| | | } |
| | | } |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return cellCodeList; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ä¿åè¿ç«æ°æ® |
| | | * @param thoroughfare éé |
| | | * @param device å·¥ä½ |
| | | * @param moduleCode 模ç»å· |
| | | * @return list |
| | | * @throws Exception e |
| | | */ |
| | | private static Integer savePassingStation(String thoroughfare, String device,String moduleCode){ |
| | | Integer result = 21; |
| | | |
| | | try { |
| | | //读è¿ç«æ¶é´ |
| | | Date startTime = new Date(); |
| | | ReadWriteEntity startTimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime");//è¿ç«æ¶é´ |
| | | if (ObjectUtil.isNotNull(startTimeRead.getValue())){ |
| | | startTime = format.parse(TimeUtil.test(TimeUtil.stringProcessing(startTimeRead.getValue().toString()))); |
| | | }else{ |
| | | result = 23; |
| | | log.info("读åå°å·¥ä½{}çStartTimeæ°æ®ï¼{},è¿åRecordDataDoneçå¼ä¸º{}",device,"IS NULLï¼",result); |
| | | return result; |
| | | } |
| | | |
| | | //读工ç«ç¶æ |
| | | String stationStatus = Constants.PASS; |
| | | ReadWriteEntity stationStatusRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StationStatus");//ç«ç¶æå°å |
| | | if (ObjectUtil.isNotNull(stationStatusRead.getValue())){ |
| | | String string = stationStatusRead.getValue().toString(); |
| | | if (Constants.TWO.equals(string)){ |
| | | stationStatus = Constants.UN_PASS; |
| | | } |
| | | }else{ |
| | | result = 23; |
| | | log.info("读åå°å·¥ä½{}StationStatusæ°æ®ï¼{},è¿åRecordDataDoneçå¼ä¸º{}",device,"IS NULLï¼",result); |
| | | return result; |
| | | } |
| | | |
| | | DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
| | | passingStationCollection.setSfcCode(moduleCode);//çµè¯ç |
| | | passingStationCollection.setLocationCode(device);//å·¥ä½ |
| | | passingStationCollection.setInboundTime(startTime);//è¿ç«æ¶é´ |
| | | passingStationCollection.setOutboundTime(new Date());//åºç«æ¶é´ |
| | | passingStationCollection.setOutRsSign(stationStatus);//ç«ç¶æå¼ |
| | | passingStationCollection.setCollectionTime(new Date());//ééæ¶é´ |
| | | daPassingStationCollectionService.save(passingStationCollection); |
| | | |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | |
| | | }else{ |
| | | result = 23; |
| | | log.info("读åå°å·¥ä½{}çStartTimeæ°æ®ï¼{},è¿åRecordDataDoneçå¼ä¸º{}",device,"IS NULLï¼",result); |
| | | return result; |
| | | } |
| | | |
| | | //读工ç«ç¶æ |
| | |
| | | } |
| | | }else{ |
| | | result = 23; |
| | | log.info("读åå°å·¥ä½{}StationStatussæ°æ®ï¼{},è¿åRecordDataDoneçå¼ä¸º{}",device,"IS NULLï¼",result); |
| | | log.info("读åå°å·¥ä½{}StationStatusæ°æ®ï¼{},è¿åRecordDataDoneçå¼ä¸º{}",device,"IS NULLï¼",result); |
| | | return result; |
| | | } |
| | | |
| | | List<DaPassingStationCollection> passingList = new ArrayList<>(); |
| | | for (String cellCode : cellCodeList) { |
| | | DaPassingStationCollection passingStationCollection = new DaPassingStationCollection(); |
| | | if (ObjectUtil.isNotNull(cellCode)){ |
| | | if (ObjectUtil.isNotNull(cellCode) && !cellCode.isEmpty()){ |
| | | passingStationCollection.setSfcCode(cellCode);//çµè¯ç |
| | | passingStationCollection.setLocationCode(device);//å·¥ä½ |
| | | passingStationCollection.setInboundTime(startTime);//è¿ç«æ¶é´ |
| | |
| | | passingStationCollection.setOutRsSign(stationStatus);//ç«ç¶æå¼ |
| | | passingStationCollection.setCollectionTime(new Date());//ééæ¶é´ |
| | | passingList.add(passingStationCollection); |
| | | }else{ |
| | | result = 23; |
| | | log.info("读åå°å·¥ä½{}CellCodeæ°æ®ï¼{},è¿åRecordDataDoneçå¼ä¸º{}",device,"IS NULLï¼",result); |
| | | } |
| | | } |
| | | |
| | |
| | | return result; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * ä¿åçµè¯è¿ç«è®°å½ |
| | | * ä¿ååæ°æ°æ®ååéå·¥åMES |
| | | * @param thoroughfare éé |
| | | * @param device å·¥ä½ |
| | | * @param moduleCode 模ç»å· |
| | | * @return list |
| | | * @throws Exception e |
| | | */ |
| | | private static Integer saveParamCollection(String thoroughfare, String device,String moduleCode){ |
| | | Integer result = 21;//è¿åç»æ |
| | | |
| | | try { |
| | | //æ¥è¯¢åæ°é
置表 |
| | | List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
| | | .eq(DaCollectionParamConf::getProcessesCode, device)//å·¥ä½ |
| | | .eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//æ¯å¦éé |
| | | ); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | |
| | | List<String> collect = list.stream() |
| | | .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); |
| | | List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(collect); |
| | | |
| | | List<DaParamCollection> collectionList = new ArrayList<>(); |
| | | List<ChildVO> mesList = new ArrayList<>(); |
| | | for (int i = 0; i < readWriteEntityList.size(); i++) { |
| | | DaParamCollection daParamCollection = new DaParamCollection(); |
| | | daParamCollection.setSfcCode(moduleCode);//模ç»ç |
| | | daParamCollection.setParamCode(list.get(i).getCollectParameterId());//åæ°ç¼ç |
| | | daParamCollection.setParamName(list.get(i).getCollectParameterName());//åæ°å称 |
| | | String paramValue = ""; |
| | | if (ObjectUtil.isNotNull(readWriteEntityList.get(i).getValue())){ |
| | | paramValue = readWriteEntityList.get(i).getValue().toString();//åæ°å¼ |
| | | } |
| | | daParamCollection.setParamValue(paramValue);//åæ°å¼ |
| | | daParamCollection.setLocationCode(device);//å·¥ä½ |
| | | daParamCollection.setCollectionTime(new Date());//ééæ¶é´ |
| | | collectionList.add(daParamCollection);//å°è£
åæ°éélist |
| | | |
| | | //åéç»å·¥åmesåæ°å°è£
|
| | | ChildVO childVO = new ChildVO(); |
| | | childVO.setItemCode(list.get(i).getCollectParameterId());//åæ°ç¼ç |
| | | childVO.setItemType(list.get(i).getItemType()); |
| | | childVO.setItemValue(paramValue);//åæ°å¼ |
| | | childVO.setItemText(list.get(i).getCollectParameterName()); |
| | | childVO.setCheckResult("1"); |
| | | childVO.setCheckTime(new Date().toString()); |
| | | mesList.add(childVO); |
| | | } |
| | | |
| | | CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | //æå
¥åæ°éé表 |
| | | daParamCollectionService.insertBatch(collectionList); |
| | | //ä¸ä¼ å°å·¥åmes |
| | | ParentVO parentVO = new ParentVO(); |
| | | parentVO.setStationCode(device);//å·¥ä½ |
| | | parentVO.setSiteCode("3983"); |
| | | |
| | | parentVO.setRecordId(UUID.randomUUID().toString()); |
| | | parentVO.setTotalResult("1"); |
| | | parentVO.setProductNum(moduleCode); |
| | | parentVO.setCheckList(mesList); |
| | | |
| | | log.info("æ§è¡å·¥åMESæ¹æ³startï¼ä¼ å
¥æ°æ®ï¼{}",parentVO); |
| | | HttpResponse execute = HttpRequest.post(orderLineUrl).body(JSONUtil.toJsonStr(parentVO)).execute(); |
| | | log.info("æ§è¡å·¥åMESæ¹æ³endï¼è¿åæ°æ®ï¼{}",execute.body()); |
| | | |
| | | }); |
| | | } |
| | | }catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * ä¿ååæ°æ°æ®ååéå·¥åMES |
| | | * @param thoroughfare éé |
| | | * @param device å·¥ä½ |
| | | * @param cellCodeList çµè¯ç éå |
| | |
| | | List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
| | | .eq(DaCollectionParamConf::getProcessesCode, device)//å·¥ä½ |
| | | .eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//æ¯å¦éé |
| | | .eq(DaCollectionParamConf::getRemarks, Constants.ONE));//ç±»å |
| | | );//ç±»å |
| | | if (CollUtil.isNotEmpty(list)) { |
| | | List<DaParamCollection> saveParamList = new ArrayList<>();//å°è£
åæ°éélist |
| | | List<DaCollectionParamConf> confColl1 = list.stream().filter(x -> Constants.INT_ONE.equals(x.getKeyNum())).collect(Collectors.toList()); |
| | |
| | | List<ReadWriteEntity> paramCollectionList0 = miloService.readFromOpcUa(collect0);//çµè¯ åæ°å¼ |
| | | |
| | | //第ä¸ä¸ªçµè¯çæ°æ® |
| | | if (CollUtil.isNotEmpty(paramCollectionList1)) { |
| | | if (CollUtil.isNotEmpty(paramCollectionList1) && !cellCodeList.get(0).isEmpty()) { |
| | | List<ChildVO> mesChildList1 = new ArrayList<>();//å°è£
ç»å·¥åMESåéçchildlist1 |
| | | for (int i = 0; i < paramCollectionList1.size(); i++) { |
| | | DaParamCollection daParamCollection = new DaParamCollection(); |
| | |
| | | childVO.setCheckResult("1"); |
| | | childVO.setCheckTime(new Date().toString()); |
| | | mesChildList1.add(childVO); |
| | | mesList.add(0, mesChildList1); |
| | | } |
| | | mesList.add(0, mesChildList1); |
| | | } |
| | | if (CollUtil.isNotEmpty(paramCollectionList2)) { |
| | | if (CollUtil.isNotEmpty(paramCollectionList2) && !cellCodeList.get(1).isEmpty()) { |
| | | List<ChildVO> mesChildList2 = new ArrayList<>();//å°è£
ç»å·¥åMESåéçchildlist2 |
| | | |
| | | for (int i = 0; i < paramCollectionList2.size(); i++) { |
| | |
| | | childVO.setCheckResult("1"); |
| | | childVO.setCheckTime(new Date().toString()); |
| | | mesChildList2.add(childVO); |
| | | mesList.add(1, mesChildList2); |
| | | } |
| | | mesList.add(1, mesChildList2); |
| | | } |
| | | if (CollUtil.isNotEmpty(paramCollectionList3)) { |
| | | if (CollUtil.isNotEmpty(paramCollectionList3) && !cellCodeList.get(2).isEmpty()) { |
| | | List<ChildVO> mesChildList3 = new ArrayList<>();//å°è£
ç»å·¥åMESåéçchildlist3 |
| | | for (int i = 0; i < paramCollectionList3.size(); i++) { |
| | | DaParamCollection daParamCollection = new DaParamCollection(); |
| | |
| | | childVO.setCheckResult("1"); |
| | | childVO.setCheckTime(new Date().toString()); |
| | | mesChildList3.add(childVO); |
| | | mesList.add(2, mesChildList3); |
| | | } |
| | | mesList.add(2, mesChildList3); |
| | | } |
| | | if (CollUtil.isNotEmpty(paramCollectionList4)) { |
| | | if (CollUtil.isNotEmpty(paramCollectionList4)&& !cellCodeList.get(3).isEmpty()) { |
| | | List<ChildVO> mesChildList4 = new ArrayList<>();//å°è£
ç»å·¥åMESåéçchildlist4 |
| | | for (int i = 0; i < paramCollectionList4.size(); i++) { |
| | | DaParamCollection daParamCollection = new DaParamCollection(); |
| | |
| | | childVO.setCheckResult("1"); |
| | | childVO.setCheckTime(new Date().toString()); |
| | | mesChildList4.add(childVO); |
| | | mesList.add(3, mesChildList4); |
| | | } |
| | | mesList.add(3, mesChildList4); |
| | | } |
| | | |
| | | //å
Œ
±åæ° |
| | | if (CollUtil.isNotEmpty(paramCollectionList0)) { |
| | | for (int i = 0; i < cellCodeList.size(); i++) {//循ç¯4个çµè¯ |
| | | List<ChildVO> mesChildList0 = new ArrayList<>();//å°è£
ç»å·¥åMESåéçchildlist0 |
| | | for (int j = 0; j < paramCollectionList0.size(); j++) { |
| | | DaParamCollection daParamCollection = new DaParamCollection(); |
| | | daParamCollection.setSfcCode(cellCodeList.get(i));//çµè¯ç |
| | | daParamCollection.setParamCode(confColl0.get(j).getCollectParameterId());//åæ°ç¼ç |
| | | daParamCollection.setParamName(confColl0.get(j).getCollectParameterName());//åæ°å称 |
| | | String paramValue = ""; |
| | | if (ObjectUtil.isNotNull(paramCollectionList0.get(j).getValue())) { |
| | | paramValue = paramCollectionList0.get(j).getValue().toString();//åæ°å¼ |
| | | } |
| | | if(confColl0.get(j).getCollectParameterName().contains("æ¶é´") && !"".equals(paramValue)){ |
| | | paramValue = format.parse(TimeUtil.test(TimeUtil.stringProcessing(paramValue))).toString(); |
| | | } |
| | | daParamCollection.setParamValue(paramValue);//åæ°å¼ |
| | | daParamCollection.setLocationCode(device);//å·¥ä½ |
| | | daParamCollection.setCollectionTime(new Date());//ééæ¶é´ |
| | | saveParamList.add(daParamCollection); |
| | | if(!cellCodeList.get(i).isEmpty()){ |
| | | List<ChildVO> mesChildList0 = new ArrayList<>();//å°è£
ç»å·¥åMESåéçchildlist0 |
| | | for (int j = 0; j < paramCollectionList0.size(); j++) { |
| | | DaParamCollection daParamCollection = new DaParamCollection(); |
| | | daParamCollection.setSfcCode(cellCodeList.get(i));//çµè¯ç |
| | | daParamCollection.setParamCode(confColl0.get(j).getCollectParameterId());//åæ°ç¼ç |
| | | daParamCollection.setParamName(confColl0.get(j).getCollectParameterName());//åæ°å称 |
| | | String paramValue = ""; |
| | | if (ObjectUtil.isNotNull(paramCollectionList0.get(j).getValue())) { |
| | | paramValue = paramCollectionList0.get(j).getValue().toString();//åæ°å¼ |
| | | } |
| | | if(confColl0.get(j).getCollectParameterName().contains("æ¶é´") && !"".equals(paramValue)){ |
| | | paramValue = format.parse(TimeUtil.test(TimeUtil.stringProcessing(paramValue))).toString(); |
| | | } |
| | | daParamCollection.setParamValue(paramValue);//åæ°å¼ |
| | | daParamCollection.setLocationCode(device);//å·¥ä½ |
| | | daParamCollection.setCollectionTime(new Date());//ééæ¶é´ |
| | | saveParamList.add(daParamCollection); |
| | | |
| | | //åéç»å·¥åmesåæ°å°è£
|
| | | ChildVO childVO = new ChildVO(); |
| | | childVO.setItemCode(confColl0.get(j).getCollectParameterName());//åæ° |
| | | childVO.setItemType(confColl0.get(j).getItemType()); |
| | | childVO.setItemValue(paramValue);//åæ°å¼ |
| | | childVO.setItemText(confColl0.get(j).getParameterSetName()); |
| | | childVO.setCheckResult("1"); |
| | | childVO.setCheckTime(new Date().toString()); |
| | | mesChildList0.add(childVO); |
| | | //åéç»å·¥åmesåæ°å°è£
|
| | | ChildVO childVO = new ChildVO(); |
| | | childVO.setItemCode(confColl0.get(j).getCollectParameterName());//åæ° |
| | | childVO.setItemType(confColl0.get(j).getItemType()); |
| | | childVO.setItemValue(paramValue);//åæ°å¼ |
| | | childVO.setItemText(confColl0.get(j).getParameterSetName()); |
| | | childVO.setCheckResult("1"); |
| | | childVO.setCheckTime(new Date().toString()); |
| | | mesChildList0.add(childVO); |
| | | } |
| | | mesList.add(i, mesChildList0); |
| | | } |
| | | mesList.get(i).addAll(mesChildList0); |
| | | /* mesList.add(mesChildList0);*/ |
| | | |
| | | //mesList.get(i).addAll(mesChildList0); |
| | | |
| | | } |
| | | |
| | | } |
| | |
| | | parentVO.setRecordId(UUID.randomUUID().toString()); |
| | | parentVO.setTotalResult("1"); |
| | | for (int i = 0; i < cellCodeList.size(); i++) {//循ç¯4个çµè¯ |
| | | parentVO.setProductNum(cellCodeList.get(i));//çµè¯ç |
| | | parentVO.setCheckList(mesList.get(i));//åæ° |
| | | //CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | log.info("æ§è¡å·¥åMESæ¹æ³startï¼ä¼ å
¥æ°æ®ï¼{}",parentVO); |
| | | HttpResponse execute = HttpRequest.post(orderLineUrl).body(JSONUtil.toJsonStr(parentVO)).execute(); |
| | | log.info("æ§è¡å·¥åMESæ¹æ³endï¼è¿åæ°æ®ï¼{}",execute.body()); |
| | | //}); |
| | | if(!cellCodeList.get(i).isEmpty()){ |
| | | parentVO.setProductNum(cellCodeList.get(i));//çµè¯ç |
| | | parentVO.setCheckList(mesList.get(i));//åæ° |
| | | //CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { |
| | | log.info("æ§è¡å·¥åMESæ¹æ³startï¼ä¼ å
¥æ°æ®ï¼{}",parentVO); |
| | | HttpResponse execute = HttpRequest.post(orderLineUrl).body(JSONUtil.toJsonStr(parentVO)).execute(); |
| | | log.info("æ§è¡å·¥åMESæ¹æ³endï¼è¿åæ°æ®ï¼{}",execute.body()); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | |
| | | } |
| | | |
| | | /** |
| | | * ä¿åè¿ç«æ°æ®ååæ°ä¿åæ°æ® |
| | | * @param device å·¥ä½å· |
| | | * 030å·¥ä½è¿åocvæµè¯ç»æ |
| | | * @param thoroughfare |
| | | * @param device |
| | | * @throws Exception |
| | | */ |
| | | private void saveParamPassingData(String device,String thoroughfare) throws Exception { |
| | | |
| | | //ä¿ååæ°ééæ°æ® |
| | | List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() |
| | | .eq(DaCollectionParamConf::getProcessesCode, device) |
| | | .eq(DaCollectionParamConf::getRemarks, Constants.ONE)); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | List<String> collect = list.stream().map(DaCollectionParamConf::getGatherAddress) |
| | | .filter(Objects::nonNull).distinct() |
| | | .collect(Collectors.toList()); |
| | | QueryPLCData(device,thoroughfare,collect); |
| | | |
| | | } |
| | | private boolean OCVResultFeedBack(String thoroughfare, String device) throws Exception { |
| | | boolean flag = true; |
| | | Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_1").getValue(); |
| | | /*if (ObjectUtil.isNotNull(value1)){ |
| | | String string = value1.toString(); |
| | | List<QingYanTestInfo> list = qingYanTestInfoService.list(new LambdaQueryWrapper<QingYanTestInfo>() |
| | | .eq(QingYanTestInfo::getKeyCode, string)); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | QingYanTestInfo qingYanTestInfo = list.get(0); |
| | | if (Constants.ONE.equals(qingYanTestInfo.getStatus())){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build()); |
| | | }else { |
| | | flag = false; |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); |
| | | } |
| | | } |
| | | }*/ |
| | | Object value2 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_2").getValue(); |
| | | /*if (ObjectUtil.isNotNull(value2)){ |
| | | String string = value2.toString(); |
| | | List<QingYanTestInfo> list = qingYanTestInfoService.list(new LambdaQueryWrapper<QingYanTestInfo>() |
| | | .eq(QingYanTestInfo::getKeyCode, string)); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | QingYanTestInfo qingYanTestInfo = list.get(0); |
| | | if (Constants.ONE.equals(qingYanTestInfo.getStatus())){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(1).build()); |
| | | }else { |
| | | flag = false; |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); |
| | | } |
| | | } |
| | | }*/ |
| | | Object value3 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_3").getValue(); |
| | | /*if (ObjectUtil.isNotNull(value3)){ |
| | | String string = value3.toString(); |
| | | List<QingYanTestInfo> list = qingYanTestInfoService.list(new LambdaQueryWrapper<QingYanTestInfo>() |
| | | .eq(QingYanTestInfo::getKeyCode, string)); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | QingYanTestInfo qingYanTestInfo = list.get(0); |
| | | if (Constants.ONE.equals(qingYanTestInfo.getStatus())){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(1).build()); |
| | | }else { |
| | | flag = false; |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); |
| | | } |
| | | } |
| | | }*/ |
| | | Object value4 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_4").getValue(); |
| | | /*if (ObjectUtil.isNotNull(value4)){ |
| | | String string = value4.toString(); |
| | | List<QingYanTestInfo> list = qingYanTestInfoService.list(new LambdaQueryWrapper<QingYanTestInfo>() |
| | | .eq(QingYanTestInfo::getKeyCode, string)); |
| | | if (CollUtil.isNotEmpty(list)){ |
| | | QingYanTestInfo qingYanTestInfo = list.get(0); |
| | | if (Constants.ONE.equals(qingYanTestInfo.getStatus())){ |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(1).build()); |
| | | }else { |
| | | flag = false; |
| | | miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); |
| | | } |
| | | } |
| | | }*/ |
| | | return flag; |
| | | } |
| | | |
| | | /** |
| | | * æ¹éæ¥è¯¢plcç«ç¹æ°æ® |
| | | * @param device ç«ç¹ |
| | | * @param collect ç¹ä½ |
| | | * @throws Exception |
| | | */ |
| | | private static void QueryPLCData(String device,String thoroughfare,List<String> collect) throws Exception { |
| | | List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(collect); |
| | | |
| | | if (CollUtil.isNotEmpty(readWriteEntityList)){ |
| | | List<DaParamCollection> collectionList = new ArrayList<>(); |
| | | Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); |
| | | String moduleCode = null; |
| | | if (ObjectUtil.isNotNull(value1)){ |
| | | moduleCode = value1.toString(); |
| | | } |
| | | for (int i = 0; i < readWriteEntityList.size(); i++) { |
| | | DaParamCollection daParamCollection = new DaParamCollection(); |
| | | if (StrUtil.isNotBlank(moduleCode)){ |
| | | daParamCollection.setModuleCode(moduleCode); |
| | | } |
| | | daParamCollection.setParamCode(collect.get(i)); |
| | | String paramValue = ""; |
| | | if (ObjectUtil.isNotNull(readWriteEntityList.get(i).getValue())){ |
| | | paramValue = readWriteEntityList.get(i).getValue().toString(); |
| | | } |
| | | daParamCollection.setParamValue(paramValue); |
| | | daParamCollection.setLocationCode(device); |
| | | daParamCollection.setCollectionTime(new Date()); |
| | | collectionList.add(daParamCollection); |
| | | } |
| | | daParamCollectionService.insertBatch(collectionList); |
| | | } |
| | | } |
| | | } |