From 8a7e936b92038a9e5c7de3e1314c43f1346202c1 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 01 八月 2024 15:02:29 +0800
Subject: [PATCH] 大理片笼出片逻辑调整:1、尺寸限制 2、fixbug:玻璃重复进出,造成按照历史任务查询笼内玻璃尺寸返回多条记录sql查询异常 3、对列表在新增数据前先按照玻璃id对历史数据进行删除后新增,保证对列表数据唯一,防止大理片笼进片异常

---
 hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java |   42 ++++++++++++++++++++++++++----------------
 1 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
index 772a88b..9e9c1fb 100644
--- a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/CacheGlassTask.java
@@ -74,11 +74,17 @@
     @Value("${mes.max.secondLength}")
     private String secondLength;
 
-    @Value("${mes.min.firstLength}")
-    private String minFirstLength;
+    @Value("${mes.min.one.firstLength}")
+    private String minOneFirstLength;
 
-    @Value("${mes.min.secondLength}")
-    private String minSecondLength;
+    @Value("${mes.min.one.secondLength}")
+    private String minOneSecondLength;
+
+    @Value("${mes.min.two.firstLength}")
+    private String minTwoFirstLength;
+
+    @Value("${mes.min.two.secondLength}")
+    private String minTwoSecondLength;
 
     @Scheduled(fixedDelay = 1000)
     public void plcHomeEdgTask() {
@@ -115,7 +121,7 @@
             inTo(glassIdeValue, confirmationWrodAddress, currentSlot);
         } else if ("2".equals(taskRequestTypeValue)) {
             //09绌洪棽 锛�1      10绌洪棽 锛�2        閮界┖闂诧細3    鍏朵粬0
-            log.info("2銆佸嚭鐗囪姹傦紝涓旂‘璁ゅ瓧涓�0锛屾墽琛岃繘鐗囦换鍔�");
+            log.info("2銆佸嚭鐗囪姹傦紝涓旂‘璁ゅ瓧涓�0锛屾墽琛屽嚭鐗囦换鍔�");
             outTo(Integer.parseInt(out08Glassstate),
                     Integer.parseInt(out10Glassstate), confirmationWrodAddress, "", 0);
         } else if ("3".equals(taskRequestTypeValue)) {
@@ -227,7 +233,7 @@
 //        2銆佸鏋滄病鏈夊巻鍙插嚭鐗囦换鍔�
 //        2.1銆佸嚭褰撳墠鐗堝浘id鏈�灏忕増搴忔渶灏忕殑鐜荤拑锛堥棶棰橈細涓ゆ潯绾块兘娌℃湁鍘嗗彶浠诲姟锛屽嚭鐗囨椂涓ゆ潯绾跨殑鐜荤拑灏哄鐩稿悓锛屾槸鍚︽壘灏哄涓嶅悓鐨勶級
         if ((out08Glassstate == 2 && out10Glassstate == 2) || (out08Glassstate == 0 && out10Glassstate == 0)) {
-            log.info("A09銆丄10涓簕},{}闈炶嚜鍔ㄧ姸鎬侊紝鏃犳硶鍑虹墖");
+            log.info("A09銆丄10涓簕},{}闈炶嚜鍔ㄧ姸鎬侊紝鏃犳硶鍑虹墖", out08Glassstate, out10Glassstate);
             return Boolean.FALSE;
         }
         log.info("0銆佸嚭鐗囦换鍔″嚭鐨勭姸鎬�:A09:銆恵}銆�;A10:銆恵}銆�)", out08Glassstate, out10Glassstate);
@@ -263,26 +269,27 @@
                     if (endcell == Const.A10_OUT_TARGET_POSITION) {
                         wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                                 "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
-                                "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") ");
+                                "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength
+                                + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") ");
                     } else {
                         wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                                 "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
-                                "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") ");
+                                "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") ");
                     }
                     wrapper.last("order by count(t.glass_id) desc  limit 2");
                     List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper);
                     if (CollectionUtil.isEmpty(list)) {
                         MPJQueryWrapper<GlassInfo> queryWrapper = new MPJQueryWrapper<GlassInfo>()
                                 .selectAll(GlassInfo.class).eq("t.glass_id", glassId);
-//                                .inSql("t.engineer_id", "select engineer_id from engineering where state = 1");
                         if (endcell == Const.A10_OUT_TARGET_POSITION) {
-                            wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
+                            queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                                     "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
-                                    "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") ");
+                                    "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength
+                                    + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") ");
                         } else {
-                            wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
+                            queryWrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                                     "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
-                                    "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") ");
+                                    "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") ");
                         }
                         GlassInfo one = glassInfoService.getOne(queryWrapper);
                         if (one != null) {
@@ -504,11 +511,12 @@
         if (endcell == Const.A10_OUT_TARGET_POSITION) {
             wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                     "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
-                    "on t.glass_id = t1.glass_id and (t1.first_length <=" + firstLength + " and t1.second_length<=" + secondLength + ") ");
+                    "on t.glass_id = t1.glass_id and (t1.first_length between " + minTwoFirstLength + " and " + firstLength
+                    + " and t1.second_length between " + minTwoSecondLength + " and " + secondLength + ") ");
         } else {
             wrapper.innerJoin("(select glass_id, case when height <= width then width else height end as first_length, " +
                     "case when width < height then width else height end as second_length from edg_storage_cage_details) t1 " +
-                    "on t.glass_id = t1.glass_id and (t1.first_length >=" + minFirstLength + " and t1.second_length>=" + minSecondLength + ") ");
+                    "on t.glass_id = t1.glass_id and (t1.first_length >=" + minOneFirstLength + " and t1.second_length>=" + minOneSecondLength + ") ");
         }
         wrapper.last("order by count(t.glass_id) desc  limit 2");
         List<EdgStorageCageDetails> list = edgStorageCageDetailsService.list(wrapper);
@@ -546,7 +554,7 @@
                 return queryMinGlass(firstSize.getWidth(), firstSize.getHeight(), glassId);
             }
             EdgStorageCageDetails outGlassInfo = edgStorageCageDetailsService.getOne(new LambdaQueryWrapper<EdgStorageCageDetails>()
-                    .eq(EdgStorageCageDetails::getGlassId, taskCache.getGlassId()));
+                    .eq(EdgStorageCageDetails::getGlassId, taskCache.getGlassId()).last("limit 1"));
             log.info("{}绾挎湁鍑虹墖浠诲姟淇℃伅,浠诲姟淇℃伅涓簕}锛岀幓鐠冧俊鎭负{}", endcell, taskCache, outGlassInfo);
             if (outGlassInfo.getWidth() == firstWidth && outGlassInfo.getHeight() == firstHeight) {
                 log.info("鏁伴噺鏈�澶氱殑瀹絳}楂榹}鍜寋}绾夸换鍔$殑瀹絳}楂榹}鐩稿悓锛屽嚭鏁伴噺鎺掔浜岀殑鐜荤拑锛屽{}楂榹}",
@@ -641,6 +649,8 @@
         edgGlassTaskInfo.setStatus(Const.EDG_GLASS_BEFORE);
         edgGlassTaskInfo.setLine(endcell);
         edgGlassTaskInfo.setTime(new Date());
+        //鍏堝皢鍘嗗彶瀵瑰垪琛ㄤ腑鏈幓鐠冪殑鏁版嵁鍒犻櫎锛岄噸鏂版柊澧炰竴浠芥渶鏂扮殑鏁版嵁
+        edgGlassTaskInfoService.remove(new LambdaQueryWrapper<EdgGlassTaskInfo>().eq(EdgGlassTaskInfo::getGlassId, glassInfo.getGlassId()));
         return edgGlassTaskInfoService.save(edgGlassTaskInfo);
     }
 

--
Gitblit v1.8.0