|
|
@@ -5,15 +5,63 @@ import com.github.zuihou.base.service.SuperServiceImpl;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dao.InspectionMapper;
|
|
|
import com.github.zuihou.business.operationManagementCenter.dto.InspectionSaveDTO;
|
|
|
import com.github.zuihou.business.operationManagementCenter.entity.Inspection;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.TTask;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.TWorkpiece;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.entity.TaskNode;
|
|
|
import com.github.zuihou.business.operationManagementCenter.service.InspectionService;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.PlanService;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.TaskService;
|
|
|
+import com.github.zuihou.business.operationManagementCenter.service.WorkpieceService;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.BomProcedure;
|
|
|
+import com.github.zuihou.business.productionReadyCenter.service.BomProcedureService;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.dao.ProductionresourceBizMapper;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.Productionresource;
|
|
|
+import com.github.zuihou.business.productionResourceCenter.entity.ResourceAutoCode;
|
|
|
+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.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.tenant.service.CodeRuleService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.compress.utils.Lists;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Arrays;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, Inspection> implements InspectionService {
|
|
|
+
|
|
|
+ private final String INSPECTION_RESOURCE_NAME = "三坐标_质检";
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TaskService taskService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ResourceAutoCodeService resourceAutoCodeService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ResourceBusinessService resourceBusinessService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CodeRuleService codeRuleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BomProcedureService bomProcedureService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ProductionresourceBizMapper productionresourceBizMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private WorkpieceService workpieceService;
|
|
|
+
|
|
|
@Override
|
|
|
public IPage<Inspection> pageList(IPage page, LbqWrapper<Inspection> wrapper) {
|
|
|
return baseMapper.pageList(page, wrapper, new DataScope());
|
|
|
@@ -23,4 +71,116 @@ public class InspectionServiceImpl extends SuperServiceImpl<InspectionMapper, In
|
|
|
public Boolean check(InspectionSaveDTO model) {
|
|
|
return true;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取具体的生产资源
|
|
|
+ * @param resourceType
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public TaskNode createTaskNode(InspectionSaveDTO model) {
|
|
|
+
|
|
|
+ List<TaskNode> taskNodeList = Lists.newArrayList();
|
|
|
+
|
|
|
+ TTask task = taskService.getById(model.getTaskId());
|
|
|
+
|
|
|
+ //在零件抽检工序末尾新增三坐标检测序节点
|
|
|
+ LbqWrapper<TTask> lbqWrapper = new LbqWrapper<TTask>();
|
|
|
+ lbqWrapper.eq(TTask::getProcedureId, task.getProcedureId()).eq(TTask::getPlanId, model.getPlanId());
|
|
|
+ //获得抽检工序对应任务
|
|
|
+ TWorkpiece tWorkpiece = workpieceService.getById(model.getWorkpieceId());
|
|
|
+
|
|
|
+ BomProcedure bomProcedure = bomProcedureService.getById(task.getProcedureId());
|
|
|
+
|
|
|
+ if(null ==task || null == bomProcedure){
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ LbqWrapper<ResourceBusiness> resourceBusinessWrapper = new LbqWrapper<ResourceBusiness>();
|
|
|
+ resourceBusinessWrapper.eq(ResourceBusiness::getName, INSPECTION_RESOURCE_NAME);
|
|
|
+ ResourceBusiness resourceBusiness = resourceBusinessService.getOne(resourceBusinessWrapper);
|
|
|
+ List<ResourceAutoCode> autoCodeList = resourceAutoCodeService.list(new LbqWrapper<ResourceAutoCode>().eq(ResourceAutoCode::getBusinessId, resourceBusiness.getId()).orderByAsc(ResourceAutoCode::getParentId).orderByAsc(ResourceAutoCode::getWeight));
|
|
|
+
|
|
|
+ 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);
|
|
|
+ List<ResourceAutoCode> childResourceAutoCodeList = autoCodeList.stream().filter(a->pautoCode.getId().toString().equals(a.getParentId().toString())).collect(Collectors.toList());
|
|
|
+ List<ResourceAutoCode> agvlist = childResourceAutoCodeList.stream().filter(a->"2".equals(a.getCategory())).collect(Collectors.toList());
|
|
|
+ for (int count = 0; count < childResourceAutoCodeList.size(); count++) { //子节点
|
|
|
+ ResourceAutoCode autoCode = childResourceAutoCodeList.get(count);
|
|
|
+ ResourceAutoCode nextAutoCode = null;
|
|
|
+ if(count < childResourceAutoCodeList.size() -1){
|
|
|
+ nextAutoCode = childResourceAutoCodeList.get(count + 1);
|
|
|
+ }
|
|
|
+ TaskNode taskNode = new TaskNode();
|
|
|
+ // 包含agv动作
|
|
|
+ if(count == 0 && agvlist.size() > 0){
|
|
|
+ taskNode.setFindAgvFlag("1");
|
|
|
+ }else{
|
|
|
+ taskNode.setFindAgvFlag("0");
|
|
|
+ }
|
|
|
+
|
|
|
+ taskNode.setTaskId(task.getId()).setOrderId(task.getOrderId())
|
|
|
+ .setTaskNodeNo(codeRuleService.getBillCode(CodeRuleModule.CODE_RULE_TASK_NODE));
|
|
|
+ taskNode.setAutoNode(autoCode).setNodeNo(autoCode.getNo()).setCompleteBatchNo(task.getCompleteBatchNo())
|
|
|
+ .setExeStatus("1").setPrority(autoCode.getWeight()).setNodeName(autoCode.getName());
|
|
|
+
|
|
|
+ //依据设备类型判断调用接口类型
|
|
|
+ if("1".equals(taskNode.getAutoNode().getCategory())){
|
|
|
+ taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
|
|
|
+ //加工设备的设备ID来源于加工任务设备
|
|
|
+ taskNode.setResourceId(task.getResourceId()).setTargetResourceId(task.getResourceId());
|
|
|
+ }else if("3".equals(taskNode.getAutoNode().getCategory())){
|
|
|
+ String command = autoCode.getCommand();
|
|
|
+ taskNode.setInterfaceType(DictionaryKey.INTERFACETYPE_PLC);
|
|
|
+ //根据配置确定操作设备ID
|
|
|
+ //String resourceType = autoCode.getResourceId()!=null? autoCode.getResourceId().toString() : null;
|
|
|
+ // 放,判断后一个动作节点是否是agv搬运,如果是,这个targetResourceId设置成空
|
|
|
+ if("2".equals(command)){
|
|
|
+ // 最后一个节点
|
|
|
+ if(count == childResourceAutoCodeList.size() - 1){
|
|
|
+ taskNode.setTargetResourceId(task.getResourceId());
|
|
|
+ }else{
|
|
|
+ if(null == nextAutoCode.getResourceId()){
|
|
|
+ taskNode.setTargetResourceId(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);
|
|
|
+
|
|
|
+ String taskType = bomProcedure.getType();
|
|
|
+ if("上料".equals(taskType)){
|
|
|
+ taskNode.setNodeType("1").setResourceId(task.getResourceId());
|
|
|
+ }else if("下料".equals(taskType)){
|
|
|
+ taskNode.setNodeType("2").setResourceId(task.getResourceId());
|
|
|
+ }else if("翻面".equals(taskType)){
|
|
|
+ taskNode.setNodeType("4").setResourceId(task.getResourceId());
|
|
|
+ }else{
|
|
|
+ taskNode.setNodeType("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //taskNode.setCompleteBatchSort(i);
|
|
|
+ taskNodeList.add(taskNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ taskNodeList.forEach(System.out::println);
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|