Browse Source

Merge remote-tracking branch 'origin/master' into master

yejian 3 years ago
parent
commit
5839016fb7

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

@@ -1,6 +1,7 @@
 package com.github.zuihou.business.mq;
 
 import com.github.zuihou.business.util.DynamicRabbitMq;
+import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.exception.BizException;
 import com.rabbitmq.client.Channel;
 import lombok.Data;
@@ -36,7 +37,7 @@ public class ConsumerHandler implements ChannelAwareMessageListener {
         log.info("[{}]收到mq消息: {}", message.getMessageProperties().getConsumerQueue(), data);
         long deliveryTag = message.getMessageProperties().getDeliveryTag();
         try {
-            handleMessage(data);
+            handleMessage(data, message.getMessageProperties().getConsumerQueue());
             channel.basicAck(deliveryTag, false);
         } catch(Exception e){
             log.error("MQ异常:"+e.getMessage());
@@ -55,7 +56,7 @@ public class ConsumerHandler implements ChannelAwareMessageListener {
      *
      * @param data 消息体
      */
-    public void handleMessage(String data) throws InterruptedException {
-        taskWork.updateTaskStatusJob(data);
+    public void handleMessage(String data, String consumerQueue) throws InterruptedException {
+        taskWork.updateTaskStatusJob(data, consumerQueue);
     }
 }

+ 25 - 7
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java

@@ -1,7 +1,9 @@
 package com.github.zuihou.business.mq;
 
+import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.DemoLine.YunjianConstant;
@@ -32,6 +34,7 @@ import com.github.zuihou.business.productionResourceCenter.service.impl.AGVNodeS
 import com.github.zuihou.business.productionResourceCenter.service.impl.MachineNodeServiceImpl;
 import com.github.zuihou.business.productionResourceCenter.service.impl.OtherNodeServiceImpl;
 import com.github.zuihou.business.productionResourceCenter.service.impl.RobotNodeServiceImpl;
+import com.github.zuihou.business.util.DynamicRabbitMq;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.CacheKey;
@@ -149,24 +152,39 @@ public class TaskWorkNode {
 
     private final String fileName = "";
 
-    public void updateTaskStatusJob(String data) throws InterruptedException {
+    public void updateTaskStatusJob(String data, String consumerQueue) throws InterruptedException {
         JSONObject jsonObject = JSONObject.parseObject(data);
         System.out.println("返回请求数据: " + data);
         String taskNodeId = jsonObject.getString("taskNodeId");
         //业务类型-1、是普通的节点类型,2-是线边库轮询
         String bizType = jsonObject.getString("bizType");
         String handMode = jsonObject.getString("handMode");
-
         //多产品搬运类型
         String carryType = jsonObject.getString("carryType");
-        if (StringUtil.isEmpty(taskNodeId) || StringUtil.isEmpty(bizType)) {
+
+        BaseContextHandler.setTenant("0000");
+        String queueName = "device.queue."+ BizConstant.MQ_GLOBAL_EXCEPTION;
+
+        if (consumerQueue.equals(queueName)) {
             AAutoNodeLog log = AAutoNodeLog.builder().build();
-            log.setExeResult("0").setManual("1").setFeedback("全局异常处理");
-            autoNodeLogService.save(log);
-            throw new RuntimeException("全局通知异常");
+            StringBuilder buffer = new StringBuilder();
+            buffer.append(jsonObject.getString("Line")).append("-设备(").append(jsonObject.getString("Name")+")").append(jsonObject.getString("Status"));
+            log.setExeResult("0").setManual("1").setFeedback("全局异常:"+ buffer.toString()).setStartTime(new Date()).setExecuteTime(new Date());
+            LbqWrapper<AAutoNodeLog> lbqWrapper = new LbqWrapper<AAutoNodeLog>();
+            lbqWrapper.eq(AAutoNodeLog::getExeResult, log.getExeResult()).eq(AAutoNodeLog::getManual, log.getManual()).eq(AAutoNodeLog::getStatus, 0).eq(AAutoNodeLog::getFeedback, log.getFeedback());
+            //判断全局异常是否已存在
+            AAutoNodeLog exist = autoNodeLogService.getOne(lbqWrapper);
+            if(null == exist){
+                autoNodeLogService.save(log);
+            }else{
+                //更新执行时间
+                exist.setExecuteTime(new Date());
+                autoNodeLogService.updateAllById(exist);
+            }
+            //throw new RuntimeException("全局通知异常");
+            return;
         }
         logger.info("=======================" + taskNodeId);
-        BaseContextHandler.setTenant("0000");
 
         TaskNode taskNode = taskNodeService.getById(taskNodeId);
 //

+ 1 - 1
imcs-admin-boot/imcs-business-biz/src/main/resources/mapper_business/base/productionReadyCenter/AAutoNodeLogMapper.xml

@@ -23,7 +23,7 @@
 
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
-        id,create_time ,create_user,update_time,update_user,method, execute_time,
+        id,create_time ,create_user,update_time,update_user,method, execute_time,manual,
         auto_node_id, exe_status, exe_result, start_time, end_time, feedback, feedback_file, status, resourceName,instructionName,procedureName,nodeNo
     </sql>
 

+ 2 - 2
imcs-admin-boot/imcs-business-controller/src/main/java/com/github/zuihou/business/controller/dispatchRecord/DispatchExceptionController.java

@@ -160,7 +160,6 @@ public class DispatchExceptionController extends SuperSimpleController<AAutoNode
     private R<Boolean> resend(@RequestBody Map<String, Long> map){
         AAutoNodeLog autoNodeLog = aAutoNodeLogService.getById(map.get("id"));
         Long taskNodeId = autoNodeLog.getTaskNodeId();
-        TWorkpiece tWorkpiece = workpieceService.getWorkPiece(taskNodeId);
         //判断重发节点操作条件(待定)
         Map<String, Object> conMap = msgUtil.redis_get_map(CacheKey.TASK_CURRENT_NODE_CONDITION + "_" + taskNodeId);
         //获取重发执行传参
@@ -168,6 +167,7 @@ public class DispatchExceptionController extends SuperSimpleController<AAutoNode
         if(StringUtils.isEmpty(jsonParam)){
             return R.fail("指令请求不存在");
         }
+
         HttpHeaders headers = new HttpHeaders();
         headers.setContentType(MediaType.parseMediaType("application/json;charset=UTF-8"));
         HttpEntity<String> formEntity = new HttpEntity<String>(jsonParam, headers);
@@ -177,7 +177,7 @@ public class DispatchExceptionController extends SuperSimpleController<AAutoNode
         JSONObject retJson = JSONObject.parseObject(returnData);
         String code = retJson.getString("code").trim();
         if(code.equals("0")){
-            autoNodeLog.setExeResult("0").setManual("1").setFeedback(retJson.getString("msg"));
+            autoNodeLog.setExeResult("0").setManual("1").setFeedback(retJson.getString("msg")).setExecuteTime(new Date());
             aAutoNodeLogService.updateAllById(autoNodeLog);
             return R.fail("指令重发失败");
         }else{