Browse Source

线边库轮询判断目标地址逻辑修改

yejian 3 years ago
parent
commit
2958447594

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

@@ -257,7 +257,7 @@ public class TaskWorkNode {
                     queryMap.put(taskNode.getId() + "count", jsonObject.getString(taskNode.getId() + "count"));
                 }
 
-                //把产线放进去,避免多次查询
+                //把产线放进去,避免多次查询节点业务参数
                 ZZoneProductionresource zoneProductionresource = zZoneProductionresourceMapper.selectOne(Wraps.<ZZoneProductionresource>lbQ().eq(ZZoneProductionresource::getResourceId, taskNode.getResourceId()));
                 ZZone zZone = zoneService.getById(zoneProductionresource.getZoneId());
                 queryMap.put("zone", zZone);
@@ -726,9 +726,19 @@ public class TaskWorkNode {
                 Storge startStore = workpieceService.getWorkPieceStock(taskNode.getCompleteBatchNo(), false);
 
                 ProductionresourcePosition po = logical(robotList,dataMap);
+
+
+
                 //机器人手抓没被锁定,并且有空闲未知
                 if (po != null) {
-                    Map returnMap = getTargetStorge(nextTaskNode, taskNode.getFindAgvFlag(), zone,bomProcedure.getType(),bomzZone);
+                    // 线边库轮询判断后续节点目标地址是否时接驳位
+                    String findAgvFlag = "0";
+
+                    TaskNode beforTaskNode = taskNodeService.getNextNTaskNode(taskNode,-1);
+                    if("1".equals(beforTaskNode.getFindAgvFlag()) && null == taskNode.getTargetResourceId()){
+                        findAgvFlag = "1";
+                    }
+                    Map returnMap = getTargetStorge(nextTaskNode, findAgvFlag, zone,bomProcedure.getType(),bomzZone);
                     targetStorge = returnMap.get("store") == null ? null : (Storge) returnMap.get("store");
 
                     if(null != targetStorge){
@@ -841,7 +851,13 @@ public class TaskWorkNode {
                 dataMap.put("method", "GetServoStacker");
                 ProductionresourcePosition po = logical(robotList,dataMap);
                 if (po != null) {
+                    // 线边库轮询判断后续节点目标地址是否时接驳位
+                    String findAgvFlag = "0";
 
+                    TaskNode beforTaskNode = taskNodeService.getNextNTaskNode(taskNode,-1);
+                    if("1".equals(beforTaskNode.getFindAgvFlag()) && null == taskNode.getTargetResourceId()){
+                        findAgvFlag = "1";
+                    }
                     Map returnMap = getTargetStorge(taskNode, taskNode.getFindAgvFlag(), zone,bomProcedure.getType(),bomzZone);
                     targetStorge = returnMap.get("store") == null ? null : (Storge) returnMap.get("store");
 

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

@@ -1382,6 +1382,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         //回调的参数
         JSONObject callBackJson = JSONObject.parseObject(bizCallBackData);
 
+        logger.info("节点:{}回调:{}",taskNode.getId(),callBackJson);
+
         //获取当前自动化节点的顺序
         int n = taskNode.getCompleteBatchSort() - 1;
 

+ 74 - 63
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl.java

@@ -296,40 +296,47 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                         log.info("节点{}检查目标库位是否满足返回{}",taskNode.getId(),returnMap);
                         //目标地址和类型
                         Storge targetStorge = returnMap.get("store")==null?null:(Storge)returnMap.get("store");
-                        String targetxbk = returnMap.get("targetxbk")==null?null:(String)returnMap.get("targetxbk");
-                        jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
-                        jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(jqrStorge, nextTaskNode.getId());
-                        //锁定一个缓存位
-                        List<ProductionresourcePosition> hcwList = jqrMap.get(jqrMap.keySet().stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p)).findFirst().get());
-                        Storge hcwStorge = storgeService.getById(hcwList.get(0).getStorgeId());
-                        hcwStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(hcwStorge, nextTaskNode.getId());
-
-                        //锁定目标库位
-                        targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(targetStorge, nextTaskNode.getId());
-
-                        //抓手缓存
-                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + nextTaskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
-                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
-                        //缓存位缓存
-                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + nextTaskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
-                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + taskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
-                        //目标缓存
-                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + nextTaskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
-
-                        //目标是线边库
-                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + nextTaskNode.getId(), targetxbk, 1, TimeUnit.DAYS);
+                        if(null != targetStorge){
+                            String targetxbk = returnMap.get("targetxbk")==null?null:(String)returnMap.get("targetxbk");
+                            jqrStorge = storgeService.getById(jqrMap.get(DemoLineConstant.DEMOLINE_RJQR_ZS).get(0).getStorgeId());
+                            jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+                            storgeService.lockStorge(jqrStorge, nextTaskNode.getId());
+                            //锁定一个缓存位
+                            List<ProductionresourcePosition> hcwList = jqrMap.get(jqrMap.keySet().stream().filter(p -> !DemoLineConstant.DEMOLINE_RJQR_ZS.equals(p)).findFirst().get());
+                            Storge hcwStorge = storgeService.getById(hcwList.get(0).getStorgeId());
+                            hcwStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+                            storgeService.lockStorge(hcwStorge, nextTaskNode.getId());
+
+                            //锁定目标库位
+                            targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+                            storgeService.lockStorge(targetStorge, nextTaskNode.getId());
+
+                            //抓手缓存
+                            msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + nextTaskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
+                            msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
+                            //缓存位缓存
+                            msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + nextTaskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
+                            msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_HCW + taskNode.getId(), hcwStorge, 1, TimeUnit.DAYS);
+                            //目标缓存
+                            msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + nextTaskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
+
+                            //目标是线边库
+                            msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + nextTaskNode.getId(), targetxbk, 1, TimeUnit.DAYS);
+
+                            //满足条件--机器人空闲,设备或线边库有一个空闲
+                            Map locationMap = new HashMap();
+                            locationMap.put("location",startStore.getPointId());
+                            dataMap.put("data", locationMap);
+                            dataMap.put("method", "MoveRobotPosition");
+                            dataMap.put("result", true);
+                        }else{
+                            dataMap.put("result", false);
+                        }
 
-                        //满足条件--机器人空闲,设备或线边库有一个空闲
-                        Map locationMap = new HashMap();
-                        locationMap.put("location",startStore.getPointId());
-                        dataMap.put("data", locationMap);
-                        dataMap.put("method", "MoveRobotPosition");
-                        dataMap.put("result", true);
+                    }else{
+                        dataMap.put("result", false);
                     }
-                    dataMap.put("result", po!=null);
+
 
                 } else if (count == 1) {
                     jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId());
@@ -377,45 +384,49 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                     log.info("节点{}检查目标库位是否满足返回{}",taskNode.getId(),returnMap);
                     //目标地址和类型
                     Storge targetStorge = returnMap.get("store")==null?null:(Storge)returnMap.get("store");
-                    String targetxbk = returnMap.get("targetxbk")==null?null:(String)returnMap.get("targetxbk");
-                    jqrStorge = storgeService.getById(robotList.get(0).getStorgeId());
+                    if(null != targetStorge){
+                        String targetxbk = returnMap.get("targetxbk")==null?null:(String)returnMap.get("targetxbk");
+                        jqrStorge = storgeService.getById(robotList.get(0).getStorgeId());
 
-                    dataMap.put("fromStorge", startStore);
+                        dataMap.put("fromStorge", startStore);
 
-                    Map locationMap = new HashMap();
-                    locationMap.put("location",startStore.getPointId());
-                    dataMap.put("data", locationMap);
-                    // TODO 有问题,需要区分是否是第一步上料
-                    //出入库类型
-                    if(taskNode.getCompleteBatchSort()==1){//TODO 条件后续再丰富
-                        dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_TRAY_CRK);
-                    }else {
-                        dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
-                    }
+                        Map locationMap = new HashMap();
+                        locationMap.put("location",startStore.getPointId());
+                        dataMap.put("data", locationMap);
+                        // TODO 有问题,需要区分是否是第一步上料
+                        //出入库类型
+                        if(taskNode.getCompleteBatchSort()==1){//TODO 条件后续再丰富
+                            dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_TRAY_CRK);
+                        }else {
+                            dataMap.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
+                        }
 
-                    //目的地为机器人手臂
-                    dataMap.put("toStorge", jqrStorge);
+                        //目的地为机器人手臂
+                        dataMap.put("toStorge", jqrStorge);
 
-                    dataMap.put("bizType", targetxbk);
-                    //锁定机器人
-                    jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                    storgeService.lockStorge(jqrStorge, nextTaskNode.getId());
+                        dataMap.put("bizType", targetxbk);
+                        //锁定机器人
+                        jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+                        storgeService.lockStorge(jqrStorge, nextTaskNode.getId());
 
-                    //锁定目标库位
-                    targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                    storgeService.lockStorge(targetStorge, nextTaskNode.getId());
+                        //锁定目标库位
+                        targetStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+                        storgeService.lockStorge(targetStorge, nextTaskNode.getId());
 
-                    //抓手缓存
-                    msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + nextTaskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
-                    msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
-                    //目标缓存
-                    msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + nextTaskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
+                        //抓手缓存
+                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + nextTaskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
+                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + YunjianConstant.YUNJIAN_JXS + taskNode.getId(), jqrStorge, 1, TimeUnit.DAYS);
+                        //目标缓存
+                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_STORE + nextTaskNode.getId(), targetStorge, 1, TimeUnit.DAYS);
 
-                    //目标是线边库
-                    msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + nextTaskNode.getId(), targetxbk, 1, TimeUnit.DAYS);
-                    dataMap.put("result", true);
+                        //目标是线边库
+                        msgUtil.redis_set(DemoCacheKey.YUNJIAN_CAMP + "_" + DemoLineConstant.YUNJIAN_TARGET_XBK_FLAG + nextTaskNode.getId(), targetxbk, 1, TimeUnit.DAYS);
+                        dataMap.put("result", true);
+                    }else{
+                        dataMap.put("result", false);
+                    }
                 }else{
-                    dataMap.put("result", po!=null);
+                    dataMap.put("result", false);
                 }
             }
         }else if ("放".equals(functionName)) {