客商主数据查询BUG修改1

This commit is contained in:
秦鸿展
2026-06-13 15:06:37 +08:00
parent 578e3b34d4
commit 192a406682
3 changed files with 42 additions and 6 deletions
@@ -15,6 +15,7 @@ public final class MdmMerchantSyncFilter {
public enum SkipReason {
EMPTY_CODE,
NOT_CUSTOMER,
INTERNAL_ORG,
ORG_MISMATCH,
DISABLED,
MISSING_NAME
@@ -53,6 +54,9 @@ public final class MdmMerchantSyncFilter {
if (!isCustomer(record)) {
return SkipReason.NOT_CUSTOMER;
}
if (StringUtils.isNotEmpty(orgNcCode) && orgNcCode.equals(trim(record.getCode()))) {
return SkipReason.INTERNAL_ORG;
}
if (!belongsToOrg(record.getDesc24(), orgNcCode)) {
return SkipReason.ORG_MISMATCH;
}
@@ -1378,7 +1378,7 @@ public class UserShipperApplicationService {
authShipper(userShipperDO);
UserShipperEntity shipperEntity = userShipperDomainService.findShipperByUserId(user.getUserId());
wlhyDomainService.addShipperUserInfo(shipperEntity);
syncWlhyShipperSafely(shipperEntity, record.getCode());
}
@Transactional(rollbackFor = Exception.class)
@@ -1388,7 +1388,34 @@ public class UserShipperApplicationService {
userShipperDO.setDataSource(1);
userShipperDO.setShipperId(existing.getShipperId());
userShipperDO.setUserId(existing.getUserId());
updateShipper(userShipperDO);
updateShipperFromMasterData(userShipperDO, record.getCode());
}
/**
* MDM 同步:本地更新成功后同步网货,网货失败仅记日志,不阻断主数据同步。
*/
private void updateShipperFromMasterData(UserShipperDO userShipperDO, String customerCode) {
LoginUser loginUser = SecurityUtils.getLoginUser();
if (ObjectUtil.isNull(loginUser)) {
throw new DigitalLogisticsException(UserError.TIMEOUT);
}
UserPo loginUserPo = loginUser.getUserPo();
userShipperDO.setUpdateBy(loginUserPo.getUserId());
userShipperDO.setUpdateByName(loginUserPo.getUserName());
userShipperDO.setUpdateTime(new Date());
updateUserInformation(userShipperDO);
userShipperDomainService.saveUserShipper(userShipperDO);
UserShipperEntity shipperEntity = userShipperDomainService.findShipperByUserId(userShipperDO.getUserId());
syncWlhyShipperSafely(shipperEntity, customerCode);
}
private void syncWlhyShipperSafely(UserShipperEntity shipperEntity, String customerCode) {
try {
wlhyDomainService.addShipperUserInfo(shipperEntity);
} catch (Exception e) {
log.warn("MDM同步委托方本地保存成功,同步网货失败(不影响主数据同步), CODE={}, userId={}, msg={}",
customerCode, shipperEntity.getUserId(), e.getMessage(), e);
}
}
private UserShipperDO buildShipperDOFromMasterData(MdmMerchantRecordDTO record, LoginUser loginUser) {
@@ -136,6 +136,7 @@ public class UserShipperMasterDataSyncService {
String maxModifyTime = lastModifyRecordTime;
int skipOrgMismatch = 0;
int skipNotCustomer = 0;
int skipInternalOrg = 0;
int skipDisabled = 0;
int skipOther = 0;
int currentPage = 1;
@@ -157,6 +158,9 @@ public class UserShipperMasterDataSyncService {
case NOT_CUSTOMER:
skipNotCustomer++;
break;
case INTERNAL_ORG:
skipInternalOrg++;
break;
case DISABLED:
skipDisabled++;
break;
@@ -201,7 +205,7 @@ public class UserShipperMasterDataSyncService {
Date now = new Date();
resultVo.setLastSyncTime(now);
saveSyncWatermark(organizationId, orgNcCode, maxModifyTime, now, resultVo,
skipOrgMismatch, skipNotCustomer, skipDisabled, skipOther);
skipOrgMismatch, skipNotCustomer, skipInternalOrg, skipDisabled, skipOther);
return resultVo;
}
@@ -225,7 +229,8 @@ public class UserShipperMasterDataSyncService {
private void saveSyncWatermark(Long organizationId, String orgNcCode, String maxModifyTime, Date syncTime,
ShipperMasterDataSyncResultVo resultVo,
int skipOrgMismatch, int skipNotCustomer, int skipDisabled, int skipOther) {
int skipOrgMismatch, int skipNotCustomer, int skipInternalOrg,
int skipDisabled, int skipOther) {
UserShipperMdmSyncEntity entity = userShipperMdmSyncMapper.selectByOrganizationId(organizationId);
if (entity == null) {
entity = new UserShipperMdmSyncEntity();
@@ -238,9 +243,9 @@ public class UserShipperMasterDataSyncService {
entity.setLastSyncTime(syncTime);
entity.setSyncStatus(resultVo.getFailCount() > 0 ? 2 : 1);
String syncMessage = String.format(
"新增%d,更新%d,跳过%d,失败%d;组织NC=%s;跳过明细[组织不匹配:%d,非客户:%d,停用:%d,其他:%d]",
"新增%d,更新%d,跳过%d,失败%d;组织NC=%s;跳过明细[组织不匹配:%d,非客户:%d,内部单位:%d,停用:%d,其他:%d]",
resultVo.getAddCount(), resultVo.getUpdateCount(), resultVo.getSkipCount(), resultVo.getFailCount(),
orgNcCode, skipOrgMismatch, skipNotCustomer, skipDisabled, skipOther);
orgNcCode, skipOrgMismatch, skipNotCustomer, skipInternalOrg, skipDisabled, skipOther);
if (resultVo.getFailCount() > 0 && !resultVo.getErrorMessages().isEmpty()) {
syncMessage += "" + resultVo.getErrorMessages().get(0);
}