From 9bc5106810d7c0e6f27e904b584c9bbfb3725a19 Mon Sep 17 00:00:00 2001 From: wujian <14790700720@163.com> Date: 星期日, 28 四月 2024 17:42:09 +0800 Subject: [PATCH] change model11 --- jcdm-main/src/main/java/com/jcdm/main/plcserver/sub/OPCUaSubscription.java | 253 ++++++++++++++++++++++++++++++-------------------- 1 files changed, 150 insertions(+), 103 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 240336b..16821e1 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 @@ -21,7 +21,6 @@ import com.kangaroohy.milo.model.ReadWriteEntity; import com.kangaroohy.milo.runner.subscription.SubscriptionCallback; import com.kangaroohy.milo.service.MiloService; -import javafx.animation.Timeline; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -141,7 +140,42 @@ 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"; + }else { + a = "4"; + } + //濡傛灉鏄繑淇伐浣嶉渶瑕佷紶杈撹繑淇伐浣嶅彿 + List<DaPassingStationCollection> daPassingStationCollections = new ArrayList<>(); + List<RmRepairRecord> rmRepairRecords = new ArrayList<>(); + 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)){ + //杩囩珯璁板綍 + 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"; + } + } + RmRepairRecord rmRepairRecord = new RmRepairRecord(); + rmRepairRecord.setBoxCode(SNCode); + rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord); + if (CollUtil.isNotEmpty(rmRepairRecords)){ + a = "1"; + } + + } log.info("-----杩斿洖codeCheckFeed-----,{}",a); // String a="1"; // 1:OK鍙敓浜� 2:NG涓嶅彲鐢熶骇 3:NG鍙繑宸� 4:PC妫�绱㈠け璐ワ紙鏃犺褰曪級5:PC妫�绱㈠け璐ワ紙杞欢锛� @@ -169,7 +203,8 @@ //濡傛灉鏄繑淇伐浣嶉渶瑕佷紶杈撹繑淇伐浣嶅彿 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); + + rework(SNCode,Node,daPassingStationCollections,rmRepairRecords); } System.out.println(entity); @@ -179,129 +214,130 @@ } } - private void rework(String SNCode,String Node) throws Exception{ + private void rework(String SNCode,String Node,List<DaPassingStationCollection> daPassingStationCollections,List<RmRepairRecord> rmRepairRecords) throws Exception{ BsOrderScheduling bsOrderScheduling = new BsOrderScheduling(); bsOrderScheduling.setEngineNo(SNCode); List<String> allProcessCoed = new ArrayList<>(); + List<BsTechnologyRouteChildInfo> bsTechnologyRouteChildInfos = new ArrayList<>(); List<String> collect = bsOrderSchedulingService.selectBsOrderSchedulingList(bsOrderScheduling).stream().map(BsOrderScheduling::getModel).collect(Collectors.toList()); if (CollUtil.isNotEmpty(collect)){ String s = collect.get(0); //鏌ユ壘娆℃満鍨嬬殑瀹屾暣宸ュ簭 - List<BsTechnologyRouteChildInfo> bsTechnologyRouteChildInfos = bsTechnologyRouteChildInfoService.selectAllTechnologyRouteByProductCode(s); + bsTechnologyRouteChildInfos = bsTechnologyRouteChildInfoService.selectAllTechnologyRouteByProductCode(s); if (CollUtil.isNotEmpty(bsTechnologyRouteChildInfos)){ allProcessCoed = bsTechnologyRouteChildInfos.stream().map(BsTechnologyRouteChildInfo::getProcessesCode).collect(Collectors.toList()); } } - RmRepairRecord rmRepairRecord = new RmRepairRecord(); - rmRepairRecord.setBoxCode(SNCode); +// RmRepairRecord rmRepairRecord = new RmRepairRecord(); +// rmRepairRecord.setBoxCode(SNCode); List<ReadWriteEntity> writeList = new ArrayList<>(); - List<RmRepairRecord> rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord); +// List<RmRepairRecord> rmRepairRecords = rmRepairRecordService.selectRmRepairRecordList(rmRepairRecord); //杩囩珯璁板綍 - DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); - PassingStationCollection.setSfcCode(SNCode); +// DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); +// PassingStationCollection.setSfcCode(SNCode); //杩囩珯璁板綍 - List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection); +// List<DaPassingStationCollection> daPassingStationCollections = passingStationCollectionServiceImpl.selectDaPassingStationCollectionList(PassingStationCollection); //鎵�鏈夊弽宸ュ伐浣� List<String> collect1 = rmRepairRecords.stream().map(RmRepairRecord::getProcessesCode).collect(Collectors.toList()); - //鏌ヨ鍑烘墍鏈夐渶瑕佽繑淇伐浣嶇殑鏈�灏弌p鍧� - Integer minOP = 0; if (CollUtil.isNotEmpty(collect1)){ + //鏌ヨ鍑烘墍鏈夐渶瑕佽繑淇伐浣嶇殑鏈�灏弌p鍧� + Integer minOP = 0; + if (CollUtil.isNotEmpty(collect1)){ - List<Integer> sortList = new ArrayList<>(); - collect1.stream().forEach(x ->{ - String op = x.replace("OP", ""); - if (StrUtil.isNotBlank(op)){ - int i = Integer.parseInt(op); - sortList.add(i); + List<Integer> sortList = new ArrayList<>(); + collect1.stream().forEach(x ->{ + String op = x.replace("OP", ""); + if (StrUtil.isNotBlank(op)){ + int i = Integer.parseInt(op); + sortList.add(i); + } + }); + if (CollUtil.isNotEmpty(sortList)){ + List<Integer> collect2 = sortList.stream().filter(Objects::nonNull).sorted().collect(Collectors.toList()); + minOP = collect2.get(0); } - }); - if (CollUtil.isNotEmpty(sortList)){ - List<Integer> collect2 = sortList.stream().sorted().collect(Collectors.toList()); - minOP = collect2.get(0); } - } + //鑾峰彇杩囩珯璁板綍鐨勬渶澶у伐浣� + String maxCode = null; + if (CollUtil.isNotEmpty(daPassingStationCollections)){ + List<DaPassingStationCollection> collect2 = daPassingStationCollections.stream().filter(x -> "涓嶅悎鏍�".equals(x.getOutRsSign())).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(collect2)){ + DaPassingStationCollection lastOne = collect2.get(collect2.size() - 1); + maxCode = lastOne.getLocationCode(); + }else { + DaPassingStationCollection lastOne = daPassingStationCollections.get(daPassingStationCollections.size() - 1); + maxCode = lastOne.getLocationCode(); + } - //鎵�鏈夋斁琛屽伐浣� - //杩囩珯璁板綍闄ゅ幓杩斾慨璁板綍灏辨槸浼�2锛岃繑淇暟鎹強鍚庨潰鍗犱綅鏁版嵁浼�1 - List<String> collect3 = daPassingStationCollections.stream().map(DaPassingStationCollection::getLocationCode).collect(Collectors.toList()); - if (CollUtil.isNotEmpty(collect1)){ - collect3 = collect3.stream().filter(x -> !collect1.contains(x)).collect(Collectors.toList()); - } - String[] parts = Node.split("[.]"); - String par = parts[0]+"."+parts[1]; - if (CollUtil.isNotEmpty(collect3)){ - collect3.forEach(x -> { - ReadWriteEntity readWriteEntity = new ReadWriteEntity(); - readWriteEntity.setIdentifier(par+"."+x); - readWriteEntity.setValue(2); - writeList.add(readWriteEntity); - }); - } - //闇�鐢熶骇宸ヤ綅 - List<String> collect4 = allProcessCoed; - if (CollUtil.isNotEmpty(collect3)){ - List<String> finalCollect = collect3; - collect4 = allProcessCoed.stream().filter(x -> !finalCollect.contains(x)).collect(Collectors.toList()); - } - if (CollUtil.isNotEmpty(collect4)){ - //鏁版嵁搴撴煡璇㈠嚭鐨勫伐浣� - collect4.forEach(x -> { - ReadWriteEntity readWriteEntity = new ReadWriteEntity(); - readWriteEntity.setIdentifier(par+"."+x); - readWriteEntity.setValue(1); - writeList.add(readWriteEntity); - }); - } -// List<String> collect2 = allProcessCoed; -// if (CollUtil.isNotEmpty(rmRepairRecords)){ -// //鏁版嵁搴撴煡璇㈠嚭鐨勫伐浣� -// rmRepairRecords.forEach(x -> { -// ReadWriteEntity readWriteEntity = new ReadWriteEntity(); -// readWriteEntity.setIdentifier(x.getProcessesCode()); -// readWriteEntity.setValue(1); -// writeList.add(readWriteEntity); -// }); -// collect2 = allProcessCoed.stream().filter(x -> !collect1.contains(x)).collect(Collectors.toList()); -// } -// if (CollUtil.isNotEmpty(collect2)){ -// collect2.forEach(x -> { -// ReadWriteEntity readWriteEntity = new ReadWriteEntity(); -// readWriteEntity.setIdentifier(x); -// readWriteEntity.setValue(2); -// writeList.add(readWriteEntity); -// }); -// } - -// String a=passingStationCollectionServiceImpl.SelectSN(SNCode,parts[1]); -// if (StrUtil.isNotBlank(a)){ -// int input = Integer.parseInt(a); -// ReadWriteEntity entity = new ReadWriteEntity(parts[0]+"."+parts[1]+".CodeCheckFeed", input); -// writeList.add(entity); -// } - ReadWriteEntity readWriteEntity = new ReadWriteEntity(); - readWriteEntity.setIdentifier(parts[0]+"."+parts[1]+".Repair_sign"); - readWriteEntity.setValue(minOP); - miloService.writeToOpcShort(readWriteEntity); - /*if (CollUtil.isNotEmpty(writeList)){ - List<ReadWriteEntity> tempList = new ArrayList<>(); - for (int i = 0; i < writeList.size(); i++) { - miloService.writeToOpc(); -// tempList.add(writeList.get(i)); -// if (tempList.size()>10){ -// miloService.writeToOpcByte(tempList); -// log.info("鍐欏叆杩斾慨锛�,{}",tempList); -// tempList = new ArrayList<>(); -// } } -// if (CollUtil.isNotEmpty(tempList)){ -// miloService.writeToOpcByte(tempList); -// log.info("鍐欏叆杩斾慨锛�,{}",tempList); -// } - }*/ - miloService.writeToOpcByte(writeList); + //鎵�鏈夋斁琛屽伐浣� + List<String> passStation = new ArrayList<>(); + //鎵�鏈夌敓浜у伐浣� + List<String> productStation = new ArrayList<>(); + //鏈�澶у伐浣嶇紪鍙� + Integer maxCodeNum = 0; + if (StrUtil.isNotEmpty(maxCode)){ + String finalMaxCode = maxCode; + //鑾峰彇褰撳墠宸ヤ綅瀵瑰簲宸ユ鍙� + List<String> collect2 = bsTechnologyRouteChildInfos.stream() + .filter(x -> x.getProcessesCode().equals(finalMaxCode)) + .map(BsTechnologyRouteChildInfo::getStepNo).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(collect2)){ + String s = collect2.get(0); + if (StrUtil.isNotBlank(s)){ + maxCodeNum = Integer.parseInt(s); + } + } + if (CollUtil.isNotEmpty(bsTechnologyRouteChildInfos)){ + bsTechnologyRouteChildInfos.forEach(x -> { + x.setStepNoNum(Integer.parseInt(x.getStepNo())); + }); + Integer finalMaxCodeNum = maxCodeNum; + //鍕鹃�夌殑杩斾慨宸ヤ綅涓渶澶х殑宸ヤ綅涔嬪悗鐨勫伐浣�----1 + List<BsTechnologyRouteChildInfo> collect3 = bsTechnologyRouteChildInfos.stream() + .filter(x -> x.getStepNoNum() >= finalMaxCodeNum).collect(Collectors.toList()); + if (CollUtil.isNotEmpty(collect3)){ + //闇�瑕佺敓浜� + productStation.addAll(collect3.stream().map(BsTechnologyRouteChildInfo::getProcessesCode).collect(Collectors.toList())); + } + //浠庣涓�涓伐浣嶅埌杩斾慨鐨勬渶澶у伐浣嶄箣闂达紝 + //鍕鹃�変簡杩斾慨鏍囪鐨勯渶瑕佺敓浜�---1锛屾湭鍕鹃�夌殑涓嶇敓浜�---2 + productStation.addAll(collect1); + } + } + if (CollUtil.isNotEmpty(productStation)){ + List<String> collect2 = allProcessCoed.stream().filter(x -> !productStation.contains(x)).collect(Collectors.toList()); + passStation.addAll(collect2); + } + String[] parts = Node.split("[.]"); + String par = parts[0]+"."+parts[1]; + if (CollUtil.isNotEmpty(passStation)){ + passStation.forEach(x -> { + ReadWriteEntity readWriteEntity = new ReadWriteEntity(); + readWriteEntity.setIdentifier(par+"."+x); + readWriteEntity.setValue(2); + writeList.add(readWriteEntity); + }); + } + if (CollUtil.isNotEmpty(productStation)){ + productStation.forEach(x -> { + ReadWriteEntity readWriteEntity = new ReadWriteEntity(); + readWriteEntity.setIdentifier(par+"."+x); + readWriteEntity.setValue(1); + writeList.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); + } + } @@ -358,7 +394,7 @@ List<DaParamCollection> daParamCollectionlist = new ArrayList<>(); if (CollUtil.isNotEmpty(nodeIdList)){ for(int i=0;i<nodeIdList.size();i++){ - if(!readWriteEntityList.get(i).getValue().toString().equals("0.0")){ + if(ObjectUtil.isNotEmpty(readWriteEntityList.get(i).getValue()) && !readWriteEntityList.get(i).getValue().toString().equals("0.0")){ DaParamCollection ParamCollection = new DaParamCollection(); ParamCollection.setParamCode(readWriteEntityList.get(i).getIdentifier().toString().split("[.]")[2]); ParamCollection.setLocationCode(parts[1]); @@ -390,6 +426,17 @@ 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)){ + String productStatusString = ProductStatus.toString(); + if (productStatusString.contains("2") || productStatusString.contains("3")){ + str1="涓嶅悎鏍�"; + }else { + str1="鍚堟牸"; + } + } DaPassingStationCollection PassingStationCollection=new DaPassingStationCollection(); PassingStationCollection.setSfcCode(SNCode); PassingStationCollection.setLocationCode(parts[1]); @@ -398,7 +445,7 @@ PassingStationCollection.setCollectionTime(new Date()); PassingStationCollection.setCreateTime(new Date()); PassingStationCollection.setBeatTime(beatTime.toString()); - PassingStationCollection.setOutRsSign("鍚堟牸"); + PassingStationCollection.setOutRsSign(str1); passingStationCollectionServiceImpl.insertDaPassingStationCollection(PassingStationCollection); log.info("-------淇濆瓨杩囩珯璁板綍鏁版嵁瀹屾垚---------"); -- Gitblit v1.9.3