|
@@ -189,17 +189,19 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
|
|
public Result<String> edit(@RequestBody BilletOriginalProductRecord billetOriginalProductRecord) {
|
|
|
BilletOriginalProductRecord bopr = billetOriginalProductRecordService.getById(billetOriginalProductRecord.getId());
|
|
|
- if(bopr == null) {
|
|
|
+ if (bopr == null) {
|
|
|
return Result.error("未找到对应数据,编辑失败!");
|
|
|
}
|
|
|
+
|
|
|
// 检查是否更新了hotChargeLength字段
|
|
|
boolean hotChargeLengthUpdated = false;
|
|
|
if (billetOriginalProductRecord.getHotChargeLength() != null &&
|
|
|
!billetOriginalProductRecord.getHotChargeLength().equals(bopr.getHotChargeLength())) {
|
|
|
hotChargeLengthUpdated = true;
|
|
|
}
|
|
|
- if (bopr.getAmount() != null && !bopr.getAmount().equals(billetOriginalProductRecord.getAmount())) {
|
|
|
- Integer newTotal = billetOriginalProductRecord.getAmount();
|
|
|
+
|
|
|
+ Integer newTotal = billetOriginalProductRecord.getAmount();
|
|
|
+ if (bopr.getAmount() != null && !bopr.getAmount().equals(newTotal)) {
|
|
|
// 确保新合计数非负
|
|
|
if (newTotal < 0) {
|
|
|
return Result.error("合计数量不能为负数,编辑失败!");
|
|
@@ -217,56 +219,45 @@ public class BilletOriginalProductRecordController extends JeecgController<Bille
|
|
|
bopr.setEightStrandSum(strandAllocation.get("eightStrandSum"));
|
|
|
// 更新合计字段
|
|
|
bopr.setAmount(newTotal);
|
|
|
- // 复制其他非空字段(忽略流支数和ID)
|
|
|
- BeanUtils.copyProperties(billetOriginalProductRecord, bopr,
|
|
|
- "id", "oneStrandSum", "twoStrandSum", "threeStrandSum",
|
|
|
- "fourStrandSum", "fiveStrandSum", "sixStrandSum",
|
|
|
- "sevenStrandSum", "eightStrandSum", "amount");
|
|
|
- // 如果更新了hotChargeLength,设置is_edit_charge为2
|
|
|
- if (hotChargeLengthUpdated) {
|
|
|
- bopr.setIsEditCharge("2");
|
|
|
- }
|
|
|
- // 判断remark字段是否为NULL,不为空代表需要起垛
|
|
|
- if (oConvertUtils.isNotEmpty(bopr.getStackInfo())){
|
|
|
- String str = bopr.getStackInfo();
|
|
|
- String[] parts = str.split("-");
|
|
|
- // 起垛的数量
|
|
|
- int stackingSum = Integer.parseInt(parts[0]);
|
|
|
- // 定尺
|
|
|
- String size = parts[1];
|
|
|
- String typeConfigId = parts[2];
|
|
|
- handleAddStack(bopr.getCcmNo(), bopr.getHeatNo(), stackingSum, size, typeConfigId);
|
|
|
- // 备注remark字段重置
|
|
|
- bopr.setStackInfo("");
|
|
|
- }
|
|
|
- // 保存修改
|
|
|
- billetOriginalProductRecordService.updateById(bopr);
|
|
|
- }else {
|
|
|
- // 复制所有非空字段(忽略ID)
|
|
|
- BeanUtils.copyProperties(billetOriginalProductRecord, bopr, "id");
|
|
|
- // 如果更新了hotChargeLength,设置is_edit_charge为2
|
|
|
- if (hotChargeLengthUpdated) {
|
|
|
- bopr.setIsEditCharge("2");
|
|
|
- }
|
|
|
- // 判断remark字段是否为NULL,不为空代表需要起垛
|
|
|
- if (oConvertUtils.isNotEmpty(bopr.getStackInfo())){
|
|
|
- String str = bopr.getStackInfo();
|
|
|
- String[] parts = str.split("-");
|
|
|
- // 起垛的数量
|
|
|
- int stackingSum = Integer.parseInt(parts[0]);
|
|
|
- // 定尺
|
|
|
- String size = parts[1];
|
|
|
- String typeConfigId = parts[2];
|
|
|
- handleAddStack(bopr.getCcmNo(), bopr.getHeatNo(), stackingSum, size, typeConfigId);
|
|
|
- // 备注remark字段重置
|
|
|
- bopr.setStackInfo("");
|
|
|
- }
|
|
|
- // 保存修改
|
|
|
- billetOriginalProductRecordService.updateById(bopr);
|
|
|
}
|
|
|
+ // 提取公共逻辑到方法中
|
|
|
+ processCommonEditLogic(bopr, billetOriginalProductRecord, hotChargeLengthUpdated);
|
|
|
+
|
|
|
return Result.OK("编辑成功!");
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 处理编辑操作中的公共逻辑
|
|
|
+ */
|
|
|
+ private void processCommonEditLogic(BilletOriginalProductRecord bopr, BilletOriginalProductRecord newRecord, boolean hotChargeLengthUpdated) {
|
|
|
+ // 复制所有非空字段(忽略ID和流支数字段)
|
|
|
+ String[] ignoreProperties = {"id", "oneStrandSum", "twoStrandSum", "threeStrandSum",
|
|
|
+ "fourStrandSum", "fiveStrandSum", "sixStrandSum",
|
|
|
+ "sevenStrandSum", "eightStrandSum", "amount"};
|
|
|
+ BeanUtils.copyProperties(newRecord, bopr, ignoreProperties);
|
|
|
+
|
|
|
+ // 如果更新了hotChargeLength,设置is_edit_charge为2
|
|
|
+ if (hotChargeLengthUpdated) {
|
|
|
+ bopr.setIsEditCharge("2");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 判断stackInfo字段是否为非空,不为空代表需要起垛
|
|
|
+ if (oConvertUtils.isNotEmpty(bopr.getStackInfo())) {
|
|
|
+ String str = bopr.getStackInfo();
|
|
|
+ String[] parts = str.split("-");
|
|
|
+ // 起垛的数量
|
|
|
+ int stackingSum = Integer.parseInt(parts[0]);
|
|
|
+ // 定尺
|
|
|
+ String size = parts[1];
|
|
|
+ String typeConfigId = parts[2];
|
|
|
+ handleAddStack(bopr.getCcmNo(), bopr.getHeatNo(), stackingSum, size, typeConfigId);
|
|
|
+ // 备注stackInfo字段重置
|
|
|
+ bopr.setStackInfo("");
|
|
|
+ }
|
|
|
+ // 保存修改
|
|
|
+ billetOriginalProductRecordService.updateById(bopr);
|
|
|
+ }
|
|
|
+
|
|
|
/***
|
|
|
* 处理起垛
|
|
|
* @param ccmNo
|