From 61cae17b15d6a7d256e25ce42f0a4ef4163fd088 Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期四, 11 九月 2025 15:54:03 +0800
Subject: [PATCH] 1、删除未修改的大屏程序

---
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java |  254 ++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 234 insertions(+), 20 deletions(-)

diff --git a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
index d1fc2b2..2f41b41 100644
--- a/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
+++ b/hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java
@@ -30,11 +30,13 @@
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
+import org.springframework.scheduling.annotation.Async;
 import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import java.util.*;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * @Author : zhoush
@@ -93,10 +95,18 @@
         String confirmationWrodAddress = plcParameterObject.getPlcParameter("confirmationWord").getAddress();
         String currentSlot = plcParameterObject.getPlcParameter("currentCell").getValue();
 
+        requestWord = "2";
+        glassIdeValue = "";
+        out06Glassstate = "1";
+        out08Glassstate = "1";
+        out11Glassstate = "1";
+        out13Glassstate = "1";
+        currentSlot = "1";
+        confirmationWrodValue = "0";
+
 
         log.info("1銆佽幏鍙栧埌鐨勮姹傚瓧涓猴細{}锛岃幏鍙栧埌鐨勬壂鎻廔D涓猴細{}锛岃幏鍙栧埌鐨勭‘璁ゅ瓧涓猴細{}锛岃幏鍙栧埌鐨勫嚭鐗囩姸鎬佸垎鍒负锛歡06:{}銆乬08:{}銆乬11:{}銆乬13:{},褰撳墠鏍煎瓙鍙蜂负锛歿}",
                 requestWord, glassIdeValue, confirmationWrodValue, out06Glassstate, out08Glassstate, out11Glassstate, out13Glassstate, currentSlot);
-
         if ("0".equals(requestWord)) {
             if ("0".equals(confirmationWrodValue)) {
                 log.info("2銆佽幏鍙栧埌鐨勮姹傚瓧涓�0锛屼笖纭瀛椾负0锛屼笉鎵ц浠诲姟");
@@ -131,10 +141,12 @@
     @Scheduled(fixedDelay = 300)
     public void plcShelfFull() {
         List<DownWorkstation> list = downGlassInfoService.queryWorkStationIsFull();
+        S7control s7control = S7object.getinstance().plccontrol;
+        PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
         if (CollectionUtils.isNotEmpty(list)) {
-            S7control s7control = S7object.getinstance().plccontrol;
-            PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
             s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 1);
+        } else {
+            s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 0);
         }
     }
 
@@ -154,7 +166,7 @@
             //涓嬬墖鏁伴噺-1
             for (DownGlassTask downGlassTask : downGlassTaskList
             ) {
-                if (Const.GLASS_CACHE_TYPE_OUT_ALL.equals(downGlassTask.getTaskType())) {
+                if (Const.GLASS_CACHE_TYPE_OUT_ALL.contains(downGlassTask.getTaskType())) {
                     downWorkstationService.update(
                             new LambdaUpdateWrapper<DownWorkstation>()
                                     .setSql("racks_number = racks_number-1")
@@ -169,7 +181,7 @@
                 damage.setLine(Const.TEMPERING_OUT_TARGET_POSITION);
                 damage.setWorkingProcedure("涓嬬墖");
                 damage.setRemark("涓嬬墖");
-                damage.setStatus(0);
+                damage.setStatus(1);
                 damage.setType(e.getTaskStatus());
                 return damage;
             }).collect(Collectors.toList());
@@ -195,7 +207,10 @@
             //鏇存柊宸ヤ綅鍏朵粬鐜荤拑淇℃伅鐨勬暟閲�
             QueryWrapper<Damage> queryWrapper = new QueryWrapper<>();
             queryWrapper.eq("process_id", downWorkstation.getFlowCardId());
-            queryWrapper.eq("technology_number", downWorkstation.getLayer());
+            queryWrapper.gt("type", 3);
+            if (downWorkstation.getLayer() != 0) {
+                queryWrapper.eq("technology_number", downWorkstation.getLayer());
+            }
             int otherNumber = damageService.count(queryWrapper);
             downWorkstationService.update(new LambdaUpdateWrapper<DownWorkstation>().set(DownWorkstation::getOtherNumber, otherNumber)
                     .eq(DownWorkstation::getWorkstationId, downWorkstation.getWorkstationId()));
@@ -222,12 +237,20 @@
         //鐜荤拑灏哄鏄惁璧颁汉宸ヤ笅鐗�
         if (glassWidth > maxWidth || glassHeight > maxHeight || glassWidth < minWidth || glassHeight < minHeight) {
             log.info("璇ョ幓鐠冨昂瀵镐笉绗﹀悎瑕佹眰锛岄渶瑕佽蛋浜哄伐涓嬬墖鐩存帴杩涚墖");
+            return;
         } else {
             log.info("璇ョ幓鐠冨昂瀵搁潪浜哄伐涓嬬墖");
             //鑾峰彇璇ョ幓鐠冪殑娴佺▼鍗℃槸鍚﹀凡缁戝畾鏋跺瓙
-            DownWorkstation one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
-                    .eq(DownWorkstation::getLayer, glassInfo.getLayer())
-                    .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
+            DownWorkstation one;
+            if (glassInfo.getCombine() != 0) {
+                one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
+                        .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
+            } else {
+                one = downWorkstationService.getOne(new LambdaQueryWrapper<DownWorkstation>()
+                        .eq(DownWorkstation::getLayer, glassInfo.getLayer())
+                        .eq(DownWorkstation::getFlowCardId, glassInfo.getFlowCardId()));
+            }
+
             //鏄惁宸茬粡缁戝畾   true锛氬凡缁戝畾    false:鏈粦瀹�
             Boolean isBind = Boolean.FALSE;
             if (null != one) {
@@ -242,8 +265,12 @@
                 if (CollectionUtils.isNotEmpty(list)) {
                     log.info("鏈夌┖鏋跺瓙,灏嗘祦绋嬪崱涓庢灦瀛愬ソ缁戝畾锛屾墽琛岃繘鐗囦换鍔� 缁撴潫");
                     //缁戝畾娴佺▼鍗�
-                    downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), glassInfo.getLayer());
-//                    downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getId(), glassInfo.getLayer());
+                    if (glassInfo.getCombine() == 0) {
+                        downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), glassInfo.getLayer());
+                    } else {
+                        downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getWorkstationId(), 0);
+                    }
+//                      downWorkstationService.updateFlowCardIdAndCount(glassInfo.getFlowCardId(), list.get(0).getId(), glassInfo.getLayer());
                     checkFlag = Boolean.TRUE;
                 }
             }
@@ -259,7 +286,8 @@
                     for (DownGlassInfoDTO e : downGlassInfoDTOList) {
                         List<GlassInfo> glassInfoList = e.getGlassInfoList();
                         List<GlassInfo> glassInfoTempList = glassInfoList.stream().filter(item -> item.getWidth() == glassInfo.getWidth() && item.getHeight() == glassInfo.getHeight()
-                                && item.getThickness() == glassInfo.getThickness() && item.getFilmsid().equals(glassInfo.getFilmsid())).collect(Collectors.toList());
+                                && item.getThickness() == glassInfo.getThickness() && item.getMarkIcon().equals(glassInfo.getMarkIcon())
+                                && item.getFilmsid().equals(glassInfo.getFilmsid())).collect(Collectors.toList());
                         if (CollectionUtils.isNotEmpty(glassInfoTempList)) {
                             for (GlassInfo item : glassInfoTempList) {
                                 //鐜荤拑鏄惁涓哄灞傦細1銆佸厛鑾峰彇褰撳墠娴佺▼鍗¤惤鏋舵渶澶氱殑灞傛暟锛屽鏋滀负绌猴紝琛ㄦ槑鏈粦瀹氭祦绋嬪崱锛屾湭钀芥灦锛岀劧鍚庢寜鐓ф槸鍚﹀彲缁戝畾鏋跺瓙鍐冲畾鏄惁鏇挎崲銆傦紙鍙拷鐣ヤ笉璁★紝鏈牎楠屼粎鍦ㄥ墠涓�娆¤皟鐢ㄨ捣浣滅敤锛�
@@ -292,6 +320,10 @@
         //灏嗕换鍔℃彃鍏ョ悊鐗囩璇︽儏琛�
         DownStorageCageDetails downStorageCageDetails = new DownStorageCageDetails();
         BeanUtils.copyProperties(glassInfo, downStorageCageDetails);
+        //褰撻渶瑕佸悎骞惰惤鏋舵椂涓嶇粦瀹氬眰鍙�
+        if (glassInfo.getCombine() != 0) {
+            downStorageCageDetails.setLayer(0);
+        }
         downStorageCageDetails.setState(Const.GLASS_STATE_IN);
         downStorageCageDetails.setSlot(nearestEmpty.getSlot());
         downStorageCageDetails.setDeviceId(nearestEmpty.getDeviceId());
@@ -316,6 +348,10 @@
         if (StringUtils.isNotBlank(glassId)) {
             GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassId));
             BeanUtils.copyProperties(glassInfo, cageDetails);
+            //褰撻渶瑕佸悎骞惰惤鏋舵椂涓嶇粦瀹氬眰鍙�
+            if (glassInfo.getCombine() != 0) {
+                cageDetails.setLayer(0);
+            }
             //鑾峰彇褰撳墠绗煎瓙绌烘牸淇℃伅
             DownStorageCage empty = downStorageCageService.selectCacheEmpty(Integer.parseInt(currentSlot), Boolean.TRUE);
             cageDetails.setSlot(empty.getSlot());
@@ -327,11 +363,151 @@
             log.info("绗煎唴娌℃湁鐜荤拑,鏃犳硶鎵ц鍑虹墖");
             return Boolean.FALSE;
         }
+//        //鑾峰彇鏈�灏忓伐绋嬩笌鐐夋暟
+//        Map<String, List<DownStorageCageDetails>> groupedMap = tempList.stream()
+//                .collect(Collectors.groupingBy(item -> item.getEngineerId() + "_" + item.getTemperingLayoutId()));
+//        // 鑾峰彇绗竴涓� 鍏堣繘鍗х悊閭d竴鐐夌殑淇℃伅
+//        List<DownStorageCageDetails> cageList =
+//                new ArrayList<>(groupedMap.values().stream().findFirst().orElse(Collections.emptyList()));
+//
+//        if (groupedMap.size() > 1) {
+//            //鎸夋祦绋嬪崱杩涜鍒嗙粍
+//            Map<String, List<DownStorageCageDetails>> getFlowCardIds = cageList.stream()
+//                    .collect(Collectors.groupingBy(item -> item.getFlowCardId() + "_" + item.getLayer()));
+//            // 鎸� 鐭竟 闄嶅簭锛岄暱杈� 闄嶅簭,鐐夊唴鐗囧簭 闄嶅簭
+//            getFlowCardIds.forEach((key, list) -> {
+//                list.sort(Comparator.comparingDouble((DownStorageCageDetails item) -> Math.min(item.getWidth(), item.getHeight()))
+//                        .reversed()
+//                        .thenComparingDouble(item -> Math.max(item.getWidth(), item.getHeight()))
+//                        .reversed()
+//                        .thenComparingInt(item -> item.getTemperingFeedSequence()));
+//            });
+//            //鑾峰彇姣忎釜娴佺▼鍗″嚭鐗囦紭鍏堢骇鏈�楂樼殑鐜荤拑
+//            tempList = getFlowCardIds.values().stream()
+//                    .map(list -> list.isEmpty() ? null : list.get(0))
+//                    .filter(Objects::nonNull)
+//                    .collect(Collectors.toList());
+//        } else {
+//            //绗煎唴鍔犳壂鐮佷綅鐜荤拑id
+//            List<String> cageGlassIds = cageList.stream()
+//                    .map(DownStorageCageDetails::getGlassId)
+//                    .collect(Collectors.toList());
+//            //鑾峰彇鐮存崯鎷胯蛋鐨勭幓鐠冨苟杩囨护璋冨凡缁忓湪绗煎唴鐨勶紝闃叉涔辨姤鐮存崯
+//            List<Damage> damageList = damageService.list(
+//                    new LambdaQueryWrapper<Damage>()
+//                            .eq(Damage::getEngineerId, cageList.get(0).getEngineerId())
+//                            .eq(Damage::getTemperingLayoutId, cageList.get(0).getTemperingLayoutId())
+//                            .and(item -> item.eq(Damage::getType, 8).or().eq(Damage::getType, 9))
+//                            .lt(Damage::getStatus, 4)
+//                            .notIn(Damage::getGlassId, cageGlassIds)
+//            );
+//            //鑾峰彇鐮存崯/鎷胯蛋鐜荤拑id
+//            List<String> damageGlassIds = damageList.stream()
+//                    .map(Damage::getGlassId)
+//                    .collect(Collectors.toList());
+//            //鑾峰彇宸插嚭鐗囩幓鐠冧俊鎭�
+//            List<DownStorageCageDetails> downStorageCageDetails = downStorageCageDetailsService.list(
+//                    new LambdaQueryWrapper<DownStorageCageDetails>()
+//                            .eq(DownStorageCageDetails::getEngineerId, cageList.get(0).getEngineerId())
+//                            .eq(DownStorageCageDetails::getTemperingLayoutId, cageList.get(0).getTemperingLayoutId())
+//            );
+//            //鑾峰彇宸插嚭鐗囩幓鐠僫d
+//            List<String> downGlassIds = downStorageCageDetails.stream()
+//                    .map(DownStorageCageDetails::getGlassId)
+//                    .collect(Collectors.toList());
+//            //鑾峰彇鎵�鏈夋湭涓嬬墖鐨勭幓鐠冧俊鎭�
+//            List<GlassInfo> glassInfoList = glassInfoService.list(
+//                    new LambdaQueryWrapper<GlassInfo>()
+//                            .eq(GlassInfo::getEngineerId, cageList.get(0).getEngineerId())
+//                            .eq(GlassInfo::getTemperingLayoutId, cageList.get(0).getTemperingLayoutId())
+//                            .notIn(CollectionUtils.isNotEmpty(damageGlassIds), GlassInfo::getGlassId, damageGlassIds)
+//                            .notIn(CollectionUtils.isNotEmpty(downGlassIds), GlassInfo::getGlassId, downGlassIds)
+//            );
+//            //鎸夋祦绋嬪崱杩涜鍒嗙粍
+//            Map<String, List<GlassInfo>> getFlowCardIds = glassInfoList.stream()
+//                    .collect(Collectors.groupingBy(item -> item.getFlowCardId() + "_" + item.getLayer()));
+//            // 鎸� 鐭竟 闄嶅簭锛岄暱杈� 闄嶅簭,鐐夊唴鐗囧簭 闄嶅簭
+//            getFlowCardIds.forEach((key, list) -> {
+//                list.sort(Comparator.comparingDouble((GlassInfo item) -> Math.min(item.getWidth(), item.getHeight()))
+//                        .reversed()
+//                        .thenComparingDouble(item -> Math.max(item.getWidth(), item.getHeight()))
+//                        .reversed()
+//                        .thenComparingInt(item -> item.getTemperingFeedSequence()));
+//            });
+//            //鑾峰彇涓�鐐夋墍鏈夋湭鍑虹墖娴佺▼鍗′紭鍏堢骇鏈�楂樼殑鐜荤拑
+//            List<GlassInfo> glassInfos = getFlowCardIds.values().stream()
+//                    .map(list -> list.isEmpty() ? null : list.get(0))
+//                    .filter(Objects::nonNull)
+//                    .collect(Collectors.toList());
+//            //鑾峰彇涓�鐐夋墍鏈夋湭鍑虹墖娴佺▼鍗′紭鍏堢骇鏈�楂樼殑鐜荤拑id
+//            List<String> noOutGlassIds = glassInfos.stream()
+//                    .map(GlassInfo::getGlassId)
+//                    .collect(Collectors.toList());
+//            //鑾峰彇鍖归厤鐨勭幓鐠冧俊鎭�
+//            List<DownStorageCageDetails> filteredList = tempList.stream()
+//                    .filter(item -> noOutGlassIds.contains(item.getGlassId()))
+//                    .collect(Collectors.toList());
+//            if (CollectionUtils.isNotEmpty(filteredList)) {
+//                tempList = filteredList;
+//            } else {
+//                //鏄惁婊$
+//                if (tempList.size() == 9) {
+//                    // 缁撴灉鍒楄〃
+//                    List<DownStorageCageDetails> resultList = new ArrayList<>();
+//
+//                    // 灏� glassInfos 杞崲鎴� Map锛屼互 flowCardId_layer 浣滀负 key
+//                    Map<String, GlassInfo> glassInfoMap = glassInfos.stream()
+//                            .collect(Collectors.toMap(
+//                                    item -> item.getFlowCardId() + "_" + item.getLayer(),
+//                                    item -> item
+//                            ));
+//
+//                    // 鎸� flowCardId 鍜� layer 杩涜鍒嗙粍
+//                    Map<String, List<DownStorageCageDetails>> groupedByFlowCardLayer = tempList.stream()
+//                            .collect(Collectors.groupingBy(item -> item.getFlowCardId() + "_" + item.getLayer()));
+//
+//                    // 閬嶅巻鍒嗙粍锛屾壘鍑烘瘡涓�缁勪腑璇樊鏈�灏忕殑 DownStorageCageDetails
+//                    for (Map.Entry<String, List<DownStorageCageDetails>> entry : groupedByFlowCardLayer.entrySet()) {
+//                        String key = entry.getKey();
+//                        List<DownStorageCageDetails> groupList = entry.getValue();
+//
+//                        // 鍙湁褰� glassInfoMap 閲屾湁鐩稿簲鐨� key 鏃讹紝鎵嶈绠楁渶鎺ヨ繎鐨勫尮閰嶉」
+//                        if (glassInfoMap.containsKey(key)) {
+//                            GlassInfo glassInfo = glassInfoMap.get(key);
+//                            double glassShortEdge = Math.min(glassInfo.getWidth(), glassInfo.getHeight());
+//                            double glassLongEdge = Math.max(glassInfo.getWidth(), glassInfo.getHeight());
+//
+//                            // 鎵惧埌璇樊鏈�灏忕殑 DownStorageCageDetails
+//                            Optional<DownStorageCageDetails> bestMatch = groupList.stream()
+//                                    .min(Comparator.comparingDouble(item -> {
+//                                        double itemShortEdge = Math.min(item.getWidth(), item.getHeight());
+//                                        double itemLongEdge = Math.max(item.getWidth(), item.getHeight());
+//
+//                                        // 鍏堟瘮杈冪煭杈硅宸�
+//                                        double shortEdgeDiff = Math.abs(itemShortEdge - glassShortEdge);
+//                                        // 鍐嶆瘮杈冮暱杈硅宸紙浠呭綋鐭竟璇樊鐩稿悓鏃讹級
+//                                        double longEdgeDiff = Math.abs(itemLongEdge - glassLongEdge);
+//
+//                                        return shortEdgeDiff * 1000 + longEdgeDiff; // 璁╃煭杈硅宸紭鍏堢骇鏇撮珮
+//                                    }));
+//
+//                            bestMatch.ifPresent(resultList::add);
+//                        }
+//                    }
+//                    tempList = resultList;
+//                } else {
+//                    return Boolean.FALSE;
+//                }
+//            }
+//        }
+
+
         //浼樺厛璧�08鐗囧彴鐨勭幓鐠冿細璧颁汉宸ヤ笅鐗囨垨鑰�2鍙锋満姊拌噦
         //1銆�08鍙板繖纰岋紝浠呰蛋1鍙锋満姊拌噦
         //2銆�08鍙扮┖闂诧紝鍏堣蛋鎵斿伐涓嬬墖鎴�2鍙锋満姊拌噦锛屾棤鐜荤拑鍑虹墖 鍦ㄨ蛋1鍙锋満姊拌噦
         //鏈烘鑷傝绂佺敤鐨勬儏鍐典笅涓嶈兘缁х画鍚戠鐢ㄧ殑鏈烘鑷傛斁鐜荤拑
         Boolean flag08 = "1".equals(out08Glassstate) ? Boolean.TRUE : Boolean.FALSE;
+        flag08 = true;
         if (!flag08) {
             generateTaskByShelf(glassStatus06, glassStatus11, flag08, glassStatus13, tempList, cageDetails, glassId);
         } else {
@@ -432,6 +608,7 @@
                     Map<String, List<DownWorkstation>> listMap = downWorkstationList.stream()
                             .filter(item -> StringUtils.isNotBlank(item.getFlowCardId())).collect(Collectors.groupingBy(item -> item.getFlowCardId() + ":" + item.getLayer()));
                     //杩囨护绛涢�夎幏鍙栨灦瀛愪笂瀵瑰簲娴佺▼鍗�+灞傛暟鐨勭瀛愬唴鐨勭幓鐠冧俊鎭�
+
                     list = tempList.stream().filter(item -> listMap.containsKey(item.getFlowCardId() + ":" + item.getLayer())).collect(Collectors.toList());
                     if (CollectionUtils.isEmpty(list) && flag08 && !"2".equals(glassStatus13)) {
                         list = tempList.stream().filter(item -> {
@@ -618,9 +795,16 @@
                 return Boolean.FALSE;
             }
         } else {
-            DownWorkstation workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>()
-                    .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer()));
-            endCell = workstation.getWorkstationId();
+            double firstLength = Math.max(downStorageCageDetails.getWidth(), downStorageCageDetails.getHeight());
+            double secondLength = Math.min(downStorageCageDetails.getWidth(), downStorageCageDetails.getHeight());
+            if (firstLength > maxWidth || secondLength > maxHeight) {
+                endCell = Const.G13_WORK_STATION;
+            } else {
+                DownWorkstation workstation;
+                workstation = downWorkstationService.getOne(new LambdaUpdateWrapper<DownWorkstation>()
+                        .eq(DownWorkstation::getFlowCardId, downStorageCageDetails.getFlowCardId()).eq(DownWorkstation::getLayer, downStorageCageDetails.getLayer()));
+                endCell = workstation.getWorkstationId();
+            }
         }
         //鏇存柊钀芥灦鐜荤拑鏁伴噺
         if (endCell == Const.G13_WORK_STATION) {
@@ -635,14 +819,36 @@
         DownGlassInfo downGlassInfo = new DownGlassInfo();
         BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo);
         //钀芥灦鐗囧簭
-        downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
-        downGlassInfo.setWorkStationId(endCell);
-        downGlassInfo.setGmtCreate(new Date());
-        downGlassInfoService.save(downGlassInfo);
-        //鐢熸垚浠诲姟淇℃伅
+        LambdaQueryWrapper<DownGlassInfo> wrapper = new LambdaQueryWrapper<DownGlassInfo>();
+        wrapper.eq(DownGlassInfo::getFlowCardId, downGlassInfo.getFlowCardId())
+                .orderByDesc(DownGlassInfo::getSequence)
+                .last("limit 1");
+        if (downStorageCageDetails.getLayer() != 0) {
+            wrapper.eq(DownGlassInfo::getLayer, downGlassInfo.getLayer());
+        }
+//        downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
+        int k = 1;
+//        DownGlassInfo downGlassInfo1 = downGlassInfoService.getOne(wrapper);
+//        if (downGlassInfo1 != null) {
+//            k = 1;
+//        } else {
+//            k = 1;
+//        }
         GlassInfo glassInfo = new GlassInfo();
         BeanUtils.copyProperties(downStorageCageDetails, glassInfo);
+        GlassInfo glassInfo1 = glassInfoService.getOne(
+                new LambdaUpdateWrapper<GlassInfo>().eq(GlassInfo::getGlassId, glassInfo.getGlassId())
+        );
+        downGlassInfo.setSequence(k);
+        downGlassInfo.setWorkStationId(endCell);
+        downGlassInfo.setGmtCreate(new Date());
+        downGlassInfo.setLayer(glassInfo1.getLayer());
+        downGlassInfoService.save(downGlassInfo);
+        //鐢熸垚浠诲姟淇℃伅
+
+
         //鍒犻櫎鐞嗙墖绗艰〃鎷胯蛋/鐮存崯鏁版嵁鏁版嵁
+        glassInfo.setLayer(glassInfo1.getLayer());
         damageService.deleteByGlassId(glassInfo.getGlassId());
         return initDownGlassTask(glassInfo, downStorageCageDetails.getSlot(), endCell, taskType);
     }
@@ -661,6 +867,14 @@
         downGlassTask.setTaskStatus(0);
         downGlassTask.setCreateTime(new Date());
         downGlassTaskService.save(downGlassTask);
+        //娣诲姞鎶ュ伐鏁版嵁
+        Damage damage = new Damage();
+        damage.setGlassId(glassInfo.getGlassId());
+        damage.setWorkingProcedure("閽㈠寲");
+        damage.setLine(4001);
+        damage.setType(1);
+        damage.setRemark("閽㈠寲鍚庡崸寮忕悊鐗�");
+        damageService.insertDamage(damage);
         //鍚憄lc鍙戦�佸懡浠�
         return sendMessageToPlc((int) glassInfo.getWidth(), (int) glassInfo.getHeight(), (int) glassInfo.getThickness(),
                 startCell, endCell, taskType);

--
Gitblit v1.8.0