From 1a444b1dc206297ed3d7199c3c5fb557f580c9af Mon Sep 17 00:00:00 2001 From: yyt <306727702@qq.com> Date: 星期日, 05 五月 2024 08:30:05 +0800 Subject: [PATCH] 更新过站 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 94 ++++++++++++++++++++++++++++++----------------- 1 files changed, 60 insertions(+), 34 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 16821e1..c91312f 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,6 +1,5 @@ package com.jcdm.main.plcserver.sub; - import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; @@ -22,6 +21,8 @@ import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; import com.kangaroohy.milo.service.MiloService; import lombok.extern.slf4j.Slf4j; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Component; import java.math.BigDecimal; @@ -36,6 +37,7 @@ @Component public class OPCUaSubscription implements SubscriptionCallback { + private static final Logger logger = LoggerFactory.getLogger("sys-user"); public static MiloService miloService; public IDaCollectionParamConfService collectionParamConfService; @@ -80,9 +82,6 @@ String ecpStr = "";//寮傚父璁板綍鏍囪 try { if(null != value && "1".equals(value.toString())) { -// if (OPCElement.OP121_ZZ_CODE_CHECK.equals(identifier)){ -// rework("2V91Y RD25D080",identifier); -// } //1銆佹绱N鍙� //2銆佽繃绔欏弬鏁伴噰闆� //3銆佹壂鐮佹灙鏁版嵁鍥炰紶 @@ -91,26 +90,23 @@ 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); + 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 + logger.info("-------鐩戝惉鍒�,{}鐨凷AVE_REQUEST_LAST鐨勪俊鍙�",identifier); + //logger.info("-------time--------------,{}",LocalDateTime.now()); this.SaveData(identifier); - } } - } } catch (Exception e) { System.out.println(e.getMessage()); @@ -174,17 +170,16 @@ if (CollUtil.isNotEmpty(rmRepairRecords)){ a = "1"; } - } - log.info("-----杩斿洖codeCheckFeed-----,{}",a); + logger.info("-----杩斿洖codeCheckFeed-----,{}",a); // String a="1"; // 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鐨勪俊鍙�",Node); miloService.writeToOpcByte(entity); - log.info("鐩戝惉鍒拌繑鍥瀋odecheckfeed淇″彿锛寋}",entity); + logger.info("鐩戝惉鍒拌繑鍥瀋odecheckfeed淇″彿锛寋}",entity); //棣栫珯浼犺緭璁㈠崟鍙� if (OPCElement.OP050_HX_CODE_CHECK.equals(Node)){ //鏌ヨ璁㈠崟鍙� @@ -196,14 +191,12 @@ 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); } System.out.println(entity); @@ -238,7 +231,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 +264,6 @@ } } - - //鎵�鏈夋斁琛屽伐浣� List<String> passStation = new ArrayList<>(); //鎵�鏈夌敓浜у伐浣� @@ -330,12 +321,30 @@ writeList.add(readWriteEntity); }); } + //瀵筄P755鍋氱壒娈婂鐞� + List<ReadWriteEntity> OP755List = new ArrayList<>(); + if (OPCElement.OP755_ZZ_CODE_CHECK.equals(Node)){ + List<String> patchList = new ArrayList<>(); + patchList.add(par+".OP740"); + patchList.add(par+".OP760"); + patchList.add(par+".OP770"); + patchList.add(par+".OP780"); + for (String s : patchList) { + ReadWriteEntity readWriteEntity = new ReadWriteEntity(); + readWriteEntity.setIdentifier(s); + readWriteEntity.setValue(0); + OP755List.add(readWriteEntity); + } + } ReadWriteEntity readWriteEntity = new ReadWriteEntity(); readWriteEntity.setIdentifier(parts[0]+"."+parts[1]+".Repair_sign"); readWriteEntity.setValue(minOP); miloService.writeToOpcShort(readWriteEntity); miloService.writeToOpcByte(writeList); - log.info("杩斾慨鍐欏叆锛�,{}",writeList); + logger.info("{}杩斾慨鍐欏叆锛�,{}",SNCode,writeList); + if (CollUtil.isNotEmpty(OP755List)){ + miloService.writeToOpcByte(OP755List); + } } } @@ -374,10 +383,10 @@ 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){ @@ -388,9 +397,12 @@ 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++){ @@ -411,23 +423,20 @@ 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()); + logger.info("ProductStatus,{}",ProductStatus.toString()); String str1="鍚堟牸" ; if (ObjectUtil.isNotEmpty(ProductStatus)){ String productStatusString = ProductStatus.toString(); @@ -446,9 +455,26 @@ 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("1"); + bsOrderScheduling.setProductionStatus("3"); + bsOrderScheduling.setFinalAssemblyOfflineTime(new Date()); + }else if("OP050".equals(parts[1])){ + bsOrderScheduling.setReport10("1"); + bsOrderScheduling.setProductionStatus("2"); + bsOrderScheduling.setBoxClosingOnlineTime(new Date()); + }else if("OP120".equals(parts[1])){ + bsOrderScheduling.setFinalAssemblyLaunchTime(new Date()); + bsOrderScheduling.setClosingBoxOfflineTime(new Date()); + } + bsOrderScheduling.setQualityStatus(str1); + bsOrderScheduling.setCurrentWorkstation(parts[1]); + bsOrderSchedulingService.updateBsOrderScheduling(bsOrderScheduling); } } } -- Gitblit v1.9.3