From b21caa5499c50384f3a3a5dd795a7a0ad197d36f Mon Sep 17 00:00:00 2001
From: zhoushihao <zsh19950802@163.com>
Date: 星期四, 06 十一月 2025 21:26:11 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java |   61 +++++++++++++++++++++++++++++-
 1 files changed, 58 insertions(+), 3 deletions(-)

diff --git a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java
index 94ca28e..241b4fe 100644
--- a/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java
+++ b/hangzhoumesParent/moduleService/CacheGlassModule/src/main/java/com/mes/job/OpcCacheGlassNewTask.java
@@ -8,6 +8,8 @@
 import com.github.xingshuangs.iot.protocol.s7.serializer.S7Serializer;
 import com.kangaroohy.milo.model.ReadWriteEntity;
 import com.kangaroohy.milo.service.MiloService;
+import com.mes.alarm.entity.ProductAlarmInfo;
+import com.mes.alarm.service.ProductAlarmInfoService;
 import com.mes.common.config.Const;
 import com.mes.common.config.ConstSysConfig;
 import com.mes.damage.service.DamageService;
@@ -113,8 +115,24 @@
     private String glassIdOne = "";
     private String glassIdTwo = "";
 
+    @Resource
+    private ProductAlarmInfoService productAlarmInfoService;
+
+    private static final String ALARM_MODULE = "纾ㄨ竟";
+    private static final String ALARM_TYPE1 = "涓�绾垮崸寮忕悊鐗囩";
+    private static final String ALARM_TYPE2 = "浜岀嚎鍗у紡鐞嗙墖绗�";
+    private static final String ALARM_CODE_NOGLASS = "noGlass";
+
     @Scheduled(fixedDelay = 1000)
     public void startOneOpcTask() throws Exception {
+        List<ProductAlarmInfo> alarmInfos = productAlarmInfoService.list(new LambdaQueryWrapper<ProductAlarmInfo>()
+                .eq(ProductAlarmInfo::getState, Const.LOAD_RAW_GLASS_NEW)
+                .eq(ProductAlarmInfo::getAlarmModule, ALARM_MODULE)
+                .eq(ProductAlarmInfo::getAlarmType, ALARM_TYPE1));
+        if (CollectionUtil.isNotEmpty(alarmInfos)) {
+            log.info("鐣岄潰鎶ヨ锛岀瓑寰呬汉宸ュ共棰勫鐞�");
+            return;
+        }
         S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class);
         S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class);
         S7DataWLExtra s7DataWLExtraTwo = s7SerializerWLTwo.read(S7DataWLExtra.class);
@@ -132,6 +150,14 @@
 
     @Scheduled(fixedDelay = 1000)
     public void startTwoOpcTask() throws Exception {
+        List<ProductAlarmInfo> alarmInfos = productAlarmInfoService.list(new LambdaQueryWrapper<ProductAlarmInfo>()
+                .eq(ProductAlarmInfo::getState, Const.LOAD_RAW_GLASS_NEW)
+                .eq(ProductAlarmInfo::getAlarmModule, ALARM_MODULE)
+                .eq(ProductAlarmInfo::getAlarmType, ALARM_TYPE2));
+        if (CollectionUtil.isNotEmpty(alarmInfos)) {
+            log.info("鐣岄潰鎶ヨ锛岀瓑寰呬汉宸ュ共棰勫鐞�");
+            return;
+        }
         S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class);
         S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class);
         S7DataWLExtra s7DataWLExtraTwo = s7SerializerWLTwo.read(S7DataWLExtra.class);
@@ -278,8 +304,19 @@
         log.info("寮�濮嬫墽琛岃繘鐗囦换鍔★紝浠诲姟淇℃伅涓猴細{},璁惧id:{},寮�濮嬫椂闂达細{}", task, deviceId, startDate);
         //鑾峰彇鐜荤拑鐨勫熀鏈俊鎭�
         GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdIn()));
-        if (null == glassInfo) {
+        if (null == glassInfo && StringUtils.isNotBlank(task.getGlassIdIn())) {
             log.info("杩涚墖鐜荤拑淇℃伅涓嶅瓨鍦紝鐜荤拑id:{}", task.getGlassIdIn());
+            ProductAlarmInfo alarmInfo = new ProductAlarmInfo();
+            alarmInfo.setState(Const.LOAD_RAW_GLASS_NEW);
+            alarmInfo.setAlarmModule(ALARM_MODULE);
+            if (deviceId == 1) {
+                alarmInfo.setAlarmType(ALARM_TYPE1);
+            } else {
+                alarmInfo.setAlarmType(ALARM_TYPE2);
+            }
+            alarmInfo.setAlarmCode(ALARM_CODE_NOGLASS);
+            alarmInfo.setAlarmMessage(task.getGlassIdIn());
+            productAlarmInfoService.save(alarmInfo);
             Date endDate = new Date();
             log.info("缁撴潫杩涚墖浠诲姟璁惧涓簕}锛岀粨鏉熸椂闂翠负锛歿}锛屽叡鑰楁椂锛歿}ms", deviceId, endDate, endDate.getTime() - startDate.getTime());
             return Boolean.FALSE;
@@ -343,6 +380,24 @@
 
     private boolean outTask(S7DataWL task, int deviceId, int cellFlag) {
         Date startDate = new Date();
+        GlassInfo glassInfo = glassInfoService.getOne(new LambdaQueryWrapper<GlassInfo>().eq(GlassInfo::getGlassId, task.getGlassIdOut()));
+        if (null == glassInfo && StringUtils.isNotBlank(task.getGlassIdIn())) {
+            log.info("杩涚墖鐜荤拑淇℃伅涓嶅瓨鍦紝鐜荤拑id:{}", task.getGlassIdIn());
+            ProductAlarmInfo alarmInfo = new ProductAlarmInfo();
+            alarmInfo.setState(Const.LOAD_RAW_GLASS_NEW);
+            alarmInfo.setAlarmModule(ALARM_MODULE);
+            if (deviceId == 1) {
+                alarmInfo.setAlarmType(ALARM_TYPE1);
+            } else {
+                alarmInfo.setAlarmType(ALARM_TYPE2);
+            }
+            alarmInfo.setAlarmCode(ALARM_CODE_NOGLASS);
+            alarmInfo.setAlarmMessage(task.getGlassIdIn());
+            productAlarmInfoService.save(alarmInfo);
+            Date endDate = new Date();
+            log.info("缁撴潫杩涚墖浠诲姟璁惧涓簕}锛岀粨鏉熸椂闂翠负锛歿}锛屽叡鑰楁椂锛歿}ms", deviceId, endDate, endDate.getTime() - startDate.getTime());
+            return Boolean.FALSE;
+        }
         //鑾峰彇瀵瑰簲鐨勮澶囩姸鎬佷俊鎭�
         S7DataWL s7DataWLOne = s7SerializerWLOne.read(S7DataWL.class);
         S7DataWL s7DataWLTwo = s7SerializerWLTwo.read(S7DataWL.class);
@@ -382,9 +437,9 @@
                 cell = Const.ONE_OUT_TARGET_POSITION;
             } else if (Const.OUT_BUSY.equals(twoOutState)) {
                 cell = Const.TWO_OUT_TARGET_POSITION;
-            }else if(Const.OUT_BUSY.equals(oneOutState)){
+            } else if (Const.OUT_BUSY.equals(oneOutState)) {
                 cell = Const.ONE_OUT_TARGET_POSITION;
-            }else{
+            } else {
                 return Boolean.FALSE;
             }
         }

--
Gitblit v1.8.0