From 997e697edaf59893248bc2467223058b221a4de2 Mon Sep 17 00:00:00 2001
From: cl <418351270@qq.com>
Date: 星期五, 12 七月 2024 14:51:47 +0800
Subject: [PATCH] 修改参数采集

---
 jcdm-main/src/main/java/com/jcdm/main/da/paramCollection/service/impl/DaParamCollectionServiceImpl.java |  128 ++++++++++++++++++++++++------------------
 1 files changed, 74 insertions(+), 54 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..f32e812 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();
@@ -324,40 +302,34 @@
                 boolean save = daPassingStationCollectionService.save(daPassingStationCollection);
 
                 //娣诲姞鍩虹鍙傛暟
-                this.manualWorkstationsAddBasicParameters(daParamCollection);
+//                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 stationCode = "M1OP100";
+                            String reportResult = RestfulService.getWorkReportResultFeedback(daParamCollection.getProductBarcode(), stationCode, 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 +339,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 +474,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) {
@@ -513,8 +537,6 @@
     public void pushGeelycvMesFeedback(String packID, String stationCode) {
         logger.info("杩涘叆浜哄伐宸ヤ綅鎺ㄩ�佸伐鍘侻ES鏁版嵁鏂规硶-pushGeelycvMesFeedback-宸ヤ綅{}-pack鐮亄}",stationCode,packID);
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback";
-//        String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback";
         String totalResult = "0";
         List<DaParamCollectionTemp> paramList = daParamCollectionTempService.list(new LambdaQueryWrapper<DaParamCollectionTemp>().eq(DaParamCollectionTemp::getSfcCode, packID).eq(DaParamCollectionTemp::getLocationCode, stationCode));
         if(paramList.size() > 0){
@@ -569,7 +591,7 @@
             try{
                 CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
                     logger.info("寮�濮嬫墽琛屽紓姝ユ柟娉�");
-                    HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute();
+                    HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute();
                     logger.info("寮傛鏂规硶鎵ц缁撴潫");
                     logger.info("鎵嬪姩宸ヤ綅浼犲伐鍘侻ES寮傛鏂规硶{}"+execute.body());
 
@@ -599,8 +621,6 @@
     public void automaticWorkstationPushGeelycvMesFeedback(String packID, String stationCode,List<DaParamCollection> paramList) {
         logger.info("杩涘叆宸ヤ綅{}-宸ュ巶MES鎺ㄩ�佹暟鎹柟娉昦utomaticWorkstationPushGeelycvMesFeedback",stationCode);
         SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-//        String url = "https://imes-uat-group.geelycv-test.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback";
-        String url = "https://imes-group.geelycv.com/api/mom-open/restful/aMesSysIntegration/deviceResultFeedback";
         String totalResult = "0";
         if(paramList.size() > 0){
             logger.info("杩涘叆宸ヤ綅{}-鎷兼暟鎹�",stationCode);
@@ -656,7 +676,7 @@
             try{
                 CompletableFuture<Void> cp1 = CompletableFuture.runAsync(() -> {
                     logger.info("寮�濮嬫墽琛屽紓姝ユ柟娉�");
-                    HttpResponse execute = HttpRequest.post(url).body(JSONUtil.toJsonStr(parentVO)).execute();
+                    HttpResponse execute = HttpRequest.post(Constants.FACTORY_EMS_UAT_GET_RUL+"deviceResultFeedback").body(JSONUtil.toJsonStr(parentVO)).execute();
                     System.out.println(execute.body());
                     logger.info("寮傛鏂规硶鎵ц缁撴潫");
                     logger.info("鑷姩宸ヤ綅浼犲伐鍘侻ES寮傛鏂规硶{}"+execute.body());

--
Gitblit v1.9.3