|
@@ -1,5 +1,6 @@
|
|
|
package com.github.zuihou.business.operationManagementCenter.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.github.zuihou.authority.utils.TimeUtils;
|
|
@@ -19,10 +20,12 @@ import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCo
|
|
|
import com.github.zuihou.business.productionResourceCenter.entity.ResourceBusiness;
|
|
|
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.common.constant.CodeRuleModule;
|
|
|
import com.github.zuihou.common.constant.DictionaryKey;
|
|
|
import com.github.zuihou.database.mybatis.auth.DataScope;
|
|
|
import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
+import com.github.zuihou.dozer.DozerUtils;
|
|
|
import com.github.zuihou.tenant.service.CodeRuleService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.compress.utils.Lists;
|
|
@@ -45,6 +48,12 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
|
|
|
private final Long INSPECTION_INTERVAL_MIN = 5L;
|
|
|
|
|
|
+ //质检工序默认名称(三坐标_质检1和三坐标_质检2流程一致,只是TaskId不同)
|
|
|
+ private final String TEST_TASK_NAME = "三坐标_质检2";
|
|
|
+
|
|
|
+ //抽检工序从清洗2工序获取AGV动作包节点(后三个任务节点)
|
|
|
+ private final String INSPECTION_SUPPORT_NAME = "清洗2";
|
|
|
+
|
|
|
@Autowired
|
|
|
private TaskService taskService;
|
|
|
|
|
@@ -69,6 +78,12 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
@Autowired
|
|
|
private TaskNodeService taskNodeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ZZoneService zoneService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private DozerUtils dozer;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<Inspection> pageList(IPage page, LbqWrapper<Inspection> wrapper) {
|
|
|
return baseMapper.pageList(page, wrapper, new DataScope());
|
|
@@ -105,14 +120,43 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
return productionresource.getId();
|
|
|
}
|
|
|
|
|
|
+ private List<TaskNode> addSupportNodes(List<TaskNode> supportNodes, boolean isHeader, Long taskId, List<TaskNode> taskNodeList,TaskNode lastNode, String zoneName){
|
|
|
+ List<TaskNode> dataList = dozer.mapList(supportNodes, TaskNode.class);
|
|
|
+ dataList.forEach(item->{
|
|
|
+ item.setTaskId(taskId).setTaskNodeNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK_NODE))
|
|
|
+ .setExeStatus("1").setPrority(lastNode.getPrority()+1+taskNodeList.size());
|
|
|
+ if(isHeader){
|
|
|
+ item.setNodeName("抽检:"+item.getNodeName());
|
|
|
+ }else{
|
|
|
+ if(item.getAutoNode().isFinal()){
|
|
|
+ item.setNodeName("抽检:运到"+ zoneName +"线接驳位");
|
|
|
+ }else{
|
|
|
+ item.setNodeName("抽检:"+item.getNodeName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setId(null);
|
|
|
+ item.setCompleteBatchSort(lastNode.getCompleteBatchSort()+taskNodeList.size()+1).setCreateTime(LocalDateTime.now());;
|
|
|
+ taskNodeList.add(item);
|
|
|
+ });
|
|
|
+ return taskNodeList;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public Boolean createTaskNode(InspectionSaveDTO model) {
|
|
|
|
|
|
List<TaskNode> taskNodeList = Lists.newArrayList();
|
|
|
|
|
|
+ //抽检序任务
|
|
|
TTask task = taskService.getById(model.getTaskId());
|
|
|
|
|
|
+ //质检序任务
|
|
|
+ TTask testTask = taskService.getOne(new LbqWrapper<TTask>().eq(TTask::getProcedureName, TEST_TASK_NAME).eq(TTask::getCompleteBatchNo, task.getCompleteBatchNo()));
|
|
|
+
|
|
|
+ //支持任务
|
|
|
+ TTask supportTask = taskService.getOne(new LbqWrapper<TTask>().eq(TTask::getProcedureName, INSPECTION_SUPPORT_NAME).eq(TTask::getCompleteBatchNo, task.getCompleteBatchNo()));
|
|
|
+ List<TaskNode> supportNodes = taskNodeService.list(new LbqWrapper<TaskNode>().eq(TaskNode::getTaskId, supportTask.getId()).orderByAsc(TaskNode::getCompleteBatchSort)).stream().skip(3L).collect(Collectors.toList());
|
|
|
+
|
|
|
//获取零件完整bom流程任务节点ID
|
|
|
List<Long> taskIds = taskNodeService.list(new LbqWrapper<TaskNode>().eq(TaskNode::getCompleteBatchNo, task.getCompleteBatchNo()).orderByAsc(TaskNode::getCompleteBatchSort)).stream().map(TaskNode::getId).collect(Collectors.toList());
|
|
|
|
|
@@ -122,17 +166,19 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
//获取抽检序最后一个节点(优先级递增排列)
|
|
|
TaskNode lastNode = inspectionList.get(0);
|
|
|
|
|
|
- //在零件抽检工序末尾新增三坐标检测序节点
|
|
|
- LbqWrapper<TTask> lbqWrapper = new LbqWrapper<TTask>();
|
|
|
- lbqWrapper.eq(TTask::getProcedureId, task.getProcedureId()).eq(TTask::getPlanId, model.getPlanId());
|
|
|
- //获得抽检工序对应任务
|
|
|
- TWorkpiece tWorkpiece = workpieceService.getById(model.getWorkpieceId());
|
|
|
+ //获取产线名称
|
|
|
+ String zoneNo = zoneService.getById(model.getZoneId()).getNo();
|
|
|
+ String zoneName = (zoneNo=="capsule")? "舱体":((zoneNo=="framework")? "框体": "保障中心");
|
|
|
|
|
|
BomProcedure bomProcedure = bomProcedureService.getById(task.getProcedureId());
|
|
|
|
|
|
- if(null ==task || null == bomProcedure){
|
|
|
- return null;
|
|
|
+ if(null == task || null == bomProcedure || null == testTask || null == supportTask){
|
|
|
+ return false;
|
|
|
}
|
|
|
+
|
|
|
+ // 增加前置AGV功能节点
|
|
|
+ taskNodeList = this.addSupportNodes(supportNodes, true, task.getId(), taskNodeList, lastNode, zoneName);
|
|
|
+
|
|
|
LbqWrapper<ResourceBusiness> resourceBusinessWrapper = new LbqWrapper<ResourceBusiness>();
|
|
|
resourceBusinessWrapper.eq(ResourceBusiness::getName, INSPECTION_RESOURCE_NAME);
|
|
|
ResourceBusiness resourceBusiness = resourceBusinessService.getOne(resourceBusinessWrapper);
|
|
@@ -140,7 +186,6 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
|
|
|
List<ResourceAutoCode> parentResourceAutoCodeList = autoCodeList.stream().filter(a->a.getParentId().longValue()==0L).collect(Collectors.toList());
|
|
|
|
|
|
-
|
|
|
for (int parentCount = 0; parentCount< parentResourceAutoCodeList.size(); parentCount++) {
|
|
|
//父节点
|
|
|
ResourceAutoCode pautoCode = parentResourceAutoCodeList.get(parentCount);
|
|
@@ -159,7 +204,7 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
}else{
|
|
|
taskNode.setFindAgvFlag("0");
|
|
|
}
|
|
|
-
|
|
|
+ //节点默认使用抽检序的任务ID
|
|
|
taskNode.setTaskId(task.getId()).setOrderId(task.getOrderId())
|
|
|
.setTaskNodeNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK_NODE));
|
|
|
taskNode.setAutoNode(autoCode).setNodeNo(autoCode.getNo()).setCompleteBatchNo(task.getCompleteBatchNo())
|
|
@@ -169,7 +214,7 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
if("1".equals(taskNode.getAutoNode().getCategory())){
|
|
|
taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
|
|
|
//加工设备的设备ID来源于加工任务设备
|
|
|
- taskNode.setResourceId(task.getResourceId()).setTargetResourceId(task.getResourceId());
|
|
|
+ taskNode.setResourceId(testTask.getResourceId()).setTargetResourceId(testTask.getResourceId());
|
|
|
}else if("3".equals(taskNode.getAutoNode().getCategory())){
|
|
|
String command = autoCode.getCommand();
|
|
|
taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
|
|
@@ -179,7 +224,7 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
if("2".equals(command)){
|
|
|
// 最后一个节点
|
|
|
if(count == childResourceAutoCodeList.size() - 1){
|
|
|
- taskNode.setTargetResourceId(task.getResourceId());
|
|
|
+ taskNode.setTargetResourceId(testTask.getResourceId());
|
|
|
}else{
|
|
|
if(null == nextAutoCode.getResourceId()){
|
|
|
taskNode.setTargetResourceId(null);
|
|
@@ -211,15 +256,18 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
taskNodeList.add(taskNode);
|
|
|
}
|
|
|
}
|
|
|
- //System.out.println(taskNodeList.size());
|
|
|
- //taskNodeList.forEach(System.out::println);
|
|
|
+
|
|
|
+
|
|
|
+ // 增加后置AGV功能节点
|
|
|
+ taskNodeList = this.addSupportNodes(supportNodes, false, task.getId(), taskNodeList, lastNode, zoneName);
|
|
|
+
|
|
|
+ taskNodeList.forEach(System.out::println);
|
|
|
|
|
|
//批量更新节点的次序值
|
|
|
UpdateWrapper<TaskNode> updateWrapper = new UpdateWrapper<TaskNode>();
|
|
|
updateWrapper.lambda().in(TaskNode::getId, taskIds.toArray()).gt(TaskNode::getCompleteBatchSort, lastNode.getCompleteBatchSort()).setSql("complete_batch_sort = complete_batch_sort + "+taskNodeList.size());
|
|
|
|
|
|
boolean bool= taskNodeService.update(updateWrapper);
|
|
|
-
|
|
|
return (bool)? taskNodeService.saveBatch(taskNodeList) : false;
|
|
|
}
|
|
|
}
|