From 537bfb7e43c78d5b3b98ba8a135b638f0461ea60 Mon Sep 17 00:00:00 2001
From: admin <15939171744@163.com>
Date: 星期日, 20 十月 2024 15:50:30 +0800
Subject: [PATCH] 优化

---
 jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java |   94 ++++++++--------------------------------------
 1 files changed, 17 insertions(+), 77 deletions(-)

diff --git a/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java b/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java
index 3221f31..43593d8 100644
--- a/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java
+++ b/jcdm-main/src/main/java/com/jcdm/main/bs/formulaChild/service/impl/BsFormulaChildInfoServiceImpl.java
@@ -17,6 +17,7 @@
 import com.jcdm.common.utils.DateUtils;
 import com.jcdm.common.utils.StringUtils;
 import com.jcdm.framework.websocket.WebSocketUsers;
+import com.jcdm.main.constant.Constants;
 import com.jcdm.main.da.paramCollection.domain.DaParamCollection;
 import com.jcdm.main.da.paramCollection.mapper.DaParamCollectionMapper;
 import com.jcdm.main.da.paramCollection.service.IDaParamCollectionService;
@@ -219,30 +220,11 @@
     public AjaxResult yzUpdateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) {
         Boolean b = true;
         String result = "1";
-//        BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo();
-//        getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode());
-//        getMaterTwo.setOperationType("2");
-//        List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo);
-//        List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList());
-//        for (String s : collect) {
-//            if(s.equals("")){
-////                return AjaxResult.success("鎵弿鏈畬鎴愶紝绂佹鎷х揣鎿嶄綔锛�");
-//            }
-//        }
-//        BsFormulaChildInfo listQuery = new BsFormulaChildInfo();
-//        listQuery.setParamCode(bsFormulaChildInfo.getParamCode());
-//        listQuery.setProcessesCode(bsFormulaChildInfo.getLocationCode());
         String paramData = bsFormulaChildInfo.getTightenTheArray();
         if(paramData.contains("N")){
             result = "3";
-//            List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
-//            bsFormulaChildInfos.get(0).setResults("NG");
-//            bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray());
-//            bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
             this.updateTighteningData(bsFormulaChildInfo,"NG",paramData);
-//            return AjaxResult.success("鎵弿缁撴灉NG,璇烽噸鏂版壂鎻忥紒");
         }else {
-//            List<BsFormulaChildInfo> bsFormulaChildInfos = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
             if(bsFormulaChildInfo.getSpareField2()!=null&&bsFormulaChildInfo.getSpareField3()!=null){
                 String tightenArray = bsFormulaChildInfo.getTightenTheArray().replace("[", "").replace("]", "").replace(" ", "");
                 String[] tightenDataParts = tightenArray.split(",");
@@ -250,15 +232,11 @@
             }
             if(b){
                 result = "3";
-//                bsFormulaChildInfos.get(0).setResults("OK");
-//                bsFormulaChildInfos.get(0).setCollectData(bsFormulaChildInfo.getTightenTheArray());
-//                bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos.get(0));
                 this.updateTighteningData(bsFormulaChildInfo,"OK",paramData);
-//                logger.info("yzUpdateTighteningFormula--鏌ヨ鏉′欢鍙傛暟锛�"+listQuery);
-//                logger.info("yzUpdateTighteningFormula--鏌ヨ缁撴灉锛�"+bsFormulaChildInfos.get(0));
                 Integer stepNumber = Integer.valueOf(bsFormulaChildInfo.getStepSort());
                 try {
-                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".MStepNumber").value(stepNumber+1).build());
+                    String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getLocationCode());//鑾峰彇閫氶亾
+                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare+"."+bsFormulaChildInfo.getLocationCode()+".MESScrew").value(stepNumber+1).build());
                 } catch (Exception e) {
                     throw new RuntimeException(e);
                 }
@@ -268,7 +246,6 @@
                     // 鎵ц鎿嶄綔
                     if(bsFormulaChildInfo.getSpareField4().equals("1")){
                         try {
-//                        WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT");
                             result = "2";
                         } catch (Exception e) {
                             throw new RuntimeException(e);
@@ -277,14 +254,8 @@
                 }
             }else {
                 result = "3";
-//                List<BsFormulaChildInfo> bsFormulaChildInfos1 = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(listQuery);
-//                bsFormulaChildInfos1.get(0).setResults("NG");
-//                String originalString = bsFormulaChildInfo.getTightenTheArray();
                 String modifiedString = paramData.replaceFirst("OK", "NG");
-//                bsFormulaChildInfos1.get(0).setCollectData(modifiedString);
-//                bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfos1.get(0));
                 this.updateTighteningData(bsFormulaChildInfo,"NG",modifiedString);
-//                return AjaxResult.success("鎵弿缁撴灉NG,璇烽噸鏂版壂鎻忥紒");
             }
         }
         return AjaxResult.success(result);
@@ -353,13 +324,6 @@
     @Override
     public AjaxResult jrmWorkpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) {
         this.clearCollectDataAndResultsByProcessesCode(bsFormulaChildInfo);
-//        List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
-//                .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
-//                .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()));
-//        for (BsFormulaChildInfo info : list) {
-//            info.setCollectData("");
-//            info.setResults("");
-//            bsFormulaChildInfoService.saveOrUpdate(info);
 //        }
         String[] split = bsFormulaChildInfo.getProductBarcode().split(",");
         try {
@@ -554,35 +518,8 @@
     @Override
     public AjaxResult workpieceRelease(BsFormulaChildInfo bsFormulaChildInfo) {
         this.clearCollectDataAndResultsByProcessesCode(bsFormulaChildInfo);
-//        List<BsFormulaChildInfo> list = bsFormulaChildInfoService.list(new LambdaQueryWrapper<BsFormulaChildInfo>()
-//                .eq(BsFormulaChildInfo::getProcessesCode, bsFormulaChildInfo.getLocationCode())
-//                .eq(BsFormulaChildInfo::getProductCode, bsFormulaChildInfo.getProductCode()));
-//        for (BsFormulaChildInfo info : list) {
-//            info.setCollectData("");
-//            info.setResults("");
-//            bsFormulaChildInfoService.saveOrUpdate(info);
-//        }
         try {
             daParamCollectionService.pushGeelycvMesFeedback(bsFormulaChildInfo.getProductBarcode(), bsFormulaChildInfo.getLocationCode());
-//            String barCode = bsFormulaChildInfo.getProductBarcode();
-//            String locationCode = bsFormulaChildInfo.getLocationCode();
-//
-//            if(StringUtils.isNotBlank(locationCode)&&StringUtils.isNotBlank(barCode)){
-//                DaPassingStationCollection daPassingStationCollection = new DaPassingStationCollection();
-//                daPassingStationCollection.setOutRsSign("1");
-//                daPassingStationCollection.setOutboundTime(new Date());
-//                daPassingStationCollection.setSfcCode(barCode);
-//                daPassingStationCollection.setLocationCode(locationCode);
-//                int updateDaPassingStation = daPassingStationCollectionService.updateDaPassingStationCollectionBySfcCodeAndLocationCode(daPassingStationCollection);
-//                logger.info("鏅�氫汉宸ュ伐浣嶆洿鏂拌繃绔欒褰晆pdateDaPassingStationCollectionBySfcCodeAndLocationCode:鏇存柊浜唟}鏉℃暟鎹�-鏇存柊鏉′欢pack鐮亄}-宸ヤ綅{}",updateDaPassingStation,barCode,locationCode);
-//            }
-
-//            DaPassingStationCollection passingStationCollectionOne = daPassingStationCollectionService.getOne(new LambdaQueryWrapper<DaPassingStationCollection>().eq(DaPassingStationCollection::getSfcCode, barCode).eq(DaPassingStationCollection::getLocationCode, locationCode));
-//            if (passingStationCollectionOne != null) {
-//                passingStationCollectionOne.setOutRsSign("1");
-//                passingStationCollectionOne.setOutboundTime(new Date());
-//                daPassingStationCollectionService.saveOrUpdate(passingStationCollectionOne);
-//            }
         }catch (Exception e){
         }
         return AjaxResult.success();
@@ -591,17 +528,19 @@
     @Override
     public AjaxResult updateTighteningFormula(BsFormulaChildInfo bsFormulaChildInfo) {
         Boolean b = true;
-        BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo();
-        getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode());
-        getMaterTwo.setOperationType("2");
-        List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo);
-        List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList());
-        for (String s : collect) {
-            if(s.equals("")){
-                return AjaxResult.error("鎵爜鏈畬鎴愶紝绂佹鎷х揣鎿嶄綔锛�");
+        if(!"OP100".equals(bsFormulaChildInfo.getLocationCode())){
+            BsFormulaChildInfo getMaterTwo = new BsFormulaChildInfo();
+            getMaterTwo.setProductCode(bsFormulaChildInfo.getProductCode());
+            getMaterTwo.setProcessesCode(bsFormulaChildInfo.getLocationCode());
+            getMaterTwo.setOperationType("2");
+            List<BsFormulaChildInfo> operationType = bsFormulaChildInfoMapper.selectBsFormulaChildInfoList(getMaterTwo);
+            List<String> collect = operationType.stream().map(BsFormulaChildInfo::getResults).collect(Collectors.toList());
+            for (String s : collect) {
+                if(s.equals("")){
+                    return AjaxResult.error("鎵爜鏈畬鎴愶紝绂佹鎷х揣鎿嶄綔锛�");
+                }
             }
         }
-
         //娣诲姞鎷х揣鍙傛暟-鍙傛暟閲囬泦琛�
         DaParamCollection daParamCollection = new DaParamCollection();
         daParamCollection.setParamCode(bsFormulaChildInfo.getParamCode());
@@ -635,8 +574,9 @@
                 bsFormulaChildInfoMapper.updateBsFormulaChildInfo(bsFormulaChildInfo);
 
                 Integer stepNumber = Integer.valueOf(bsFormulaChildInfo.getStepSort());
+                String thoroughfare = Constants.thoroughfareMap.get(bsFormulaChildInfo.getLocationCode());//鑾峰彇閫氶亾
                 try {
-                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".MStepNumber").value(stepNumber+1).build());
+                    miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare+"."+bsFormulaChildInfo.getLocationCode()+".MESScrew").value(stepNumber+1).build());
                 } catch (Exception e) {
                     throw new RuntimeException(e);
                 }
@@ -652,7 +592,7 @@
     //                        List<DaPassingStationCollection> daPassingStationCollections = daPassingStationCollectionMapper.selectDaPassingStationCollectionList(daPassingStationCollection);
     //                        daPassingStationCollections.get(0).setOutboundTime(new Date());
     //                        daPassingStationCollectionMapper.updateDaPassingStationCollection(daPassingStationCollections.get(0));
-//                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier("PACK."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(21).build());
+                            miloService.writeToOpcShort(ReadWriteEntity.builder().identifier(thoroughfare +"."+bsFormulaChildInfo.getLocationCode()+".RecordDataDone").value(11).build());
                             WebSocketUsers.sendMessageToUserByText(map.get(bsFormulaChildInfo.getLocationCode()), "OUT");
                         } catch (Exception e) {
                             throw new RuntimeException(e);

--
Gitblit v1.9.3