Bläddra i källkod

优化逻辑代码(完成度70%)
后续持续改进

oyq28 3 år sedan
förälder
incheckning
ff90c52c04

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 406 - 1604
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/mq/TaskWorkNode.java


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

@@ -192,6 +192,11 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return baseMapper.pageList(page, expectStartTime, expectEndTime, wrapper);
     }
 
+    /**
+     * 保存节点
+     * @param taskBatchNo
+     * @param sysUser
+     */
     @Override
     public void saveTaskNodeByTaskBatchNo(String taskBatchNo, SysUser sysUser) {
         //生成节点任务
@@ -330,6 +335,11 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return stockId;
     }
 
+    /**
+     * 上下料操作
+     * @param map
+     * @return
+     */
 
     @Override
     public TaskNode finishTaskNode(Map map) {
@@ -448,6 +458,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
     }
 
+    /**
+     * 质检操作
+     * @param map
+     * @param user
+     * @return
+     */
     @Override
     public TaskNode finishTestTaskNode(Map map, SysUser user) {
         Map taskNodeMap = (Map) map.get("taskNode");
@@ -515,6 +531,8 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
 
     /**
+     * 工序材料库存
+     *
      * @param autoNode
      */
     @Override
@@ -575,6 +593,11 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return R.success(uniqueCode);
     }
 
+    /**
+     * 工序托盘库存
+     *
+     * @param autoNode
+     */
     @Override
     public R<String> BomProcedureTrayStock(TaskNode taskNode, AutoNode autoNode, TTask task, String uniqueCode) {
         //如果没有分配到资源,则不做出入库,这种情况基本是异常情况
@@ -666,6 +689,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return R.success("");
     }
 
+    /**
+     * 任务节点过程分析
+     *
+     * @param taskNode
+     * @return
+     */
     @Override
     public Map getTaskNodeProcessAnalysis(TaskNode taskNode) {
         Map map = new HashMap();
@@ -712,6 +741,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return map;
     }
 
+    /**
+     * 获取节点质检结果
+     *
+     * @param taskNode
+     * @return
+     */
     @Override
     public Map getTaskTest(TaskNode taskNode) {
         Map map = new HashMap();
@@ -746,6 +781,14 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return map;
     }
 
+    /**
+     *  获取工序材料
+     *
+     * @param meterialList
+     * @param task
+     * @param taskNode
+     * @return
+     */
     @Override
     public List<BomProcedureMeterial> packageProcedureMeterialList(List<BomProcedureMeterial> meterialList, TTask task, TaskNode taskNode) {
         //查询原材料唯一码
@@ -775,6 +818,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return meterialList;
     }
 
+    /**
+     * 验证材料
+     *
+     * @param bean
+     * @return
+     */
     @Override
     public String checkMeterialResult(TaskNode bean) {
         //验证,必须有一个不为空,验证的其中一个
@@ -815,7 +864,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return "此码在当前库位中";
     }
 
-
+    /**
+     * 获取任务节点库存
+     *
+     * @param bean
+     * @return
+     */
     @Override
     public List<StockInfo> getTaskNodeStockList(TaskNode bean) {
         //最后返回
@@ -1010,6 +1064,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         return storgeId;
     }
 
+    /**
+     * 任务节点回调处理
+     *
+     * @param bean
+     * @return
+     */
     @Override
     public String taskNodeCallback(TaskNodeCallBackDTO bean) {
         log.info("回调参数======================" + JSONObject.toJSONString(bean));
@@ -1076,6 +1136,15 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         msgUtil.pushToNextMq(taskNode, task, taskNodeList, n, callBackJson);
     }
 
+    /**
+     * 更改节点状态
+     * @param taskNode
+     * @param task
+     * @param taskNodeList
+     * @param lg
+     * @param callBackJson
+     * @param r
+     */
 
     public void updateBizStatus(TaskNode taskNode, TTask task, List<TaskNode> taskNodeList, AAutoNodeLog lg, JSONObject callBackJson, R<String> r) {
         //如果是推送当前节点到mq(一个节点执行多次。就不需要更新数据状态)
@@ -1106,8 +1175,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
         task.setProcess(Double.parseDouble(numberFormat.format(100 * (float) (n + 1) / (float) taskNodeList.size())));
 
         if (this.isLastTask(n, taskNode, taskNodeList)) {
-            task.setStatus("3");
-            task.setEndTime(new Date());
+            task.setStatus("3").setEndTime(new Date());
             taskMapper.updateById(task);
             //推送
             //删除正在执行的缓存

+ 5 - 4
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/NodeOperationService.java

@@ -1,6 +1,8 @@
 package com.github.zuihou.business.productionResourceCenter.service;
 
 
+
+import com.github.zuihou.business.edgeLibrary.entity.Storge;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 
@@ -19,13 +21,12 @@ public interface NodeOperationService {
 
     public void  initResource(TaskNode taskNode, TTask task, Map dataMap);
 
-    public boolean checkCondition(TaskNode taskNode);
+    public Map checkCondition(TaskNode taskNode, TTask task, Map<String, Object> dataMap);
 
-    public void operation(TaskNode taskNode);
+    public void operation(Map<String, Object> map);
 
     public boolean confirmStatus(TaskNode taskNode);
 
-    public void move();
+    public void move(Storge fromStorge, Storge toStorage);
 
-    public void storage();
 }

+ 191 - 5
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/AGVNodeServiceImpl.java

@@ -1,30 +1,202 @@
 package com.github.zuihou.business.productionResourceCenter.service.impl;
 
 
+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.edgeLibrary.entity.Storge;
+import com.github.zuihou.business.edgeLibrary.service.StorgeService;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+import com.github.zuihou.business.operationManagementCenter.service.TaskNodeService;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
+import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
 import com.github.zuihou.business.productionResourceCenter.service.NodeOperationService;
+import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.common.constant.BizConstant;
+import com.github.zuihou.common.util.StringUtil;
+import com.github.zuihou.database.mybatis.conditions.Wraps;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import com.github.zuihou.business.util.MsgUtil;
 
 @Slf4j
 @Service
 public class AGVNodeServiceImpl implements NodeOperationService {
 
+    @Autowired
+    private ProductionresourcePositionMapper productionresourcePositionMapper;
+
+    @Autowired
+    private StorgeService storgeService;
+
+    @Autowired
+    private ProductionresourcePositionService productionresourcePositionService;
+
+    @Autowired
+    private TaskNodeService taskNodeService;
+
+    @Autowired
+    private MsgUtil msgUtil;
+
+    private ProductionresourcePosition productionresourcePosition;
+    private String zoneNo;
+    private String[] jbwarr = null;
+
+
     @Override
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
+        //初始化线边库位
+        productionresourcePosition = getResourcePosition(taskNode);
 
     }
 
     @Override
-    public boolean checkCondition(TaskNode taskNode) {
-        return false;
+    public Map checkCondition(TaskNode taskNode, TTask task, Map<String, Object> dataMap) {
+        //业务类型
+        String bizType = dataMap.get("bizType") == null ? "" : dataMap.get("bizType").toString();
+        //具体的搬运类型
+        String carryType = dataMap.get("carryType") == null ? "" : dataMap.get("carryType").toString();
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("taskNode", taskNode);
+        map.put("task", task);
+        map.put("bizType", bizType);
+
+        if (BizConstant.MQ_TASK_NODE_TYPE_COMMON.equals(bizType)) {
+            if (DemoLineConstant.DEMOLINE_OP01_02.equals(taskNode.getNodeNo())) {
+                //agv从wms接驳口A取料运到质量中心的接驳位B或C
+                //节点2的任务都在节点1被锁定过了,只要从缓存拿出来对应的值即可
+                Storge jbwAstorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo());
+                //2、取出接驳位
+                Storge jbwstorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JBW + taskNode.getId().toString());
+                //3、把起始终点库位存放到map,用于接口
+                map.put("fromStorge", jbwAstorge);
+                map.put("toStorge", jbwstorge);
+                //这个节点没有需要验证的内容,都在前一个节点验证并且锁定了
+                map.put("result", true);
+                map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_CRK);
+                //4、记录机器人的库位,下一个步骤使用
+                msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), jbwstorge, 1, TimeUnit.DAYS);
+            }
+            else if (DemoLineConstant.DEMOLINE_OP01_08.equals(taskNode.getNodeNo())){
+                //agv运输到产线接驳位
+                //根据工件获取所在的生产单元(产线)
+                zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
+                        : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
+                if (DemoLineConstant.DEMOLINE_WORK_SPACE1.equals(zoneNo)) {//智能生产单元
+                    jbwarr = new String[] {DemoLineConstant.JBW_F, DemoLineConstant.JBW_G};
+                } else if (DemoLineConstant.DEMOLINE_WORK_SPACE2.equals(zoneNo)) {//柔性智能加工生产区
+                    jbwarr = new String[] {DemoLineConstant.JBW_H, DemoLineConstant.JBW_I};
+                }
+                //当前毛坯所预占的接驳位
+                Storge jbwFromStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_JBW_STORAGE + "_" + task.getCompleteBatchNo()) == null ? null : (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_JBW_STORAGE + "_" + task.getCompleteBatchNo());
+                //查询是否被锁定
+                Storge jbwdbStorge = storgeService.getById(jbwFromStorge.getId());
+
+                List<ProductionresourcePosition> jbwList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jbwarr);
+                //接驳位有空闲
+                if (CollectionUtil.isNotEmpty(jbwList) && "1".equals(jbwdbStorge.getLockStatus())) {
+                    map.put("fromStorge", jbwFromStorge);
+                    //锁定接驳位库位
+                    Storge jbwstorge = storgeService.getById(jbwList.get(0).getStorgeId());
+                    //锁定接驳位库位
+                    jbwstorge.setCompleteBatchNo(task.getCompleteBatchNo());
+                    storgeService.lockStorge(jbwstorge, taskNode.getId());
+                    TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
+                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JBW + nextTaskNode.getId(), jbwstorge, 1, TimeUnit.DAYS);
+                    //目的地为接驳位
+                    map.put("toStorge", jbwstorge);
+                    //出入库类型
+                    map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_PLATE_CRK);
+                    //记录产品流转到的库位
+                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_JBW_STORAGE + "_" + task.getCompleteBatchNo(), jbwstorge, 1, TimeUnit.DAYS);
+                }
+                //判断接驳位是否为空
+                map.put("result", (CollectionUtil.isNotEmpty(jbwList)));
+            }
+
+            else if (DemoLineConstant.DEMOLINE_OP05_01.equals(taskNode.getNodeNo())) {
+                //接驳位有一个为空
+                jbwarr = new String[] {DemoLineConstant.JBW_D, DemoLineConstant.JBW_E};
+                List<ProductionresourcePosition> jbwList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jbwarr);
+                if (jbwList != null && jbwList.size() > 0) {
+                    //取出前一步骤存放的上下料站库位
+                    Storge jbwFromStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_JBW_STORAGE + "_" + task.getCompleteBatchNo()) == null ? null : (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CIRCULATION_JBW_STORAGE + "_" + task.getCompleteBatchNo());
+                    map.put("fromStorge", jbwFromStorge);
+                    //锁定其中一个
+                    ProductionresourcePosition jbwp = jbwList.get(0);
+                    //预占库位为下个节点准备
+                    Storge jbwstorge = storgeService.getById(jbwp.getStorgeId());
+                    //锁定接驳位库位
+                    jbwstorge.setCompleteBatchNo(task.getCompleteBatchNo());
+                    storgeService.lockStorge(jbwstorge, taskNode.getId());
+                    TaskNode nextTaskNode = taskNodeService.getNextNTaskNode(taskNode, 1);
+                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JBW + nextTaskNode.getId(), jbwstorge, 1, TimeUnit.DAYS);
+                    //目的地为接驳位
+                    map.put("toStorge", jbwstorge);
+                    //出入库类型
+                    map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_PLATE_CRK);
+                    //记录产品流转到的库位
+//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" +task.getCompleteBatchNo(), jbwstorge, 1, TimeUnit.DAYS);
+                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_JBW_STORAGE + "_" + task.getCompleteBatchNo(), jbwstorge, 1, TimeUnit.DAYS);
+                }
+                map.put("result", (CollectionUtil.isNotEmpty(jbwList)));
+            }
+
+            else if (DemoLineConstant.DEMOLINE_OP06_04.equals(taskNode.getNodeNo())) {
+                //节点4的任务都在节点3被锁定过了,只要从缓存拿出来对应的值即可
+                //1、取出机器人
+               jbwarr = new String[] {DemoLineConstant.JBW_A};
+                List<ProductionresourcePosition> jbwAList = productionresourcePositionService.getFreeProductionresourcePositionByNos(jbwarr);
+                if (CollectionUtil.isNotEmpty(jbwAList)) {
+                    Storge jbwAstorge = storgeService.getById(jbwAList.get(0).getStorgeId());
+                    map.put("toStorge", jbwAstorge);
+                }
+                //临时这样写
+                Map queryMap = new HashMap();
+                String jbwarrB[] = {DemoLineConstant.JBW_B};
+                queryMap.put("codes", StringUtil.changeIdsArrToSubQueryStr(jbwarrB));
+                List<ProductionresourcePosition> jbwBList = productionresourcePositionMapper.getPPList(queryMap);
+                if (CollectionUtil.isNotEmpty(jbwBList)) {
+                    Storge jbwBstorge = storgeService.getById(jbwBList.get(0).getStorgeId());
+                    map.put("fromStorge", jbwBstorge);
+                }
+                map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_METERIAL_CRK);
+                map.put("result", true);
+            }
+        }
+        return map;
     }
 
     @Override
-    public void operation(TaskNode taskNode) {
+    public void operation(Map<String, Object> conMap) {
+        TaskNode taskNode = (TaskNode) conMap.get("taskNode");
+        TTask task = (TTask) conMap.get("task");
+        //业务类型
+        String bizType = conMap.get("bizType").toString();
+        //出入库类型
+        String stockType = conMap.get(DemoLineConstant.DEMOLINE_STOCK_TYPE) == null ? "" : conMap.get(DemoLineConstant.DEMOLINE_STOCK_TYPE).toString();
+
+        JSONObject jsonObject = new JSONObject();
+        JSONObject bizJsonObject = new JSONObject();
+        //
+        Storge fstorge = (Storge) conMap.get("fromStorge");
+        Storge tstorge = (Storge) conMap.get("toStorge");
+        jsonObject.put("start", fstorge.getPointId());
+        jsonObject.put("goal", tstorge.getPointId());
+        jsonObject.put("transferType", "agv");
+        //此数据用来业务回传
+        bizJsonObject.put("srcPosition", fstorge.getId().toString());
+        bizJsonObject.put("targetPostion", tstorge.getId().toString());
 
     }
 
@@ -34,12 +206,26 @@ public class AGVNodeServiceImpl implements NodeOperationService {
     }
 
     @Override
-    public void move() {
+    public void move(Storge fromStorage, Storge toStorage) {
 
     }
 
-    @Override
     public void storage() {
 
     }
+
+    /**
+     *
+     * 获取当前设备的库位
+     * @param taskNode
+     * @return
+     */
+    public ProductionresourcePosition getResourcePosition(TaskNode taskNode) {
+        List<ProductionresourcePosition> resourcePositionList = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId, taskNode.getResourceId()));
+        ProductionresourcePosition productionresourcePosition = null;
+        if (resourcePositionList != null && resourcePositionList.size() > 0) {
+            productionresourcePosition = resourcePositionList.get(0);
+        }
+        return productionresourcePosition;
+    }
 }

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

@@ -1,17 +1,38 @@
 package com.github.zuihou.business.productionResourceCenter.service.impl;
 
 
+import cn.hutool.core.collection.CollectionUtil;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.github.zuihou.business.DemoLine.DemoCacheKey;
+import com.github.zuihou.business.DemoLine.DemoLineConstant;
+import com.github.zuihou.business.edgeLibrary.entity.Storge;
+import com.github.zuihou.business.edgeLibrary.service.StorgeService;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 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.BomProcedureProgramGroupMapper;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedureProgramGroup;
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
 import com.github.zuihou.business.productionResourceCenter.service.NodeOperationService;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.business.util.MsgUtil;
+import com.github.zuihou.common.util.StringUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import static java.util.stream.Collectors.groupingBy;
 
 @Slf4j
 @Service
@@ -20,33 +41,332 @@ public class MachineNodeServiceImpl implements NodeOperationService {
     @Autowired
     private ProductionresourcePositionService productionresourcePositionService;
 
+    @Autowired
+    private StorgeService storgeService;
+
+    @Autowired
+    private TaskNodeService taskNodeService;
+
+    @Autowired
+    private MsgUtil msgUtil;
+
+    @Autowired
+    private ProductionresourcePositionMapper productionresourcePositionMapper;
+
+    @Autowired
+    private BomProcedureProgramGroupMapper bomProcedureProgramGroupMapper;
+
+    @Autowired
+    private WorkpieceService workpieceService;
+
+    @Autowired
+    private BomProcedureService bomProcedureService;
+
+    //关联线边库
+    private String[] zxzxXBKarr = null;
+
+    //关联接驳位
+    private String[] jbwarr = null;
+
+    private String ZK_ip_zlzx = "192.168.170.61";
+
+    //智能单元
+    private String ZK_ip_zndy = "192.168.170.81";
+
+    private String ZK_ip_rxx = "192.168.170.71";
+
+
     @Override
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
 
-        Map map = productionresourcePositionService.getProductionresourcePositionMap();
-        List<ProductionresourcePosition> productionresourcePositionList = (List<ProductionresourcePosition>)map.get((long)taskNode.getResourceId());
-
+        //Map map = productionresourcePositionService.getProductionresourcePositionMap();
+        //List<ProductionresourcePosition> productionresourcePositionList = (List<ProductionresourcePosition>)map.get((long)taskNode.getResourceId());
+        String functionName = dataMap.get("functionName").toString();
         //获取种类
-        String categoryName = dataMap.get("categoryName").toString();
-        switch(categoryName){
-            case "上下料站" :   break;
-            case "WMS" :       break;
-            case "打标机" :     break;
-            case "smu50" :     break;
-            case "清洗烘干机" :     break;
-            case "三坐标检测仪" :     break;
-
+        if ("WMS_OUT".equals(functionName)) {
+            this.zxzxXBKarr = new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
+            this.jbwarr = new String[]{DemoLineConstant.JBW_A, DemoLineConstant.JBW_B};
         }
 
+
     }
 
     @Override
-    public boolean checkCondition(TaskNode taskNode) {
-        return false;
+    public Map checkCondition(TaskNode taskNode, TTask task, Map<String, Object> dataMap) {
+        //业务类型
+        String bizType = dataMap.get("bizType") == null ? "" : dataMap.get("bizType").toString();
+        //具体的搬运类型
+        String carryType = dataMap.get("carryType") == null ? "" : dataMap.get("carryType").toString();
+
+        Map<String, Object> map = new HashMap<>();
+        map.put("taskNode", taskNode);
+        map.put("task", task);
+        map.put("bizType", bizType);
+
+        String categoryName = dataMap.get("categoryName").toString();
+        String functionName = dataMap.get("functionName").toString();
+
+        switch (categoryName) {
+            case "WMS":
+                //WMS出库
+                if ("WMS_OUT".equals(functionName)) {
+                    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();
+                    String jbwarr[] = {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 "上下料站":
+                //托盘夹具放入上下料站
+                if ("QSTATION_OUT".equals(functionName)) {
+                    //1、取出质量中心机器人
+                    Storge jqrStorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.JQR1 + taskNode.getId());
+                    //重新锁定一下机器人的库位,更新一下被锁定的业务ID(由于搬运拆成两个节点)
+                    //storgeService.lockStorge(jqrStorge, taskNode.getId());
+                    //2、取出上下料站
+                    Storge sxlzstorge = (Storge) msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.SXLZ + taskNode.getId());
+                    map.put("zkIp", ZK_ip_zlzx);
+                    //3、把起始终点库位存放到map,用于接口
+                    map.put("fromStorge", jqrStorge);
+                    map.put("toStorge", sxlzstorge);
+                    //出入库类型
+                    map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_TRAY_CRK);
+
+                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "putMaterial");
+                    map.put("Data", sxlzstorge);
+                    //这个节点没有需要验证的内容,都在前一个节点验证并且锁定了
+                    map.put("result", true);
+                    //4、记录机器人的库位,下一个步骤使用
+//                msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), sxlzstorge, 1, TimeUnit.DAYS);
+                }
+                else if ("QSTATION_OUT".equals(functionName)) {
+                    map.put("zkIp", ZK_ip_zndy);
+                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "putMaterial");
+                    //前序绑定的sum50
+                    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);
+                        map.put("Data", sum50Storge);
+                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), sum50Storge, 1, TimeUnit.DAYS);
+                    } else {
+                        //前序绑定的线边库
+                        Object xbkStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK + taskNode.getId());
+                        if (xbkStorge != null) {
+                            xbkStorge = (Storge) xbkStorge;
+                            //目的地为线边库
+                            map.put("toStorge", xbkStorge);
+                            map.put("Data", xbkStorge);
+                            //临时存放到了线边库的标志
+                            map.put(DemoLineConstant.DEMOLINE_XBKFLAG, "1");
+                            //临时存放到了智能单元的线边库
+                            map.put(DemoLineConstant.DEMOLINE_XBK_TYPE, DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK);
+                        }
+                    }
+                    map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
+                    //
+                    map.put("result", true);
+                }
+
+                break;
+
+            case "打标机":
+                if("DBJ_PRINT".equals(functionName)){
+                    //打标
+                    map.put("zkIp", ZK_ip_rxx);
+                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
+                    //获取打标唯一码
+                    String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
+                    map.put("Data", unionCode);//打标内容
+                    map.put("result", true);
+                }
+
+
+                break;
+            case "smu50":
+                if ("SMU50_IN".equals(functionName)) {
+                    map.put("zkIp", ZK_ip_zndy);
+                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "putMaterial");
+                    //前序绑定的sum50
+                    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);
+                        map.put("Data", sum50Storge);
+                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_CIRCULATION_STORAGE + "_" + task.getCompleteBatchNo(), sum50Storge, 1, TimeUnit.DAYS);
+                    } else {
+                        //前序绑定的线边库
+                        Object xbkStorge = msgUtil.redis_get(DemoCacheKey.DEMOLINE_CAMP + "_" + DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK + taskNode.getId());
+                        if (xbkStorge != null) {
+                            xbkStorge = (Storge) xbkStorge;
+                            //目的地为线边库
+                            map.put("toStorge", xbkStorge);
+                            map.put("Data", xbkStorge);
+                            //临时存放到了线边库的标志
+                            map.put(DemoLineConstant.DEMOLINE_XBKFLAG, "1");
+                            //临时存放到了智能单元的线边库
+                            map.put(DemoLineConstant.DEMOLINE_XBK_TYPE, DemoLineConstant.NODE_RESOURCE_ZNSCDY_XBK);
+                        }
+                    }
+                    map.put(DemoLineConstant.DEMOLINE_STOCK_TYPE, DemoLineConstant.DEMOLINE_STOCK_TYPE_ALL_CRK);
+                    //
+                    map.put("result", true);
+                }
+                else if ("SMU50_FILE".equals(functionName)) {
+                    Map queryMap = new HashMap<>();
+                    queryMap.put("procedureId", task.getProcedureId());
+                    queryMap.put("haveFile", "1");
+                    List<BomProcedureProgramGroup> bomProcedureProgramGroupList = bomProcedureProgramGroupMapper.getProgramGroupList(queryMap);
+                    List<Map<String, String>> fileList = new ArrayList<Map<String, String>>();
+                    bomProcedureProgramGroupList.forEach(i -> {
+                        Map<String, String> m = new HashMap<>();
+                        m.put("fileName", i.getSubmittedFileName());
+                        fileList.add(m);
+                    });
+                    if (fileList != null && fileList.size() > 0) {//先按一个处理
+                        String fileName = bomProcedureProgramGroupList.get(0).getSubmittedFileName();
+                        map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "uploadProgram");
+                        map.put("Data", JSONArray.parseArray(JSONObject.toJSONString(fileList)));
+                        msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo(), fileName, 1, TimeUnit.DAYS);
+
+                    }
+                    map.put("result", true);
+                }
+                else if ("SMU50_EXEC".equals(functionName)) {
+                    //执行程序,分多次执行
+                    String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
+                            : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
+
+//                if (DemoLineConstant.DEMOLINE_WORK_SPACE1.equals(zoneNo)) {
+//                    map.put("zkIp",ZK_ip_zndy);
+//                }else{
+//                    map.put("zkIp",ZK_ip_rxx);
+//                }
+                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "execProgram");
+                    //当前执行数量
+//                int currCount = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo()) == null ? 0 : Integer.parseInt(msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo()).toString());
+                    String fileName = msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()) == null ? "" : msgUtil.redis_get(DemoCacheKey.DEMOLINE_PROGRAME_NAMES + task.getCompleteBatchNo()).toString();
+                    String fileNames[] = fileName.split(",");
+//                if (currCount < fileNames.length) {
+//                    String uploadFileName = fileNames[currCount];
+//                    Map<String, String> m = new HashMap<>();
+//                    m.put("fileName", uploadFileName);
+//                    map.put("data", JSONArray.parseArray(JSONObject.toJSONString(m)));
+//                    map.put(DemoLineConstant.DEMOLINE_EXEPRO_FLAG, "1");
+//                    //当前执行数量
+//                    msgUtil.redis_set(DemoCacheKey.DEMOLINE_PROGRAME_CURRCOUNT + task.getCompleteBatchNo(), ++currCount, 1, TimeUnit.DAYS);
+//                }
+//                Map fileMap = new HashMap();
+//                fileMap.put("fileName", fileName);
+                    map.put("Data", fileName);
+                    map.put("result", true);
+                }
+
+
+                break;
+            case "清洗烘干机":
+                if ("RX_CLEAN".equals(functionName)) {
+                    //清洗,PLC接口
+                    map.put("zkIp", ZK_ip_rxx);
+                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "Clean");
+                    map.put("result", true);
+                }
+                break;
+            case "三坐标检测仪":
+                if ("SZB_CHECK".equals(functionName)) {
+                    map.put("zkIp", ZK_ip_zlzx);
+                    map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "testwork");
+                    //查出工序三坐标相关
+                    BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
+
+                    Map queryMap = new HashMap();
+                    String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
+                    queryMap.put("WorkId", unionCode);
+                    queryMap.put("WorkType", StringUtil.isNotEmpty(procedure.getProgramTestPrograme()) ? procedure.getProgramTestPrograme() : "1111");
+
+                    map.put("Data", JSONObject.toJSONString(queryMap));
+
+                    map.put("result", true);
+                }
+
+                break;
+        }
+
+        return map;
     }
 
     @Override
-    public void operation(TaskNode taskNode) {
+    public void operation(Map<String, Object> map) {
 
     }
 
@@ -56,11 +376,10 @@ public class MachineNodeServiceImpl implements NodeOperationService {
     }
 
     @Override
-    public void move() {
+    public void move(Storge fromStorage, Storge toStorage) {
 
     }
 
-    @Override
     public void storage() {
 
     }

Filskillnaden har hållts tillbaka eftersom den är för stor
+ 1154 - 3
imcs-admin-boot/imcs-business-biz/src/main/java/com/github/zuihou/business/productionResourceCenter/service/impl/RobotNodeServiceImpl.java


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

@@ -7,19 +7,16 @@ import com.github.zuihou.business.edgeLibrary.service.StockInfoService;
 import com.github.zuihou.business.operationManagementCenter.entity.TTask;
 import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
 import com.github.zuihou.business.operationManagementCenter.service.TaskService;
-import com.github.zuihou.business.operationManagementCenter.service.impl.TaskNodeServiceImpl;
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.business.websocket.WebSocketServer;
 import com.github.zuihou.common.constant.BizConstant;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.BeansException;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.ApplicationContext;
 import org.springframework.context.ApplicationContextAware;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Component;
-import org.springframework.web.client.RestTemplate;
 
 import javax.annotation.Resource;
 import java.util.HashMap;

Vissa filer visades inte eftersom för många filer har ändrats