From f68d3c71819feb59e7a227a5d992b059b900916c Mon Sep 17 00:00:00 2001
From: ZengTao <2773468879@qq.com>
Date: 星期五, 28 三月 2025 08:28:26 +0800
Subject: [PATCH] 修改报表,界面添加查询流程卡个数,调整推送数据到前端的间隔

---
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java |  117 ++++++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 93 insertions(+), 24 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 95facd4..c6288dd 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
@@ -81,7 +81,6 @@
 
 
     @Scheduled(fixedDelay = 300)
-    @Async
     public void plcHomeEdgTask() {
         PlcParameterObject plcParameterObject = S7object.getinstance().PlcMesObject;
         String requestWord = plcParameterObject.getPlcParameter("requestWord").getValue();
@@ -95,10 +94,18 @@
         String confirmationWrodAddress = plcParameterObject.getPlcParameter("confirmationWord").getAddress();
         String currentSlot = plcParameterObject.getPlcParameter("currentCell").getValue();
 
+//        requestWord="3";
+//        glassIdeValue="P25031802|4|1";
+//        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,18 +138,18 @@
     }
 
     @Scheduled(fixedDelay = 300)
-    @Async
     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);
         }
     }
 
     @Scheduled(fixedDelay = 1000)
-    @Async
     public void dealDamageTask() {
         Date startDate = new Date();
         log.info("涓嬬墖鐮存崯鐜荤拑娓呴櫎浠诲姟寮�濮嬫墽琛屾椂闂达細{}", startDate);
@@ -158,7 +165,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")
@@ -173,7 +180,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());
@@ -187,7 +194,6 @@
      * 鏇存柊宸茬粦瀹氬伐浣嶆祦绋嬪崱鐨勭牬鎹�/鎷胯蛋鐨勬暟閲忎俊鎭�
      */
     @Scheduled(fixedDelay = 1000)
-    @Async
     public void updateWorkStationOtherCount() {
         Date startDate = new Date();
         log.info("涓嬬墖鐮存洿鏂版崯鐜荤拑鏁伴噺浠诲姟寮�濮嬫墽琛屾椂闂达細{}", startDate);
@@ -200,7 +206,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()));
@@ -227,12 +236,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) {
@@ -247,8 +264,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;
                 }
             }
@@ -264,7 +285,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銆佸厛鑾峰彇褰撳墠娴佺▼鍗¤惤鏋舵渶澶氱殑灞傛暟锛屽鏋滀负绌猴紝琛ㄦ槑鏈粦瀹氭祦绋嬪崱锛屾湭钀芥灦锛岀劧鍚庢寜鐓ф槸鍚﹀彲缁戝畾鏋跺瓙鍐冲畾鏄惁鏇挎崲銆傦紙鍙拷鐣ヤ笉璁★紝鏈牎楠屼粎鍦ㄥ墠涓�娆¤皟鐢ㄨ捣浣滅敤锛�
@@ -297,6 +319,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());
@@ -321,6 +347,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());
@@ -337,6 +367,7 @@
         //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 {
@@ -437,6 +468,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 -> {
@@ -623,9 +655,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) {
@@ -640,14 +679,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);
     }
@@ -666,6 +727,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