demand: 运单修改件数重量体积批次同步修改,运单分批总件数小于运单件数时重量体积也应小于运单,运单分批总件数等于运单件数时重量体积也应等于运单,运单已分批不允许修改件数重量体积并精确提示对应批次
committer: heyu
This commit is contained in:
parent
918ed5a85f
commit
3814a1f315
@ -94,4 +94,10 @@ public interface EmisTmsSiteBatchDtlMapper extends BaseMapper<EmisTmsSiteBatchDt
|
||||
*/
|
||||
List<EmisTmsSiteBatchDtl> selectEmisTmsSiteBatchDtlByBatchNo(@Param("batchNo") String batchNo);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param batchDtl
|
||||
* @return
|
||||
*/
|
||||
int updateBatchDtlByBillCode(EmisTmsSiteBatchDtl batchDtl);
|
||||
}
|
||||
|
||||
@ -5371,9 +5371,34 @@ public class EmisBaseService {
|
||||
|
||||
// 如果查询结果数量大于0,说明该运单已分批,抛出业务异常
|
||||
if (batchDtlList != null && batchDtlList.size() > 0) {
|
||||
// 提取批次号并去重
|
||||
Set<String> batchNoSet = batchDtlList.stream()
|
||||
.map(EmisTmsSiteBatchDtl::getBatchNo)
|
||||
.filter(StringUtils::isNotBlank)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
String batchNoStr = String.join(",", batchNoSet);
|
||||
throw new EmisBizError(EmisBizErrorType.PARAM_ERROR,
|
||||
"运单[" + emisWaybillSave.getBillCode() + "]已分批,不允许修改件数、重量、体积");
|
||||
"运单[" + emisWaybillSave.getBillCode() + "]已分批,不允许修改件数、重量、体积。" + "批次号:" + batchNoStr);
|
||||
}
|
||||
updateBatchDtlByBillCode(emisWaybillSave);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据运单号更新批次详情表
|
||||
*
|
||||
* @param emisWaybillSave 保存的运单信息
|
||||
*/
|
||||
private void updateBatchDtlByBillCode(EmisWaybill emisWaybillSave) {
|
||||
EmisTmsSiteBatchDtl batchDtl = new EmisTmsSiteBatchDtl();
|
||||
|
||||
batchDtl.setBatchParcelQty(emisWaybillSave.getParcelQty());
|
||||
batchDtl.setBatchWeight(emisWaybillSave.getBillWeight());
|
||||
batchDtl.setBatchVolume(emisWaybillSave.getTotalVolume());
|
||||
batchDtl.setBillCode(emisWaybillSave.getBillCode());
|
||||
|
||||
emisTmsSiteBatchDtlMapper.updateBatchDtlByBillCode(batchDtl);
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws ParseException {
|
||||
|
||||
@ -163,11 +163,18 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
|
||||
|
||||
}
|
||||
|
||||
private void checkItemDtl(EmisTmsSiteBatch oldSiteBatch, EmisTmsSiteBatchDtl itemDtl, EmisWaybill emisWaybill,
|
||||
private void checkItemDtl(EmisTmsSiteBatch oldSiteBatch, EmisTmsSiteBatchDtl itemDtl, EmisWaybill emisWaybill,
|
||||
EmisTransPlanRule rule) throws EmisBizError {
|
||||
if (emisWaybill.getParcelQty().equals(itemDtl.getBatchParcelQty())
|
||||
&& emisWaybill.getBillWeight().equals(itemDtl.getBatchWeight())
|
||||
&& emisWaybill.getTotalVolume().equals(itemDtl.getBatchVolume())) {
|
||||
// 安全比较:检查批次数据是否与运单数据完全一致
|
||||
boolean isParcelQtyEqual = Objects.equals(emisWaybill.getParcelQty(), itemDtl.getBatchParcelQty());
|
||||
// 重量比较:使用compareTo方法比较大小是否相等
|
||||
boolean isWeightEqual = emisWaybill.getBillWeight() != null && itemDtl.getBatchWeight() != null
|
||||
&& emisWaybill.getBillWeight().compareTo(itemDtl.getBatchWeight()) == 0;
|
||||
// 体积比较:使用compareTo方法比较大小是否相等
|
||||
boolean isVolumeEqual = emisWaybill.getTotalVolume() != null && itemDtl.getBatchVolume() != null
|
||||
&& emisWaybill.getTotalVolume().compareTo(itemDtl.getBatchVolume()) == 0;
|
||||
|
||||
if (isParcelQtyEqual && isWeightEqual && isVolumeEqual) {
|
||||
checkUnique(oldSiteBatch, itemDtl.getBillCode());
|
||||
return;
|
||||
}
|
||||
@ -189,7 +196,7 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
|
||||
List<EmisTmsSiteBatch> existingBatches = selectTmsSiteBatchBySiteAndBillCode(
|
||||
oldSiteBatch.getStartSiteCode(),
|
||||
oldSiteBatch.getNextSiteCode(),
|
||||
itemDtl.getBillCode(),itemDtl.getId());
|
||||
itemDtl.getBillCode(), itemDtl.getId());
|
||||
|
||||
// 创建包含当前批次的临时批次列表用于分组去重
|
||||
List<EmisTmsSiteBatch> allBatches = new ArrayList<>(existingBatches);
|
||||
@ -224,6 +231,42 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
|
||||
.filter(Objects::nonNull)
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
if (totalParcelQty < emisWaybill.getParcelQty()) {
|
||||
if (totalWeight.compareTo(emisWaybill.getBillWeight()) >= 0) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
"因为:" + itemDtl.getBillCode() + "的批次总件数(" + totalParcelQty + ")小于运单件数("
|
||||
+ emisWaybill.getParcelQty() + ");所以:" +
|
||||
itemDtl.getBillCode() + "的批次总重量(" + totalWeight + ")应小于运单重量("
|
||||
+ emisWaybill.getBillWeight() + ")");
|
||||
}
|
||||
|
||||
if (totalVolume.compareTo(emisWaybill.getTotalVolume()) >= 0) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
"因为:" + itemDtl.getBillCode() + "的批次总件数(" + totalParcelQty + ")小于运单件数("
|
||||
+ emisWaybill.getParcelQty() + ");所以:" +
|
||||
itemDtl.getBillCode() + "的批次总体积(" + totalVolume + ")应小于运单体积("
|
||||
+ emisWaybill.getTotalVolume() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
if (totalParcelQty == emisWaybill.getParcelQty()) {
|
||||
if (totalWeight.compareTo(emisWaybill.getBillWeight()) != 0) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
"因为:" + itemDtl.getBillCode() + "的批次总件数(" + totalParcelQty + ")等于运单件数("
|
||||
+ emisWaybill.getParcelQty() + ");所以:" +
|
||||
itemDtl.getBillCode() + "的批次总重量(" + totalWeight + ")应等于运单重量("
|
||||
+ emisWaybill.getBillWeight() + ")");
|
||||
}
|
||||
|
||||
if (totalVolume.compareTo(emisWaybill.getTotalVolume()) != 0) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
"因为:" + itemDtl.getBillCode() + "的批次总件数(" + totalParcelQty + ")等于运单件数("
|
||||
+ emisWaybill.getParcelQty() + ");所以:" +
|
||||
itemDtl.getBillCode() + "的批次总体积(" + totalVolume + ")应等于运单体积("
|
||||
+ emisWaybill.getTotalVolume() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
// 校验总重量、总件数、总体积不能超过运单数据
|
||||
if (totalWeight.compareTo(emisWaybill.getBillWeight()) > 0) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
@ -257,9 +300,13 @@ public class EmisTmsSiteBatchServiceImpl extends EmisBaseService implements IEmi
|
||||
|
||||
if (matchingBatch != null) {
|
||||
// 检查批次重量、体积、件数是否一致
|
||||
if (!Objects.equals(matchingBatch.getTotalWeight(), itemDtl.getBatchWeight()) ||
|
||||
!Objects.equals(matchingBatch.getTotalVolume(), itemDtl.getBatchVolume()) ||
|
||||
!Objects.equals(matchingBatch.getTotalParcelQty(), itemDtl.getBatchParcelQty())) {
|
||||
boolean isBatchWeightEqual = matchingBatch.getTotalWeight() != null && itemDtl.getBatchWeight() != null
|
||||
&& matchingBatch.getTotalWeight().compareTo(itemDtl.getBatchWeight()) == 0;
|
||||
boolean isBatchVolumeEqual = matchingBatch.getTotalVolume() != null && itemDtl.getBatchVolume() != null
|
||||
&& matchingBatch.getTotalVolume().compareTo(itemDtl.getBatchVolume()) == 0;
|
||||
boolean isBatchParcelQtyEqual = Objects.equals(matchingBatch.getTotalParcelQty(), itemDtl.getBatchParcelQty());
|
||||
|
||||
if (!isBatchWeightEqual || !isBatchVolumeEqual || !isBatchParcelQtyEqual) {
|
||||
throw new EmisBizError(EmisBizErrorType.FAIL,
|
||||
itemDtl.getBillCode() + "的批次重量、体积、件数与批次" + matchingBatch.getBatchNo() + "不一致,请检查后重新录入");
|
||||
}
|
||||
|
||||
@ -223,4 +223,14 @@
|
||||
set del_flag = '1'
|
||||
where batch_no = #{batchNo} and del_flag = '0'
|
||||
</update>
|
||||
|
||||
<update id="updateBatchDtlByBillCode" parameterType="EmisTmsSiteBatchDtl">
|
||||
update emis_tms_site_batch_dtl
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
batch_volume = #{batchVolume},
|
||||
batch_parcel_qty = #{batchParcelQty},
|
||||
batch_weight = #{batchWeight}
|
||||
</trim>
|
||||
where bill_code = #{billCode} and del_flag = '0'
|
||||
</update>
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue
Block a user