소스 검색

工序做完后清除相应工序的redis暂存值

yejian 3 년 전
부모
커밋
742bf0d6d0

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

@@ -173,6 +173,30 @@ public class TaskWorkNode {
         String taskNodeId = jsonObject.getString("taskNodeId");
         logger.info("节点{}准备开始执行任务",taskNodeId);
         taskNode = taskNodeService.getById(taskNodeId);
+
+        if(null == taskNode){
+            return;
+        }
+
+        // add by yejian on 20220726 使用完成后释放redis资源
+        if(taskNode.getCompleteBatchSort() != 1){
+            TaskNode beforTaskNode  = taskNodeService.getNextNTaskNode(taskNode, -1);
+            // 下一工序
+            if(!beforTaskNode.getTaskId().equals(taskNode.getTaskId())){
+                List<TaskNode> operationTaskNodes = taskNodeService.list(Wraps.<TaskNode>lbQ().eq(TaskNode::getTaskId, beforTaskNode.getTaskId()));
+                List<Long> operationTaskNodeIds = operationTaskNodes.stream().map(operationTaskNode -> operationTaskNode.getId()).collect(Collectors.toList());
+                for(Long operationTaskNodeId : operationTaskNodeIds){
+                    // 清除redis里面的内容
+                    msgUtil.redis_del(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + operationTaskNodeId);
+                    msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + operationTaskNodeId);
+                    msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + operationTaskNodeId);
+                    msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + operationTaskNodeId);
+                    msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + operationTaskNodeId);
+                    msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE + "_" +  + operationTaskNodeId);
+                }
+            }
+        }
+
         tTask = taskMapper.selectById(taskNode.getTaskId());
         //初始化业务日志
         log = getBusinessLog(tTask, taskNode);

+ 17 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/impl/TaskNodeServiceImpl.java

@@ -1834,6 +1834,23 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
             }
             return result;
         }
+
+        // 最后一个工序最后一个节点
+        TaskNode nextTaskNode  = this.getNextNTaskNode(taskNode, 1);
+        if(null == nextTaskNode){
+            List<TaskNode> operationTaskNodes = baseMapper.selectList(Wraps.<TaskNode>lbQ().eq(TaskNode::getTaskId, taskNode.getTaskId()));
+            List<Long> operationTaskNodeIds = operationTaskNodes.stream().map(operationTaskNode -> operationTaskNode.getId()).collect(Collectors.toList());
+            for(Long operationTaskNodeId : operationTaskNodeIds){
+                // 清除redis里面的内容
+                msgUtil.redis_del(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + operationTaskNodeId);
+                msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + operationTaskNodeId);
+                msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + operationTaskNodeId);
+                msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + operationTaskNodeId);
+                msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + operationTaskNodeId);
+                msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE + "_" + operationTaskNodeId);
+            }
+        }
+
         return R.success("");
     }
 

+ 18 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/util/MsgUtil.java

@@ -2,6 +2,8 @@ package com.github.zuihou.business.util;
 
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.github.zuihou.business.DemoLine.DemoCacheKey;
+import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.DemoLine.YunjianConstant;
 import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
 import com.github.zuihou.business.edgeLibrary.service.impl.StockInfoServiceImpl;
@@ -20,6 +22,7 @@ import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.business.productionResourceCenter.service.impl.ZZoneServiceImpl;
 import com.github.zuihou.business.websocket.WebSocketServer;
 import com.github.zuihou.common.constant.BizConstant;
+import com.github.zuihou.common.constant.CacheKey;
 import com.github.zuihou.common.constant.DictionaryKey;
 import com.github.zuihou.common.constant.ParameterKey;
 import com.github.zuihou.common.util.SmbShareFileUtil;
@@ -41,6 +44,7 @@ import org.springframework.web.client.RestTemplate;
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 @Component
 public class MsgUtil implements ApplicationContextAware {
@@ -241,6 +245,20 @@ public class MsgUtil implements ApplicationContextAware {
 
                 if(1 == measuringResult){
                     logger.info("三坐标测量失败直接下料");
+
+                    // 清楚当前节点工序的redis暂存值
+                    List<TaskNode> operationTaskNodes = taskNodeService.list(Wraps.<TaskNode>lbQ().eq(TaskNode::getTaskId, taskNode.getTaskId()));
+                    List<Long> operationTaskNodeIds = operationTaskNodes.stream().map(operationTaskNode -> operationTaskNode.getId()).collect(Collectors.toList());
+                    for(Long operationTaskNodeId : operationTaskNodeIds){
+                        // 清除redis里面的内容
+                        msgUtil.redis_del(YunjianConstant.YUNJIAN_CALLBACK_PARAM + "_" + operationTaskNodeId);
+                        msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + operationTaskNodeId);
+                        msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + operationTaskNodeId);
+                        msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + operationTaskNodeId);
+                        msgUtil.redis_del(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + operationTaskNodeId);
+                        msgUtil.redis_del(CacheKey.TASK_CURRENT_NODE + "_" + operationTaskNodeId);
+                    }
+
                     //获取下料工序
                     List<BomProcedure> bomProcedureList = bomProcedureService.list(Wraps.<BomProcedure>lbQ().eq(BomProcedure::getBomId,task.getBomId()).eq(BomProcedure::getType,"下料").orderByAsc(BomProcedure::getSort));
                     if(CollectionUtil.isNotEmpty(bomProcedureList)){