Parcourir la source

更新节点异常更新操作

oyq28 il y a 3 ans
Parent
commit
8e38f10142

+ 21 - 4
imcs-admin-boot/imcs-authority-server/src/main/java/com/github/zuihou/job/DashboardJob.java

@@ -2,9 +2,11 @@ package com.github.zuihou.job;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ReflectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.databind.ObjectMapper;
@@ -140,12 +142,17 @@ public class DashboardJob {
             repairMap.put("repairData", repairData);
             dataScreenMap.put("repairMap", repairMap);
 
+            //警报数据
             QueryWrap<AAutoNodeLog> warnWrap = this.handlerWrapper(null, params);
             LbqWrapper<AAutoNodeLog> warnWrapper = warnWrap.lambda();
-            Date start = new Date();
-            Date end = DateUtil.stringToDate7(DateUtil.dateToString(new Date()) + " 23:59:59");
-            warnWrapper.between(AAutoNodeLog::getCreateTime,start, end);
-            warnWrapper.and(condition -> condition.isNull(AAutoNodeLog::getExeResult).or().eq(AAutoNodeLog::getExeResult,"0")).orderByDesc(AAutoNodeLog::getCreateTime);
+            //Date start = new Date();
+            //警报弹框只执行一次
+            //Date end = DateUtil.stringToDate7(DateUtil.dateToString(new Date()) + " 23:59:59");
+            //warnWrapper.between(AAutoNodeLog::getCreateTime,start, end);
+            //warnWrapper.isNull(AAutoNodeLog::getExeResult).le(AAutoNodeLog::getEndTime,new Date());
+            //warnWrapper.and(condition -> condition.isNull(AAutoNodeLog::getExeResult).or().eq(AAutoNodeLog::getExeResult,"0")).orderByDesc(AAutoNodeLog::getCreateTime);
+            //返回还未处理、执行状态为失败,并且还未推送的日志记录
+            warnWrapper.eq(AAutoNodeLog::getExeResult,"0").eq(AAutoNodeLog::getStatus,"0").eq(AAutoNodeLog::getSendStatus,"0");
             IPage<AAutoNodeLog> warnData = autoNodeLogService.pageList(new Page<AAutoNodeLog>(), warnWrapper);
 
             Map warnMap = Maps.newHashMap();
@@ -161,6 +168,16 @@ public class DashboardJob {
             String pushMsg = objectMapper.writeValueAsString(pushMap);
             //logger.info("推送前端======"+pushMsg);
             webSocketServer.BroadCastInfo(pushMsg);
+
+            //更新推送状态
+            if(CollectionUtil.isNotEmpty(warnData.getRecords())) {
+                Long[] ids = warnData.getRecords().stream().map(item -> {
+                    return item.getId();
+                }).toArray(Long[]::new);
+                UpdateWrapper<AAutoNodeLog> updateWrapper = new UpdateWrapper<AAutoNodeLog>();
+                updateWrapper.lambda().set(AAutoNodeLog::getSendStatus, "1").in(AAutoNodeLog::getId, ids);
+                autoNodeLogService.update(null, updateWrapper);
+            }
         }
         catch (Exception e){
             logger.error("推送异常======"+e.getMessage());

+ 4 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/MqInit.java

@@ -56,6 +56,10 @@ public class MqInit implements ApplicationRunner {
         }
         //资源数据中已包含项目设定的线边库设备(七个) MQ关联使用ID直接访问
 
+        //新增MQ公共异常
+        dynamicRabbitMq.addQueue(BizConstant.MQ_GLOBAL_EXCEPTION);
+        dynamicRabbitMq.startListener(BizConstant.MQ_GLOBAL_EXCEPTION);
+
         //添加三个线边库轮询虚拟的MQ
 //        dynamicRabbitMq.addQueue(DemoLineConstant.NODE_RESOURCE_ZLZX_XBK);
 //        dynamicRabbitMq.startListener(DemoLineConstant.NODE_RESOURCE_ZLZX_XBK);

+ 10 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/productionReadyCenter/entity/AAutoNodeLog.java

@@ -93,6 +93,16 @@ public class AAutoNodeLog extends Entity<Long> {
     @Excel(name = "处理状态(1-已处理0-未处理)")
     private String status;
 
+
+    /**
+     * 是否推送(1-已处理0-未处理)
+     */
+    @ApiModelProperty(value = "是否推送(1-已处理0-未处理)")
+    @Length(max = 4, message = "是否推送(1-已处理0-未处理)长度不能超过4")
+    @TableField(value = "send_status", condition = LIKE)
+    @Excel(name = "处理状态(1-已处理0-未处理)")
+    private String sendStatus;
+
     /**
      * 开始时间
      */

+ 4 - 0
imcs-admin-boot/imcs-common/src/main/java/com/github/zuihou/common/constant/BizConstant.java

@@ -196,6 +196,10 @@ public interface BizConstant {
 
     String ROBOT_TYPE_NOCACHE = "NOCACHE";
 
+    //公共接口异常名称
+
+    String MQ_GLOBAL_EXCEPTION = "GLOBAL_EXCEPTION";
+
 
 
 }