调整同步TMS修改
This commit is contained in:
+92
-27
@@ -608,6 +608,74 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
businessOrderAccountMapper.insert(acc);
|
businessOrderAccountMapper.insert(acc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 同步地址明细表(business_document_address_multi):逻辑删旧 + 按调整后扁平字段插新
|
||||||
|
syncAddressDetail(orderId, toSave, loginUser, now);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同步地址明细表:把「调整后业务单」的装/卸货扁平字段写回 business_document_address_multi。
|
||||||
|
* 与 applyAddressMapping 口径一致(装货取第一条、卸货取最后一条),此处各保留一条。
|
||||||
|
*/
|
||||||
|
private void syncAddressDetail(Long orderId, BusinessDocumentOrder toSave, LoginUser loginUser, Date now) {
|
||||||
|
// 逻辑删旧
|
||||||
|
List<BusinessDocumentAddressMulti> oldList = businessDocumentAddressMultiMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<BusinessDocumentAddressMulti>()
|
||||||
|
.eq(BusinessDocumentAddressMulti::getOrderId, String.valueOf(orderId))
|
||||||
|
.eq(BusinessDocumentAddressMulti::getDelFlag, 1));
|
||||||
|
if (oldList != null) {
|
||||||
|
for (BusinessDocumentAddressMulti old : oldList) {
|
||||||
|
old.setDelFlag(0);
|
||||||
|
old.setUpdateBy(loginUser != null ? loginUser.getUserid() : null);
|
||||||
|
old.setUpdateTime(now);
|
||||||
|
businessDocumentAddressMultiMapper.updateById(old);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Long userId = loginUser != null ? loginUser.getUserid() : null;
|
||||||
|
// 装货
|
||||||
|
BusinessDocumentAddressMulti loading = new BusinessDocumentAddressMulti();
|
||||||
|
loading.setOrderId(String.valueOf(orderId));
|
||||||
|
loading.setAreaCode(toSave.getLoadingAreaId());
|
||||||
|
loading.setAreaName(toSave.getLoadingName());
|
||||||
|
loading.setAddress(toSave.getLoadingAddress());
|
||||||
|
loading.setLongitude(toSave.getLoadingLongitude());
|
||||||
|
loading.setLatitude(toSave.getLoadingLatitude());
|
||||||
|
loading.setContactName(toSave.getFreighterName());
|
||||||
|
loading.setContactPhone(toSave.getLoadingPhone());
|
||||||
|
loading.setLayDate(toSave.getLoadingDate());
|
||||||
|
loading.setLayType(1L);
|
||||||
|
loading.setDelFlag(1);
|
||||||
|
loading.setOrganizationId(toSave.getOrganizationId());
|
||||||
|
loading.setOrganizationName(toSave.getOrganizationName());
|
||||||
|
loading.setTopOrganizationId(toSave.getTopOrganizationId());
|
||||||
|
loading.setCreateBy(userId);
|
||||||
|
loading.setCreateTime(now);
|
||||||
|
loading.setUpdateBy(userId);
|
||||||
|
loading.setUpdateTime(now);
|
||||||
|
businessDocumentAddressMultiMapper.insert(loading);
|
||||||
|
|
||||||
|
// 卸货
|
||||||
|
BusinessDocumentAddressMulti unload = new BusinessDocumentAddressMulti();
|
||||||
|
unload.setOrderId(String.valueOf(orderId));
|
||||||
|
unload.setAreaCode(toSave.getUnloadAreaId());
|
||||||
|
unload.setAreaName(toSave.getUnloadName());
|
||||||
|
unload.setAddress(toSave.getUnloadAddress());
|
||||||
|
unload.setLongitude(toSave.getUnloadLongitude());
|
||||||
|
unload.setLatitude(toSave.getUnloadLatitude());
|
||||||
|
unload.setContactName(toSave.getDischargerName());
|
||||||
|
unload.setContactPhone(toSave.getUnloadPhone());
|
||||||
|
unload.setLayDate(toSave.getUnloadingData());
|
||||||
|
unload.setLayType(2L);
|
||||||
|
unload.setDelFlag(1);
|
||||||
|
unload.setOrganizationId(toSave.getOrganizationId());
|
||||||
|
unload.setOrganizationName(toSave.getOrganizationName());
|
||||||
|
unload.setTopOrganizationId(toSave.getTopOrganizationId());
|
||||||
|
unload.setCreateBy(userId);
|
||||||
|
unload.setCreateTime(now);
|
||||||
|
unload.setUpdateBy(userId);
|
||||||
|
unload.setUpdateTime(now);
|
||||||
|
businessDocumentAddressMultiMapper.insert(unload);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void copySnapshot(BusinessDocumentOrder order, BusinessDocumentOrderAdjustDetail detail) {
|
private void copySnapshot(BusinessDocumentOrder order, BusinessDocumentOrderAdjustDetail detail) {
|
||||||
@@ -702,37 +770,34 @@ public class BusinessDocumentOrderAdjustService {
|
|||||||
}
|
}
|
||||||
tmsOrderAddDTO.setCargoInfoList(cargoInfoList);
|
tmsOrderAddDTO.setCargoInfoList(cargoInfoList);
|
||||||
|
|
||||||
// 装货地址
|
// 装货地址:统一以「调整后业务单」的扁平字段为准,避免明细表(business_document_address_multi)旧值覆盖
|
||||||
List<BusinessDocumentAddressMulti> loadingAddrList = businessDocumentAddressMultiMapper.selectList(
|
TmsAddressMultiDTO loadingDto = new TmsAddressMultiDTO();
|
||||||
new LambdaQueryWrapper<BusinessDocumentAddressMulti>()
|
loadingDto.setAreaCode(after.getLoadingAreaId());
|
||||||
.eq(BusinessDocumentAddressMulti::getOrderId, String.valueOf(after.getId()))
|
loadingDto.setAreaName(after.getLoadingName());
|
||||||
.eq(BusinessDocumentAddressMulti::getDelFlag, 1)
|
loadingDto.setAddress(after.getLoadingAddress());
|
||||||
.eq(BusinessDocumentAddressMulti::getLayType, 1L));
|
loadingDto.setLongitude(after.getLoadingLongitude());
|
||||||
|
loadingDto.setLatitude(after.getLoadingLatitude());
|
||||||
|
loadingDto.setContactName(after.getFreighterName());
|
||||||
|
loadingDto.setContactPhone(after.getLoadingPhone());
|
||||||
|
loadingDto.setLayDate(after.getLoadingDate());
|
||||||
|
loadingDto.setLayType(1);
|
||||||
List<TmsAddressMultiDTO> loadingAddressList = new ArrayList<>();
|
List<TmsAddressMultiDTO> loadingAddressList = new ArrayList<>();
|
||||||
if (loadingAddrList != null) {
|
loadingAddressList.add(loadingDto);
|
||||||
for (BusinessDocumentAddressMulti addr : loadingAddrList) {
|
|
||||||
TmsAddressMultiDTO dto = new TmsAddressMultiDTO();
|
|
||||||
BeanUtil.copyProperties(addr, dto);
|
|
||||||
loadingAddressList.add(dto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmsOrderAddDTO.setLoadingAddressList(loadingAddressList);
|
tmsOrderAddDTO.setLoadingAddressList(loadingAddressList);
|
||||||
|
|
||||||
// 卸货地址
|
// 卸货地址:同样以「调整后业务单」的扁平字段为准
|
||||||
List<BusinessDocumentAddressMulti> unloadAddrList = businessDocumentAddressMultiMapper.selectList(
|
TmsAddressMultiDTO unloadDto = new TmsAddressMultiDTO();
|
||||||
new LambdaQueryWrapper<BusinessDocumentAddressMulti>()
|
unloadDto.setAreaCode(after.getUnloadAreaId());
|
||||||
.eq(BusinessDocumentAddressMulti::getOrderId, String.valueOf(after.getId()))
|
unloadDto.setAreaName(after.getUnloadName());
|
||||||
.eq(BusinessDocumentAddressMulti::getDelFlag, 1)
|
unloadDto.setAddress(after.getUnloadAddress());
|
||||||
.eq(BusinessDocumentAddressMulti::getLayType, 2L));
|
unloadDto.setLongitude(after.getUnloadLongitude());
|
||||||
|
unloadDto.setLatitude(after.getUnloadLatitude());
|
||||||
|
unloadDto.setContactName(after.getDischargerName());
|
||||||
|
unloadDto.setContactPhone(after.getUnloadPhone());
|
||||||
|
unloadDto.setLayDate(after.getUnloadingData());
|
||||||
|
unloadDto.setLayType(2);
|
||||||
List<TmsAddressMultiDTO> unloadAddressList = new ArrayList<>();
|
List<TmsAddressMultiDTO> unloadAddressList = new ArrayList<>();
|
||||||
if (unloadAddrList != null) {
|
unloadAddressList.add(unloadDto);
|
||||||
for (BusinessDocumentAddressMulti addr : unloadAddrList) {
|
|
||||||
TmsAddressMultiDTO dto = new TmsAddressMultiDTO();
|
|
||||||
BeanUtil.copyProperties(addr, dto);
|
|
||||||
dto.setLayType(2);
|
|
||||||
unloadAddressList.add(dto);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tmsOrderAddDTO.setUnloadAddressList(unloadAddressList);
|
tmsOrderAddDTO.setUnloadAddressList(unloadAddressList);
|
||||||
|
|
||||||
// 费用明细
|
// 费用明细
|
||||||
|
|||||||
Reference in New Issue
Block a user