Kaynağa Gözat

节点逻辑判断修改和补充注释

oyq28 3 yıl önce
ebeveyn
işleme
d1263db651

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

@@ -64,6 +64,8 @@ public class AGVNodeServiceImpl implements NodeOperationService {
 
     @Override
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
+        //初始化接驳位数据
+
         //初始化线边库位
         productionresourcePosition = getResourcePosition(taskNode);
 
@@ -80,9 +82,10 @@ public class AGVNodeServiceImpl implements NodeOperationService {
         map.put("task", task);
         map.put("bizType", bizType);
 
+        //AGV设备操作关联接驳位(起点和终点都是接驳位库位),接驳位占用暂存在线边库
 
         String moduleName = dataMap.get("moduleName").toString();
-        List<ModuleInstruction> instructions = dataMap.get("instructions") == null ? Lists.newArrayList() : (List<ModuleInstruction>)dataMap.get("instructions");
+        //List<ModuleInstruction> instructions = dataMap.get("instructions") == null ? Lists.newArrayList() : (List<ModuleInstruction>)dataMap.get("instructions");
         ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
         String functionName = resourceAutoCode.getCommand();
 

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

@@ -29,10 +29,12 @@ import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.common.constant.DictionaryKey;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
 import com.github.zuihou.tenant.entity.Module;
 import com.github.zuihou.tenant.entity.ModuleInstruction;
 import com.github.zuihou.tenant.service.ModuleService;
 import com.google.common.collect.Maps;
+import io.swagger.models.auth.In;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -43,6 +45,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicInteger;
 import java.util.stream.Collectors;
 
 import static java.util.stream.Collectors.groupingBy;
@@ -104,16 +107,17 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
     @Override
     public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
+        //获取当前设备模型
         String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
         if(StringUtil.isNotEmpty(moduleName)) {
-            List<Module> modules = moduleService.list(new QueryWrapper<Module>().like("name", moduleName));
-            if(modules.size()>0){
-                deviceArr = modules.stream().map(Module::getNo).toArray(String[]::new);
+            Module module = moduleService.getOne(new LbqWrapper<Module>().eq(Module::getName, moduleName).eq(Module::getStatus, 1));
+            if(null != module){
+                deviceArr = new String[]{module.getNo()};
                 deviceList = productionresourcePositionService.getFreeProductionresourcePositionByNos(deviceArr);
             }
         }
-        //初始化默认设定(后期动态获取)
-        xbkArr = dataMap.get("bizType")!=null? new String[]{dataMap.get("bizType").toString()}: new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
+        //初始化关联线边库(依据产线ID获取)
+        xbkArr = new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
         xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(xbkArr);
     }
 
@@ -133,6 +137,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 //        ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
 //        String functionName = resourceAutoCode.getCommand();
 
+        //生产设备操作不关联接驳位,资源占用只暂存在线边库
+
         ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
         String functionName = resourceAutoCode.getCommand();
         String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
@@ -153,104 +159,19 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         // 设备占用 当前节点锁定线边库
         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);
-            //锁定当前节点与线边库
+            //storge.setTargetId(task.getResourceId());
+            //锁定当前节点与线边库库位
             storgeService.lockStorge(storge, taskNode.getId());
+            //更新零件节点的库位信息————workpiece
+
             map.put("result", false);
             return map;
         }
 
         switch (moduleName) {
-            // 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;
-            case "上下料站":
-                //同步等待上下料手动操作是否完成
-                //boolean isCompleted = false;
-                //Storge startStore = workpieceService.getWorkPieceStock(taskNode.getId(),false);
-                //实现页面操作,取消轮询等待
-                map.put("result", true);
-                break;
 
             case "打标机":
                 if("print".equals(functionName)){
@@ -259,7 +180,9 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     map.put(DemoLineConstant.DEMOLINE_BIZ_TYPE, "print");
                     //获取打标唯一码
                     String unionCode = workpieceService.getUnionCode(task.getCompleteBatchNo());
-                    map.put("Data", unionCode);//打标内容
+                    JSONObject data = new JSONObject();
+                    data.put("labelContent", unionCode);
+                    map.put("data", data);//打标内容
                     map.put("result", true);
                 }
 
@@ -282,7 +205,7 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
                     }
                     map.put("result", true);
-                } else if ("SMU50_EXEC".equals(functionName)) {
+                } else if ("execProgram".equals(functionName)) {
                     //执行程序,分多次执行
                     String zoneNo = msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()) == null ? ""
                             : msgUtil.redis_get(DemoCacheKey.DEMOLINE_WORKOP_ZONE + task.getCompleteBatchNo()).toString();
@@ -368,8 +291,6 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     BomProcedure procedure = bomProcedureService.getById(task.getProcedureId());
 
                     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);

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

@@ -95,6 +95,13 @@ public class OtherNodeServiceImpl implements NodeOperationService {
             return map;
         }
         switch(moduleName){
+            case "上下料站":
+                //同步等待上下料手动操作是否完成
+                //boolean isCompleted = false;
+                //Storge startStore = workpieceService.getWorkPieceStock(taskNode.getId(),false);
+                //实现页面操作,取消轮询等待
+                map.put("result", true);
+                break;
             case "WMS":
                 if ("WMS_OUT".equals(command)) {
                     ProductionresourcePosition productionresourcePosition = this.logical(jbwList, false);
@@ -191,6 +198,9 @@ public class OtherNodeServiceImpl implements NodeOperationService {
             map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
             return null;
         }
+        //动态判定库位数量限制(N-1)
+        //int current_running_num = taskNodeService.
+
         deviceList = deviceList.stream().filter(position->position.getStatus()=="1" && position.getLockStatus()=="1").collect(Collectors.toList());
         //设备被锁定
         if(deviceList.size() == 0) {

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

@@ -111,11 +111,13 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 deviceList = productionresourcePositionService.getFreeProductionresourcePositionByIds(deviceArr);
             }
         }
+        //获取机器人操作线边库
         xbkArr = dataMap.get("robotType")!=null? new String[]{
                     DictionaryKey.YJ_ZONE_XBK.get(dataMap.get("robotType").toString())
                 }: new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
         xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(xbkArr);
         //jbwArr = modules.stream().map(Module::getNo).toArray(String[]::new);
+        // 获取机器人抓取、放可操作的接驳位(依据产线  待定)
         List<Productionresource> dataList = productionresourceService.list(new QueryWrapper<Productionresource>().like("name", robotType));
         if(dataList.size()>0) {
             jbwArr = dataList.stream().map(Productionresource::getId).toArray(String[]::new);
@@ -164,18 +166,20 @@ public class RobotNodeServiceImpl implements NodeOperationService {
                 //操作质量中心边库 具有取、移动、放三种指令
                   //取放上下料站
                   //取放三坐标
-
+                map.put("deviceUrl", ZK_ip_zlzx);
                 break;
             case "柔性线机器人":
                 //操作柔性线边库 具有取、移动、放三种指令
                  //取放加工设备  设备存在缓存位
                 String count = dataMap.get(taskNode.getId().toString() + "count") == null ? "0" : dataMap.get(taskNode.getId().toString() + "count").toString();
                 map = this.commandHandle(map, startStore, jqrStorge, functionName, count);
+                map.put("deviceUrl", ZK_ip_rxx);
                 break;
             case "智能单元机器人":
                 //操作智能单元线边库 具有取、移动、放三种指令
                 //取放加工设备 无缓存位处理
                 map = this.commandHandle(map, startStore, jqrStorge, functionName);
+                map.put("deviceUrl", ZK_ip_zndy);
                 break;
             case "舱体线机器人":
                 //操作舱体线边库 具有取、移动、放三种指令
@@ -193,6 +197,7 @@ public class RobotNodeServiceImpl implements NodeOperationService {
 
                 break;
         }
+
         return map;
     }