浏览代码

保存taskNode的设备ID问题

oyq28 3 年之前
父节点
当前提交
8724518931

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

@@ -48,6 +48,7 @@ import com.github.zuihou.tenant.entity.ProductionlineUser;
 import com.github.zuihou.tenant.service.CodeRuleService;
 import com.github.zuihou.tenant.service.ProductionlineService;
 import com.github.zuihou.tenant.service.ProductionlineUserService;
+import com.github.zuihou.tenant.service.ProductionresourceService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
@@ -211,6 +212,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     private PlateMapper plateMapper;
 
 
+
     private static Logger logger = LoggerFactory.getLogger(TaskNodeServiceImpl.class);
 
     //获取子二级节点
@@ -287,7 +289,7 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
     /**
      *
-     * @param taskBatchNo计划ID
+     * @param taskBatchNo 计划ID
      * @param sysUser
      */
     @Override
@@ -329,7 +331,6 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 //                    taskNode.setAutoNode(autoNode).setAutoNodeCode(autoNode.getCode()).setCompleteBatchNo(t.getCompleteBatchNo())
 //                            .setNodeNo(autoNode.getNodeNo()).setExeStatus("1").setPrority(autoCode.getWeight());
                         taskNode.setTaskId(t.getId()).setOrderId(t.getOrderId())
-                                .setResourceId(getResourceIdByAutoCode(t, autoCode))
                                 .setTaskNodeNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK_NODE));
                         taskNode.setAutoNode(autoCode).setNodeNo(autoCode.getNo()).setCompleteBatchNo(t.getCompleteBatchNo())
                                 .setExeStatus("1").setPrority(autoCode.getWeight());
@@ -337,9 +338,19 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 //                        taskNode.setInterfaceType(autoNode.getInterfaceType().getKey());
 //                    }
                         //依据设备类型判断调用接口类型
-                        if("1".equals(taskNode.getAutoNode().getCategory()) || "3".equals(taskNode.getAutoNode().getCategory())){
+                        if("1".equals(taskNode.getAutoNode().getCategory())){
+                            taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
+                            //加工设备的设备ID来源于加工任务设备
+                            taskNode.setResourceId(taskNode.getTaskId());
+                        }else if("3".equals(taskNode.getAutoNode().getCategory())){
                             taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
-                        }else if("2".equals(taskNode.getAutoNode().getCategory())){
+                            //根据配置确定操作设备ID
+                            //String resourceType = autoCode.getResourceId()!=null? autoCode.getResourceId().toString() : null;
+                            if(null!= autoCode.getResourceId()) {
+                                taskNode.setResourceId(getResourceIdByAutoCode(autoCode.getResourceId().toString()));
+                            }
+                        }
+                        else if("2".equals(taskNode.getAutoNode().getCategory())){
                             taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_AGV);
                         }else if("4".equals(taskNode.getAutoNode().getCategory())){
                             taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_WMS);
@@ -387,12 +398,13 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
 
     /**
      * 获取具体的生产资源
-     * @param autoCode
+     * @param resourceType
      * @return
      */
-    private Long getResourceIdByAutoCode(TTask task, ResourceAutoCode autoCode){
-        Long resourceId = autoCode.getCategory()=="1"? task.getResourceId(): 0L;
-        return resourceId;
+    private Long getResourceIdByAutoCode(String resourceType){
+        String robotName = DictionaryKey.YJ_ROBOT_NODES.get(resourceType);
+        Productionresource productionresource =  productionresourceBizMapper.selectOne(new LbqWrapper<Productionresource>().eq(Productionresource::getName, robotName));
+        return productionresource.getId();
     }
 
 

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

@@ -85,9 +85,9 @@ public interface DictionaryKey {
     //云箭机器人
     Map<String, String> YJ_ROBOT_NODES = new HashMap<String, String>(){
         {
-            put("1", "舱体线机器人");
-            put("2", "伺服舵机");
-            put("3", "框体线机器人");
+            put("1", "舱体_机器人");
+            put("2", "保障中心_伺服舵机");
+            put("3", "框体_机器人");
         }
     };