Explorar o código

fix:优化中央刀库自动化上刀,物料回调优化

wang.sq@aliyun.com hai 1 mes
pai
achega
674be60ed5

+ 42 - 24
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/strategy/impl/CacheRobotStrategy.java

@@ -193,7 +193,7 @@ public class CacheRobotStrategy implements RobotStrategy {
             List<Long> hcwStorgeIdList = productionresourcePositionService.list(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getResourceId, taskNode.getResourceId()).ne(ProductionresourcePosition::getPointId, DemoLineConstant.DEMOLINE_RJQR_ZS)).stream().map(ProductionresourcePosition::getStorgeId).collect(Collectors.toList());
             List<TWorkpiece> workpieceList = workpieceService.list(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getIsEnd, "0").in(TWorkpiece::getStorgeId, hcwStorgeIdList));
             if (workpieceList.size() > 2 || workpieceList.size() == 0) {
-                msgUtil.createWarnLog("机器人设备暂存位数据有误", "DataException");
+                returnMap.put("resultMsg","机器人设备暂存位数据有误");
                 returnMap.put("result", false);
             }
             Object jqrPriotyFlag = msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + taskNode.getId());
@@ -202,24 +202,40 @@ public class CacheRobotStrategy implements RobotStrategy {
                 return returnMap;
             }
 
-            List<TWorkpiece> collect = workpieceList.stream().filter(item -> !item.getTaskNodeId().equals(taskNode.getId())).collect(Collectors.toList());
-            if(collect.isEmpty() || collect.size()==0){
-                returnMap.put("result", false);
-                return returnMap;
-            }
-            TWorkpiece workpiece = collect.get(0);
-
-            Object hcwStorgeFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + workpiece.getTaskNodeId());
-            if(ObjectUtil.isEmpty(hcwStorgeFlag)){
-                Object hcwPriotyFlag = msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId());
-                TTask task = taskService.getById(taskNode.getTaskId());
-                //判断交换位目标设备是否与暂存位任务设备一致
-                if(ObjectUtil.isEmpty(hcwPriotyFlag) && taskNode.getTargetResourceId().equals(task.getResourceId())) {
-                    msgUtil.redis_set(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId(), "1");
-                    returnMap.put("result", false);
-                    return returnMap;
+            Optional<TWorkpiece> first = workpieceList.stream().filter(item -> !item.getTaskNodeId().equals(taskNode.getId())).findFirst();
+            if(first.isPresent()){
+                TWorkpiece workpiece = first.get();
+                Object hcwStorgeFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + workpiece.getTaskNodeId());
+                if(ObjectUtil.isEmpty(hcwStorgeFlag)){
+                    Object hcwPriotyFlag = msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId());
+                    TTask task = taskService.getById(taskNode.getTaskId());
+                    //判断交换位目标设备是否与暂存位任务设备一致
+                    if(ObjectUtil.isEmpty(hcwPriotyFlag) && taskNode.getTargetResourceId().equals(task.getResourceId())) {
+                        msgUtil.redis_set(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId(), "1");
+                        returnMap.put("result", false);
+                        return returnMap;
+                    }
                 }
             }
+
+//            List<TWorkpiece> collect = workpieceList.stream().filter(item -> !item.getTaskNodeId().equals(taskNode.getId())).collect(Collectors.toList());
+//            if(collect.isEmpty() || collect.size()==0){
+//                returnMap.put("result", false);
+//                return returnMap;
+//            }
+//            TWorkpiece workpiece = collect.get(0);
+//
+//            Object hcwStorgeFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + workpiece.getTaskNodeId());
+//            if(ObjectUtil.isEmpty(hcwStorgeFlag)){
+//                Object hcwPriotyFlag = msgUtil.redis_get(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId());
+//                TTask task = taskService.getById(taskNode.getTaskId());
+//                //判断交换位目标设备是否与暂存位任务设备一致
+//                if(ObjectUtil.isEmpty(hcwPriotyFlag) && taskNode.getTargetResourceId().equals(task.getResourceId())) {
+//                    msgUtil.redis_set(DemoLineConstant.JQR_HCW_PART_PRIOTY_EXEC_FLAG + workpiece.getTaskNodeId(), "1");
+//                    returnMap.put("result", false);
+//                    return returnMap;
+//                }
+//            }
         }
         //锁定暂存缓存位库位
         if(startStorge==null){
@@ -257,12 +273,14 @@ public class CacheRobotStrategy implements RobotStrategy {
             //已在暂存位上工装没有暂存位缓存时限制正常接入
             ProductionresourcePosition hcwStorgePosition = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getResourceId, taskNode.getResourceId()).ne(ProductionresourcePosition::getPointId, DemoLineConstant.DEMOLINE_RJQR_ZS).ne(ProductionresourcePosition::getStorgeId, hcwStorge.getId()).last("limit 1"));
             TWorkpiece tWorkpiece = workpieceService.getOne(new LbqWrapper<TWorkpiece>().eq(TWorkpiece::getIsEnd, "0").eq(TWorkpiece::getStorgeId, hcwStorgePosition.getStorgeId()).last("limit 1"));
-            Object preHcwXbkFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + tWorkpiece.getTaskNodeId());
-            if(ObjectUtil.isEmpty(preHcwXbkFlag)){
-                returnMap.put("msg", "已暂存位工装数据无缓存数据");
-                returnMap.put("result", false);
-                taskNodeService.freeLock(taskNode.getCompleteBatchNo());
-                return returnMap;
+            if(tWorkpiece !=null){
+                Object preHcwXbkFlag = msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_HCW_XBK_FLAG + tWorkpiece.getTaskNodeId());
+                if(ObjectUtil.isEmpty(preHcwXbkFlag)){
+                    returnMap.put("msg", "已暂存位工装数据无缓存数据");
+                    returnMap.put("result", false);
+                    taskNodeService.freeLock(taskNode.getCompleteBatchNo());
+                    return returnMap;
+                }
             }
             targetStorge = hcwStorge;
             returnMap.put(YunjianConstant.YUNJIAN_XBKFLAG, "1");
@@ -389,7 +407,7 @@ public class CacheRobotStrategy implements RobotStrategy {
             //当前库位不在暂存位上,在线边库上
             if(!startStore.getPointId().contains("MERK")){
                 dataMap.put("result", false);
-                dataMap.put("resultMsg", "条件判断不通过,线边库临时暂存位被占用,节点名字"+ taskNode.getNodeName()+"节点id:"+taskNode.getId());
+                dataMap.put("resultMsg", "条件判断不通过,线边库临时暂存, 等待目标位置释放,节点名字"+ task.getProcedureName()+"-"+ taskNode.getNodeName()+"节点id:"+taskNode.getId());
                 return dataMap;
             }