From f79a481bc7b8095cf1ffd0a62bb00cf70ee8629e Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期一, 12 八月 2024 09:00:21 +0800
Subject: [PATCH] 1、大理片 fixbug:出片破损任务异常

---
 hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/DownLoadCacheGlassTask.java |   56 +++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 49 insertions(+), 7 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 7e31c30..b17990c 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
@@ -7,6 +7,8 @@
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.mes.common.S7object;
 import com.mes.common.config.Const;
+import com.mes.damage.entity.Damage;
+import com.mes.damage.service.DamageService;
 import com.mes.device.PlcParameterObject;
 import com.mes.downglassinfo.entity.DownGlassInfo;
 import com.mes.downglassinfo.entity.DownGlassTask;
@@ -54,9 +56,8 @@
     DownWorkstationService downWorkstationService;
     @Autowired
     DownGlassInfoService downGlassInfoService;
-
-    @Value("${mes.threshold}")
-    private Integer threshold;
+    @Autowired
+    DamageService damageService;
 
     @Value("${mes.throughWidth}")
     private Integer throughWidth;
@@ -126,6 +127,43 @@
         }
     }
 
+    @Scheduled(fixedDelay = 300)
+    public void plcShelfFull() {
+        List<DownWorkstation> list = downGlassInfoService.queryWorkStationIsFull();
+        if (CollectionUtils.isNotEmpty(list)) {
+            S7control s7control = S7object.getinstance().plccontrol;
+            PlcParameterObject plcMesObject = S7object.getinstance().PlcMesObject;
+            s7control.writeWord(plcMesObject.getPlcParameter("alarm_signal").getAddress(), 1);
+        }
+    }
+
+    @Scheduled(fixedDelay = 1000)
+    public void dealDamageTask() {
+        Date startDate = new Date();
+        log.info("涓嬬墖鐮存崯鐜荤拑娓呴櫎浠诲姟寮�濮嬫墽琛屾椂闂达細{}", startDate);
+        List<DownGlassTask> downGlassTaskList = downGlassTaskService.list(new LambdaQueryWrapper<DownGlassTask>()
+                .in(DownGlassTask::getTaskType, Const.GLASS_CACHE_TYPE_OUT_ALL).in(DownGlassTask::getTaskStatus, Const.GLASS_STATE_DAMAGE_TAKE));
+        if (CollectionUtils.isNotEmpty(downGlassTaskList)) {
+            //鑾峰彇鐮存崯/鎷胯蛋鐜荤拑id
+            List<String> glassList = downGlassTaskList.stream().map(DownGlassTask::getGlassId).collect(Collectors.toList());
+            //灏嗕换鍔¤〃涓殑鏁版嵁鍒犻櫎
+            downGlassTaskService.remove(new LambdaQueryWrapper<DownGlassTask>().in(DownGlassTask::getTaskType, Const.GLASS_CACHE_TYPE_OUT_ALL).in(DownGlassTask::getGlassId, glassList));
+            List<Damage> damageList = downGlassTaskList.stream().map(e -> {
+                Damage damage = new Damage();
+                damage.setGlassId(e.getGlassId());
+                damage.setLine(Const.TEMPERING_OUT_TARGET_POSITION);
+                damage.setWorkingProcedure("涓嬬墖");
+                damage.setRemark("涓嬬墖");
+                damage.setStatus(0);
+                damage.setType(e.getTaskStatus());
+                return damage;
+            }).collect(Collectors.toList());
+            damageService.batchInsertDamage(damageList);
+        }
+        Date endDate = new Date();
+        log.info("鏈浠诲姟缁撴潫鏃堕棿锛歿}锛屽叡鑰楁椂锛歿}ms", endDate, endDate.getTime() - startDate.getTime());
+    }
+
     public void inTo(String glassId, String requestWord, String currentSlot) {
         log.info("1銆佹寜鐓х幓鐠僫d:{}鑾峰彇鐜荤拑灏忕墖淇℃伅,褰撳墠鏍煎瓙涓�:{}", glassId, currentSlot);
         //娣诲姞杩涚墖浠诲姟  鏌ユ壘绌烘牸
@@ -170,7 +208,7 @@
             }
             if (!checkFlag) {
                 log.info("鏃犵┖鏋跺瓙,鑾峰彇宸茬粦瀹氭灦瀛愮殑娴佺▼鍗′俊鎭�,鏌ョ湅鐜荤拑淇℃伅鏄惁鍙瀵硅皟");
-                List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.FALSE);
+                List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Const.WORK_STATION_ALL, Boolean.FALSE);
                 log.info("鑾峰彇鏋跺瓙涓婂凡缁戝畾娴佺▼鍗¤惤鏋剁殑鏁伴噺鍙婃湭钀芥灦鐨勭幓鐠冩暟鎹細{}", downGlassInfoDTOList);
                 if (CollectionUtils.isEmpty(downGlassInfoDTOList)) {
                     log.info("宸茬粦瀹氭祦绋嬪崱鍧囨棤鏈惤鏋剁幓鐠冿紝璇峰強鏃跺鐞嗘灦瀛愪笂鐨勭幓鐠冿紝娓呴櫎娴佺▼鍗�,鎵ц杩涚墖浠诲姟");
@@ -309,6 +347,7 @@
             }
         }
         List<Integer> workStationAll = Arrays.asList(1, 2, 3, 4, 5, 6);
+        //鑾峰彇闈炴湰娆¤惤鏋剁殑鏋跺瓙淇℃伅
         List<Integer> offWorkStationList = workStationAll.stream().filter(e -> !workList.contains(e)).collect(Collectors.toList());
         List<DownStorageCageDetails> list = new ArrayList();
         //鏄惁鏈夌┖鏋跺瓙 true锛氭湁   false:鏃�
@@ -387,12 +426,12 @@
         loop:
         if (StringUtils.isBlank(tempGlassId)) {
             //鑾峰彇姝e湪钀芥灦鐨勭粦瀹氭祦绋嬪崱鐨勪俊鎭�(娴佺▼鍗°�佸眰鏁般�佽惤鏋舵暟閲�)
-            List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationIsIn(Boolean.TRUE);
+            //钀芥灦鐜荤拑鏁颁负0锛屽嵆浣跨粦瀹氫簡娴佺▼鍗★紝涔熸棤娉曟壘鍒板搴旂殑鏋跺瓙淇℃伅锛屽彧鑳介噸鏂扮粦瀹�
+            List<DownGlassInfoDTO> downGlassInfoDTOList = downGlassInfoService.queryWorkStationFlowCard(workList);
             List<String> downGlassFlowList = downGlassInfoDTOList.stream().map(item -> item.getFlowCardId() + ":" + item.getLayer()).collect(Collectors.toList());
             if (CollectionUtils.isEmpty(downGlassFlowList)) {
                 //鏋跺瓙閮芥湭缁戝畾娴佺▼鍗★紝鍑虹鍐呭瓙鏁伴噺鏈�澶氬昂瀵告渶澶х殑鐜荤拑id,鏃�  鍒欒繑鍥炴壂鎻忔壂鍒扮殑鐜荤拑id杩涜鍑虹墖
                 tempGlassId = downStorageCageDetailsService.getGlassInfoMaxCount(glassId, offWorkStationList);
-
                 isNeedBind = Boolean.TRUE;
                 break loop;
             }
@@ -456,6 +495,7 @@
                         if (CollectionUtils.isNotEmpty(downStorageCageDetails)) {
                             tempGlassId = downStorageCageDetails.get(0).getGlassId();
                             break;
+
                         }
                     }
                 }
@@ -513,7 +553,7 @@
             endCell = workstation.getWorkstationId();
         }
         //鏇存柊钀芥灦鐜荤拑鏁伴噺
-        if (endCell == 7) {
+        if (endCell == Const.G13_WORK_STATION) {
             downWorkstationService.update(new UpdateWrapper<DownWorkstation>().eq("flow_card_id", downStorageCageDetails.getFlowCardId())
                     .eq("layer", downStorageCageDetails.getLayer()).setSql("other_number = other_number +1"));
         } else {
@@ -526,6 +566,8 @@
         BeanUtils.copyProperties(downStorageCageDetails, downGlassInfo);
         //钀芥灦鐗囧簭
         downGlassInfo.setSequence(downGlassInfoService.queryMaxSequence(downGlassInfo.getFlowCardId(), downGlassInfo.getLayer()));
+        downGlassInfo.setWorkStationId(endCell);
+        downGlassInfo.setGmtCreate(new Date());
         downGlassInfoService.save(downGlassInfo);
         //鐢熸垚浠诲姟淇℃伅
         GlassInfo glassInfo = new GlassInfo();

--
Gitblit v1.8.0