yaoyq 3 роки тому
батько
коміт
5f18eb61c0

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

@@ -26,7 +26,11 @@ import com.github.zuihou.business.productionReadyCenter.entity.*;
 import com.github.zuihou.business.productionReadyCenter.service.*;
 import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourcePositionMapper;
 import com.github.zuihou.business.productionResourceCenter.entity.ProductionresourcePosition;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceBusiness;
 import com.github.zuihou.business.productionResourceCenter.service.ProductionresourcePositionService;
+import com.github.zuihou.business.productionResourceCenter.service.ResourceAutoCodeService;
+import com.github.zuihou.business.productionResourceCenter.service.ResourceBusinessService;
 import com.github.zuihou.business.productionResourceCenter.service.ZZoneService;
 import com.github.zuihou.business.util.DynamicRabbitMq;
 import com.github.zuihou.business.util.MsgUtil;
@@ -176,6 +180,12 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     @Autowired
     private WorkpieceService workpieceService;
 
+    @Autowired
+    private ResourceBusinessService resourceBusinessService;
+
+    @Autowired
+    private ResourceAutoCodeService resourceAutoCodeService;
+
     @Autowired
     private ZZoneService zoneService;
 
@@ -247,6 +257,96 @@ public class TaskNodeServiceImpl extends SuperServiceImpl<TaskNodeMapper, TaskNo
     }
 
 
+
+    public void saveTaskNodeByTaskBatchNoNew(String taskBatchNo, SysUser sysUser) {
+        //生成节点任务
+        List<TTask> taskList = taskService.list(Wraps.<TTask>lbQ().eq(TTask::getTaskBatchNo, taskBatchNo).orderByDesc(TTask::getPrority));
+        Map<String, List<TTask>> taskMap = taskList.stream().collect(groupingBy(TTask::getCompleteBatchNo));
+
+        List<Long> procedureList = taskList.stream().map(p -> p.getProcedureId()).collect(Collectors.toList());
+        //List<AutoNode>autoList = autoNodeService.list(Wraps.<AutoNode>lbQ().in(AutoNode::getProcedureId,procedureList));
+        //执行任务对应的自动化程序
+//        AutoNode model = new AutoNode();
+//        model.setProcedureIds(StringUtil.changeIdsListToSubQueryStr(procedureList));
+//        List<AutoNode> autoList = autoNodeMapper.getNodeList(model);
+//        Map<Long, List<AutoNode>> autoNodeMap = autoList.stream().collect(groupingBy(AutoNode::getProcedureId));
+
+        List<ResourceBusiness>resourceBusinessList = resourceBusinessService.list();
+        Map<Long, ResourceBusiness> resourceBusinessMap = resourceBusinessList.stream().collect(Collectors.toMap(ResourceBusiness::getId, t->t));
+
+        List<ResourceAutoCode> resourceAutoCodeList = resourceAutoCodeService.list();
+        Map<Long, List<ResourceAutoCode>> resourceAutoCodeMap = resourceAutoCodeList.stream().collect(groupingBy(ResourceAutoCode::getBusinessId));
+
+
+
+
+        List<TaskNode> taskNodeList = new ArrayList<TaskNode>();
+        for (String key : taskMap.keySet()) {
+            int i = 1;
+            for (TTask t : taskList) {
+                //取出resrouceId
+                Long resourceBusinessId = t.getResourceBusinessId();
+                List<ResourceAutoCode> autoCodeList = resourceAutoCodeMap.get(resourceBusinessId);
+
+                for (ResourceAutoCode autoCode : autoCodeList) {
+                    TaskNode taskNode = new TaskNode();
+//                    taskNode.setAutoNode(autoNode).setAutoNodeCode(autoNode.getCode()).setCompleteBatchNo(t.getCompleteBatchNo())
+//                            .setNodeNo(autoNode.getNodeNo()).setExeStatus("1").setPrority(autoCode.getWeight());
+                    taskNode.setCompleteBatchNo(t.getCompleteBatchNo())
+                            .setExeStatus("1").setPrority(autoCode.getWeight());
+//                    if (autoNode.getInterfaceType() != null) {
+//                        taskNode.setInterfaceType(autoNode.getInterfaceType().getKey());
+//                    }
+                    taskNode.setCompleteBatchSort(i);
+                    taskNodeList.add(taskNode);
+                    i++;
+                }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+//                List<AutoNode> autoNodeList = autoNodeMap.get(t.getProcedureId());
+//                for (AutoNode autoNode : autoNodeList) {
+//                    TaskNode taskNode = new TaskNode();
+//                    taskNode.setAutoNode(autoNode).setAutoNodeCode(autoNode.getCode()).setCompleteBatchNo(t.getCompleteBatchNo())
+//                            .setNodeNo(autoNode.getNodeNo()).setExeStatus("1").setPrority(autoNode.getPrority());
+//                    if (autoNode.getInterfaceType() != null) {
+//                        taskNode.setInterfaceType(autoNode.getInterfaceType().getKey());
+//                    }
+//                    //是否延迟
+//                    taskNode.setDelayFlag(autoNode.getDelayFlag()).setTaskId(t.getId()).setOrderId(t.getOrderId()).setResourceId(autoNode.getResourceId())
+//                            .setTaskNodeNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK_NODE));
+//                    //添加二级子节点
+//                    if (null != autoNode.getParentId()) {
+//                        taskNode.setChildrenNode(autoNode.getChildrenNode());
+//                    }
+//                    if (BizConstant.TASK_NODE_MANUALNODE_LOADING.equals(autoNode.getCode())) {//如果是人工的。则分配给人
+//                        taskNode.setLoadingUserId(getLoadingUserId("1", sysUser)).setNodeType("1");//上料
+//                    } else if (BizConstant.TASK_NODE_MANUALNODE_CUTTING.equals(autoNode.getCode())) {//如果是人工的。则分配给人
+//                        taskNode.setLoadingUserId(getLoadingUserId("2", sysUser)).setNodeType("2");//下料
+//                    } else if (BizConstant.TASK_NODE_MANUALNODE_TEST.equals(autoNode.getCode())) {//质检
+//                        taskNode.setLoadingUserId(getLoadingUserId("3", sysUser)).setNodeType("3");//质检
+//                    }
+//                    taskNode.setCompleteBatchSort(i);
+//                    taskNodeList.add(taskNode);
+//                    i++;
+//                }
+            }
+        }
+        this.saveBatch(taskNodeList);
+    }
+
+
     /**
      * 获取上下料站的员工
      *

+ 8 - 0
imcs-admin-boot/imcs-business-entity/src/main/java/com/github/zuihou/business/operationManagementCenter/entity/TTask.java

@@ -323,6 +323,14 @@ public class TTask extends Entity<Long> {
     @TableField(exist = false)
     private float ratedWorkHours;
 
+    /**
+     * 工序ID
+     */
+    @ApiModelProperty(value = "资源业务ID")
+    @TableField("resource_business_id")
+    @Excel(name = "资源业务ID")
+    private Long resourceBusinessId;
+
     /**
      * 计划编号
      */