Forráskód Böngészése

更新设备操作节点

oyq28 3 éve
szülő
commit
54071d18ba

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

@@ -235,14 +235,6 @@ public class AGVNodeServiceImpl implements NodeOperationService {
         return false;
     }
 
-    @Override
-    public void move(Storge fromStorage, Storge toStorage) {
-
-    }
-
-    public void storage() {
-
-    }
 
     /**
      *

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

@@ -4,6 +4,7 @@ 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.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.edgeLibrary.entity.Storge;
@@ -23,9 +24,12 @@ import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCo
 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.constant.DictionaryKey;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
+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 lombok.extern.slf4j.Slf4j;
 import org.apache.commons.compress.utils.Lists;
@@ -37,6 +41,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
 
 import static java.util.stream.Collectors.groupingBy;
 
@@ -71,8 +76,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
     @Autowired
     private BomProcedureProgramMapper bomProcedureProgramMapper;
 
-    //关联接驳位
-    private String[] jbwarr = null;
+    @Autowired
+    private ModuleService moduleService;
 
     private Map<String, Object> map = Maps.newHashMap();
 
@@ -85,35 +90,64 @@ public class MachineNodeServiceImpl implements NodeOperationService {
 
     private String ZK_ip_rxx = "192.168.170.71";
 
+    private String[] deviceArr, jbwArr;
+
+    private String[] xbkArr;
+
+    private List<ProductionresourcePosition> xbkList;
+
+    private List<ProductionresourcePosition> deviceList;
+
     @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);
+                deviceList = productionresourcePositionService.getFreeProductionresourcePositionByNos(deviceArr);
+            }
+        }
+        //初始化默认设定(后期动态获取)
+        xbkArr = dataMap.get("bizType")!=null? new String[]{dataMap.get("bizType").toString()}: new String[]{DemoLineConstant.NODE_RESOURCE_ZLZX_XBK};
+        xbkList = productionresourcePositionService.getFreeProductionresourcePositionByNos(xbkArr);
     }
 
     @Override
     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();
+//        //业务类型
+//        String bizType = dataMap.get("bizType") == null ? "" : dataMap.get("bizType").toString();
+//        //具体的搬运类型
+//        String carryType = dataMap.get("carryType") == null ? "" : dataMap.get("carryType").toString();
+//
+//        map.put("taskNode", taskNode);
+//        map.put("task", task);
+//        map.put("bizType", bizType);
+//
+//        String moduleName = dataMap.get("moduleName").toString();
+//        List<ModuleInstruction> instructions = dataMap.get("instructions") == null ? Lists.newArrayList() : (List<ModuleInstruction>)dataMap.get("instructions");
+//        ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
+//        String functionName = resourceAutoCode.getCommand();
 
-        map.put("taskNode", taskNode);
-        map.put("task", task);
-        map.put("bizType", bizType);
-
-        String moduleName = dataMap.get("moduleName").toString();
-        List<ModuleInstruction> instructions = dataMap.get("instructions") == null ? Lists.newArrayList() : (List<ModuleInstruction>)dataMap.get("instructions");
         ResourceAutoCode resourceAutoCode = taskNode.getAutoNode();
         String functionName = resourceAutoCode.getCommand();
+        String moduleName = dataMap.get("moduleName") == null ? "" : dataMap.get("moduleName").toString();
+
+        ProductionresourcePosition productionresourcePosition = this.logical(deviceList, true);
+        boolean bool =  productionresourcePosition!=null ? true : false;
+        if(!bool){
+            map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
+            return map;
+        }
 
         switch (moduleName) {
             case "WMS":
                 //WMS出库
                 if ("WMS_OUT".equals(functionName)) {
-                    jbwarr = new String[]{DemoLineConstant.JBW_A, DemoLineConstant.JBW_B};
+                    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);
+                    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)) {
                         //获取下一个节点,用于锁定
@@ -169,8 +203,8 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     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));
+                    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());
@@ -201,7 +235,6 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     map.put("result", true);
                 }
 
-
                 break;
             case "smu50":
                  if ("SMU50_FILE".equals(functionName)) {
@@ -252,7 +285,6 @@ public class MachineNodeServiceImpl implements NodeOperationService {
                     map.put("result", true);
                 }
 
-
                 break;
             case "清洗烘干机":
                 if ("RX_CLEAN".equals(functionName)) {
@@ -345,12 +377,35 @@ public class MachineNodeServiceImpl implements NodeOperationService {
         return false;
     }
 
-    @Override
-    public void move(Storge fromStorage, Storge toStorage) {
+    /**
+     *  设备动态逻辑判断处理
+     *
+     * @param deviceList
+     * @param useXbk
+     * @return
+     */
+    private ProductionresourcePosition logical(List<ProductionresourcePosition> deviceList, boolean useXbk){
+        //设备不存在
+        if(deviceList == null || deviceList.size() == 0){
+            map.put("msg", DictionaryKey.NodeException.NO_RESOURCE);
+            return null;
+        }
+        deviceList = deviceList.stream().filter(position->position.getStatus()=="1" && position.getLockStatus()=="1").collect(Collectors.toList());
+        //设备被锁定
+        if(deviceList.size() == 0) {
+            if(useXbk){
+                if(xbkList.size() == 0){
+                    map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
+                    return null;
+                }
+                return xbkList.get(0);
+            }
+            map.put("msg", DictionaryKey.NodeException.RESOURCE_LOCK);
+            return null;
+        }
+        //设备托盘、夹具条件不满足  待定
 
+        return deviceList.get(0);
     }
 
-    public void storage() {
-
-    }
 }

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

@@ -1391,15 +1391,6 @@ public class RobotNodeServiceImpl implements NodeOperationService {
         return false;
     }
 
-    @Override
-    public void move(Storge fromStorage, Storge toStorage) {
-
-    }
-
-    public void storage() {
-
-    }
-
     public ProductionresourcePosition getResourcePosition(TaskNode taskNode) {
         List<ProductionresourcePosition> resourcePositionList = productionresourcePositionMapper.selectList(Wraps.<ProductionresourcePosition>lbQ().eq(ProductionresourcePosition::getResourceId, taskNode.getResourceId()));
         ProductionresourcePosition productionresourcePosition = null;