|
|
|
@ -1619,7 +1619,9 @@ public class PODetailServiceImpl extends ServiceImpl<PODetailMapper, PODetail> i |
|
|
|
model.setAQty(qtyTargets[1]); |
|
|
|
|
|
|
|
validatePoDetailUpdate(model, existingDetail); |
|
|
|
validateRequiredPriceAndQty(model, model.getOrderNo()); |
|
|
|
// 编辑路径专用:qty/aQty 双 null代表本次不动数量列(resolveAQtyEditTargets 的语义), |
|
|
|
// 需用 existing 的既有值兜底参与必填校验,避免“仅改 po_no”无端报 PO Qty 不能为空。 |
|
|
|
validateRequiredPriceAndQtyForEdit(model, existingDetail, model.getOrderNo()); |
|
|
|
poFieldAuthSupport.validateWriteFields(writableFieldMap, model); |
|
|
|
|
|
|
|
applyCalculatedPoValue(model); |
|
|
|
@ -2624,6 +2626,32 @@ public class PODetailServiceImpl extends ServiceImpl<PODetailMapper, PODetail> i |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 编辑路径专用校验: |
|
|
|
* resolveAQtyEditTargets 在“数量未变化”时会将 model.qty/aQty 回写 null, |
|
|
|
* 作为 updatePoDetailForEdit XML 中 <if test="qty != null"> 不更新该列的标记, |
|
|
|
* 不能被严格校验误判为“未传数量”。因此 qty/aQty/price 均先取 model 当前值, |
|
|
|
* null 时回退到 existingDetail 的既有值;仅当两边都为 null 才抛“不能为空”。 |
|
|
|
*/ |
|
|
|
private void validateRequiredPriceAndQtyForEdit(PODetailVo vo, PODetail existing, String context) { |
|
|
|
if (vo == null) { |
|
|
|
throw new RuntimeException("参数不能为空"); |
|
|
|
} |
|
|
|
String prefix = StringUtils.hasText(context) ? context + ":" : ""; |
|
|
|
Double effectivePrice = vo.getPrice() != null ? vo.getPrice() |
|
|
|
: (existing == null ? null : existing.getPrice()); |
|
|
|
Double effectiveQty = vo.getQty() != null ? vo.getQty() |
|
|
|
: (existing == null ? null : existing.getQty()); |
|
|
|
Double effectiveAQty = vo.getAQty() != null ? vo.getAQty() |
|
|
|
: (existing == null ? null : existing.getAQty()); |
|
|
|
if (effectivePrice == null) { |
|
|
|
throw new RuntimeException(prefix + "Unit Price 不能为空"); |
|
|
|
} |
|
|
|
if (effectiveQty == null && effectiveAQty == null) { |
|
|
|
throw new RuntimeException(prefix + "PO Qty 不能为空"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private String calculatePoValue(Double price, Double qty) { |
|
|
|
if (price == null || qty == null) { |
|
|
|
return null; |
|
|
|
|