From 9ecf2257e5cbe2c45a3adae4a56531e5065b5e5a Mon Sep 17 00:00:00 2001 From: hdy <1105738590@qq.com> Date: 星期一, 17 三月 2025 14:27:43 +0800 Subject: [PATCH] 修改 --- billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java | 176 +++++++++++++++++++++++++++++++++++++--------------------- 1 files changed, 111 insertions(+), 65 deletions(-) diff --git a/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java b/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java index 84bb29a..d66e297 100644 --- a/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java +++ b/billion-main/src/main/java/com/billion/main/plcServer/sub/OPCUaSubscription.java @@ -16,6 +16,7 @@ import com.billion.main.om.domain.OmProductionOrderInfo; import com.billion.main.om.service.IOmOrderSchedulingService; import com.billion.main.om.service.IOmProductionOrderInfoService; +import com.billion.main.plcServer.util.TimeUtil; import com.billion.main.sys.domain.SysCount; import com.billion.main.sys.service.ISysCountService; import com.kangaroohy.milo.model.ReadWriteEntity; @@ -23,7 +24,6 @@ import com.kangaroohy.milo.service.MiloService; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; -import com.billion.main.plcServer.util.TimeUtil; import java.text.SimpleDateFormat; import java.time.LocalDateTime; @@ -99,7 +99,7 @@ if(Constants.ONLINE.contains(device)){ miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(11).build()); } - //闄ら宸ョ珯鎵�鏈夊伐绔� + //1.2//闄ら宸ョ珯鎵�鏈夊伐绔� else if( Constants.PLC1.contains(device) || Constants.PLC2.contains(device) || @@ -134,21 +134,43 @@ OmOrderScheduling omOrderScheduling = new OmOrderScheduling(); Object SFCCode = miloService.readFromOpcUa(thoroughfare + "." + device + ".SFCCode").getValue(); //涓婄嚎宸ヤ綅 +// if(Constants.ONLINE.contains(device) || Constants.TEST.equals(device) ){ if(Constants.ONLINE.contains(device)){ Object workOrderNumber = miloService.readFromOpcUa(thoroughfare + "." + device + ".WorkOrderNumber").getValue(); Object nowQty = miloService.readFromOpcUa(thoroughfare + "." + device + ".PalletID").getValue(); omOrderScheduling.setWorkOrderNo(workOrderNumber.toString()); omOrderScheduling.setNowQty(nowQty.toString()); omOrderScheduling.setSfcCode(SFCCode.toString()); + Date Time = new Date(); + ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StartTime"); + Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString()))); + omOrderScheduling.setOnlineTime(Time); + omOrderScheduling.setStatus("1"); //鎵樼洏缁戝畾SFCCode鍜屽伐鍗曞拰浜х嚎 if(Constants.OP005.equals(device)){ + omProductionOrderInfoService.updateBodyStatus1(); omOrderScheduling.setRemarks("Body"); + sysCountService.updateSerialNumber(); + OmProductionOrderInfo getBodyOrder2 = omProductionOrderInfoService.getBodyOrder(); + if (Objects.equals(getBodyOrder2.getBodyQty(), getBodyOrder2.getPlanQty())){ + omProductionOrderInfoService.updateBodyStatus2(); + } } if(Constants.C005.equals(device)){ + omProductionOrderInfoService.updateHeadStatus1(); omOrderScheduling.setRemarks("Head"); + sysCountService.updateHeadNumber(); + OmProductionOrderInfo getHeadOrder2 = omProductionOrderInfoService.getHeadOrder(); + if (Objects.equals(getHeadOrder2.getHeadQty(), getHeadOrder2.getPlanQty())){ + omProductionOrderInfoService.updateHeadStatus2(); + } } omOrderSchedulingService.insertOmOrderScheduling(omOrderScheduling); }else if(Constants.OFFLINE.contains(device)){ + Date Time = new Date(); + ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime"); + Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString()))); + omOrderScheduling.setOfflineTime(Time); if(Constants.C060.equals(device)){ omOrderScheduling.setRemarks("Head"); omOrderScheduling.setSfcCode(SFCCode.toString()); @@ -161,10 +183,10 @@ if (nowQty == headQty){ UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo()); - updateWrapper.set("head_status", "3"); + updateWrapper.set("head_status", "2"); omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper); } - } else if (Constants.OP310.equals(device)) { + } else if (Constants.OP300.equals(device)) { omOrderScheduling.setRemarks("Body"); omOrderScheduling.setSfcCode(SFCCode.toString()); List<OmOrderScheduling> omOrderSchedulingList = omOrderSchedulingService.selectOmOrderSchedulingList(omOrderScheduling); @@ -176,7 +198,7 @@ if (nowQty == bodyQty){ UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo()); - updateWrapper.set("body_status", "3"); + updateWrapper.set("body_status", "2"); omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper); } } @@ -196,46 +218,17 @@ if (nowQty == preQty){ UpdateWrapper<OmProductionOrderInfo> updateWrapper = new UpdateWrapper<>(); updateWrapper.eq("work_order_no", omProductionOrderInfoList.get(0).getWorkOrderNo()); - updateWrapper.set("pre_status", "3"); + updateWrapper.set("pre_status", "2"); omProductionOrderInfoService.update(new OmProductionOrderInfo(),updateWrapper); } - } - //鏌ヨdescriptive瀛楁绛変簬1鐨勯噰闆嗛」淇濆瓨鍒版壂鐮佷繚瀛樺埌da_material_collection琛ㄩ噷 - DaCollectionParamConf daCollectionParamConf1 = new DaCollectionParamConf(); - daCollectionParamConf1.setProcessesCode(device); - daCollectionParamConf1.setDescriptive("3"); - List<DaCollectionParamConf> daCollectionParamConfList1 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf1); - for (DaCollectionParamConf conf : daCollectionParamConfList1) { - String gatherAddress = conf.getGatherAddress(); - Object valueObj = miloService.readFromOpcUa(gatherAddress).getValue(); // 鑾峰彇鍘熷鍊煎璞♀��:ml-citation{ref="4" data="citationList"} - if (valueObj != null ) { - DaMaterialCollection materialCollection = new DaMaterialCollection(); - materialCollection.setSfcCode(SFCCode.toString()); - materialCollection.setLocationCode(device); - materialCollection.setParamName(conf.getParameterSetName()); - materialCollection.setParamValue((String) miloService.readFromOpcUa(gatherAddress).getValue()); - materialCollection.setCollectTime(new Date()); - daMaterialCollectionService.insertDaMaterialCollection(materialCollection); + sysCountService.updatePreNumber(); + omProductionOrderInfoService.updatePreStatus1(); + OmProductionOrderInfo getPreOrder2 = omProductionOrderInfoService.getPreOrder(); + if (Objects.equals(getPreOrder2.getPreQty(), getPreOrder2.getPlanQty())){ + omProductionOrderInfoService.updatePreStatus2(); } } - //鏌ヨdescriptive瀛楁绛変簬2鐨勯噰闆嗛」淇濆瓨鍒版壂鐮佷繚瀛樺埌da_param_collection琛ㄩ噷 - DaCollectionParamConf daCollectionParamConf2 = new DaCollectionParamConf(); - daCollectionParamConf2.setProcessesCode(device); - daCollectionParamConf2.setDescriptive("4"); - List<DaCollectionParamConf> daCollectionParamConfList2 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf2); - for (DaCollectionParamConf conf : daCollectionParamConfList2) { - String gatherAddress = conf.getGatherAddress(); - Object valueObj = miloService.readFromOpcUa(gatherAddress).getValue(); // 鑾峰彇鍘熷鍊煎璞♀��:ml-citation{ref="4" data="citationList"} - if (valueObj != null ) { - DaParamCollection paramCollection = new DaParamCollection(); - paramCollection.setSfcCode(SFCCode.toString()); - paramCollection.setLocationCode(device); - paramCollection.setParamName(conf.getParameterSetName()); - paramCollection.setParamValue((String) miloService.readFromOpcUa(gatherAddress).getValue()); - paramCollection.setCollectionTime(new Date()); - daParamCollectionService.insertDaParamCollection(paramCollection); - } - } + //鍑虹珯淇濆瓨 DaStationCollection daStationCollection = new DaStationCollection(); daStationCollection.setLocationCode(device); daStationCollection.setSfcCode(SFCCode.toString()); @@ -251,6 +244,61 @@ daStationCollection.setStatus(StationStatus.toString()); daStationCollectionService.insertDaStationCollection(daStationCollection); miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".RecordDataDone").value(21).build()); + //鏌ヨdescriptive瀛楁绛変簬1鐨勯噰闆嗛」淇濆瓨鍒版壂鐮佷繚瀛樺埌da_material_collection琛ㄩ噷 + DaCollectionParamConf daCollectionParamConf1 = new DaCollectionParamConf(); + daCollectionParamConf1.setProcessesCode(device); + daCollectionParamConf1.setDescriptive("1"); + List<DaCollectionParamConf> daCollectionParamConfList1 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf1); + for (DaCollectionParamConf conf : daCollectionParamConfList1) { + String gatherAddress = conf.getGatherAddress(); + String valueObj = null; + ReadWriteEntity entity = miloService.readFromOpcUa(gatherAddress); + if (entity != null) { + Object value = entity.getValue(); + if (value != null) { + valueObj = value.toString(); // 鏈�缁堣祴鍊� + if (!Objects.equals(valueObj, " ")) { + DaMaterialCollection materialCollection = new DaMaterialCollection(); + materialCollection.setSfcCode(SFCCode.toString()); + materialCollection.setLocationCode(device); + materialCollection.setParamName(conf.getParameterSetName()); + materialCollection.setParamValue(miloService.readFromOpcUa(gatherAddress).getValue().toString()); + Date Time = new Date(); + ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime"); + Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString()))); + materialCollection.setCollectTime(Time); + daMaterialCollectionService.insertDaMaterialCollection(materialCollection); + } + else { + log.debug("閲囬泦椤逛负绌�: {}", gatherAddress); + } + } + } + } +// 鏌ヨdescriptive瀛楁绛変簬2鐨勯噰闆嗛」淇濆瓨鍒版壂鐮佷繚瀛樺埌da_param_collection琛ㄩ噷 + DaCollectionParamConf daCollectionParamConf2 = new DaCollectionParamConf(); + daCollectionParamConf2.setProcessesCode(device); + daCollectionParamConf2.setDescriptive("2"); + List<DaCollectionParamConf> daCollectionParamConfList2 = daCollectionParamConfService.selectDaCollectionParamConfList(daCollectionParamConf2); + for (DaCollectionParamConf conf : daCollectionParamConfList2) { + String gatherAddress = conf.getGatherAddress(); + String valueObj = miloService.readFromOpcUa(gatherAddress).getValue().toString(); // 鑾峰彇鍘熷鍊煎璞♀��:ml-citation{ref="4" data="citationList"} + if (!Objects.equals(valueObj, "0.0") && !Objects.equals(valueObj, "0")) { + DaParamCollection paramCollection = new DaParamCollection(); + paramCollection.setSfcCode(SFCCode.toString()); + paramCollection.setLocationCode(device); + paramCollection.setParamName(conf.getParameterSetName()); + paramCollection.setParamValue(miloService.readFromOpcUa(gatherAddress).getValue().toString()); + Date Time = new Date(); + ReadWriteEntity TimeRead = miloService.readFromOpcUa(thoroughfare + "." + device + ".StopTime"); + Time = format.parse(TimeUtil.test(TimeUtil.stringProcessing(TimeRead.getValue().toString()))); + paramCollection.setCollectTime(Time); + daParamCollectionService.insertDaParamCollection(paramCollection); + } + else { + log.debug("閲囬泦椤逛负绌�: {}", gatherAddress); + } + } } } } @@ -258,6 +306,7 @@ log.error(e.getMessage()); } } + //棣栧伐绔欎笅鍙戝伐鍗�,骞剁敓鎴怱N鐮� private static final String[] MONTH = {"A","B","C","D","E","F","G","H","I","J","K","L"}; public void plackWorkOrder(String thoroughfare, String device, String tab, String valueString) { @@ -286,7 +335,6 @@ String SFCCode = A1 + A2 + A3+ A4 + A5; miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); - sysCountService.updateSerialNumber(); }else{ sysCountService.clean(); sysCountService.updateYear(); @@ -298,7 +346,6 @@ String SFCCode = A1 + A2 + newA3+ A4 + A5; miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); - sysCountService.updateSerialNumber(); } // 鏇存柊 WorkOrderRequestDone 鍦板潃鍧� BsBomChildInfo bsbomChildInfo= new BsBomChildInfo(); @@ -306,13 +353,14 @@ bsbomChildInfo.setBomCode(getBodyOrder.getWorkOrderNo()); //鍙戜笅宸ヨ壓閰嶆柟 formula(thoroughfare, device, bsbomChildInfo); - omProductionOrderInfoService.updateBodyStatus1(); +// omProductionOrderInfoService.updateBodyStatus1(); //鍒ゆ柇缂镐綋宸ュ崟瀹屾垚 - OmProductionOrderInfo getBodyOrder2 = omProductionOrderInfoService.getBodyOrder(); - if (Objects.equals(getBodyOrder2.getBodyQty(), getBodyOrder2.getPlanQty())){ - omProductionOrderInfoService.updateBodyStatus2(); - } - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getBodyOrder2.getBodyQty()).build()); +// OmProductionOrderInfo getBodyOrder2 = omProductionOrderInfoService.getBodyOrder(); +// if (Objects.equals(getBodyOrder2.getBodyQty(), getBodyOrder2.getPlanQty())){ +// omProductionOrderInfoService.updateBodyStatus2(); +// } + String PalletID = String.valueOf(getBodyOrder.getBodyQty() + 1); + miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build()); miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build()); } else{ @@ -338,7 +386,6 @@ String SFCCode = A1 + A2 + A3+ A4 + A5; miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); - sysCountService.updateHeadNumber(); }else{ sysCountService.clean(); sysCountService.updateYear(); @@ -350,7 +397,6 @@ String SFCCode = A1 + A2 + newA3+ A4 + A5; miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); - sysCountService.updateHeadNumber(); } // 鏇存柊 WorkOrderRequestDone 鍦板潃鍧� BsBomChildInfo bsbomChildInfo= new BsBomChildInfo(); @@ -358,13 +404,14 @@ bsbomChildInfo.setBomCode(getHeadOrder.getWorkOrderNo()); //鍙戜笅宸ヨ壓閰嶆柟 formula(thoroughfare, device, bsbomChildInfo); - omProductionOrderInfoService.updateHeadStatus1(); +// omProductionOrderInfoService.updateHeadStatus1(); //鍒ゆ柇缂镐綋宸ュ崟瀹屾垚 - OmProductionOrderInfo getHeadOrder2 = omProductionOrderInfoService.getHeadOrder(); - if (Objects.equals(getHeadOrder2.getHeadQty(), getHeadOrder2.getPlanQty())){ - omProductionOrderInfoService.updateHeadStatus2(); - } - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getHeadOrder2.getHeadQty()).build()); +// OmProductionOrderInfo getHeadOrder2 = omProductionOrderInfoService.getHeadOrder(); +// if (Objects.equals(getHeadOrder2.getHeadQty(), getHeadOrder2.getPlanQty())){ +// omProductionOrderInfoService.updateHeadStatus2(); +// } + String PalletID = String.valueOf(getHeadOrder.getHeadQty() + 1); + miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build()); miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build()); } else{ @@ -389,7 +436,6 @@ String SFCCode = A1 + A2 + A3+ A4 + A5; miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); - sysCountService.updatePreNumber(); }else{ sysCountService.clean(); sysCountService.updateYear(); @@ -401,7 +447,6 @@ String SFCCode = A1 + A2 + newA3+ A4 + A5; miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".SFCCode").value(SFCCode).build()); miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".MESSFCCode").value(SFCCode).build()); - sysCountService.updateHeadNumber(); } // 鏇存柊 WorkOrderRequestDone 鍦板潃鍧� BsBomChildInfo bsbomChildInfo= new BsBomChildInfo(); @@ -409,13 +454,14 @@ bsbomChildInfo.setBomCode(getPreOrder.getWorkOrderNo()); //鍙戜笅宸ヨ壓閰嶆柟 formula(thoroughfare, device, bsbomChildInfo); - omProductionOrderInfoService.updatePreStatus1(); +// omProductionOrderInfoService.updatePreStatus1(); //鍒ゆ柇缂镐綋宸ュ崟瀹屾垚 - OmProductionOrderInfo getPreOrder2 = omProductionOrderInfoService.getPreOrder(); - if (Objects.equals(getPreOrder2.getPreQty(), getPreOrder2.getPlanQty())){ - omProductionOrderInfoService.updatePreStatus2(); - } - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(getPreOrder2.getPreQty()).build()); +// OmProductionOrderInfo getPreOrder2 = omProductionOrderInfoService.getPreOrder(); +// if (Objects.equals(getPreOrder2.getPreQty(), getPreOrder2.getPlanQty())){ +// omProductionOrderInfoService.updatePreStatus2(); +// } + String PalletID = String.valueOf(getPreOrder.getPreQty() + 1); + miloService.writeToOpcUa(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".PalletID").value(PalletID).build()); miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare + "." + device + ".WorkOrderRequestDone").value(11).build()); } else{ -- Gitblit v1.9.3