From ef58b9f5268fb32189123bc39d8c69e41612befb Mon Sep 17 00:00:00 2001 From: cl <418351270@qq.com> Date: 星期四, 04 七月 2024 15:19:23 +0800 Subject: [PATCH] 修改参数采集 --- jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java | 117 +++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 70 insertions(+), 47 deletions(-) diff --git a/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java b/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java index fa722ee..680bc0f 100644 --- a/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java +++ b/jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java @@ -265,15 +265,12 @@ @Override public void saveCampaignTimeParameters(DaParamCollection daParamCollection) { -// List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>() -// .eq(BsFormulaChildInfo::getProcessesCode, daParamCollection.getLocationCode()) -// .eq(BsFormulaChildInfo::getSpareField4, "1") -// ); + BsFormulaChildInfo childInfo = daParamCollection.getFormulaChildEntity(); if(StringUtils.isNotBlank(childInfo.getResults())){ if(!childInfo.getResults().equals("OK")){ try { - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("MOZU1."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); } catch (Exception e) { throw new RuntimeException(e); } @@ -281,35 +278,16 @@ } }else { try { - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("MOZU1."+daParamCollection.getLocationCode()+".RecordDataDone").value(22).build()); } catch (Exception e) { throw new RuntimeException(e); } return; } -// BsFormulaChildInfo bsFormulaChildInfo = new BsFormulaChildInfo(); -// bsFormulaChildInfo.setProcessesCode(daParamCollection.getLocationCode()); -// bsFormulaChildInfo.setProductCode(daParamCollection.getProductCode()); -// bsFormulaChildInfo.setSpareField4("1"); -// List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(bsFormulaChildInfo); + String result = childInfo.getResults(); if(result != null && !result.isEmpty()){ try { -// //鏇存柊鍙傛暟閲囬泦閰嶇疆琛� -// DaCollectionParamConf daCollectionParamConf = new DaCollectionParamConf(); -// daCollectionParamConf.setProcessesCode(daParamCollection.getLocationCode()); -// daCollectionParamConf.setCollectParameterId("OUTT"); -// List<DaCollectionParamConf> daCollectionParamConfs = daCollectionParamConfMapper.selectDaCollectionParamConfList(daCollectionParamConf); -// DaParamCollection saveData = new DaParamCollection(); -// saveData.setWorkOrderNo(daParamCollection.getWorkOrderNo()); -// saveData.setProductCode(daParamCollection.getProductCode()); -// saveData.setLocationCode(daParamCollection.getLocationCode()); -// saveData.setSfcCode(daParamCollection.getProductBarcode()); -// saveData.setParamCode(daCollectionParamConfs.get(0).getCollectParameterId()); -// saveData.setParamName(daCollectionParamConfs.get(0).getCollectParameterName()); -// saveData.setCollectionTime(new Date()); -// saveData.setParamValue(DateUtil.formatDateTime(new Date())); -// daParamCollectionMapper.insertDaParamCollection(saveData); //澧炲姞杩囩珯璁板綍 DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); @@ -326,38 +304,31 @@ //娣诲姞鍩虹鍙傛暟 this.manualWorkstationsAddBasicParameters(daParamCollection); -// //鏇存柊杩囩珯璁板綍琛ㄥ嚭绔欐椂闂� -// DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection(); -// daPassingStationCollection.setWorkOrderNo(daParamCollection.getWorkOrderNo()); -// daPassingStationCollection.setLocationCode(daParamCollection.getLocationCode()); -// List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection); -// daPassingStationCollections.get(0).setOutboundTime(new Date()); -// int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); - -// OPCUaSubscription.SaveParamData(daParamCollection.getProductBarcode(),"OP",daParamCollection.getLocationCode(),daParamCollection.getWorkOrderNo(),daParamCollection.getProductCode()); + //鍗婅嚜鍔ㄥ伐浣嶏紝鍏堝皢鑷姩鏁版嵁淇濆瓨鍒版暟鎹簱 + this.saveParameters(daParamCollection); //缁檕pc鍙�21 - miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); - if(daParamCollection.getLocationCode().equals("OP240")){ + miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("MOZU1."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); + if(daParamCollection.getLocationCode().equals("M1OP100-1") || daParamCollection.getLocationCode().equals("M1OP100-2") ){ try{ CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> { - logger.info("OP230鎶ュ伐寮�濮�-宸ュ巶MES寮傛鏂规硶"); - String reportResult = RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(), "OP230", format.format(new Date())); + logger.info("OP100鎶ュ伐寮�濮�-宸ュ巶MES寮傛鏂规硶"); + String reportResult = RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(), daParamCollection.getLocationCode(), format.format(new Date())); JSONObject jsonObject = new JSONObject(reportResult); String code = jsonObject.getStr("code"); if("success".equals(code)){ //濡傛灉鎴愬姛锛屾墽琛屾姤宸ユ垚鍔熸柟娉曪紝淇敼鏄惁鎶ュ伐涓�1锛屾坊鍔犳姤宸ユ椂闂� - omProductionOrdeInfoService.updateOrderByProductNum("1",daParamCollection.getProductBarcode(),"OP230"); + omProductionOrdeInfoService.updateOrderByProductNum("1",daParamCollection.getProductBarcode(),daParamCollection.getLocationCode()); }else{ //瑙f瀽宸ュ巶mes杩斿洖缁撴灉锛屽鏋滃け璐ワ紝鎵ц鎶ュ伐澶辫触鏂规硶锛屼慨鏀规槸鍚︽姤宸ヤ负2锛屾坊鍔犳姤宸ユ椂闂� - omProductionOrdeInfoService.updateOrderByProductNum("2",daParamCollection.getProductBarcode(),"OP230"); + omProductionOrdeInfoService.updateOrderByProductNum("2",daParamCollection.getProductBarcode(),daParamCollection.getLocationCode()); } - logger.info("OP230鎶ュ伐缁撴潫-宸ュ巶MES寮傛鏂规硶{}"+reportResult); + logger.info("OP100鎶ュ伐缁撴潫-宸ュ巶MES寮傛鏂规硶{}"+reportResult); }); }catch (Exception e){ System.out.println(e.getMessage()); } -// RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(),"OP230",format.format(new Date())); + } @@ -367,6 +338,62 @@ } } + + //鍗婅嚜鍔ㄥ伐浣嶏紝鍏堝皢鑷姩鏁版嵁淇濆瓨鍒版暟鎹簱 + public void saveParameters(DaParamCollection daParamCollection) { + //娣诲姞鑷姩宸ヤ綅鍙傛暟鏁版嵁 + //鏌ヨ鍙傛暟閰嶇疆琛� + List<DaCollectionParamConf> list = daCollectionParamConfService.list(new LambdaQueryWrapper<DaCollectionParamConf>() + .eq(DaCollectionParamConf::getProcessesCode, daParamCollection.getLocationCode())//宸ヤ綅 + .eq(DaCollectionParamConf::getWhetherToCollect, Constants.ONE)//鏄惁閲囬泦 + );//绫诲瀷 + + List<String> collectAddressList = list.stream() + .map(DaCollectionParamConf::getGatherAddress).collect(Collectors.toList()); + List<ReadWriteEntity> paramCollectionList = null;//妯$粍 鍙傛暟鍊� + try { + paramCollectionList = miloService.readFromOpcUa(collectAddressList); + } catch (Exception e) { + throw new RuntimeException(e); + } + + if (CollUtil.isNotEmpty(paramCollectionList)) { + List<DaParamCollection> saveParamList = new ArrayList<>();//灏佽鍙傛暟閲囬泦list + List<DaParamCollectionTemp> saveParamListTemp = new ArrayList<>();//灏佽鍙傛暟閲囬泦list + for (int i = 0; i < paramCollectionList.size(); i++) { + DaParamCollection collection = new DaParamCollection(); + collection.setSfcCode(daParamCollection.getProductBarcode());//妯$粍鐮� + collection.setParamCode(list.get(i).getCollectParameterId());//鍙傛暟缂栫爜 + collection.setParamName(list.get(i).getCollectParameterName());//鍙傛暟鍚嶇О + String paramValue = ""; + if (ObjectUtil.isNotNull(paramCollectionList.get(i).getValue())) { + paramValue = paramCollectionList.get(i).getValue().toString();//鍙傛暟鍊� + } + collection.setParamValue(paramValue);//鍙傛暟鍊� + collection.setLocationCode(daParamCollection.getLocationCode());//宸ヤ綅 + collection.setCollectionTime(new Date());//閲囬泦鏃堕棿 + saveParamList.add(collection);//灏佽鍙傛暟閲囬泦list + + DaParamCollectionTemp collectionTemp = new DaParamCollectionTemp(); + collectionTemp.setSfcCode(daParamCollection.getProductBarcode());//妯$粍鐮� + collectionTemp.setParamCode(list.get(i).getCollectParameterId());//鍙傛暟缂栫爜 + collectionTemp.setParamName(list.get(i).getCollectParameterName());//鍙傛暟鍚嶇О + + if (ObjectUtil.isNotNull(paramCollectionList.get(i).getValue())) { + paramValue = paramCollectionList.get(i).getValue().toString();//鍙傛暟鍊� + } + collectionTemp.setParamValue(paramValue);//鍙傛暟鍊� + collectionTemp.setLocationCode(daParamCollection.getLocationCode());//宸ヤ綅 + collectionTemp.setCollectionTime(new Date());//閲囬泦鏃堕棿 + saveParamListTemp.add(collectionTemp);//灏佽鍙傛暟閲囬泦list + + } + //鎻掑叆鍙傛暟閲囬泦琛� + daParamCollectionService.insertBatch(saveParamList); + //鎻掑叆鍙傛暟閲囬泦琛� + daParamCollectionTempService.insertBatch(saveParamListTemp); + } + } @Override public void insertBatch(List<DaParamCollection> confList){ try{ @@ -446,11 +473,7 @@ daPassingStationCollections.get(0).setOutboundTime(new Date()); int i = daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0)); -// OPCUaSubscription.SaveParamData(daParamCollection.getProductBarcode(),"OP",daParamCollection.getLocationCode(),daParamCollection.getWorkOrderNo(),daParamCollection.getProductCode()); - - //缁檕pc鍙�21 try { -// miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+daParamCollection.getLocationCode()+".RecordDataDone").value(21).build()); String strA = daParamCollection.getLocationCode(); miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+strA+".RecordDataDone").value(21).build()); } catch (Exception e) { -- Gitblit v1.9.3