From 4b5ed4d0e19f7ad51e392952deb12ac32cd74237 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A7=A6=E9=B8=BF=E5=B1=95?= <18031053041@163.com> Date: Thu, 10 Sep 2026 23:07:59 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=90=8C=E6=AD=A5TMS?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessDocumentOrderAdjustService.java | 119 ++++++++++++++---- 1 file changed, 92 insertions(+), 27 deletions(-) diff --git a/mhd_oms/src/main/java/com/mhd/oms/application/service/businessDocumentOrder/BusinessDocumentOrderAdjustService.java b/mhd_oms/src/main/java/com/mhd/oms/application/service/businessDocumentOrder/BusinessDocumentOrderAdjustService.java index 3b11809fe..1411518ec 100644 --- a/mhd_oms/src/main/java/com/mhd/oms/application/service/businessDocumentOrder/BusinessDocumentOrderAdjustService.java +++ b/mhd_oms/src/main/java/com/mhd/oms/application/service/businessDocumentOrder/BusinessDocumentOrderAdjustService.java @@ -608,6 +608,74 @@ public class BusinessDocumentOrderAdjustService { 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 oldList = businessDocumentAddressMultiMapper.selectList( + new LambdaQueryWrapper() + .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) { @@ -702,37 +770,34 @@ public class BusinessDocumentOrderAdjustService { } tmsOrderAddDTO.setCargoInfoList(cargoInfoList); - // 装货地址 - List loadingAddrList = businessDocumentAddressMultiMapper.selectList( - new LambdaQueryWrapper() - .eq(BusinessDocumentAddressMulti::getOrderId, String.valueOf(after.getId())) - .eq(BusinessDocumentAddressMulti::getDelFlag, 1) - .eq(BusinessDocumentAddressMulti::getLayType, 1L)); + // 装货地址:统一以「调整后业务单」的扁平字段为准,避免明细表(business_document_address_multi)旧值覆盖 + TmsAddressMultiDTO loadingDto = new TmsAddressMultiDTO(); + loadingDto.setAreaCode(after.getLoadingAreaId()); + loadingDto.setAreaName(after.getLoadingName()); + loadingDto.setAddress(after.getLoadingAddress()); + loadingDto.setLongitude(after.getLoadingLongitude()); + loadingDto.setLatitude(after.getLoadingLatitude()); + loadingDto.setContactName(after.getFreighterName()); + loadingDto.setContactPhone(after.getLoadingPhone()); + loadingDto.setLayDate(after.getLoadingDate()); + loadingDto.setLayType(1); List loadingAddressList = new ArrayList<>(); - if (loadingAddrList != null) { - for (BusinessDocumentAddressMulti addr : loadingAddrList) { - TmsAddressMultiDTO dto = new TmsAddressMultiDTO(); - BeanUtil.copyProperties(addr, dto); - loadingAddressList.add(dto); - } - } + loadingAddressList.add(loadingDto); tmsOrderAddDTO.setLoadingAddressList(loadingAddressList); - // 卸货地址 - List unloadAddrList = businessDocumentAddressMultiMapper.selectList( - new LambdaQueryWrapper() - .eq(BusinessDocumentAddressMulti::getOrderId, String.valueOf(after.getId())) - .eq(BusinessDocumentAddressMulti::getDelFlag, 1) - .eq(BusinessDocumentAddressMulti::getLayType, 2L)); + // 卸货地址:同样以「调整后业务单」的扁平字段为准 + TmsAddressMultiDTO unloadDto = new TmsAddressMultiDTO(); + unloadDto.setAreaCode(after.getUnloadAreaId()); + unloadDto.setAreaName(after.getUnloadName()); + unloadDto.setAddress(after.getUnloadAddress()); + unloadDto.setLongitude(after.getUnloadLongitude()); + unloadDto.setLatitude(after.getUnloadLatitude()); + unloadDto.setContactName(after.getDischargerName()); + unloadDto.setContactPhone(after.getUnloadPhone()); + unloadDto.setLayDate(after.getUnloadingData()); + unloadDto.setLayType(2); List unloadAddressList = new ArrayList<>(); - if (unloadAddrList != null) { - for (BusinessDocumentAddressMulti addr : unloadAddrList) { - TmsAddressMultiDTO dto = new TmsAddressMultiDTO(); - BeanUtil.copyProperties(addr, dto); - dto.setLayType(2); - unloadAddressList.add(dto); - } - } + unloadAddressList.add(unloadDto); tmsOrderAddDTO.setUnloadAddressList(unloadAddressList); // 费用明细