Browse Source

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

laoyao 3 years ago
parent
commit
fb1200e6f9

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

@@ -12,8 +12,10 @@ import com.github.zuihou.business.operationManagementCenter.dao.PlanMapper;
 import com.github.zuihou.business.operationManagementCenter.dao.TTaskMapper;
 import com.github.zuihou.business.operationManagementCenter.dao.TaskNodeMapper;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
+import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
 import com.github.zuihou.business.productionReadyCenter.dao.AAutoNodeLogMapper;
 import com.github.zuihou.business.productionReadyCenter.entity.AAutoNodeLog;
 import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProductionresource;
@@ -87,6 +89,9 @@ public class TaskWorkNode {
     @Autowired
     private StorgeService storgeService;
 
+    @Autowired
+    private WorkpieceService workpieceService;
+
     @Autowired
     private ProductionresourcePositionService productionresourcePositionService;
 
@@ -523,173 +528,175 @@ public class TaskWorkNode {
         nodeOperationService.initResource(taskNode, task, map);
 
         //线边库轮询两个机械手和接驳位资源。如果两个都有空则从线边库搬运到接驳位
-        if (BizConstant.MQ_TASK_NODE_TYPE_STORAGE_WAIT_ZLZX.equals(bizType)) {
-            //执行线边库队列标志
-            map.put(DemoLineConstant.DEMOLINE_EXEXBKFLAG, "1");
-            if (BizConstant.MQ_TASK_NODE_TYPE_STORAGE_WAIT_ZLZX_JBW.equals(carryType)) {
-                int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()).toString());
-                if (currCount == 1) {
-                    //判断接驳位D\E是否为空
-                    String jbwarr[] = {DemoLineConstant.JBW_D, DemoLineConstant.JBW_E};
-                    Map plateMap = storgeService.getPlateStorgeByNo(jbwarr, task.getCompleteBatchNo());
-                    //获取锁定的托板上的库位
-                    Storge plantStorge = plateMap.get("storge") == null ? null : (Storge) plateMap.get("storge");
-                    String jbwCode = plateMap.get("jbwCode") == null ? "" : plateMap.get("jbwCode").toString();
-
-                    //判断机器人库位是否为空
-                    String jrqarr[] = {DemoLineConstant.JQR1};
-                    List<ProductionresourcePosition> jqrList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jrqarr);
-                    if (plantStorge != null && CollectionUtil.isNotEmpty(jqrList)) {
-                        //锁定其中一个
-                        //获取下一个节点,用于锁定
-                        TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
-                        //锁定库位,锁定的业务ID是下一个节点的ID
-                        plantStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(plantStorge, nextTaskNode.getId());
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.TB + taskNode.getId(), plantStorge, 1, TimeUnit.DAYS);
-
-                        Storge jqrStorge = storgeService.getById(jqrList.get(0).getStorgeId());
-                        map.put("toStorge", jqrStorge);
-                        //机器人库位锁定
-                        jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(jqrStorge, taskNode.getId());
-
-                        //线边库库位ID
-                        String storgeId = dataMap.get("storgeId").toString();
-                        Storge xbkstorge = storgeService.getById(storgeId);
-                        //把参数传芳map
-                        map.put("fromStorge", xbkstorge);
-                        //所属接驳位
-                        map.put("jbwCode", jbwCode);
-                        //记录产品流转到的库位
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), jqrStorge, 1, TimeUnit.DAYS);
-                        map.put("result", (plantStorge != null && jqrList != null && jqrList.size() > 0));
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
-                    }
-                    //机器人和托板有空位
-                    map.put("result", plantStorge != null && CollectionUtil.isNotEmpty(jqrList));
-                }
-                else if (currCount == 2) {
-                    Storge jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
-                    Object plantStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.TB + taskNode.getId());
-                    map.put("fromStorge", jqrStorge);
-                    map.put("toStorge", plantStorge);
-                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), plantStorge, 1, TimeUnit.DAYS);
-                    //前一步已经锁定完毕,直接满足条件
-                    map.put("result", true);
-                }
-            }
-            else if (BizConstant.MQ_TASK_NODE_TYPE_STORAGE_WAIT_ZLZX_SZB.equals(carryType)) {//从线边库到三坐标
-                int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()).toString());
-                if (currCount == 1) {
-                    //判断接驳位D\E是否为空
-                    String szbarr[] = {DemoLineConstant.Q3ZUOBIAO};
-                    List<ProductionresourcePosition> szbList = productionresourcePositionService.getFreeProductionresourcePositionByNos(szbarr);
-
-                    //判断机器人库位是否为空
-                    String jrqarr[] = {DemoLineConstant.JQR1};
-                    List<ProductionresourcePosition> jqrList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jrqarr);
-
-                    Storge szbStorge = null;
-                    if (CollectionUtil.isNotEmpty(szbList) && CollectionUtil.isNotEmpty(jqrList)) {
-                        //锁定其中一个
-                        //获取下一个节点,用于锁定
-                        TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
-                        //锁定库位,锁定的业务ID是下一个节点的ID
-                        szbStorge = storgeService.getById(szbList.get(0).getStorgeId());
-                        szbStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(szbStorge, nextTaskNode.getId());
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.Q3ZUOBIAO + nextTaskNode.getId(), szbStorge, 1, TimeUnit.DAYS);
-
-                        Storge jqrStorge = storgeService.getById(jqrList.get(0).getStorgeId());
-                        map.put("toStorge", jqrStorge);
-                        //机器人库位锁定
-                        jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(jqrStorge, taskNode.getId());
-
-                        //线边库库位ID
-                        String storgeId = dataMap.get("storgeId").toString();
-                        Storge xbkstorge = storgeService.getById(storgeId);
-                        //把参数传芳map
-                        map.put("fromStorge", xbkstorge);
-                        //记录产品流转到的库位
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), jqrStorge, 1, TimeUnit.DAYS);
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
-                    }
-                    //机器人和托板有空位
-                    map.put("result", (CollectionUtil.isNotEmpty(szbList) && CollectionUtil.isNotEmpty(jqrList)));
-                } else if (currCount == 2) {
-                    Storge jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
-                    Object szbStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.Q3ZUOBIAO + taskNode.getId());
-                    map.put("fromStorge", jqrStorge);
-                    map.put("toStorge", szbStorge);
-                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), szbStorge, 1, TimeUnit.DAYS);
-                    //前一步已经锁定完毕,直接满足条件
-                    map.put("result", true);
-                }
-            }
-
-        }
-        else if (BizConstant.MQ_TASK_NODE_TYPE_STORAGE_WAIT_ZNDY.equals(bizType)) {
-            //智能单元
-            //执行线边库队列标志
-            map.put(DemoLineConstant.DEMOLINE_EXEXBKFLAG, "1");
-            int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()).toString());
-            if (currCount == 1) {
-                //判断接驳位D\E是否为空
-                String sum50[] = {DemoLineConstant.DEMOLINE_SUM50_ZNDY};
-                List<ProductionresourcePosition> sum50List = productionresourcePositionService.getFreeProductionresourcePositionByNos(sum50);
-
-                //判断机器人库位是否为空
-                String jrqarr[] = {DemoLineConstant.JQR2};
-                List<ProductionresourcePosition> jqrList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jrqarr);
-
-                if (sum50List != null && sum50List.size() > 0 && jqrList != null && jqrList.size() > 0) {
-                    Storge sum50Storge = storgeService.getById(sum50List.get(0).getStorgeId());
-                    sum50Storge.setCompleteBatchNo(task.getCompleteBatchNo());
-                    storgeService.lockStorge(sum50Storge, taskNode.getId());
-                    //放入缓存,下个节点使用
-                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_SUM50_ZNDY + taskNode.getId(), sum50Storge, 1, TimeUnit.DAYS);
-
-                    //线边库库位ID
-                    String storgeId = dataMap.get("storgeId").toString();
-                    Storge xbkstorge = storgeService.getById(storgeId);
-                    //把参数传芳map
-                    map.put("fromStorge", xbkstorge);
-
-                    Storge jqrStorge = storgeService.getById(jqrList.get(0).getStorgeId());
-                    map.put("toStorge", jqrStorge);
-                    //记录产品流转到的库位
-                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), jqrStorge, 1, TimeUnit.DAYS);
-                    //机器人库位锁定
-                    jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                    storgeService.lockStorge(jqrStorge, taskNode.getId());
-                    map.put("result", (sum50List != null && sum50List.size() > 0 && jqrList != null && jqrList.size() > 0));
-                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
-                }
-            } else if (currCount == 2) {
-                Storge jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
-                Object sum50Storge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_SUM50_ZNDY + taskNode.getId());
-                if (sum50Storge != null) {//前序是绑定到sum50
-                    sum50Storge = (Storge) sum50Storge;
-                    //目的地为机器人手臂
-                    map.put("toStorge", sum50Storge);
-                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), sum50Storge, 1, TimeUnit.DAYS);
-                }
-                map.put("fromStorge", jqrStorge);
-                map.put("result", true);
-                logger.error("12");
-            }
-
-        }
-        else {//正常节点类型
+//        if (BizConstant.MQ_TASK_NODE_TYPE_STORAGE_WAIT_ZLZX.equals(bizType)) {
+//            //执行线边库队列标志
+//            map.put(DemoLineConstant.DEMOLINE_EXEXBKFLAG, "1");
+//            if (BizConstant.MQ_TASK_NODE_TYPE_STORAGE_WAIT_ZLZX_JBW.equals(carryType)) {
+//                int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()).toString());
+//                if (currCount == 1) {
+//                    //判断接驳位D\E是否为空
+//                    String jbwarr[] = {DemoLineConstant.JBW_D, DemoLineConstant.JBW_E};
+//                    Map plateMap = storgeService.getPlateStorgeByNo(jbwarr, task.getCompleteBatchNo());
+//                    //获取锁定的托板上的库位
+//                    Storge plantStorge = plateMap.get("storge") == null ? null : (Storge) plateMap.get("storge");
+//                    String jbwCode = plateMap.get("jbwCode") == null ? "" : plateMap.get("jbwCode").toString();
+//
+//                    //判断机器人库位是否为空
+//                    String jrqarr[] = {DemoLineConstant.JQR1};
+//                    List<ProductionresourcePosition> jqrList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jrqarr);
+//                    if (plantStorge != null && CollectionUtil.isNotEmpty(jqrList)) {
+//                        //锁定其中一个
+//                        //获取下一个节点,用于锁定
+//                        TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
+//                        //锁定库位,锁定的业务ID是下一个节点的ID
+//                        plantStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+//                        storgeService.lockStorge(plantStorge, nextTaskNode.getId());
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.TB + taskNode.getId(), plantStorge, 1, TimeUnit.DAYS);
+//
+//                        Storge jqrStorge = storgeService.getById(jqrList.get(0).getStorgeId());
+//                        map.put("toStorge", jqrStorge);
+//                        //机器人库位锁定
+//                        jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+//                        storgeService.lockStorge(jqrStorge, taskNode.getId());
+//
+//                        //线边库库位ID
+//                        String storgeId = dataMap.get("storgeId").toString();
+//                        Storge xbkstorge = storgeService.getById(storgeId);
+//                        //把参数传芳map
+//                        map.put("fromStorge", xbkstorge);
+//                        //所属接驳位
+//                        map.put("jbwCode", jbwCode);
+//                        //记录产品流转到的库位
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), jqrStorge, 1, TimeUnit.DAYS);
+//                        map.put("result", (plantStorge != null && jqrList != null && jqrList.size() > 0));
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
+//                    }
+//                    //机器人和托板有空位
+//                    map.put("result", plantStorge != null && CollectionUtil.isNotEmpty(jqrList));
+//                }
+//                else if (currCount == 2) {
+//                    Storge jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
+//                    Object plantStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.TB + taskNode.getId());
+//                    map.put("fromStorge", jqrStorge);
+//                    map.put("toStorge", plantStorge);
+//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), plantStorge, 1, TimeUnit.DAYS);
+//                    //前一步已经锁定完毕,直接满足条件
+//                    map.put("result", true);
+//                }
+//            }
+//            else if (BizConstant.MQ_TASK_NODE_TYPE_STORAGE_WAIT_ZLZX_SZB.equals(carryType)) {//从线边库到三坐标
+//                int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()).toString());
+//                if (currCount == 1) {
+//                    //判断接驳位D\E是否为空
+//                    String szbarr[] = {DemoLineConstant.Q3ZUOBIAO};
+//                    List<ProductionresourcePosition> szbList = productionresourcePositionService.getFreeProductionresourcePositionByNos(szbarr);
+//
+//                    //判断机器人库位是否为空
+//                    String jrqarr[] = {DemoLineConstant.JQR1};
+//                    List<ProductionresourcePosition> jqrList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jrqarr);
+//
+//                    Storge szbStorge = null;
+//                    if (CollectionUtil.isNotEmpty(szbList) && CollectionUtil.isNotEmpty(jqrList)) {
+//                        //锁定其中一个
+//                        //获取下一个节点,用于锁定
+//                        TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
+//                        //锁定库位,锁定的业务ID是下一个节点的ID
+//                        szbStorge = storgeService.getById(szbList.get(0).getStorgeId());
+//                        szbStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+//                        storgeService.lockStorge(szbStorge, nextTaskNode.getId());
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.Q3ZUOBIAO + nextTaskNode.getId(), szbStorge, 1, TimeUnit.DAYS);
+//
+//                        Storge jqrStorge = storgeService.getById(jqrList.get(0).getStorgeId());
+//                        map.put("toStorge", jqrStorge);
+//                        //机器人库位锁定
+//                        jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+//                        storgeService.lockStorge(jqrStorge, taskNode.getId());
+//
+//                        //线边库库位ID
+//                        String storgeId = dataMap.get("storgeId").toString();
+//                        Storge xbkstorge = storgeService.getById(storgeId);
+//                        //把参数传芳map
+//                        map.put("fromStorge", xbkstorge);
+//                        //记录产品流转到的库位
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), jqrStorge, 1, TimeUnit.DAYS);
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
+//                    }
+//                    //机器人和托板有空位
+//                    map.put("result", (CollectionUtil.isNotEmpty(szbList) && CollectionUtil.isNotEmpty(jqrList)));
+//                } else if (currCount == 2) {
+//                    Storge jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
+//                    Object szbStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.Q3ZUOBIAO + taskNode.getId());
+//                    map.put("fromStorge", jqrStorge);
+//                    map.put("toStorge", szbStorge);
+//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), szbStorge, 1, TimeUnit.DAYS);
+//                    //前一步已经锁定完毕,直接满足条件
+//                    map.put("result", true);
+//                }
+//            }
+//
+//        }
+//        else if (BizConstant.MQ_TASK_NODE_TYPE_STORAGE_WAIT_ZNDY.equals(bizType)) {
+//            //智能单元
+//            //执行线边库队列标志
+//            map.put(DemoLineConstant.DEMOLINE_EXEXBKFLAG, "1");
+//            int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo()).toString());
+//            if (currCount == 1) {
+//                //判断接驳位D\E是否为空
+//                String sum50[] = {DemoLineConstant.DEMOLINE_SUM50_ZNDY};
+//                List<ProductionresourcePosition> sum50List = productionresourcePositionService.getFreeProductionresourcePositionByNos(sum50);
+//
+//                //判断机器人库位是否为空
+//                String jrqarr[] = {DemoLineConstant.JQR2};
+//                List<ProductionresourcePosition> jqrList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jrqarr);
+//
+//                if (sum50List != null && sum50List.size() > 0 && jqrList != null && jqrList.size() > 0) {
+//                    Storge sum50Storge = storgeService.getById(sum50List.get(0).getStorgeId());
+//                    sum50Storge.setCompleteBatchNo(task.getCompleteBatchNo());
+//                    storgeService.lockStorge(sum50Storge, taskNode.getId());
+//                    //放入缓存,下个节点使用
+//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_SUM50_ZNDY + taskNode.getId(), sum50Storge, 1, TimeUnit.DAYS);
+//
+//                    //线边库库位ID
+//                    String storgeId = dataMap.get("storgeId").toString();
+//                    Storge xbkstorge = storgeService.getById(storgeId);
+//                    //把参数传芳map
+//                    map.put("fromStorge", xbkstorge);
+//
+//                    Storge jqrStorge = storgeService.getById(jqrList.get(0).getStorgeId());
+//                    map.put("toStorge", jqrStorge);
+//                    //记录产品流转到的库位
+//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), jqrStorge, 1, TimeUnit.DAYS);
+//                    //机器人库位锁定
+//                    jqrStorge.setCompleteBatchNo(task.getCompleteBatchNo());
+//                    storgeService.lockStorge(jqrStorge, taskNode.getId());
+//                    map.put("result", (sum50List != null && sum50List.size() > 0 && jqrList != null && jqrList.size() > 0));
+//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_XBK_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
+//                }
+//            } else if (currCount == 2) {
+//                Storge jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
+//                Object sum50Storge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.DEMOLINE_SUM50_ZNDY + taskNode.getId());
+//                if (sum50Storge != null) {//前序是绑定到sum50
+//                    sum50Storge = (Storge) sum50Storge;
+//                    //目的地为机器人手臂
+//                    map.put("toStorge", sum50Storge);
+//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), sum50Storge, 1, TimeUnit.DAYS);
+//                }
+//                map.put("fromStorge", jqrStorge);
+//                map.put("result", true);
+//                logger.error("12");
+//            }
+//
+//        }
+        if (bizType == "0")  {//正常节点类型
             BomProcedureProductionresource bomProcedureProductionresource = bomProcedureProductionresourceService.getOne(new QueryWrapper<BomProcedureProductionresource>().eq("resourceId",task.getResourceId()).eq("procedureId", task.getProcedureId()));
             //List<ResourceAutoCode>  resourceAutoCodeList = resourceAutoCodeService.getNodeList(resourceAutoCode);
             //业务序列节点
             //ResourceAutoCode parentAutoCode = resourceAutoCodeService.getById(resourceAutoCode.getParentId());
             logger.info("=============进入自动化节点条件检测==============" + resourceAutoCode.getName() );
             map = nodeOperationService.checkCondition(taskNode, task, map);
-
+        }else{
+            logger.info("=============进入线边库条件检测==============" + resourceAutoCode.getName() );
+            map = checkXbkCon(taskNode, task, map);
         }
         return map;
     }
@@ -716,5 +723,49 @@ public class TaskWorkNode {
         }
     }
 
+    /**
+     *  线边库条件处理判断
+     * @param map
+     *
+     * @return
+     */
+    public Map checkXbkCon(TaskNode taskNode,TTask task, Map<String, Object> map){
+        Storge xbkStorage = workpieceService.getWorkPieceStock(taskNode.getId(),false);
+        if(xbkStorage.getLockStatus()=="1"){
+            map.put("msg", DictionaryKey.NodeException.RUNNING_FALSE);
+            map.put("result", false);
+        }else{
+            // 获取锁定节点设备ID
+            //Long campId = xbkStorage.getCampId();
+            Long targetId = xbkStorage.getTargetId();
+            if(!taskNodeService.getRunStatus(targetId)){
+                map.put("result", false);
+                map.put("msg", DictionaryKey.NodeException.RUNNING_FALSE);
+                return map;
+            }
+            ProductionresourcePosition resourcePosition = productionresourcePositionService.getOne(new LbqWrapper<ProductionresourcePosition>().eq(ProductionresourcePosition::getResourceId, targetId));
+            Productionresource productionresource = productionresourceService.getOne(new QueryWrap<Productionresource>().eq("id", targetId));
+            //任意设备条件判断
+            boolean bool = resourcePosition!=null && resourcePosition.getLockStatus() == "1" && resourcePosition.getStatus() == "1" && resourcePosition.getHaveGoods() == "0";
+            if(productionresource.getModuleDesc()=="接驳位"){
+                //锁定对象是接驳位
+                String[] jbwarr = new String[]{productionresource.getCode()};
+                Map plateMap = storgeService.getPlateStorgeByNo(jbwarr, task.getCompleteBatchNo());
+                Storge plantStorge = plateMap.get("storge") == null ? null : (Storge) plateMap.get("storge");
+                bool = bool && (plantStorge!=null );
+            }
+            if(bool){
+                //实现移动操作到具体设备
+
+                //线边库解锁
+                storgeService.unlockStorge(xbkStorage);
+            }else{
+                map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
+            }
+            map.put("result", bool);
+        }
+        return map;
+    }
+
 }
 

+ 7 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/operationManagementCenter/service/TaskNodeService.java

@@ -146,4 +146,11 @@ public interface TaskNodeService extends SuperService<TaskNode> {
      * @return
      */
     int selectCurrentProduceSort(Map param);
+
+    /**
+     * 调用接口获取采集设备状态
+     * @param resourceId
+     * @return
+     */
+    boolean getRunStatus(Long resourceId);
 }

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

@@ -1669,6 +1669,10 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return baseMapper.selectCurrentProduceSort(param);
     }
 
+    @Override
+    public boolean getRunStatus(Long resourceId) {
+        return true;
+    }
 
     @Override
     public void deleteByWorkpieceSort(Map param) {

+ 105 - 80
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/MachineNodeServiceImpl.java

@@ -137,95 +137,119 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         String functionName = resourceAutoCode.getCommand();
         String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
 
+        //采集接口判断当前设备是否在线
+        if(!taskNodeService.getRunStatus(task.getResourceId())){
+            map.put("result", false);
+            map.put("msg", DictionaryKey.NodeException.RUNNING_FALSE);
+            return map;
+        }
+
         ProductionresourcePosition productionresourcePosition = this.logical(deviceList, true);
         boolean bool =  productionresourcePosition!=null ? true : false;
         if(!bool){
-            map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
+            map.put("result", false);
+            return map;
+        }
+        // 设备占用 当前节点锁定线边库
+        boolean isXbk = map.get("useXbk") == null ? false : true;
+        if(isXbk){
+            Storge storge = storgeService.getById(productionresourcePosition.getStorgeId());
+            //设定线边库目标ID
+            storge.setTargetId(task.getResourceId());
+            //TaskNode nextCode = taskNodeService.getNextNTaskNode(taskNode, 1);
+            //锁定当前节点与线边库
+            storgeService.lockStorge(storge, taskNode.getId());
+            map.put("result", false);
             return map;
         }
 
         switch (moduleName) {
-            case "WMS":
+            // case "WMS":
                 //WMS出库
-                if ("WMS_OUT".equals(functionName)) {
-                    jbwArr = new String[]{DemoLineConstant.JBW_A, DemoLineConstant.JBW_B};
-                    String[] zxzxXBKarr = new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
-                    List<ProductionresourcePosition> xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(zxzxXBKarr);
-                    List<ProductionresourcePosition> jbwList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jbwArr);
-                    Map<String, List<ProductionresourcePosition>> jbwMap = jbwList.stream().collect(groupingBy(ProductionresourcePosition::getCode));
-                    if (CollectionUtil.isNotEmpty(xbkList) && jbwMap.containsKey(DemoLineConstant.JBW_B) && jbwMap.containsKey(DemoLineConstant.JBW_A)) {
-                        //获取下一个节点,用于锁定
-                        TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
-                        //预占A接驳位
-                        List<ProductionresourcePosition> jbwAList = jbwMap.get(DemoLineConstant.JBW_A);
-                        Storge storgeA = storgeService.getById(jbwAList.get(0).getStorgeId());
-                        storgeA.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(storgeA, nextTaskNode.getId());
-                        //获取接驳位A位置
-                        map.put("toStorge", storgeA);
-                        map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_RK);
-                        map.put("locationName", "Location-8002");
-                        map.put(DemoLineConstant.DEMOLINE_WMS_TYPE, DemoLineConstant.DEMOLINE_WMS_CHUKU);//出库
-
-                        Map jsonMap = new HashMap();
-                        jsonMap.put("productNo", task.getMeterialId());
-                        jsonMap.put("productCount", "1");
-                        List<Map> list = new ArrayList<>();
-                        list.add(jsonMap);
-                        map.put("boxes", JSONArray.parseArray(JSONObject.toJSONString(list)));
-
-                        //除去接驳位之后,B、C随机一个
-                        List<ProductionresourcePosition> jbwBCList = jbwMap.get(DemoLineConstant.JBW_B);
-                        //随机选第一个接驳位
-                        ProductionresourcePosition p = jbwBCList.get(0);
-                        //预占库位为下个节点准备
-                        Storge jbwstorge = storgeService.getById(p.getStorgeId());
-
-                        //锁定接驳位库位,锁定的业务ID是下一个节点的ID
-                        jbwstorge.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(jbwstorge, nextTaskNode.getId());
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JBW + "" + nextTaskNode.getId().toString(), jbwstorge, 1, TimeUnit.DAYS);
-
-                        //锁定线边库
-                        ProductionresourcePosition xbkP = xbkList.get(0);
-                        Storge storgeXbk = storgeService.getById(xbkP.getStorgeId());
-                        //获取到运料的节点。
-                        TaskNode next6TaskNode = taskNodeService.getNextNTaskNode(taskNode, 6);
-                        storgeXbk.setCompleteBatchNo(task.getCompleteBatchNo());
-                        storgeService.lockStorge(storgeXbk, next6TaskNode.getId());
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.NODE_RESOURCE_ZLZX_XBK + next6TaskNode.getId(), storgeXbk, 1, TimeUnit.DAYS);
-                        //记录产品流转到的库位
-                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), storgeA, 1, TimeUnit.DAYS);
-                    }
-                    //条件
-                    map.put("result", (CollectionUtil.isNotEmpty(xbkList) && jbwMap.containsKey(DemoLineConstant.JBW_B) && jbwMap.containsKey(DemoLineConstant.JBW_A)));
-                }
-                //WMS入库
-                else if ("WMS_IN".equals(functionName)) {
-                    //WMS入库
-                    map.put(DemoLineConstant.DEMOLINE_GOODS_TYPE, DemoLineConstant.DEMOLINE_GOODS_TYPE_CHENGPIN);//成品
-                    map.put(DemoLineConstant.DEMOLINE_WMS_TYPE, DemoLineConstant.DEMOLINE_WMS_RUKU);//入库
-                    //TODO临时这样写
-                    Map queryMap = new HashMap();
-                    jbwArr = new String[]{DemoLineConstant.JBW_A};
-                    queryMap.put("codes", StringUtil.changeIdsArrToSubQueryStr(jbwArr));
-                    List<ProductionresourcePosition> jbwAList = productionresourcePositionMapper.getPPList(queryMap);
-                    if (CollectionUtil.isNotEmpty(jbwAList)) {
-                        Storge jbwAstorge = storgeService.getById(jbwAList.get(0).getStorgeId());
-                        map.put("fromStorge", jbwAstorge);
-                    }
-                    map.put("locationName", "Location-8002");
-                    Map jsonMap = new HashMap();
-                    jsonMap.put("productNo", task.getBomId());
-                    jsonMap.put("productCount", "1");
-                    List<Map> list = new ArrayList<>();
-                    list.add(jsonMap);
-                    map.put("boxes", JSONArray.parseArray(JSONObject.toJSONString(list)));
-                    map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_CK);
-                    map.put("result", true);
-                }
-                break;
+//                if ("WMS_OUT".equals(functionName)) {
+//                    jbwArr = new String[]{DemoLineConstant.JBW_A, DemoLineConstant.JBW_B};
+//                    String[] zxzxXBKarr = new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
+//                    List<ProductionresourcePosition> xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(zxzxXBKarr);
+//                    List<ProductionresourcePosition> jbwList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jbwArr);
+//                    Map<String, List<ProductionresourcePosition>> jbwMap = jbwList.stream().collect(groupingBy(ProductionresourcePosition::getCode));
+//                    if (CollectionUtil.isNotEmpty(xbkList) && jbwMap.containsKey(DemoLineConstant.JBW_B) && jbwMap.containsKey(DemoLineConstant.JBW_A)) {
+//                        //获取下一个节点,用于锁定
+//                        TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
+//                        //预占A接驳位
+//                        List<ProductionresourcePosition> jbwAList = jbwMap.get(DemoLineConstant.JBW_A);
+//                        Storge storgeA = storgeService.getById(jbwAList.get(0).getStorgeId());
+//                        storgeA.setCompleteBatchNo(task.getCompleteBatchNo());
+//                        storgeService.lockStorge(storgeA, nextTaskNode.getId());
+//                        //获取接驳位A位置
+//                        map.put("toStorge", storgeA);
+//                        map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_RK);
+//                        map.put("locationName", "Location-8002");
+//                        map.put(DemoLineConstant.DEMOLINE_WMS_TYPE, DemoLineConstant.DEMOLINE_WMS_CHUKU);//出库
+//
+//                        Map jsonMap = new HashMap();
+//                        jsonMap.put("productNo", task.getMeterialId());
+//                        jsonMap.put("productCount", "1");
+//                        List<Map> list = new ArrayList<>();
+//                        list.add(jsonMap);
+//                        map.put("boxes", JSONArray.parseArray(JSONObject.toJSONString(list)));
+//
+//                        //除去接驳位之后,B、C随机一个
+//                        List<ProductionresourcePosition> jbwBCList = jbwMap.get(DemoLineConstant.JBW_B);
+//                        //随机选第一个接驳位
+//                        ProductionresourcePosition p = jbwBCList.get(0);
+//                        //预占库位为下个节点准备
+//                        Storge jbwstorge = storgeService.getById(p.getStorgeId());
+//
+//                        //锁定接驳位库位,锁定的业务ID是下一个节点的ID
+//                        jbwstorge.setCompleteBatchNo(task.getCompleteBatchNo());
+//                        storgeService.lockStorge(jbwstorge, nextTaskNode.getId());
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JBW + "" + nextTaskNode.getId().toString(), jbwstorge, 1, TimeUnit.DAYS);
+//
+//                        //锁定线边库
+//                        ProductionresourcePosition xbkP = xbkList.get(0);
+//                        Storge storgeXbk = storgeService.getById(xbkP.getStorgeId());
+//                        //获取到运料的节点。
+//                        TaskNode next6TaskNode = taskNodeService.getNextNTaskNode(taskNode, 6);
+//                        storgeXbk.setCompleteBatchNo(task.getCompleteBatchNo());
+//                        storgeService.lockStorge(storgeXbk, next6TaskNode.getId());
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.NODE_RESOURCE_ZLZX_XBK + next6TaskNode.getId(), storgeXbk, 1, TimeUnit.DAYS);
+//                        //记录产品流转到的库位
+//                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), storgeA, 1, TimeUnit.DAYS);
+//                    }
+//                    //条件
+//                    map.put("result", (CollectionUtil.isNotEmpty(xbkList) && jbwMap.containsKey(DemoLineConstant.JBW_B) && jbwMap.containsKey(DemoLineConstant.JBW_A)));
+//                }
+//                //WMS入库
+//                else if ("WMS_IN".equals(functionName)) {
+//                    //WMS入库
+//                    map.put(DemoLineConstant.DEMOLINE_GOODS_TYPE, DemoLineConstant.DEMOLINE_GOODS_TYPE_CHENGPIN);//成品
+//                    map.put(DemoLineConstant.DEMOLINE_WMS_TYPE, DemoLineConstant.DEMOLINE_WMS_RUKU);//入库
+//                    //TODO临时这样写
+//                    Map queryMap = new HashMap();
+//                    jbwArr = new String[]{DemoLineConstant.JBW_A};
+//                    queryMap.put("codes", StringUtil.changeIdsArrToSubQueryStr(jbwArr));
+//                    List<ProductionresourcePosition> jbwAList = productionresourcePositionMapper.getPPList(queryMap);
+//                    if (CollectionUtil.isNotEmpty(jbwAList)) {
+//                        Storge jbwAstorge = storgeService.getById(jbwAList.get(0).getStorgeId());
+//                        map.put("fromStorge", jbwAstorge);
+//                    }
+//                    map.put("locationName", "Location-8002");
+//                    Map jsonMap = new HashMap();
+//                    jsonMap.put("productNo", task.getBomId());
+//                    jsonMap.put("productCount", "1");
+//                    List<Map> list = new ArrayList<>();
+//                    list.add(jsonMap);
+//                    map.put("boxes", JSONArray.parseArray(JSONObject.toJSONString(list)));
+//                    map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_CK);
+//                    map.put("result", true);
+//                }
+//                break;
             case "上下料站":
+                //同步等待上下料手动操作是否完成
+                //boolean isCompleted = false;
+                //Storge startStore = workpieceService.getWorkPieceStock(taskNode.getId(),false);
+                //实现页面操作,取消轮询等待
+                map.put("result", true);
                 break;
 
             case "打标机":
@@ -439,6 +463,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
                     return null;
                 }
+                map.put("useXbk", true);
                 return xbkList.get(0);
             }
             map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);

+ 1 - 0
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/OtherNodeServiceImpl.java

@@ -69,6 +69,7 @@ public class OtherNodeServiceImpl implements NodeOperationService {
         if(StringUtil.isNotEmpty(moduleName)) {
             List<Module> modules = moduleService.list(new QueryWrapper<Module>().like("name", moduleName));
             if(modules.size()>0){
+                //设备关联接驳位
                 jbwArr = modules.stream().map(Module::getNo).toArray(String[]::new);
                 jbwList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jbwArr);
             }

+ 6 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/edgeLibrary/dto/StorgePageDTO.java

@@ -83,4 +83,10 @@ public class StorgePageDTO implements Serializable {
     @ApiModelProperty(value = "权重")
     private Integer weight;
 
+    /**
+     * 目标设备ID
+     */
+    @ApiModelProperty(value = "权重")
+    private Long targetId;
+
 }

+ 6 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/edgeLibrary/dto/StorgeSaveDTO.java

@@ -82,4 +82,10 @@ public class StorgeSaveDTO implements Serializable {
     @ApiModelProperty(value = "权重")
     private Integer weight;
 
+    /**
+     * 目标设备ID
+     */
+    @ApiModelProperty(value = "权重")
+    private Long targetId;
+
 }

+ 6 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/edgeLibrary/dto/StorgeUpdateDTO.java

@@ -87,4 +87,10 @@ public class StorgeUpdateDTO implements Serializable {
     @ApiModelProperty(value = "权重")
     private Integer weight;
 
+    /**
+     * 目标设备ID
+     */
+    @ApiModelProperty(value = "权重")
+    private Long targetId;
+
 }

+ 7 - 1
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/edgeLibrary/entity/Storge.java

@@ -135,6 +135,11 @@ public class Storge extends Entity<Long> {
     @Excel(name = "柔性产品点位ID")
     private String rpointId;
 
+    @ApiModelProperty(value = "目标设备ID")
+    @TableField(value = "target_id", condition = LIKE)
+    @Excel(name = "目标设备ID")
+    private Long targetId;
+
     @ApiModelProperty(value = "智能产品点位ID")
     @Length(max = 64, message = "智能产品点位ID")
     @TableField(value = "z_point_id", condition = LIKE)
@@ -163,7 +168,7 @@ public class Storge extends Entity<Long> {
 
     @Builder
     public Storge(Long id, LocalDateTime createTime, Long updateUser, Long createUser, LocalDateTime updateTime, 
-                    Long shelvesId, Long storgeTypeId, String no, String name, String status,Integer weight) {
+                    Long shelvesId, Long storgeTypeId, String no, String name, String status,Integer weight, Long targetId) {
         this.id = id;
         this.createTime = createTime;
         this.updateUser = updateUser;
@@ -175,6 +180,7 @@ public class Storge extends Entity<Long> {
         this.name = name;
         this.status = status;
         this.weight = weight;
+        this.targetId = targetId;
     }
 
 }

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

@@ -110,4 +110,13 @@ public interface DictionaryKey {
         }
     };
 
+    //设备关联线边库
+    Map<String, String> YJ_ZONE_XBK = new HashMap<String, String>(){
+        {
+            put("1", "舱体线边库");
+            put("2", "框体线边库");
+            put("3", "保障中心线边库");
+        }
+    };
+
 }