|
|
|
@ -408,7 +408,12 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
if (!StringUtils.hasText(orderNo) || !StringUtils.hasText(orderType)) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
List<ProductionPlanNodeAssigneeData> list = productionPlanMapper.queryNodeAssigneeList(orderNo, normalizeOrderType(orderType)); |
|
|
|
String normalizedOrderType = normalizeOrderType(orderType); |
|
|
|
ProductionPlanOrderRowData order = productionPlanMapper.queryOrderByOrderNo(orderNo, normalizedOrderType); |
|
|
|
if (order == null) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
List<ProductionPlanNodeAssigneeData> list = productionPlanMapper.queryNodeAssigneeList(orderNo, normalizedOrderType); |
|
|
|
if (list == null) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
@ -430,7 +435,7 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
} |
|
|
|
item.setAssigneeUserIdList(idList); |
|
|
|
} |
|
|
|
return list; |
|
|
|
return filterNodeAssigneeListByTaskType(normalizedOrderType, order.getTaskType(), list); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
@ -455,6 +460,16 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
if (validList.isEmpty()) { |
|
|
|
return; |
|
|
|
} |
|
|
|
if (ORDER_TYPE_CABLE_COP.equals(normalizedOrderType)) { |
|
|
|
String allowedNodeCode = resolveCableCopNodeCodeByTaskType(order.getTaskType()); |
|
|
|
if (StringUtils.hasText(allowedNodeCode)) { |
|
|
|
for (ProductionPlanNodeAssigneeData item : validList) { |
|
|
|
if (!allowedNodeCode.equals(item.getNodeCode())) { |
|
|
|
throw new XJException("当前任务类型仅允许分配节点:" + resolveCableCopNodeNameByNodeCode(allowedNodeCode)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
List<ProductionPlanNodeAssigneeData> insertList = new ArrayList<>(); |
|
|
|
for (ProductionPlanNodeAssigneeData item : validList) { |
|
|
|
String roleType = buildNodeRoleType(normalizedOrderType, item.getNodeCode()); |
|
|
|
@ -558,7 +573,10 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
nodeMap = nodeList.stream().collect(Collectors.groupingBy(ProductionPlanOrderNodeData::getOrderNo, LinkedHashMap::new, Collectors.toList())); |
|
|
|
} |
|
|
|
for (ProductionPlanOrderRowData row : rows) { |
|
|
|
List<ProductionPlanOrderNodeData> rowNodeList = nodeMap.getOrDefault(row.getOrderNo(), Collections.emptyList()); |
|
|
|
List<ProductionPlanOrderNodeData> rowNodeList = filterNodeListByTaskType( |
|
|
|
row, |
|
|
|
nodeMap.getOrDefault(row.getOrderNo(), Collections.emptyList()) |
|
|
|
); |
|
|
|
row.setNodeList(rowNodeList); |
|
|
|
fillNodeProgress(row, rowNodeList); |
|
|
|
} |
|
|
|
@ -580,8 +598,17 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
fullNodeMap = fullNodeList.stream().collect(Collectors.groupingBy(ProductionPlanOrderNodeData::getOrderNo, LinkedHashMap::new, Collectors.toList())); |
|
|
|
} |
|
|
|
for (ProductionPlanOrderRowData row : rows) { |
|
|
|
List<ProductionPlanOrderNodeData> rowVisibleNodeList = visibleNodeMap.getOrDefault(row.getOrderNo(), Collections.emptyList()); |
|
|
|
List<ProductionPlanOrderNodeData> rowFullNodeList = fullNodeMap.getOrDefault(row.getOrderNo(), rowVisibleNodeList); |
|
|
|
List<ProductionPlanOrderNodeData> rowVisibleNodeList = filterNodeListByTaskType( |
|
|
|
row, |
|
|
|
visibleNodeMap.getOrDefault(row.getOrderNo(), Collections.emptyList()) |
|
|
|
); |
|
|
|
List<ProductionPlanOrderNodeData> rowFullNodeList = filterNodeListByTaskType( |
|
|
|
row, |
|
|
|
fullNodeMap.getOrDefault(row.getOrderNo(), rowVisibleNodeList) |
|
|
|
); |
|
|
|
if (rowFullNodeList.isEmpty() && !rowVisibleNodeList.isEmpty()) { |
|
|
|
rowFullNodeList = rowVisibleNodeList; |
|
|
|
} |
|
|
|
row.setNodeList(rowVisibleNodeList); |
|
|
|
fillNodeProgress(row, rowFullNodeList); |
|
|
|
} |
|
|
|
@ -639,7 +666,7 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
data.setOrderNo(generateOrderNo(orderType)); |
|
|
|
data.setCreateBy(userId); |
|
|
|
productionPlanMapper.insertOrder(data); |
|
|
|
rebuildOrderNode(data.getOrderNo(), orderType, data.getNodeList(), data.getStatus()); |
|
|
|
rebuildOrderNode(data.getOrderNo(), orderType, data.getTaskType(), data.getNodeList(), data.getStatus()); |
|
|
|
if (Boolean.TRUE.equals(data.getAutoAssignAllUsers())) { |
|
|
|
autoAssignNodeUsersByRoleType(data.getOrderNo(), orderType, userId); |
|
|
|
} |
|
|
|
@ -649,14 +676,20 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
if (existsOrder == null) { |
|
|
|
throw new I18nException("lc.production.order.not.exists.cannot.save"); |
|
|
|
} |
|
|
|
boolean cableCopTaskTypeChanged = ORDER_TYPE_CABLE_COP.equals(orderType) |
|
|
|
&& !isSameCableCopTaskType(existsOrder.getTaskType(), data.getTaskType()); |
|
|
|
productionPlanMapper.updateOrder(data); |
|
|
|
if (data.getNodeList() != null && !data.getNodeList().isEmpty()) { |
|
|
|
rebuildOrderNode(data.getOrderNo(), orderType, data.getNodeList(), data.getStatus()); |
|
|
|
rebuildOrderNode(data.getOrderNo(), orderType, data.getTaskType(), data.getNodeList(), data.getStatus()); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (cableCopTaskTypeChanged) { |
|
|
|
rebuildOrderNode(data.getOrderNo(), orderType, data.getTaskType(), null, data.getStatus()); |
|
|
|
return; |
|
|
|
} |
|
|
|
int nodeCount = productionPlanMapper.countOrderNode(data.getOrderNo()); |
|
|
|
if (nodeCount <= 0) { |
|
|
|
rebuildOrderNode(data.getOrderNo(), orderType, null, data.getStatus()); |
|
|
|
rebuildOrderNode(data.getOrderNo(), orderType, data.getTaskType(), null, data.getStatus()); |
|
|
|
} |
|
|
|
log.info("保存订单成功, orderType={}, orderNo={}, userId={}", orderType, data.getOrderNo(), userId); |
|
|
|
} |
|
|
|
@ -730,6 +763,9 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
if (!StringUtils.hasText(data.getTaskType())) { |
|
|
|
throw new I18nException("lc.production.task.type.required"); |
|
|
|
} |
|
|
|
if (!StringUtils.hasText(resolveCableCopNodeCodeByTaskType(data.getTaskType()))) { |
|
|
|
throw new XJException("线缆/COP任务类型仅支持:线缆自制、COP自制"); |
|
|
|
} |
|
|
|
} else if (ORDER_TYPE_MACHINING.equals(orderType)) { |
|
|
|
if (!StringUtils.hasText(data.getModelNo())) { |
|
|
|
throw new I18nException("lc.production.model.required"); |
|
|
|
@ -756,10 +792,13 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void rebuildOrderNode(String orderNo, String orderType, List<ProductionPlanOrderNodeData> fromClientNodeList, String orderStatus) { |
|
|
|
private void rebuildOrderNode(String orderNo, String orderType, String taskType, List<ProductionPlanOrderNodeData> fromClientNodeList, String orderStatus) { |
|
|
|
List<ProductionPlanOrderNodeData> nodeList = fromClientNodeList; |
|
|
|
if (ORDER_TYPE_CABLE_COP.equals(orderType)) { |
|
|
|
nodeList = filterCableCopNodeListByTaskType(nodeList, taskType); |
|
|
|
} |
|
|
|
if (nodeList == null || nodeList.isEmpty()) { |
|
|
|
nodeList = buildDefaultNodeList(orderType); |
|
|
|
nodeList = buildDefaultNodeList(orderType, taskType); |
|
|
|
} |
|
|
|
List<ProductionPlanOrderNodeData> normalizedNodeList = normalizeNodeStatus(nodeList, orderStatus); |
|
|
|
productionPlanMapper.deleteOrderNode(orderNo); |
|
|
|
@ -797,11 +836,16 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private List<ProductionPlanOrderNodeData> buildDefaultNodeList(String orderType) { |
|
|
|
private List<ProductionPlanOrderNodeData> buildDefaultNodeList(String orderType, String taskType) { |
|
|
|
List<ProductionPlanOrderNodeData> nodeList = new ArrayList<>(); |
|
|
|
if (ORDER_TYPE_CABLE_COP.equals(orderType)) { |
|
|
|
nodeList.add(buildNode("lineProduction", "线缆生产", 1)); |
|
|
|
nodeList.add(buildNode("copProduction", "COP生产", 2)); |
|
|
|
String nodeCode = resolveCableCopNodeCodeByTaskType(taskType); |
|
|
|
if (!StringUtils.hasText(nodeCode)) { |
|
|
|
nodeList.add(buildNode("lineProduction", "线缆生产", 1)); |
|
|
|
nodeList.add(buildNode("copProduction", "COP生产", 2)); |
|
|
|
return nodeList; |
|
|
|
} |
|
|
|
nodeList.add(buildNode(nodeCode, resolveCableCopNodeNameByNodeCode(nodeCode), 1)); |
|
|
|
return nodeList; |
|
|
|
} |
|
|
|
if (ORDER_TYPE_MACHINING.equals(orderType)) { |
|
|
|
@ -832,6 +876,75 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
return node; |
|
|
|
} |
|
|
|
|
|
|
|
private boolean isSameCableCopTaskType(String sourceTaskType, String targetTaskType) { |
|
|
|
String source = sourceTaskType == null ? "" : sourceTaskType.trim(); |
|
|
|
String target = targetTaskType == null ? "" : targetTaskType.trim(); |
|
|
|
return source.equals(target); |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveCableCopNodeCodeByTaskType(String taskType) { |
|
|
|
if (!StringUtils.hasText(taskType)) { |
|
|
|
return null; |
|
|
|
} |
|
|
|
String value = taskType.trim(); |
|
|
|
if (value.contains("线缆")) { |
|
|
|
return "lineProduction"; |
|
|
|
} |
|
|
|
if (value.toUpperCase().contains("COP")) { |
|
|
|
return "copProduction"; |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private String resolveCableCopNodeNameByNodeCode(String nodeCode) { |
|
|
|
if ("lineProduction".equals(nodeCode)) { |
|
|
|
return "线缆生产"; |
|
|
|
} |
|
|
|
if ("copProduction".equals(nodeCode)) { |
|
|
|
return "COP生产"; |
|
|
|
} |
|
|
|
return nodeCode; |
|
|
|
} |
|
|
|
|
|
|
|
private List<ProductionPlanOrderNodeData> filterCableCopNodeListByTaskType(List<ProductionPlanOrderNodeData> nodeList, String taskType) { |
|
|
|
if (nodeList == null || nodeList.isEmpty()) { |
|
|
|
return nodeList; |
|
|
|
} |
|
|
|
String allowedNodeCode = resolveCableCopNodeCodeByTaskType(taskType); |
|
|
|
if (!StringUtils.hasText(allowedNodeCode)) { |
|
|
|
return nodeList; |
|
|
|
} |
|
|
|
return nodeList.stream() |
|
|
|
.filter(item -> item != null && allowedNodeCode.equals(item.getNodeCode())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
private List<ProductionPlanOrderNodeData> filterNodeListByTaskType(ProductionPlanOrderRowData row, List<ProductionPlanOrderNodeData> nodeList) { |
|
|
|
if (row == null || nodeList == null || nodeList.isEmpty()) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
if (!ORDER_TYPE_CABLE_COP.equals(row.getOrderType())) { |
|
|
|
return nodeList; |
|
|
|
} |
|
|
|
return filterCableCopNodeListByTaskType(nodeList, row.getTaskType()); |
|
|
|
} |
|
|
|
|
|
|
|
private List<ProductionPlanNodeAssigneeData> filterNodeAssigneeListByTaskType(String orderType, String taskType, List<ProductionPlanNodeAssigneeData> list) { |
|
|
|
if (list == null || list.isEmpty()) { |
|
|
|
return Collections.emptyList(); |
|
|
|
} |
|
|
|
if (!ORDER_TYPE_CABLE_COP.equals(orderType)) { |
|
|
|
return list; |
|
|
|
} |
|
|
|
String allowedNodeCode = resolveCableCopNodeCodeByTaskType(taskType); |
|
|
|
if (!StringUtils.hasText(allowedNodeCode)) { |
|
|
|
return list; |
|
|
|
} |
|
|
|
return list.stream() |
|
|
|
.filter(item -> item != null && allowedNodeCode.equals(item.getNodeCode())) |
|
|
|
.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
private String reportOrderNode(ProductionPlanNodeReportData data, String orderType) { |
|
|
|
if (data == null || !StringUtils.hasText(data.getOrderNo()) || !StringUtils.hasText(data.getNodeCode())) { |
|
|
|
throw new I18nException("lc.production.report.param.incomplete"); |
|
|
|
@ -843,6 +956,12 @@ public class ProductionPlanServiceImpl implements ProductionPlanService { |
|
|
|
if (STATUS_DONE.equals(order.getStatus())) { |
|
|
|
throw new I18nException("lc.production.order.done.cannot.report"); |
|
|
|
} |
|
|
|
if (ORDER_TYPE_CABLE_COP.equals(orderType)) { |
|
|
|
String allowedNodeCode = resolveCableCopNodeCodeByTaskType(order.getTaskType()); |
|
|
|
if (StringUtils.hasText(allowedNodeCode) && !allowedNodeCode.equals(data.getNodeCode())) { |
|
|
|
throw new XJException("当前任务类型仅允许报工节点:" + resolveCableCopNodeNameByNodeCode(allowedNodeCode)); |
|
|
|
} |
|
|
|
} |
|
|
|
ProductionPlanOrderNodeData node = productionPlanMapper.queryOrderNodeByCode(data.getOrderNo(), data.getNodeCode()); |
|
|
|
if (node == null) { |
|
|
|
throw new I18nException("lc.production.report.node.not.exists"); |
|
|
|
|