|
@@ -31,12 +31,9 @@ public class OrderService extends GenericProvider {
|
|
|
if (!Arrays.asList("start", "back", "end").contains(operate)) {
|
|
if (!Arrays.asList("start", "back", "end").contains(operate)) {
|
|
|
return "-1^非法的操作类型: " + operate;
|
|
return "-1^非法的操作类型: " + operate;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- // ================= 1. 基础校验与主表查询 (公共逻辑) =================
|
|
|
|
|
if (id == null || id.trim().isEmpty()) {
|
|
if (id == null || id.trim().isEmpty()) {
|
|
|
return "-1^id为空";
|
|
return "-1^id为空";
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
List<String> idList = Arrays.stream(id.split(","))
|
|
List<String> idList = Arrays.stream(id.split(","))
|
|
|
.map(String::trim)
|
|
.map(String::trim)
|
|
|
.filter(s -> !s.isEmpty())
|
|
.filter(s -> !s.isEmpty())
|
|
@@ -45,12 +42,10 @@ public class OrderService extends GenericProvider {
|
|
|
if (idList.isEmpty()) {
|
|
if (idList.isEmpty()) {
|
|
|
return "-1^id非法";
|
|
return "-1^id非法";
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
String safeIdStr = idList.stream()
|
|
String safeIdStr = idList.stream()
|
|
|
.map(s -> s.replace("'", "''"))
|
|
.map(s -> s.replace("'", "''"))
|
|
|
.collect(Collectors.joining("','"));
|
|
.collect(Collectors.joining("','"));
|
|
|
|
|
|
|
|
- // 查询入库登记子表
|
|
|
|
|
String sqlMain = "SELECT * from t_sjhxhclrkysdjbzb where parent_id_ in('" + safeIdStr + "')";
|
|
String sqlMain = "SELECT * from t_sjhxhclrkysdjbzb where parent_id_ in('" + safeIdStr + "')";
|
|
|
List<Map<String, Object>> inSubList = commonDao.query(sqlMain);
|
|
List<Map<String, Object>> inSubList = commonDao.query(sqlMain);
|
|
|
|
|
|
|
@@ -58,7 +53,6 @@ public class OrderService extends GenericProvider {
|
|
|
return "-1^未找到入库登记子表记录";
|
|
return "-1^未找到入库登记子表记录";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // ================= 2. 查询订单子表 (公共逻辑) =================
|
|
|
|
|
List<String> ddzIdList = inSubList.stream()
|
|
List<String> ddzIdList = inSubList.stream()
|
|
|
.map(m -> {
|
|
.map(m -> {
|
|
|
Object val = m.get("ding_dan_zi_id_");
|
|
Object val = m.get("ding_dan_zi_id_");
|
|
@@ -84,7 +78,6 @@ public class OrderService extends GenericProvider {
|
|
|
(v1, v2) -> v1
|
|
(v1, v2) -> v1
|
|
|
));
|
|
));
|
|
|
|
|
|
|
|
- // ================= 3. 【第一阶段】全量预校验与SQL构造 (核心差异点) =================
|
|
|
|
|
List<String> updateSqls = new ArrayList<>();
|
|
List<String> updateSqls = new ArrayList<>();
|
|
|
|
|
|
|
|
for (Map<String, Object> inSub : inSubList) {
|
|
for (Map<String, Object> inSub : inSubList) {
|
|
@@ -96,25 +89,23 @@ public class OrderService extends GenericProvider {
|
|
|
|
|
|
|
|
Map<String, Object> orderSub = orderSubMap.get(ddzId);
|
|
Map<String, Object> orderSub = orderSubMap.get(ddzId);
|
|
|
|
|
|
|
|
- // 获取数值
|
|
|
|
|
- double inQty = getDoubleValue(inSub.get("shu_liang_"));
|
|
|
|
|
- double currentYuLing = getDoubleValue(orderSub.get("yu_ling_liang_"));
|
|
|
|
|
- double currentDaiRuKu = getDoubleValue(orderSub.get("dai_ru_ku_shu_lia"));
|
|
|
|
|
- double orderQty = getDoubleValue(orderSub.get("shu_liang_")); // 订单总量,start时用
|
|
|
|
|
|
|
+ int inQty = getIntValue(inSub.get("shu_liang_"));
|
|
|
|
|
+ int currentYuLing = getIntValue(orderSub.get("yu_ling_liang_"));
|
|
|
|
|
+ int currentDaiRuKu = getIntValue(orderSub.get("dai_ru_ku_shu_lia"));
|
|
|
|
|
+ int orderQty = getIntValue(orderSub.get("shu_liang_")); // 订单总量,start时用
|
|
|
|
|
|
|
|
if (inQty < 0) {
|
|
if (inQty < 0) {
|
|
|
return "-1^数量必须为正数 (当前值:" + inQty + ")";
|
|
return "-1^数量必须为正数 (当前值:" + inQty + ")";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- // --- 根据 operate 计算新值和校验 ---
|
|
|
|
|
- double newYuLing = 0.0;
|
|
|
|
|
- Double newDaiRuKu = null; // null 表示该操作不更新此字段
|
|
|
|
|
|
|
+ int newYuLing = 0;
|
|
|
|
|
+ Integer newDaiRuKu = null; // null 表示该操作不更新此字段
|
|
|
boolean checkPassed = false;
|
|
boolean checkPassed = false;
|
|
|
String errorMsg = "";
|
|
String errorMsg = "";
|
|
|
|
|
|
|
|
if ("start".equals(operate)) {
|
|
if ("start".equals(operate)) {
|
|
|
// [START] 占用预留,减少待入库
|
|
// [START] 占用预留,减少待入库
|
|
|
- double availableQty = orderQty - currentYuLing;
|
|
|
|
|
|
|
+ int availableQty = orderQty - currentYuLing;
|
|
|
if (availableQty < inQty) {
|
|
if (availableQty < inQty) {
|
|
|
errorMsg = "已超过可入库数量! (可用:" + availableQty + ", 申请:" + inQty + ")";
|
|
errorMsg = "已超过可入库数量! (可用:" + availableQty + ", 申请:" + inQty + ")";
|
|
|
} else {
|
|
} else {
|
|
@@ -149,11 +140,11 @@ public class OrderService extends GenericProvider {
|
|
|
String mingCheng = Objects.toString(orderSub.get("ming_cheng_"), "");
|
|
String mingCheng = Objects.toString(orderSub.get("ming_cheng_"), "");
|
|
|
String bianMa = Objects.toString(orderSub.get("bian_ma_"), "");
|
|
String bianMa = Objects.toString(orderSub.get("bian_ma_"), "");
|
|
|
String operateStr = "";
|
|
String operateStr = "";
|
|
|
- if(operate.equals("start")){
|
|
|
|
|
|
|
+ if ("start".equals(operate)) {
|
|
|
operateStr = "启动";
|
|
operateStr = "启动";
|
|
|
- } else if (operate.equals("back")){
|
|
|
|
|
|
|
+ } else if ("back".equals(operate)) {
|
|
|
operateStr = "撤回";
|
|
operateStr = "撤回";
|
|
|
- } else if (operate.equals("end")){
|
|
|
|
|
|
|
+ } else if ("end".equals(operate)) {
|
|
|
operateStr = "结束";
|
|
operateStr = "结束";
|
|
|
}
|
|
}
|
|
|
// 统一错误消息格式
|
|
// 统一错误消息格式
|
|
@@ -194,6 +185,21 @@ public class OrderService extends GenericProvider {
|
|
|
return "1^success!";
|
|
return "1^success!";
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private int getIntValue(Object obj) {
|
|
|
|
|
+ if (obj == null) {
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (obj instanceof Number) {
|
|
|
|
|
+ return ((Number) obj).intValue();
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ return Integer.parseInt(obj.toString().trim());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ logger.warn("getIntValue parse failed, obj={}", obj, e);
|
|
|
|
|
+ return 0;
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
public void deleteErrorRecord(String id) throws Exception {
|
|
public void deleteErrorRecord(String id) throws Exception {
|
|
|
if (id == null || id.trim().isEmpty()) {
|
|
if (id == null || id.trim().isEmpty()) {
|
|
|
return;
|
|
return;
|