diff --git a/sql/longchuang_production_plan.sql b/sql/longchuang_production_plan.sql
index 96ba56a..8c37310 100644
--- a/sql/longchuang_production_plan.sql
+++ b/sql/longchuang_production_plan.sql
@@ -165,6 +165,9 @@ go
LC_RENOVATION_ASSY
LC_RENOVATION_INSPECT
LC_RENOVATION_PACK
+机加工生产:
+ LC_MACHINING_PRODUCTION
+ LC_MACHINING_INSPECTION
以下为按角色名称的示例初始化,请按你们实际角色名调整
*/
update dbo.sys_role set role_type = 'LC_HOME_LIFT_STOCKING' where role_name like '%家用电梯%' and role_name like '%仓库配料%';
@@ -180,4 +183,34 @@ update dbo.sys_role set role_type = 'LC_RENOVATION_STOCKING' where role_name lik
update dbo.sys_role set role_type = 'LC_RENOVATION_ASSY' where role_name like '%改造%' and role_name like '%组装%';
update dbo.sys_role set role_type = 'LC_RENOVATION_INSPECT' where role_name like '%改造%' and role_name like '%检验%';
update dbo.sys_role set role_type = 'LC_RENOVATION_PACK' where role_name like '%改造%' and role_name like '%打包%';
+update dbo.sys_role set role_type = 'LC_MACHINING_PRODUCTION' where role_name like '%机加工%' and role_name like '%生产%';
+update dbo.sys_role set role_type = 'LC_MACHINING_INSPECTION' where role_name like '%机加工%' and role_name like '%检验%';
+go
+
+/*
+可选:为历史机加工任务补齐“机加工检验”节点
+*/
+insert into dbo.lc_production_order_node
+(order_id, node_code, node_name, sort_no, status, create_time, update_time)
+select
+ n.order_id,
+ 'machiningInspection',
+ N'机加工检验',
+ 2,
+ case
+ when o.status = N'已完成' then N'已完成'
+ when n.status = N'已完成' then N'进行中'
+ else N'未开始'
+ end,
+ getdate(),
+ getdate()
+from dbo.lc_production_order_node n
+inner join dbo.lc_production_order o on o.id = n.order_id and o.order_type = 'MACHINING'
+where n.node_code = 'machiningProduction'
+ and not exists (
+ select 1
+ from dbo.lc_production_order_node x
+ where x.order_id = n.order_id
+ and x.node_code = 'machiningInspection'
+ );
go
diff --git a/src/main/java/com/xujie/sys/modules/longchuang/service/impl/ProductionPlanServiceImpl.java b/src/main/java/com/xujie/sys/modules/longchuang/service/impl/ProductionPlanServiceImpl.java
index e4bf4b2..ea6274a 100644
--- a/src/main/java/com/xujie/sys/modules/longchuang/service/impl/ProductionPlanServiceImpl.java
+++ b/src/main/java/com/xujie/sys/modules/longchuang/service/impl/ProductionPlanServiceImpl.java
@@ -65,6 +65,10 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
private static final String ORDER_TYPE_CABLE_COP = "CABLE_COP";
private static final String ORDER_TYPE_RENOVATION = "RENOVATION";
private static final String ORDER_TYPE_MACHINING = "MACHINING";
+ private static final String MACHINING_NODE_PRODUCTION = "machiningProduction";
+ private static final String MACHINING_NODE_INSPECTION = "machiningInspection";
+ private static final String MACHINING_NODE_PRODUCTION_NAME = "机加工生产";
+ private static final String MACHINING_NODE_INSPECTION_NAME = "机加工检验";
private static final String STATUS_PLAN = "已排产";
private static final String STATUS_PROCESSING = "进行中";
@@ -221,8 +225,8 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
throw new XJException("请先拍照或录制视频");
}
String orderType = normalizeOrderType(data.getOrderType());
- if (ORDER_TYPE_MACHINING.equals(orderType)) {
- throw new XJException("机加工报工无需上传影像");
+ if (ORDER_TYPE_MACHINING.equals(orderType) && !isMachiningInspectionNode(orderType, data.getNodeCode())) {
+ throw new XJException("机加工仅检验节点支持上传影像");
}
boolean reportNode = !Boolean.FALSE.equals(data.getReportNode());
String logNo = reportNode ? reportOrderNode(data, orderType) : validateMediaUploadOnly(data, orderType);
@@ -352,7 +356,9 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
productionPlanMapper.updateOrderStatus(reportLog.getOrderNo(), STATUS_PLAN, null, userId);
}
- if (ORDER_TYPE_CABLE_COP.equals(normalizedOrderType) || ORDER_TYPE_MACHINING.equals(normalizedOrderType)) {
+ boolean needRollbackQty = ORDER_TYPE_CABLE_COP.equals(normalizedOrderType)
+ || isMachiningProductionNode(normalizedOrderType, reportLog.getNodeCode());
+ if (needRollbackQty) {
BigDecimal reportQty = reportLog.getReportQty() == null ? BigDecimal.ZERO : reportLog.getReportQty();
if (reportQty.compareTo(BigDecimal.ZERO) > 0) {
productionPlanMapper.decreaseOrderReportQty(reportLog.getOrderNo(), reportQty, userId);
@@ -858,7 +864,8 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
return nodeList;
}
if (ORDER_TYPE_MACHINING.equals(orderType)) {
- nodeList.add(buildNode("machiningProduction", "机加工生产", 1));
+ nodeList.add(buildNode(MACHINING_NODE_PRODUCTION, MACHINING_NODE_PRODUCTION_NAME, 1));
+ nodeList.add(buildNode(MACHINING_NODE_INSPECTION, MACHINING_NODE_INSPECTION_NAME, 2));
return nodeList;
}
if (ORDER_TYPE_HOME_LIFT.equals(orderType)) {
@@ -1047,21 +1054,30 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
Long userId = getCurrentUserId();
String userName = getCurrentUserName();
productionPlanMapper.updateOrderNodeToDone(data.getOrderNo(), data.getNodeCode(), data.getRemark(), userId);
- if (ORDER_TYPE_CABLE_COP.equals(orderType) || ORDER_TYPE_MACHINING.equals(orderType)) {
- BigDecimal reportQty = data.getReportQty() == null ? BigDecimal.ZERO : data.getReportQty();
+ BigDecimal reportQty = data.getReportQty();
+ boolean qtyRequired = ORDER_TYPE_CABLE_COP.equals(orderType)
+ || isMachiningProductionNode(orderType, data.getNodeCode());
+ if (qtyRequired) {
+ reportQty = reportQty == null ? BigDecimal.ZERO : reportQty;
if (reportQty.compareTo(BigDecimal.ZERO) <= 0) {
throw new I18nException("lc.production.report.qty.gt.zero");
}
- if (ORDER_TYPE_MACHINING.equals(orderType)) {
- productionPlanMapper.increaseOrderReportQty(data.getOrderNo(), reportQty, userId);
- } else {
- productionPlanMapper.updateCableCopReportQty(
- data.getOrderNo(),
- reportQty,
- order.getTaskQty() == null ? BigDecimal.ZERO : order.getTaskQty(),
- userId
- );
- }
+ } else if (isMachiningInspectionNode(orderType, data.getNodeCode())
+ && (reportQty == null || reportQty.compareTo(BigDecimal.ZERO) <= 0)) {
+ reportQty = BigDecimal.ONE;
+ }
+ if (reportQty != null) {
+ data.setReportQty(reportQty);
+ }
+ if (ORDER_TYPE_CABLE_COP.equals(orderType)) {
+ productionPlanMapper.updateCableCopReportQty(
+ data.getOrderNo(),
+ reportQty,
+ order.getTaskQty() == null ? BigDecimal.ZERO : order.getTaskQty(),
+ userId
+ );
+ } else if (isMachiningProductionNode(orderType, data.getNodeCode())) {
+ productionPlanMapper.increaseOrderReportQty(data.getOrderNo(), reportQty, userId);
}
int unDoneCount = productionPlanMapper.countUnDoneOrderNode(data.getOrderNo());
if (unDoneCount > 0) {
@@ -1075,7 +1091,9 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
data.setReportUserName(userName);
String logNo = generateLogNo(orderType);
data.setLogNo(logNo);
- data.setRemark(ORDER_TYPE_MACHINING.equals(orderType)&&data.getReportQty() != null ? "报工数量:"+data.getReportQty():"");
+ if (isMachiningProductionNode(orderType, data.getNodeCode()) && data.getReportQty() != null) {
+ data.setRemark("报工数量:" + data.getReportQty());
+ }
productionPlanMapper.insertNodeReportLog(data);
return logNo;
}
@@ -1448,14 +1466,25 @@ public class ProductionPlanServiceImpl implements ProductionPlanService {
return null;
}
if (ORDER_TYPE_MACHINING.equals(orderType)) {
- if ("machiningProduction".equals(nodeCode)) {
+ if (MACHINING_NODE_PRODUCTION.equals(nodeCode)) {
return "LC_MACHINING_PRODUCTION";
}
+ if (MACHINING_NODE_INSPECTION.equals(nodeCode)) {
+ return "LC_MACHINING_INSPECTION";
+ }
return null;
}
return null;
}
+ private boolean isMachiningProductionNode(String orderType, String nodeCode) {
+ return ORDER_TYPE_MACHINING.equals(orderType) && MACHINING_NODE_PRODUCTION.equals(nodeCode);
+ }
+
+ private boolean isMachiningInspectionNode(String orderType, String nodeCode) {
+ return ORDER_TYPE_MACHINING.equals(orderType) && MACHINING_NODE_INSPECTION.equals(nodeCode);
+ }
+
private void finishOrder(String orderNo, String orderType) {
if (!StringUtils.hasText(orderNo)) {
throw new I18nException("lc.production.finish.param.empty");
diff --git a/src/main/resources/mapper/longchuang/ProductionPlanMapper.xml b/src/main/resources/mapper/longchuang/ProductionPlanMapper.xml
index 44f0b1d..428dc59 100644
--- a/src/main/resources/mapper/longchuang/ProductionPlanMapper.xml
+++ b/src/main/resources/mapper/longchuang/ProductionPlanMapper.xml
@@ -77,7 +77,9 @@
and a.plan_finish_date #{query.planEndDate}
- order by isnull(a.plan_delivery_date, a.plan_finish_date) asc
+ order by
+ case when a.status = '已完成' then 1 else 0 end asc,
+ isnull(a.plan_delivery_date, a.plan_finish_date) asc