فهرست منبع

新增resourceCategory字段和优化部分代码
新增设备处理接口

oyq28 4 سال پیش
والد
کامیت
9a4a8bc793

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

@@ -29,7 +29,13 @@ import com.github.zuihou.business.productionReadyCenter.service.AutoNodeService;
 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.entity.ZZoneProductionresource;
+import com.github.zuihou.business.productionResourceCenter.service.NodeOperationService;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.business.productionResourceCenter.service.ZZoneProductionresourceService;
+import com.github.zuihou.business.productionResourceCenter.service.impl.AGVNodeServiceImpl;
+import com.github.zuihou.business.productionResourceCenter.service.impl.MachineNodeServiceImpl;
+import com.github.zuihou.business.productionResourceCenter.service.impl.RobotNodeServiceImpl;
 import com.github.zuihou.business.util.MsgUtil;
 import com.github.zuihou.business.websocket.WebSocketServer;
 import com.github.zuihou.common.constant.BizConstant;
@@ -38,7 +44,12 @@ import com.github.zuihou.common.constant.DictionaryKey;
 import com.github.zuihou.common.util.StringUtil;
 import com.github.zuihou.context.BaseContextHandler;
 import com.github.zuihou.database.mybatis.conditions.Wraps;
+import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
+import com.github.zuihou.tenant.entity.Module;
+import com.github.zuihou.tenant.entity.Productionresource;
+import com.github.zuihou.tenant.service.ModuleService;
 import com.github.zuihou.tenant.service.ProductionresourceService;
+import com.google.common.collect.Maps;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -107,6 +118,14 @@ public class TaskWorkNode {
     @Autowired
     private MsgUtil msgUtil;
 
+    @Autowired
+    private ZZoneProductionresourceService zZoneProductionresourceService;
+
+    @Autowired
+    private ModuleService  moduleService;
+
+    private NodeOperationService nodeOperationService;
+
     private String url = "http://127.0.0.1:8764/task/testTask";
 
     private String plcURL ="http://192.168.170.202:8089";
@@ -165,6 +184,8 @@ public class TaskWorkNode {
                     }
                     //获取每个节点对应的执行地址
                     String autoProgrameUrl = getInterfaceUrl(taskNode);
+                    //判断节点设备类型
+                    String[] category = getResourceCategory(taskNode.getResourceId().toString());
 
                     //把当前节点存放缓存
                     msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE + "_" + task.getResourceId(), taskNode.getAutoNode().getId()) ;
@@ -197,12 +218,25 @@ public class TaskWorkNode {
                             //不用调接口,直接返回成功
                             msgUtil.redis_set(CacheKey.TASK_CURRENT_NODE_STATUS + "_" + taskNode.getId(), "0");
                         } else {
-                            Map queryMap = new HashMap();
+                            Map queryMap = Maps.newHashMap();
                             queryMap.put("bizType",bizType);
                             queryMap.put("carryType",carryType);
                             if(j.containsKey(taskNode.getId()+"count")){
                                 queryMap.put(taskNode.getId()+"count",j.getString(taskNode.getId()+"count"));
                             }
+
+                            if("1" == category[0]){
+                                nodeOperationService = new MachineNodeServiceImpl();
+                                queryMap.put("zonId",  category[1]);
+                                queryMap.put("categoryName",  category[2]);
+                                nodeOperationService.initResource(taskNode, task, queryMap);
+                            }else if("2" == category[0]){
+                                nodeOperationService = new AGVNodeServiceImpl();
+                            }else if("3" == category[0]){
+                                nodeOperationService = new RobotNodeServiceImpl();
+                            }
+
+
                             //运行条件验证
                             Map conMap = checkCon(taskNode, task, queryMap);
                             //组装接口参数
@@ -258,6 +292,13 @@ public class TaskWorkNode {
         return autoProgrameUrl;
     }
 
+    private String[] getResourceCategory(String resourceId){
+        Productionresource productionresource = productionresourceService.getOne(new QueryWrap<Productionresource>().eq("id", resourceId));
+        ZZoneProductionresource zZoneProductionresource = zZoneProductionresourceService.getOne(new QueryWrap<ZZoneProductionresource>().eq("resource_id", productionresource.getId()));
+        Module module = moduleService.getById(new QueryWrap<Module>().eq("id", productionresource.getModuleId()));
+        return new String[]{productionresource.getResourcesCategory(), zZoneProductionresource.getZoneId().toString(), module.getName()};
+    }
+
     /**
      * 生成请求参数
      *

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

@@ -5,8 +5,8 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.github.zuihou.authority.service.common.ParameterService;
 import com.github.zuihou.base.R;
+import com.github.zuihou.base.service.SuperServiceImpl;
 import com.github.zuihou.business.DemoLine.DemoCacheKey;
 import com.github.zuihou.business.DemoLine.DemoLineConstant;
 import com.github.zuihou.business.edgeLibrary.dao.StockInfoMapper;
@@ -19,8 +19,6 @@ import com.github.zuihou.business.operationManagementCenter.dao.*;
 import com.github.zuihou.business.operationManagementCenter.dto.TaskNodeCallBackDTO;
 import com.github.zuihou.business.operationManagementCenter.entity.*;
 import com.github.zuihou.business.operationManagementCenter.service.*;
-import com.github.zuihou.base.service.SuperServiceImpl;
-
 import com.github.zuihou.business.productionReadyCenter.dao.AutoNodeLogMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.AutoNodeMapper;
 import com.github.zuihou.business.productionReadyCenter.dao.BBomMapper;
@@ -32,7 +30,6 @@ import com.github.zuihou.business.productionResourceCenter.service.Productionres
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.business.util.DynamicRabbitMq;
 import com.github.zuihou.business.util.MsgUtil;
-import com.github.zuihou.business.websocket.WebSocketServer;
 import com.github.zuihou.common.constant.BizConstant;
 import com.github.zuihou.common.constant.CacheKey;
 import com.github.zuihou.common.constant.CodeRuleModule;
@@ -50,16 +47,13 @@ import lombok.extern.slf4j.Slf4j;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.stereotype.Service;
-import org.springframework.web.client.RestTemplate;
 
 import java.text.NumberFormat;
 import java.util.*;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
-import static com.github.zuihou.common.constant.CacheKey.RESOURCE;
 import static com.github.zuihou.utils.BizAssert.isFalse;
 import static java.util.stream.Collectors.groupingBy;
 
@@ -143,18 +137,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     @Autowired
     private StockInfoMapper stockInfoMapper;
 
-    @Autowired
-    private RestTemplate restTemplate;
-
     @Autowired
     private TTaskMapper taskMapper;
 
     @Autowired
     private AutoNodeLogMapper autoNodeLogMapper;
 
-    @Autowired
-    private ParameterService parameterService;
-
     @Autowired
     private OrderMapper orderMapper;
 

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

@@ -25,6 +25,7 @@ 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.service.CodeRuleService;
+import com.google.common.collect.Maps;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -509,7 +510,7 @@ public class TaskServiceImpl extends SuperServiceImpl<TTaskMapper, TTask> implem
     @Override
     public Map<String,Integer> getTaskCount(){
         Map<String,String> map = baseMapper.getTaskDdCount();
-        Map<String,Integer> entryMap = new HashMap<>();
+        Map<String,Integer> entryMap = Maps.newHashMap();
         for(Map.Entry<String,String> entry: map.entrySet()){
             Object object = entry.getValue();
             entryMap.put(entry.getKey(),Integer.parseInt(String.valueOf(object)));

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

@@ -1,6 +1,11 @@
 package com.github.zuihou.business.productionResourceCenter.service;
 
 
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+
+import java.util.Map;
+
 /**
  * <p>
  * 业务接口
@@ -12,4 +17,15 @@ package com.github.zuihou.business.productionResourceCenter.service;
  */
 public interface NodeOperationService {
 
+    public void  initResource(TaskNode taskNode, TTask task, Map dataMap);
+
+    public boolean checkCondition(TaskNode taskNode);
+
+    public void operation(TaskNode taskNode);
+
+    public boolean confirmStatus(TaskNode taskNode);
+
+    public void move();
+
+    public void storage();
 }

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

@@ -0,0 +1,45 @@
+package com.github.zuihou.business.productionResourceCenter.service.impl;
+
+
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+import com.github.zuihou.business.productionResourceCenter.service.NodeOperationService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+@Slf4j
+@Service
+public class AGVNodeServiceImpl implements NodeOperationService {
+
+    @Override
+    public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
+
+    }
+
+    @Override
+    public boolean checkCondition(TaskNode taskNode) {
+        return false;
+    }
+
+    @Override
+    public void operation(TaskNode taskNode) {
+
+    }
+
+    @Override
+    public boolean confirmStatus(TaskNode taskNode) {
+        return false;
+    }
+
+    @Override
+    public void move() {
+
+    }
+
+    @Override
+    public void storage() {
+
+    }
+}

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

@@ -0,0 +1,67 @@
+package com.github.zuihou.business.productionResourceCenter.service.impl;
+
+
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+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 lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.Map;
+
+@Slf4j
+@Service
+public class MachineNodeServiceImpl implements NodeOperationService {
+
+    @Autowired
+    private ProductionresourcePositionService productionresourcePositionService;
+
+    @Override
+    public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
+
+        Map map = productionresourcePositionService.getProductionresourcePositionMap();
+        List<ProductionresourcePosition> productionresourcePositionList = (List<ProductionresourcePosition>)map.get((long)taskNode.getResourceId());
+
+        //获取种类
+        String categoryName = dataMap.get("categoryName").toString();
+        switch(categoryName){
+            case "上下料站" :   break;
+            case "WMS" :       break;
+            case "打标机" :     break;
+            case "smu50" :     break;
+            case "清洗烘干机" :     break;
+            case "三坐标检测仪" :     break;
+
+        }
+
+    }
+
+    @Override
+    public boolean checkCondition(TaskNode taskNode) {
+        return false;
+    }
+
+    @Override
+    public void operation(TaskNode taskNode) {
+
+    }
+
+    @Override
+    public boolean confirmStatus(TaskNode taskNode) {
+        return false;
+    }
+
+    @Override
+    public void move() {
+
+    }
+
+    @Override
+    public void storage() {
+
+    }
+}

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

@@ -0,0 +1,45 @@
+package com.github.zuihou.business.productionResourceCenter.service.impl;
+
+
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
+import com.github.zuihou.business.productionResourceCenter.service.NodeOperationService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.util.Map;
+
+@Slf4j
+@Service
+public class RobotNodeServiceImpl implements NodeOperationService {
+
+    @Override
+    public void initResource(TaskNode taskNode, TTask task, Map dataMap) {
+
+    }
+
+    @Override
+    public boolean checkCondition(TaskNode taskNode) {
+        return false;
+    }
+
+    @Override
+    public void operation(TaskNode taskNode) {
+
+    }
+
+    @Override
+    public boolean confirmStatus(TaskNode taskNode) {
+        return false;
+    }
+
+    @Override
+    public void move() {
+
+    }
+
+    @Override
+    public void storage() {
+
+    }
+}

+ 2 - 1
imcs-admin-boot/imcs-tenant-biz/src/main/resources/mapper_tenant/base/defaults/ProductionresourceMapper.xml

@@ -19,6 +19,7 @@
         <result column="status" jdbcType="VARCHAR" property="status"/>
         <result column="remark" jdbcType="VARCHAR" property="remark"/>
         <result column="resources_type" jdbcType="VARCHAR" property="resourcesType"/>
+        <result column="resources_category" jdbcType="VARCHAR" property="resourcesCategory"/>
         <result column="ip" jdbcType="VARCHAR" property="ip"/>
         <result column="port" jdbcType="VARCHAR" property="port"/>
     </resultMap>
@@ -26,7 +27,7 @@
     <!-- 通用查询结果列 -->
     <sql id="Base_Column_List">
         id,create_time,create_user,update_time,update_user,
-        tenant_id, productionline_id, box_id, type, category, module_id, name, code, status, remark, resources_type,lineDesc,moduleDesc,tenantDesc,pic,
+        tenant_id, productionline_id, box_id, type, category, module_id, name, code, status, remark, resources_type,resources_category,lineDesc,moduleDesc,tenantDesc,pic,
         ip,port
     </sql>
 

+ 9 - 0
imcs-admin-boot/imcs-tenant-entity/src/main/java/com/github/zuihou/tenant/entity/Productionresource.java

@@ -164,6 +164,15 @@ public class Productionresource extends Entity<Long> {
     @Excel(name = "生产资源类型(1-企业管理中的 2-全部资源管理)")
     private String resourcesType;
 
+    /**
+     * 生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)
+     */
+    @ApiModelProperty(value = "生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)")
+    @Length(max = 4, message = "生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)长度不能超过4")
+    @TableField(value = "resources_category", condition = LIKE)
+    @Excel(name = "生产资源种类(1-基础机器类 2-ARV搬运类 3-机器人操作类)")
+    private String resourcesCategory;
+
     /**
      * IP
      */