From 0ece4e0ed07f412178150c3badaa2ce49cb52e86 Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期一, 02 十二月 2024 09:30:13 +0800
Subject: [PATCH] 使用sqlserver 移除mysql代码

---
 hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageTask.java |   78 ++++++++++++++++++++-------------------
 1 files changed, 40 insertions(+), 38 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageTask.java b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageTask.java
index 725415b..865eb34 100644
--- a/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageTask.java
+++ b/hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/OpcPlcStorageCageTask.java
@@ -1,11 +1,10 @@
 package com.mes.job;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.lang.Assert;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
-import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.github.yulichang.toolkit.JoinWrappers;
-import com.github.yulichang.wrapper.MPJLambdaWrapper;
 import com.kangaroohy.milo.model.ReadWriteEntity;
 import com.kangaroohy.milo.service.MiloService;
 import com.mes.base.entity.BigStorageCageBaseInfo;
@@ -26,9 +25,8 @@
 import com.mes.damage.service.DamageService;
 import com.mes.glassinfo.entity.GlassInfo;
 import com.mes.glassinfo.service.GlassInfoService;
-import com.mes.temperingglass.entity.TemperingGlass;
 import com.mes.temperingglass.entity.TemperingGlassInfo;
-import com.mes.temperingglass.service.TemperingGlassService;
+import com.mes.temperingglass.service.TemperingGlassInfoService;
 import com.mes.utils.RedisUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang.StringUtils;
@@ -50,7 +48,7 @@
     @Resource
     private BigStorageCageDetailsService bigStorageCageDetailsService;
     @Resource
-    private TemperingGlassService temperingGlassService;
+    private TemperingGlassInfoService temperingGlassInfoService;
     @Resource
     private DamageService damageService;
     @Resource
@@ -108,7 +106,7 @@
         }
         //鑾峰彇杩涚墖浠诲姟琛�
         List<BigStorageCageTask> inTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_in_one_task");
-        if (CollectionUtils.isEmpty(inTaskList)) {
+        if (CollectionUtil.isEmpty(inTaskList)) {
             log.info("褰撳墠澶ц溅鏃犺繘鐗囩幓鐠冿紝缁撴潫杩涚墖浠诲姟");
         }
 
@@ -183,36 +181,41 @@
         }
         //鑾峰彇鍑虹墖浠诲姟琛�
         List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task");
-        if (CollectionUtils.isNotEmpty(outTaskList)) {
+        if (CollectionUtil.isNotEmpty(outTaskList)) {
             log.info("鏈夋鍦ㄦ墽琛岀殑鍑虹墖浠诲姟锛岀粨鏉熸湰娆″嚭鐗囦换鍔�");
             return;
         }
         //todo:鏄惁鍏佽閽㈠寲
         if (redisUtil.getCacheObject("temperingSwitch")) {
             //鏄惁鏈夋鍦ㄩ挗鍖栫殑鐜荤拑:閽㈠寲灏忕墖琛ㄥ叧鑱斿巻鍙蹭换鍔¤〃锛岀瓫閫夋湭鍑虹鐨勭幓鐠冧俊鎭�
-            List<TemperingGlass> temperingGlassList = temperingGlassService.selectJoinList(TemperingGlass.class, new MPJLambdaWrapper<TemperingGlass>()
-                    .selectAll(TemperingGlass.class)
-                    .leftJoin(BigStorageCageHistoryTask.class, BigStorageCageHistoryTask::getGlassId, TemperingGlass::getGlassId)
-                    .eq(TemperingGlass::getState, Const.TEMPERING_NEW)
-                    .eq(BigStorageCageHistoryTask::getTaskType, Const.BIG_STORAGE_BEFORE_OUT)
-                    .isNull(BigStorageCageHistoryTask::getGlassId)
-                    .orderBy(Boolean.TRUE, sequenceOrder, TemperingGlass::getTemperingFeedSequence));
-            //todo:鍘嗗彶浠诲姟琛�
-            if (CollectionUtils.isNotEmpty(temperingGlassList)) {
-                log.info("鏈夋鍦ㄥ嚭鐗囩殑閽㈠寲浠诲姟");
-                computeOutGlassInfo(temperingGlassList, "big_storage_cage_out_one_task", Const.TEMPERING_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
-                Date endDate = new Date();
-                log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime());
-                return;
+//            鑾峰彇褰撳墠閽㈠寲浠诲姟鏈畬鎴愬嚭鐗囩殑鐜荤拑淇℃伅
+            List<TemperingGlassInfo> unFinishTemperingGlassInfoList = temperingGlassInfoService.list(new LambdaQueryWrapper<TemperingGlassInfo>().eq(TemperingGlassInfo::getState, Const.TEMPERING_NEW));
+            if (CollectionUtil.isNotEmpty(unFinishTemperingGlassInfoList)) {
+                List<String> glassIdList = unFinishTemperingGlassInfoList.stream().map(TemperingGlassInfo::getGlassId).collect(Collectors.toList());
+                List<BigStorageCageHistoryTask> historyTaskList = bigStorageCageHistoryTaskService.list(new LambdaQueryWrapper<BigStorageCageHistoryTask>()
+                        .eq(BigStorageCageHistoryTask::getTaskType, Const.BIG_STORAGE_BEFORE_OUT)
+                        .in(BigStorageCageHistoryTask::getGlassId, glassIdList));
+                List<TemperingGlassInfo> temperingGlassList = unFinishTemperingGlassInfoList;
+                if (CollectionUtil.isNotEmpty(historyTaskList)) {
+                    List<String> taskGlassList = historyTaskList.stream().map(BigStorageCageHistoryTask::getGlassId).collect(Collectors.toList());
+                    temperingGlassList = unFinishTemperingGlassInfoList.stream().filter(e -> !taskGlassList.contains(e.getGlassId())).collect(Collectors.toList());
+                }
+                if (CollectionUtil.isNotEmpty(temperingGlassList)) {
+                    log.info("鏈夋鍦ㄥ嚭鐗囩殑閽㈠寲浠诲姟");
+                    computeOutGlassInfo(temperingGlassList, "big_storage_cage_out_one_task", temperingOutTargetPosition, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
+                    Date endDate = new Date();
+                    log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime());
+                    return;
+                }
             }
             //閽㈠寲浼樺厛锛氳幏鍙栫悊鐗囩  鐜荤拑灏忕墖  鐮存崯琛� 鏁伴噺   鍒ゆ柇绗煎唴鐗堝浘鏄惁鍒伴綈
             List<TemperingLayoutDTO> temperingLayoutDTOList = bigStorageCageDetailsService.temperingIsAll();
-            if (CollectionUtils.isNotEmpty(temperingLayoutDTOList)) {
+            if (CollectionUtil.isNotEmpty(temperingLayoutDTOList)) {
                 //鐜荤拑鍒伴綈鍖呮嫭宸插嚭鐗囩殑
                 //鍒伴綈锛屽皢鐜荤拑灏忕墖鏁版嵁瀛樺叆閽㈠寲灏忕墖琛紝閫昏緫鐢熸垚鍑虹墖浠诲姟  缁撴潫
                 for (TemperingLayoutDTO item : temperingLayoutDTOList) {
 //                    if (item.getEngineerId().equals(redisUtil.getCacheObject("temperingengineerId"))) {
-                    List<TemperingGlass> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlass.class, JoinWrappers.lambda(GlassInfo.class)
+                    List<TemperingGlassInfo> temperingGlassInfos = glassInfoService.selectJoinList(TemperingGlassInfo.class, JoinWrappers.lambda(GlassInfo.class)
                             .selectAll(GlassInfo.class)
                             .select("-1 as state")
                             .selectAs(BigStorageCageDetails::getSlot, TemperingGlassInfo::getSlot)
@@ -221,9 +224,9 @@
                             .eq(GlassInfo::getTemperingLayoutId, item.getTemperingLayoutId())
                             .eq(GlassInfo::getEngineerId, item.getEngineerId())
                             .orderBy(Boolean.TRUE, sequenceOrder, GlassInfo::getTemperingFeedSequence));
-                    if (CollectionUtils.isNotEmpty(temperingGlassInfos)) {
-                        temperingGlassService.saveBatch(temperingGlassInfos);
-                        computeOutGlassInfo(temperingGlassInfos, "big_storage_cage_out_one_task", Const.TEMPERING_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
+                    if (CollectionUtil.isNotEmpty(temperingGlassInfos)) {
+                        temperingGlassInfoService.saveBatch(temperingGlassInfos);
+                        computeOutGlassInfo(temperingGlassInfos, "big_storage_cage_out_one_task", temperingOutTargetPosition, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
                         Date endDate = new Date();
                         log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime());
                         return;
@@ -237,15 +240,15 @@
                 .eq(BigStorageCageDetails::getState, Const.GLASS_STATE_ARTIFICIAL)
                 .orderByAsc(BigStorageCageDetails::getSlot)
                 .orderByAsc(BigStorageCageDetails::getId));
-        if (CollectionUtils.isNotEmpty(artificialList)) {
-            computeOutGlassInfo(artificialList, "big_storage_cage_out_one_task", Const.ARTIFICIAL_OUT_TARGET_POSITION, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
+        if (CollectionUtil.isNotEmpty(artificialList)) {
+            computeOutGlassInfo(artificialList, "big_storage_cage_out_one_task", artificialOutTargetPosition, Const.GLASS_STATE_OUT_ING, Const.BIG_STORAGE_BEFORE_OUT);
             Date endDate = new Date();
             log.info("澶х悊鐗囩鍑虹墖浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms,缁撴潫鎵爜浠诲姟", endDate, endDate.getTime() - startDate.getTime());
             return;
         }
         //鏄惁瀛樺湪闇�瑕佸唴閮ㄨ皟搴︾殑鏍煎瓙:鎵ц鍐呴儴璋冨害浠诲姟
         List<TemperingLayoutDTO> temperingOccupySlotList = bigStorageCageDetailsService.queryTemperingOccupySlot();
-        if (CollectionUtils.isNotEmpty(temperingOccupySlotList)) {
+        if (CollectionUtil.isNotEmpty(temperingOccupySlotList)) {
             loop:
             for (TemperingLayoutDTO temperingOccupySlot : temperingOccupySlotList) {
                 List<SlotSequenceDTO> slotSequenceList = bigStorageCageDetailsService.queryGlassMaxAndMin(temperingOccupySlot.getEngineerId(), temperingOccupySlot.getTemperingLayoutId());
@@ -256,11 +259,10 @@
                     int totalCount = first.getGlassCount() + second.getGlassCount();
                     if (totalCount <= 6 && first.getMinSequence() == second.getMaxSequence() + 1
                             && second.getRemainWidth() > slotWidth && slotWidth >= 0) {
-
                         List<BigStorageCageDetails> list = bigStorageCageDetailsService.list(new LambdaQueryWrapper<BigStorageCageDetails>()
                                 .eq(BigStorageCageDetails::getSlot, first.getSlot()).eq(BigStorageCageDetails::getState, Const.GLASS_STATE_IN)
                                 .orderBy(Boolean.TRUE, sequenceOrder, BigStorageCageDetails::getTemperingFeedSequence));
-                        if (CollectionUtils.isNotEmpty(list)) {
+                        if (CollectionUtil.isNotEmpty(list)) {
                             computeOutGlassInfo(list, "big_storage_cage_out_one_task", second.getSlot(), Const.GLASS_STATE_SCHEDULE_ING, Const.BIG_STORAGE_BEFORE_DISPATCH);
                         }
                         //浣跨敤Arrays.asList() 浣跨敤removeAll鎶ラ敊锛屾敼涓烘甯镐娇鐢↙ist
@@ -286,12 +288,12 @@
         }
         //鑾峰彇杩涚墖浠诲姟琛�
         List<BigStorageCageTask> inTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_in_one_task");
-        if (CollectionUtils.isEmpty(inTaskList)) {
+        if (CollectionUtil.isEmpty(inTaskList)) {
             log.info("褰撳墠澶ц溅鏃犺繘鐗囩幓鐠冿紝缁撴潫瀹屾垚杩涚墖浠诲姟");
             return;
         }
         List<BigStorageCageTask> unFinishTaskList = inTaskList.stream().filter(e -> e.getTaskState() <= 1 || e.getStartSlot() == 0).collect(Collectors.toList());
-        if (CollectionUtils.isNotEmpty(unFinishTaskList)) {
+        if (CollectionUtil.isNotEmpty(unFinishTaskList)) {
             log.info("瀛樺湪鏈畬鎴愮殑鐜荤拑淇℃伅,鐜荤拑锛歿}", unFinishTaskList);
             return;
         }
@@ -344,12 +346,12 @@
         }
         //鑾峰彇杩涚墖浠诲姟琛�
         List<BigStorageCageTask> outTaskList = bigStorageCageTaskService.queryTaskMessage("big_storage_cage_out_one_task");
-        if (CollectionUtils.isEmpty(outTaskList)) {
+        if (CollectionUtil.isEmpty(outTaskList)) {
             log.info("褰撳墠澶ц溅鏃犺繘鐗囩幓鐠冿紝缁撴潫瀹屾垚杩涚墖浠诲姟");
             return;
         }
         List<BigStorageCageTask> unFinishTaskList = outTaskList.stream().filter(e -> e.getTaskState() <= 1 || e.getStartSlot() == 0).collect(Collectors.toList());
-        if (CollectionUtils.isNotEmpty(unFinishTaskList)) {
+        if (CollectionUtil.isNotEmpty(unFinishTaskList)) {
             log.info("瀛樺湪鏈畬鎴愮殑鐜荤拑淇℃伅,鐜荤拑锛歿}", unFinishTaskList);
             return;
         }
@@ -542,7 +544,7 @@
             bigStorageCageTaskList.add(new BigStorageCageTask(e.getGlassId(), e.getSlot(), targetSlot,
                     0));
         }
-        Assert.isFalse(CollectionUtils.isEmpty(bigStorageCageTaskList), "鏈幏鍙栧嚭鐗囨暟鎹紝缁撴潫鍑虹墖浠诲姟");
+        Assert.isFalse(CollectionUtil.isEmpty(bigStorageCageTaskList), "鏈幏鍙栧嚭鐗囨暟鎹紝缁撴潫鍑虹墖浠诲姟");
         log.info("鑾峰彇鍑虹墖浠诲姟鏁版嵁{}鏉★紝鎵ц淇濆瓨", bigStorageCageTaskList.size());
         List<String> glassIds = bigStorageCageTaskList.stream().map(BigStorageCageTask::getGlassId).collect(Collectors.toList());
         int glassCount = bigStorageCageTaskList.size();
@@ -582,7 +584,7 @@
                 .in(BigStorageCageDetails::getSlot, slotList).in(BigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL));
         Map<Integer, Double> slotRemainMap = new HashMap<>();
         //鏄惁瀛樺湪鏈夋牸瀛愰潪绌虹殑鐜荤拑
-        if (CollectionUtils.isNotEmpty(inSlotGlassList)) {
+        if (CollectionUtil.isNotEmpty(inSlotGlassList)) {
             //瀛樺湪  灏嗘牸瀛愬唴鐨勭幓鐠冨垎鍒繘琛屾洿鏂�
             slotRemainMap = inSlotGlassList.stream()
                     .collect(Collectors.groupingBy(BigStorageCageDetails::getSlot, Collectors.summingDouble(item -> Math.max(item.getWidth(), item.getHeight()) + glassGap)));
@@ -595,7 +597,7 @@
         //杩囨护涓嶅瓨鍦ㄧ幓鐠冪殑鏍煎瓙 灏嗗搴﹂噸缃负鍘熷瀹藉害5000
         Set<Integer> remainSlotList = slotRemainMap.keySet();
         slotList.removeAll(remainSlotList);
-        if (CollectionUtils.isNotEmpty(slotList)) {
+        if (CollectionUtil.isNotEmpty(slotList)) {
             bigStorageCageService.update(new LambdaUpdateWrapper<BigStorageCage>().set(BigStorageCage::getRemainWidth, slotWidth)
                     .in(BigStorageCage::getSlot, slotList));
         }

--
Gitblit v1.8.0