From 8b43954926db6b4df6a61ab6e04d6cb11189069d Mon Sep 17 00:00:00 2001 From: 吴健 <14790700720@163.com> Date: 星期二, 15 四月 2025 08:54:08 +0800 Subject: [PATCH] add-415 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 517 +++++++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 447 insertions(+), 70 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 2bfd0a8..2cb2892 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 @@ -1,9 +1,9 @@ package com.jcdm.main.plcserver.sub; - import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; +import com.jcdm.common.core.domain.BaseEntity; import com.jcdm.main.bs.domain.BsTechnologyRouteChildInfo; import com.jcdm.main.bs.orderScheduling.domain.BsOrderScheduling; import com.jcdm.main.bs.orderScheduling.service.IBsOrderSchedulingService; @@ -14,6 +14,8 @@ import com.jcdm.main.da.paramCollection.domain.DaParamCollection; import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService; import com.jcdm.main.da.passingStationCollection.domain.DaPassingStationCollection; +import com.jcdm.main.da.passingStationCollection.domain.ProductNewPassStation; +import com.jcdm.main.da.passingStationCollection.service.ProductNewPassStationService; import com.jcdm.main.da.passingStationCollection.service.impl.DaPassingStationCollectionServiceImpl; import com.jcdm.main.plcserver.conf.OPCElement; import com.jcdm.main.rm.repairRecord.domain.RmRepairRecord; @@ -22,6 +24,9 @@ import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; import com.kangaroohy.milo.service.MiloService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.ObjectUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.math.BigDecimal; @@ -36,6 +41,7 @@ @Component public class OPCUaSubscription implements SubscriptionCallback { + private static final Logger logger = LoggerFactory.getLogger("sys-user"); public static MiloService miloService; public IDaCollectionParamConfService collectionParamConfService; @@ -53,6 +59,7 @@ public IRmRepairRecordService rmRepairRecordService; public IBsTechnologyRouteChildInfoService bsTechnologyRouteChildInfoService; + public ProductNewPassStationService productNewPassStationService; public HashMap<String,List<DaCollectionParamConf>> allCollectParamList = new HashMap<>(); @@ -63,7 +70,8 @@ IBsOrderSchedulingService bsOrderSchedulingService, List<DaOpcuaConfig> lists, IRmRepairRecordService rmRepairRecordService, - IBsTechnologyRouteChildInfoService bsTechnologyRouteChildInfoService) { + IBsTechnologyRouteChildInfoService bsTechnologyRouteChildInfoService, + ProductNewPassStationService productNewPassStationService) { OPCUaSubscription.miloService = miloService; this.collectionParamConfService = collectionParamConfService; this.daParamCollectionService = daParamCollectionService; @@ -72,6 +80,7 @@ this.lists = lists; this.rmRepairRecordService = rmRepairRecordService; this.bsTechnologyRouteChildInfoService = bsTechnologyRouteChildInfoService; + this.productNewPassStationService = productNewPassStationService; } @@ -79,10 +88,7 @@ public void onSubscribe(String identifier, Object value) { String ecpStr = "";//寮傚父璁板綍鏍囪 try { - if(null != value && "1".equals(value.toString())) { -// if (OPCElement.OP121_ZZ_CODE_CHECK.equals(identifier)){ -// rework("2V91Y RD25D080",identifier); -// } + if(null != value && "1".equals(value.toString())) { //1銆佹绱N鍙� //2銆佽繃绔欏弬鏁伴噰闆� //3銆佹壂鐮佹灙鏁版嵁鍥炰紶 @@ -91,26 +97,139 @@ List<String> collect2 = lists.stream().filter(x -> OPCElement.SAVE_DATA.equals(x.getrFunction())) .map(DaOpcuaConfig::getNode).collect(Collectors.toList()); if (collect1.contains(identifier)){ - log.info("-------鐩戝惉鍒�,{}鐨凜ODE_CHECK鐨勪俊鍙�",identifier); - log.info("-------time--------------,{}",LocalDateTime.now()); + logger.info("-------鐩戝惉鍒�,{}鐨凜ODE_CHECK鐨勪俊鍙�",identifier); + //logger.info("-------time--------------,{}",LocalDateTime.now()); //sn - this.SNRetrieval(identifier,value.toString()); - if (identifier.equals(OPCElement.OP120_ZZ_CODE_CHECK) && "1".equals(value.toString())){ - //鎬昏涓婄嚎鎵爜浼犺緭鏁版嵁 - log.info("-------鐩戝惉鍒�,{}鐨勬壂鐮佹灙鎵爜鐨凜ODE_CHECK鐨勪俊鍙�",identifier); - scannerGunMessage(); + if (OPCElement.OP010_CODE_CHECK.equals(identifier)){ + ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP010.CodeCheckFeed", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity);//鍐欏畬鎴� + } else if (OPCElement.OP020_CODE_CHECK.equals(identifier)) { + ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.CodeCheckFeed", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity);//鍐欏畬鎴� + } else if (OPCElement.OP030_CODE_CHECK.equals(identifier)) { + ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP030.CodeCheckFeed", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity);//鍐欏畬鎴� + Object SNCodeObject = miloService.readFromOpcUa("CFL4HX.OP030.Code").getValue(); + if (ObjectUtil.isNotEmpty(SNCodeObject)){ + String snCode = SNCodeObject.toString(); + if (StrUtil.isNotBlank(snCode)){ + String type = productNewFlag(snCode); + if ("280".equals(type) || "380".equals(type)){ + //鑾峰彇绠变綋鐮� + ProductNewPassStation productNewPassStation = new ProductNewPassStation(); + productNewPassStation.setFinishFlag(OPCElement.UN_FINISH); + productNewPassStation.setSfcCode(snCode); + List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(productNewPassStation); + if (CollUtil.isNotEmpty(productPassStationList)){ + List<ProductNewPassStation> collect = productPassStationList.stream().sorted(Comparator.comparing(ProductNewPassStation::getCreateTime).reversed()).collect(Collectors.toList()); + ProductNewPassStation productNewPassStation1 = collect.get(0); + String boxCode = productNewPassStation1.getBoxCode(); + passingStationCollectionServiceImpl.sendMessage(type+"*"+boxCode,"OP030"); + } + + } else if ("196".equals(type) || "296".equals(type)){ + ReadWriteEntity entity6 = new ReadWriteEntity("CFL4HX.OP030.CodeComplete", 1); + miloService.writeToOpcByte(entity6); + } + } + + } + } else if (OPCElement.OP040_CODE_CHECK.equals(identifier)) { + ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP040.CodeCheckFeed", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity);//鍐欏畬鎴� + //鎺ㄩ�佹暟鎹� + log.info("杩涘叆OP040.CodeCheck"); + tile2("CFL4HX.OP040.CodeCheck"); + } else { + this.SNRetrieval(identifier,value.toString()); + if (identifier.equals(OPCElement.OP120_ZZ_CODE_CHECK) && "1".equals(value.toString())){ + //鎬昏涓婄嚎鎵爜浼犺緭鏁版嵁 + logger.info("-------鐩戝惉鍒�,{}鐨勬壂鐮佹灙鎵爜鐨凜ODE_CHECK鐨勪俊鍙�",identifier); + scannerGunMessage(); + } } + } if (collect2.contains(identifier)){ if ("1".equals(value.toString())){ - log.info("-------鐩戝惉鍒�,{}鐨凷AVE_REQUEST_LAST鐨勪俊鍙�",identifier); - log.info("-------time--------------,{}",LocalDateTime.now()); - //save - this.SaveData(identifier); + logger.info("-------鐩戝惉鍒�,{}鐨凷AVE_REQUEST_LAST鐨勪俊鍙�",identifier); + //logger.info("-------time--------------,{}",LocalDateTime.now()); + //HX绾挎敼瑁� + if (OPCElement.OP010_REQUEST_PRODUCT_TYPE.equals(identifier)){ + Object SNCodeObject = miloService.readFromOpcUa("CFL4HX.OP010.Code").getValue(); + if (ObjectUtil.isNotEmpty(SNCodeObject)){ + String snCode = SNCodeObject.toString(); + ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP010.ProductTypeSN",snCode); + OPCUaSubscription.miloService.writeToOpcUa(entity3);//鍐欎骇鍝丼N鍙峰弽棣� + ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP010.SNDone", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity2);//鍐欏畬鎴� + + } + } else if (OPCElement.OP010_SAVE_REQUEST.equals(identifier)) { + ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP010.SaveFeed", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity2);//鍐欏畬鎴� + } else if (OPCElement.OP020_PRINT_REQUEST.equals(identifier)) { + Object SNCodeObject = miloService.readFromOpcUa("CFL4HX.OP020.Code").getValue(); + if (ObjectUtil.isNotEmpty(SNCodeObject)){ + String snCode = SNCodeObject.toString(); + DaPassingStationCollection passingStationCollectionCheck = new DaPassingStationCollection(); + passingStationCollectionCheck.setLocationCode("OP020"); + passingStationCollectionCheck.setSfcCode(snCode); + List<DaPassingStationCollection> checkList = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(passingStationCollectionCheck); + if (CollUtil.isNotEmpty(checkList)){ + if (snCode.startsWith("380")){ + log.info("enter-380"); + String[] split = snCode.split(StrUtil.SPACE); + if (split.length>1){ + ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", split[0]); + OPCUaSubscription.miloService.writeToOpcUa(entity);//鍐欏畬鎴� + ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP020.PrintSN2", "鈽�"+split[1]+"鈽�"); + OPCUaSubscription.miloService.writeToOpcUa(entity2);//鍐欏畬鎴� + ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 2); + OPCUaSubscription.miloService.writeToOpcByte(entity3);//鍐欏畬鎴� + } + } else { + ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", snCode); + OPCUaSubscription.miloService.writeToOpcByte(entity);//鍐欏畬鎴� + ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 2); + OPCUaSubscription.miloService.writeToOpcByte(entity3);//鍐欏畬鎴� + } + } else { + if (snCode.startsWith("380")){ + log.info("enter-380"); + String[] split = snCode.split(StrUtil.SPACE); + if (split.length>1){ + ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", split[0]); + OPCUaSubscription.miloService.writeToOpcUa(entity);//鍐欏畬鎴� + ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP020.PrintSN2", "鈽�"+split[1]+"鈽�"); + OPCUaSubscription.miloService.writeToOpcUa(entity2);//鍐欏畬鎴� + ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity3);//鍐欏畬鎴� + } + } else { + ReadWriteEntity entity = new ReadWriteEntity("CFL4HX.OP020.PrintSN1", snCode); + OPCUaSubscription.miloService.writeToOpcByte(entity);//鍐欏畬鎴� + ReadWriteEntity entity3 = new ReadWriteEntity("CFL4HX.OP020.SendSNDone", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity3);//鍐欏畬鎴� + } + } + + } + } else if (OPCElement.OP030_SAVE_REQUEST.equals(identifier)) { + cleanForm("CFL4HX.OP030.SaveFeed"); + ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP030.SaveFeed", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity2);//鍐欏畬鎴� + + } else if (OPCElement.OP040_SAVE_REQUEST.equals(identifier)) { + cleanForm040(OPCElement.OP040_SAVE_REQUEST); + ReadWriteEntity entity2 = new ReadWriteEntity("CFL4HX.OP040.SaveFeed", 1); + OPCUaSubscription.miloService.writeToOpcByte(entity2);//鍐欏畬鎴� + } else { + this.SaveData(identifier); + } } } - } } catch (Exception e) { System.out.println(e.getMessage()); @@ -129,7 +248,7 @@ } if (null != SNCodeObject){ String SNCode = SNCodeObject.toString(); - passingStationCollectionServiceImpl.sendMessage(SNCode); + passingStationCollectionServiceImpl.sendMessage(SNCode,"OP120"); } } @@ -140,13 +259,34 @@ Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); if(null != SNCodeObject) { String SNCode=SNCodeObject.toString(); -// String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]); +// String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]); String a; BsOrderScheduling bsOrderSchedulingQuery = new BsOrderScheduling(); bsOrderSchedulingQuery.setEngineNo(SNCode); List<BsOrderScheduling> queryOrderList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderSchedulingQuery); if (CollUtil.isNotEmpty(queryOrderList)){ a = "1"; + //濡傛灉鏄�佽溅鍨嬶紝鍒ゆ柇鏄惁閲嶅鎵爜 + if (OPCElement.OP050_CODE_CHECK.equals(Node)){ + String type = productNewFlag(SNCode); + if (!"280".equals(type) && !"380".equals(type) && !"196".equals(type) && !"296".equals(type) ){ + DaPassingStationCollection passCheck = new DaPassingStationCollection(); + passCheck.setSfcCode(SNCode); + passCheck.setLocationCode("OP060"); + List<DaPassingStationCollection> passCheckList = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(passCheck); + if (CollUtil.isNotEmpty(passCheckList)){ + //鏄惁杩斾慨 + a = "5"; +// RmRepairRecord repairRecordCheck = new RmRepairRecord(); +// repairRecordCheck.setBoxCode(SNCode); +// repairRecordCheck.setProcessesCode("OP050"); +// List<RmRepairRecord> repairCheckList = rmRepairRecordService.selectRmRepairRecordList(repairRecordCheck); +// if (CollUtil.isEmpty(repairCheckList)){ +// +// } + } + } + } }else { a = "4"; } @@ -159,52 +299,101 @@ DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); PassingStationCollection.setSfcCode(SNCode); daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection); - if (CollUtil.isNotEmpty(daPassingStationCollections)){ - DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1); - String outRsSign = lastOne.getOutRsSign(); - if ("鍚堟牸".equals(outRsSign)){ - a = "1"; - }else { - a = "2"; - } - } +// if (CollUtil.isNotEmpty(daPassingStationCollections)){ +// DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1); +// String outRsSign = lastOne.getOutRsSign(); +// if ("鍚堟牸".equals(outRsSign)){ +// a = "1"; +// }else { +// a = "2"; +// } +// } RmRepairRecord rmRepairRecord = new RmRepairRecord(); rmRepairRecord.setBoxCode(SNCode); rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord); if (CollUtil.isNotEmpty(rmRepairRecords)){ a = "1"; + }else { + a = "2"; } - } - log.info("-----杩斿洖codeCheckFeed-----,{}",a); + logger.info("-----杩斿洖codeCheckFeed-----,{}",a); // String a="1"; + //zz涓婄嚎宸ヤ綅鏌ヨhx绾挎槸鍚﹁繃绔欏悎鏍� + if (OPCElement.OP120_ZZ_CODE_CHECK.equals(Node)){ + //杩囩珯璁板綍 + DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); + PassingStationCollection.setSfcCode(SNCode); + PassingStationCollection.setLocationCode("OP160"); + List<DaPassingStationCollection> ZZOP120PassCheck = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection); + if (CollUtil.isEmpty(ZZOP120PassCheck)){ + a = ""; + } else { + DaPassingStationCollection passingStationCollection = ZZOP120PassCheck.get(0); + String outRsSign = passingStationCollection.getOutRsSign(); + if (!OPCElement.QUALIFIED.equals(outRsSign)){ + a = ""; + } + } + } // 1:OK鍙敓浜� 2:NG涓嶅彲鐢熶骇 3:NG鍙繑宸� 4:PC妫�绱㈠け璐ワ紙鏃犺褰曪級5:PC妫�绱㈠け璐ワ紙杞欢锛� if (StrUtil.isNotBlank(a)){ int input = Integer.parseInt(a); ReadWriteEntity entity = new ReadWriteEntity(parts[0]+"."+parts[1]+".CodeCheckFeed", input); - log.info("-------鐩戝惉鍒�,{}鐨凜odeCheck鐨勪俊鍙�",Node); + logger.info("鍙戝姩鏈哄彿锛歿},鐩戝惉鍒皗}鐨凜odeCheck鐨勪俊鍙�",SNCode,Node); miloService.writeToOpcByte(entity); - log.info("鐩戝惉鍒拌繑鍥瀋odecheckfeed淇″彿锛寋}",entity); + logger.info("鐩戝惉鍒拌繑鍥瀋odecheckfeed淇″彿锛寋}",entity); //棣栫珯浼犺緭璁㈠崟鍙� - if (OPCElement.OP050_HX_CODE_CHECK.equals(Node)){ - //鏌ヨ璁㈠崟鍙� - BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); - bsOrderScheduling.setEngineNo(SNCode); - List<BsOrderScheduling> tempList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); - String orderNum = ""; - if (CollUtil.isNotEmpty(tempList)){ - BsOrderScheduling bsOrderScheduling1 = tempList.get(0); - orderNum = bsOrderScheduling1.getOrderNo(); - } - - ReadWriteEntity entity2 = new ReadWriteEntity(parts[0]+"."+parts[1]+".OrderNumber", orderNum); - miloService.writeToOpcUa(entity2); - } +// if (OPCElement.OP050_HX_CODE_CHECK.equals(Node)){ +// //鏌ヨ璁㈠崟鍙� +// BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); +// bsOrderScheduling.setEngineNo(SNCode); +// List<BsOrderScheduling> tempList = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling); +// String orderNum = ""; +// if (CollUtil.isNotEmpty(tempList)){ +// BsOrderScheduling bsOrderScheduling1 = tempList.get(0); +// orderNum = bsOrderScheduling1.getOrderNo(); +// } +// ReadWriteEntity entity2 = new ReadWriteEntity(parts[0]+"."+parts[1]+".OrderNumber", orderNum); +// miloService.writeToOpcUa(entity2); +// } //濡傛灉鏄繑淇伐浣嶉渶瑕佷紶杈撹繑淇伐浣嶅彿 if (OPCElement.OP465_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP355_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP695_ZZ_CODE_CHECK.equals(Node) || OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){ - rework(SNCode,Node,daPassingStationCollections,rmRepairRecords); + } + if (OPCElement.OP050_CODE_CHECK.equals(Node)) { + //鏂版満鍨�050 + String type = productNewFlag(SNCode); + if ("280".equals(type) || "380".equals(type)){ + ProductNewPassStation productNewPassStation = new ProductNewPassStation(); + productNewPassStation.setSfcCode(SNCode); + List<ProductNewPassStation> passStationList = productNewPassStationService.getProductPassStationList(productNewPassStation); + ProductNewPassStation productNewPassStation2 = new ProductNewPassStation(); + productNewPassStation2.setFinishFlag("0"); + List<ProductNewPassStation> collect = productNewPassStationService.getProductPassStationList(productNewPassStation2) + .stream().sorted(Comparator.comparing(ProductNewPassStation::getCreateTime)) + .collect(Collectors.toList()); + String partSfcCode = ""; + if (CollUtil.isNotEmpty(collect)){ + ProductNewPassStation passStation = collect.get(0); + partSfcCode = passStation.getSfcCode(); + } + if (CollUtil.isNotEmpty(passStationList)){ + ProductNewPassStation passStation = passStationList.get(0); + String productType = ""; + if (ObjectUtils.isNotEmpty(passStation)){ + productType = passStation.getProductType(); + } + passingStationCollectionServiceImpl.sendMessage(SNCode+"*sfcCode*"+productType+"*"+partSfcCode,"OP050"); + } + } + } + if (OPCElement.OP060_CODE_CHECK.equals(Node)){ + String type = productNewFlag(SNCode); + if ("280".equals(type) || "380".equals(type)){ + checkBoxRod(Node); + } } System.out.println(entity); @@ -238,7 +427,7 @@ //杩囩珯璁板綍 // List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection); - //鎵�鏈夊弽宸ュ伐浣� + //鎵�鏈夎繑宸ュ伐浣� List<String> collect1 = rmRepairRecords.stream().map(RmRepairRecord::getProcessesCode).collect(Collectors.toList()); if (CollUtil.isNotEmpty(collect1)){ //鏌ヨ鍑烘墍鏈夐渶瑕佽繑淇伐浣嶇殑鏈�灏弌p鍧� @@ -271,8 +460,6 @@ } } - - //鎵�鏈夋斁琛屽伐浣� List<String> passStation = new ArrayList<>(); //鎵�鏈夌敓浜у伐浣� @@ -298,7 +485,7 @@ Integer finalMaxCodeNum = maxCodeNum; //鍕鹃�夌殑杩斾慨宸ヤ綅涓渶澶х殑宸ヤ綅涔嬪悗鐨勫伐浣�----1 List<BsTechnologyRouteChildInfo> collect3 = bsTechnologyRouteChildInfos.stream() - .filter(x -> x.getStepNoNum() >= finalMaxCodeNum).collect(Collectors.toList()); + .filter(x -> x.getStepNoNum() > finalMaxCodeNum).collect(Collectors.toList()); if (CollUtil.isNotEmpty(collect3)){ //闇�瑕佺敓浜� productStation.addAll(collect3.stream().map(BsTechnologyRouteChildInfo::getProcessesCode).collect(Collectors.toList())); @@ -350,7 +537,7 @@ readWriteEntity.setValue(minOP); miloService.writeToOpcShort(readWriteEntity); miloService.writeToOpcByte(writeList); - log.info("杩斾慨鍐欏叆锛�,{}",writeList); + logger.info("{}杩斾慨鍐欏叆锛�,{}",SNCode,writeList); if (CollUtil.isNotEmpty(OP755List)){ miloService.writeToOpcByte(OP755List); } @@ -384,7 +571,26 @@ allCollectParamList.put(gatherAddress,list); } } + //60鍙噰闆嗚�佽溅鍨� + if (OPCElement.OP060_SAVE_REQUEST.equals(Node) || OPCElement.OP060_SAVE_REQUEST_LAST.equals(Node)){ + String s = productNewFlag(SNCode); + if ("280".equals(s) || "380".equals(s) || "196".equals(s) || "296".equals(s)){ + list = new ArrayList<>(); + } + } + //80銆�100鍙噰闆嗘柊杞﹀瀷 + if (OPCElement.OP080_SAVE_REQUEST.equals(Node) + || OPCElement.OP080_SAVE_REQUEST_LAST.equals(Node) + || OPCElement.OP100_SAVE_REQUEST.equals(Node) + || OPCElement.OP100_SAVE_REQUEST_LAST.equals(Node)){ + String s = productNewFlag(SNCode); + if (StrUtil.isNotEmpty(s)){ + if (!"280".equals(s) && !"380".equals(s) && !"196".equals(s)){ + list = new ArrayList<>(); + } + } + } List<String> nodeIdList = list.stream().map(info -> { String nodeid = info.getGatherAddress(); return nodeid; @@ -392,23 +598,36 @@ List<ReadWriteEntity> readWriteEntityList = new ArrayList<>(); if(CollUtil.isNotEmpty(nodeIdList)){ - long time1 = new Date().getTime(); + //long time1 = new Date().getTime(); readWriteEntityList = miloService.readFromOpcUa(nodeIdList); - long time2 = new Date().getTime(); - log.info("璇诲彇鐐逛綅鑺辫垂鏃堕棿锛歿},",time2-time1); + //long time2 = new Date().getTime(); + //logger.info("璇诲彇鐐逛綅鑺辫垂鏃堕棿锛歿},",time2-time1); } //杩斿洖plc淇濆瓨鎴愬姛 if (parts.length==3){ if ("SaveRequest".equals(parts[2])){ + if (OPCElement.OP050_SAVE_REQUEST.equals(Node)){ + cleanForm050(Node); + } else if (OPCElement.OP060_SAVE_REQUEST.equals(Node)){ + cleanForm060(Node); + } ReadWriteEntity entity = new ReadWriteEntity(parts[0] + "." + parts[1] + ".SaveFeed", 1); miloService.writeToOpcByte(entity); }else if ("SaveRequestLast".equals(parts[2])){ + if (OPCElement.OP050_SAVE_REQUEST_LAST.equals(Node)){ + cleanForm050(Node); + } else if (OPCElement.OP060_SAVE_REQUEST_LAST.equals(Node)){ + cleanForm060(Node); + } ReadWriteEntity entity = new ReadWriteEntity(parts[0] + "." + parts[1] + ".SaveFeedLast", 1); miloService.writeToOpcByte(entity); } - log.info("-------璇锋眰杩斿洖,{}鐨凷aveFeedLast鐨勪俊鍙�",Node); - log.info("-------璇锋眰杩斿洖-----,{}",LocalDateTime.now()); + logger.info("{}淇濆瓨璇锋眰淇″彿杩斿洖,MES->PLC鐨凷aveFeedLast淇″彿",Node); + //logger.info("-------璇锋眰杩斿洖-----,{}",LocalDateTime.now()); } + + BsOrderScheduling bsOrderScheduling=bsOrderSchedulingService.selectBsOrderSchedulingSNCode(SNCode); + List<DaParamCollection> daParamCollectionlist = new ArrayList<>(); if (CollUtil.isNotEmpty(nodeIdList)){ for(int i=0;i<nodeIdList.size();i++){ @@ -422,32 +641,25 @@ ParamCollection.setParamValue(readWriteEntityList.get(i).getValue().toString()); } ParamCollection.setSfcCode(SNCode); - ParamCollection.setParamName(list.get(i).getCollectParameterName()); + ParamCollection.setParamName(list.get(i).getParameterSetName()); ParamCollection.setParamUpper(list.get(i).getParamUpper()); ParamCollection.setParamLower(list.get(i).getParamLower()); ParamCollection.setUnit(list.get(i).getCollectParameterUnit()); ParamCollection.setState("鍚堟牸"); ParamCollection.setType(list.get(i).getCollectParameterType()); ParamCollection.setCollectionTime(new Date()); + ParamCollection.setWorkOrderNo(bsOrderScheduling.getOrderNo()); daParamCollectionlist.add(ParamCollection); } } daParamCollectionService.saveBeachDaParamCollection(daParamCollectionlist); - log.info("-------淇濆瓨鏁版嵁瀹屾垚---------"); + logger.info("{}鍙戝姩鏈猴紙{}锛夐噰闆嗘暟鎹繚瀛樺畬鎴�",SNCode,Node); } - - - - Long beatTime = 0L; - if (ObjectUtil.isNotEmpty(object)){ - String str = object.toString(); - beatTime = Float.valueOf(str).longValue(); - } Object ProductStatus = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".ProductStatus").getValue(); - log.info("ProductStatus,{}",ProductStatus.toString()); String str1="鍚堟牸" ; if (ObjectUtil.isNotEmpty(ProductStatus)){ + logger.info("ProductStatus,{}",ProductStatus.toString()); String productStatusString = ProductStatus.toString(); if (productStatusString.contains("2") || productStatusString.contains("3")){ str1="涓嶅悎鏍�"; @@ -455,8 +667,14 @@ str1="鍚堟牸"; } } + Long beatTime = 0L; + if (ObjectUtil.isNotEmpty(object)){ + String str = object.toString(); + beatTime = Float.valueOf(str).longValue(); + } DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); PassingStationCollection.setSfcCode(SNCode); + PassingStationCollection.setProductCode(bsOrderScheduling.getModel()); PassingStationCollection.setLocationCode(parts[1]); PassingStationCollection.setOutboundTime(new Date()); PassingStationCollection.setInboundTime(new Date(new Date().getTime()-beatTime*1000)); @@ -464,9 +682,168 @@ PassingStationCollection.setCreateTime(new Date()); PassingStationCollection.setBeatTime(beatTime.toString()); PassingStationCollection.setOutRsSign(str1); + PassingStationCollection.setWorkOrderNo(bsOrderScheduling.getOrderNo()); passingStationCollectionServiceImpl.insertDaPassingStationCollection(PassingStationCollection); - log.info("-------淇濆瓨杩囩珯璁板綍鏁版嵁瀹屾垚---------"); + logger.info("{}鍙戝姩鏈猴紙{}锛夎繃绔欐暟鎹繚瀛樺畬鎴�",SNCode,Node); + //鏇存柊宸ュ崟鐘舵�� + if ("OP790".equals(parts[1])) { + //bsOrderScheduling.setReport20("0"); + bsOrderScheduling.setProductionStatus("3"); + bsOrderScheduling.setFinalAssemblyOfflineTime(new Date()); + }else if("OP050".equals(parts[1])){ + bsOrderScheduling.setReport10("0"); + bsOrderScheduling.setProductionStatus("2"); + bsOrderScheduling.setBoxClosingOnlineTime(new Date()); + }else if("OP120".equals(parts[1])){ + bsOrderScheduling.setReport20("0"); + bsOrderScheduling.setFinalAssemblyLaunchTime(new Date()); + bsOrderScheduling.setClosingBoxOfflineTime(new Date()); + } + bsOrderScheduling.setQualityStatus(str1); + bsOrderScheduling.setCurrentWorkstation(parts[1]); + bsOrderSchedulingService.updateBsOrderScheduling(bsOrderScheduling); } } + + + public String productNewFlag(String SNCode){ + String type; + if (SNCode.startsWith("280")){ + type = "280"; + } else if (SNCode.startsWith("380")){ + type = "380"; + } else if (SNCode.startsWith("196")){ + type = "196"; + } else if (SNCode.startsWith("296")){ + type = "296"; + }else { + type = "oldType"; + } + return type; + } + + public void tile2(String Node) throws Exception { + String[] parts = Node.split("[.]"); + Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); + if (null != SNCodeObject) { + String SNCode = SNCodeObject.toString(); + String productNewFlag = productNewFlag(SNCode); + if ("380".equals(productNewFlag)){ + ProductNewPassStation passStation = new ProductNewPassStation(); + passStation.setSfcCode(SNCode); + List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(passStation); + if (CollUtil.isNotEmpty(productPassStationList)){ + ProductNewPassStation productNewPassStation = productPassStationList.get(0); + String boxCode = productNewPassStation.getBoxCode(); + String productType = productNewPassStation.getProductType(); + log.info("鍙戦�佸埌OP040鐨勯〉闈㈡暟鎹畃roductType,{}",productType); + log.info("鍙戦�佸埌OP040鐨勯〉闈㈡暟鎹産oxCode,{}",boxCode); + passingStationCollectionServiceImpl.sendMessage(productType+"*"+boxCode, "OP040"); + } + } else if ("280".equals(productNewFlag)){ + + } else if ("196".equals(productNewFlag)){ + ReadWriteEntity entity6 = new ReadWriteEntity("CFL4HX.OP040.CodeComplete", 1); + miloService.writeToOpcByte(entity6); +// ProductNewPassStation passStation = new ProductNewPassStation(); +// passStation.setSfcCode(SNCode); +// List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(passStation); +// if (CollUtil.isNotEmpty(productPassStationList)){ +// ProductNewPassStation productNewPassStation = productPassStationList.get(0); +// String boxCode = productNewPassStation.getBoxCode(); +// String productType = productNewPassStation.getProductType(); +// log.info("鍙戦�佸埌OP040鐨勯〉闈㈡暟鎹畃roductType,{}",productType); +// log.info("鍙戦�佸埌OP040鐨勯〉闈㈡暟鎹産oxCode,{}",boxCode); +// passingStationCollectionServiceImpl.sendMessage(productType+"*"+boxCode, "OP040"); +// } + } + } + } + + + public void cleanForm(String Node) throws Exception { + String[] parts = Node.split("[.]"); + Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); + if (ObjectUtils.isNotEmpty(SNCodeObject)){ + String snCode = SNCodeObject.toString(); + String s = productNewFlag(snCode); + if ("280".equals(s) || "380".equals(s)){ + log.info("鍙戦�佸埌OP030鐨勬竻闄�"); + passingStationCollectionServiceImpl.sendMessage("clean","OP030"); + } + } + + } + + public void cleanForm040(String Node) throws Exception { + String[] parts = Node.split("[.]"); + Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); + if (ObjectUtils.isNotEmpty(SNCodeObject)){ + String snCode = SNCodeObject.toString(); + String s = productNewFlag(snCode); + if ("280".equals(s) || "380".equals(s)){ + log.info("鍙戦�佸埌OP040鐨勯〉闈㈡竻闄�"); + passingStationCollectionServiceImpl.sendMessage("clean*clean","OP040"); + } + } + } + + public void cleanForm050(String Node) throws Exception { + String[] parts = Node.split("[.]"); + Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); + if (ObjectUtils.isNotEmpty(SNCodeObject)){ + String snCode = SNCodeObject.toString(); + String s = productNewFlag(snCode); + if ("280".equals(s) || "380".equals(s)){ + ProductNewPassStation passStation = new ProductNewPassStation(); + passStation.setSfcCode(snCode); + List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(passStation); + if (CollUtil.isNotEmpty(productPassStationList)){ + productNewPassStationService.updatePassStationBySfcCode(snCode); + } + passingStationCollectionServiceImpl.sendMessage("clean*clean","OP050"); + } + } + } + + public void cleanForm060(String Node) throws Exception { + String[] parts = Node.split("[.]"); + Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); + if (ObjectUtils.isNotEmpty(SNCodeObject)){ + String snCode = SNCodeObject.toString(); + String s = productNewFlag(snCode); + if ("280".equals(s) || "380".equals(s)){ + passingStationCollectionServiceImpl.sendMessage("clean*clean","OP060"); + } + } + } + + + public void checkBoxRod(String Node) throws Exception { + String[] parts = Node.split("[.]"); + Object SNCodeObject = miloService.readFromOpcUa(parts[0] + "." + parts[1] + ".Code").getValue(); + if (null != SNCodeObject) { + String SNCode = SNCodeObject.toString(); + String s = productNewFlag(SNCode); + if ("280".equals(s) || "380".equals(s)){ + sendTo060(SNCode,parts); + } + } + } + + private void sendTo060(String SNCode, String[] parts) throws Exception { + String boxCode = ""; + String rodCode = ""; + ProductNewPassStation productNewPassStation = new ProductNewPassStation(); + productNewPassStation.setSfcCode(SNCode); + List<ProductNewPassStation> productPassStationList = productNewPassStationService.getProductPassStationList(productNewPassStation); + if (CollUtil.isNotEmpty(productPassStationList)){ + ProductNewPassStation passStation = productPassStationList.get(0); + boxCode = passStation.getBoxCode(); + rodCode = passStation.getRodCode(); + } + //閰嶇摝鏍¢獙 + passingStationCollectionServiceImpl.sendMessage(boxCode + "*" + rodCode + "*" + SNCode, parts[1]); + } } -- Gitblit v1.9.3