From 9a5ab9f2f92f798fe15d7bad13428d9ddace83f9 Mon Sep 17 00:00:00 2001 From: cl <418351270@qq.com> Date: 星期五, 19 七月 2024 09:08:04 +0800 Subject: [PATCH] 修改报工工位,及上传参数itemType --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 173 +++++++++++++++++++++++++++++++++++---------------------- 1 files changed, 105 insertions(+), 68 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java index 6a0efe1..ef55561 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java +++ b/jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java @@ -119,17 +119,18 @@ // } } }else if(Constants.OP030.equals(device)){ - Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue(); + Object value1 = miloService.readFromOpcUa(thoroughfare + "." + device + ".Scaner").getValue();//鐢佃姱鐮� if (ObjectUtil.isNotNull(value1)){ String cellCode = value1.toString(); - //鍙嶉鐢佃姱ocv妫�娴嬬粨鏋� - boolean b = OCVResultFeedBack(thoroughfare, device,cellCode);//瀵规浛鎹㈢數鑺牎楠� + scanResult = 11; + //鍙嶉鐢佃姱ocv妫�娴嬬粨鏋�,杩欓噷涓嶇敤鍐嶈繘琛屾娴嬶紝鍙鐮佹病闂灏卞彲浠ヤ簡 + /*boolean b = OCVResultFeedBack(thoroughfare, device,cellCode);//瀵规浛鎹㈢數鑺牎楠� //鍥涗釜鐢佃姱鐨勭姸鎬� if (b){ scanResult = 11; }else { scanResult = 12; - } + }*/ }else { scanResult = 12; } @@ -161,17 +162,27 @@ if (ObjectUtil.isNotNull(productTypeObjcet)){ String productType = productTypeObjcet.toString();//浜у搧绫诲瀷 String materialCode = Constants.materialMap.get(productType); + //璋冪敤宸ュ巶MES锛屼繚瀛樺埌鏁版嵁搴�,骞朵笖灏嗗伐鍗曚紶缁橮LC CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { - //璋冪敤宸ュ巶MES锛屼繚瀛樺埌鏁版嵁搴�,骞朵笖灏嗗伐鍗曚紶缁橮LC (鐩墠涓存椂鐢ㄨ鏂规硶锛� receivingWorkOrders(thoroughfare, device,materialCode); }); - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,11); }else{ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); } + }else if (Constants.OP150.contains(device)){//浜哄伐宸ヤ綅 + Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); + if (ObjectUtil.isNull(modulCodeObjcet)){ + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(12).build()); + }else{ + String productNum = modulCodeObjcet.toString(); + //灏嗕骇鍝丼N鍙戦�佸埌鍓嶅彴 + productNum = "productNum,"+ productNum; + WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); + } }else if (Constants.ModuleList.contains(device)){//鏈夋ā缁勭爜鐨勫伐浣� Object modulCodeObjcet = miloService.readFromOpcUa(thoroughfare + "." + device + ".ModuleCode").getValue(); if (ObjectUtil.isNull(modulCodeObjcet)){ @@ -194,14 +205,33 @@ Integer result = 21; //璇诲彇鐢佃姱鐮� List<String> cellCodeList = readCellCodeList(thoroughfare, device); - if(ObjectUtil.isNull(cellCodeList) || cellCodeList.size() != 4){ + if(ObjectUtil.isNull(cellCodeList) || cellCodeList.size() != 4 ){ result = 23; }else{ + String cellCode1 = cellCodeList.get(0); + String cellCode2 = cellCodeList.get(1); + String cellCode3 = cellCodeList.get(2); + String cellCode4 = cellCodeList.get(3); + if ((!cellCode1.isEmpty() && cellCode2.isEmpty()) || (cellCode1.isEmpty() && !cellCode2.isEmpty()) + || (!cellCode3.isEmpty() && cellCode4.isEmpty()) || (!cellCode4.isEmpty() && cellCode3.isEmpty())) { + result = 23; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); + return; + } + result = savePassingStation(thoroughfare, device,cellCodeList);//淇濆瓨杩囩珯 if(result == 21) { + if(Constants.OP030.contains(device)){ + daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode1); + daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode2); + daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode3); + daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode4); + } result = saveParamCollection(device,cellCodeList);//淇濆瓨鍙傛暟锛屽彂閫佸伐鍘侻ES } + } + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(result).build()); log.info("鍐欏叆鍒板伐浣峽}鐨凴ecordDataDone鏁版嵁锛歿}",device,result); } else if (Constants.OP100_OP150.contains(device)){//浜哄伐宸ヤ綅 @@ -236,40 +266,8 @@ log.error(e.getMessage()); } } -/* public void receivingWorkOrders(String thoroughfare ,String device) { - String paramProductNum = ""; - try { - List<OmProductionOrdeInfo> orderList = omProductionOrdeInfoService.list(new LambdaQueryWrapper<OmProductionOrdeInfo>() - .eq(OmProductionOrdeInfo::getOrderStatus, Constants.ONE));//宸ュ崟鐘舵�� - - if (CollUtil.isNotEmpty(orderList)){ - Long id = orderList.get(0).getId(); - String productNum = orderList.get(0).getProductNum();//妯$粍鐮� - String orderNum = orderList.get(0).getWorkOrderNo(); - //涓嬪彂浜у搧妯$粍鐮� - miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build()); - miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(orderNum).build()); - //miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(1).build()); - - //鏇存柊宸ュ崟鐘舵�佷负鎵ц涓� - OmProductionOrdeInfo omProductionOrdeInfo = new OmProductionOrdeInfo(); - omProductionOrdeInfo.setId(id); - omProductionOrdeInfo.setOrderStatus("3"); - omProductionOrdeInfoService.updateOmProductionOrdeInfo(omProductionOrdeInfo); - - //灏嗕骇鍝丼N鍙戦�佸埌鍓嶅彴 - productNum = "productNum,"+ productNum; - WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); - }*//*else{ - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordSNDone").value(2).build());//娌℃湁瑕佺敓浜х殑宸ュ崟 - }*//* - } catch (Exception e) { - throw new RuntimeException(e); - } - }*/ - - public void receivingWorkOrders(String thoroughfare ,String device ,String materialCode) + public synchronized void receivingWorkOrders(String thoroughfare ,String device ,String materialCode) { String paramProductNum = ""; try { @@ -298,12 +296,15 @@ omProductionOrdeInfo.setCreateUser("宸ュ巶MES"); omProductionOrdeInfoService.save(omProductionOrdeInfo); - //鍙戦�佺粰鍓嶅彴 - WebSocketUsers.sendMessageToUserByText(map.get(device), dataObject.getStr("productNum")); + String productNum = dataObject.getStr("productNum"); + String orderNum = dataObject.getStr("productionOrderNum"); + //涓嬪彂浜у搧妯$粍鐮� + miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(productNum).build()); + miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(orderNum).build()); - //鍐橮LC - miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".ModuleCode").value(dataObject.getStr("productNum")).build()); - miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderNumber").value(dataObject.getStr("productionOrderNum")).build()); + //灏嗕骇鍝丼N鍙戦�佸埌鍓嶅彴 + productNum = "productNum,"+ productNum; + WebSocketUsers.sendMessageToUserByText(map.get(device), productNum); } } catch (Exception e) { @@ -330,11 +331,11 @@ try { List<ReadWriteEntity> readWriteEntityList = miloService.readFromOpcUa(readList);//鐢佃姱鐮� for (ReadWriteEntity readWriteEntity : readWriteEntityList) { - if (ObjectUtil.isNotNull(readWriteEntity.getValue()) && !"".equals(readWriteEntity.getValue().toString().trim())){ + if (ObjectUtil.isNotNull(readWriteEntity.getValue()) && !readWriteEntity.getValue().toString().trim().isEmpty()){ cellCodeList.add(readWriteEntity.getValue().toString());//灏佽鐢佃姱鐮� - }/*else{ + }else{ cellCodeList.add("");//灏佽鐢佃姱鐮� - }*/ + } } } catch (Exception e) { @@ -507,9 +508,9 @@ //鎻掑叆鍙傛暟閲囬泦琛� daParamCollectionService.insertBatch(collectionList); - //濡傛灉220宸ヤ綅锛岃繘琛屾姤宸� + //濡傛灉220宸ヤ綅锛岃繘琛屾姤宸�,鍥犱负涓婂眰绯荤粺鍙敮鎸�6浣嶏紝鎵�鏈夋姤宸ュ伐浣嶄慨鏀逛负M1P220 if("M1OP220".equals(device)) { - RestfulService.getWorkReportResultFeedback(moduleCode, "M1OP220", format.format(new Date())); + getWorkReportResultFeedback(moduleCode, "M1P220", format.format(new Date())); } //涓婁紶鍒板伐鍘俶es @@ -524,6 +525,11 @@ parentVO.setTotalResult("1"); } parentVO.setProductNum(moduleCode); + + //娣诲姞鍩虹鏁版嵁 + List<ChildVO> basicList = getCollectParamBasicData(device,moduleCode); + mesList.addAll(basicList); + parentVO.setCheckList(mesList); log.info("鎵ц宸ュ巶MES鏂规硶start锛屽伐浣嶅彿{} 浼犲叆鏁版嵁锛歿}",device ,parentVO); @@ -763,6 +769,11 @@ break; } + + //娣诲姞鍩虹鏁版嵁 + List<ChildVO> basicList = getCollectParamBasicData(device,cellCodeList.get(i)); + mesChildList.addAll(basicList); + parentVO.setCheckList(mesChildList);//鍙傛暟 //CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { log.info("鎵ц宸ュ巶MES鏂规硶start锛屼紶鍏ユ暟鎹細{}",parentVO); @@ -790,20 +801,18 @@ boolean flag = true; List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() - .eq(DaTestDeviceInterfaceTemp::getStationCode, device) + .eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); if (Constants.ONE.equals(daTestDeviceInterfaceTemp.getTotalResult())){ - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(1).build()); + flag = true; }else { flag = false; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); } daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); }else { flag = false; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); log.info("璇诲彇鍒板伐浣峽},娴嬭瘯璁惧杩斿洖鐨勬暟鎹煡璇笉鍒帮紝鐢佃姱鐮佷负锛歿}",device,cellCode); } return flag; @@ -820,7 +829,7 @@ if (ObjectUtil.isNotNull(value1)){ String cellCode = value1.toString(); List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() - .eq(DaTestDeviceInterfaceTemp::getStationCode, device) + //.eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); @@ -830,18 +839,22 @@ flag = false; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); } - daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); + //daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(5).build()); + log.info("璇诲彇鍒板伐浣峽},OP020宸ヤ綅娌℃湁缁欐祴璇曠粨鏋�",device); } }else { flag = false; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(2).build()); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_1").value(5).build()); log.info("璇诲彇鍒板伐浣峽},PLC娌℃湁缁欑數鑺爜",device); } Object value2 = miloService.readFromOpcUa(thoroughfare + "." + device + ".CellCode_2").getValue(); if (ObjectUtil.isNotNull(value2)){ String cellCode = value2.toString(); List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() - .eq(DaTestDeviceInterfaceTemp::getStationCode, device) + //.eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); @@ -851,11 +864,15 @@ flag = false; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); } - daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); + //daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(5).build()); + log.info("璇诲彇鍒板伐浣峽},OP020宸ヤ綅娌℃湁缁欐祴璇曠粨鏋�",device); } }else { flag = false; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(2).build()); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_2").value(5).build()); log.info("璇诲彇鍒板伐浣峽},PLC娌℃湁缁欑數鑺爜",device); } @@ -863,7 +880,7 @@ if (ObjectUtil.isNotNull(value3)){ String cellCode = value3.toString(); List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() - .eq(DaTestDeviceInterfaceTemp::getStationCode, device) + //.eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); @@ -873,11 +890,15 @@ flag = false; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); } - daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); + //daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(5).build()); + log.info("璇诲彇鍒板伐浣峽},OP020宸ヤ綅娌℃湁缁欐祴璇曠粨鏋�",device); } }else { flag = false; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(2).build()); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_3").value(5).build()); log.info("璇诲彇鍒板伐浣峽},PLC娌℃湁缁欑數鑺爜",device); } @@ -885,7 +906,7 @@ if (ObjectUtil.isNotNull(value4)){ String cellCode = value4.toString(); List<DaTestDeviceInterfaceTemp> list = daTestDeviceInterfaceTempService.list(new LambdaQueryWrapper<DaTestDeviceInterfaceTemp>() - .eq(DaTestDeviceInterfaceTemp::getStationCode, device) + //.eq(DaTestDeviceInterfaceTemp::getStationCode, "M1OP020") .eq(DaTestDeviceInterfaceTemp::getProductNum,cellCode)); if (CollUtil.isNotEmpty(list)){ DaTestDeviceInterfaceTemp daTestDeviceInterfaceTemp = list.get(list.size()-1); @@ -895,11 +916,15 @@ flag = false; miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); } - daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); + //daTestDeviceInterfaceTempService.deleteDaTestDeviceInterfaceTempByProductNum(cellCode); + }else { + flag = false; + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(5).build()); + log.info("璇诲彇鍒板伐浣峽},OP020宸ヤ綅娌℃湁缁欐祴璇曠粨鏋�",device); } }else { flag = false; - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(2).build()); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".CellStatus_4").value(5).build()); log.info("璇诲彇鍒板伐浣峽},PLC娌℃湁缁欑數鑺爜",device); } @@ -932,12 +957,13 @@ /** * 鑾峰彇閲囬泦鍙傛暟鍩虹鏁版嵁 - * @param productCode * @param stationCode + * @param sfcCode * @return list */ - public List<ChildVO> getCollectParamBasicData(String productCode , String stationCode) { + public static List<ChildVO> getCollectParamBasicData(String stationCode,String sfcCode) { List<ChildVO> basicList = new ArrayList<>(); + List<DaParamCollection> collectionList = new ArrayList<>(); try { //鏌ヨ鍙傛暟閰嶇疆琛� List<DaCollectionParamConf> list = collectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() @@ -954,7 +980,18 @@ childVO.setCheckResult("1"); childVO.setCheckTime(format.format(new Date())); basicList.add(childVO); + + DaParamCollection daParamCollection = new DaParamCollection(); + daParamCollection.setSfcCode(sfcCode);//妯$粍鐮� + daParamCollection.setParamCode(conf.getCollectParameterId());//鍙傛暟缂栫爜 + daParamCollection.setParamName(conf.getCollectParameterName());//鍙傛暟鍚嶇О + + daParamCollection.setParamValue(conf.getParamCentral());//鍙傛暟鍊� + daParamCollection.setLocationCode(stationCode);//宸ヤ綅 + daParamCollection.setCollectionTime(new Date());//閲囬泦鏃堕棿 + collectionList.add(daParamCollection);//灏佽鍙傛暟閲囬泦list } + daParamCollectionService.insertBatch(collectionList); } return basicList; }catch (Exception e) { -- Gitblit v1.9.3