同步过滤逻辑修改3

This commit is contained in:
秦鸿展
2026-07-13 17:42:04 +08:00
parent 38b2de852b
commit 8377d9f2a5
2 changed files with 24 additions and 9 deletions
@@ -70,13 +70,28 @@ public class UserShipperMasterDataSyncService {
public void syncMasterData() {
LoginUser loginUser = requireLoginUser();
Long organizationId = loginUser.getUserPo().getOrganizationId();
String lockKey = LOCK_PREFIX + organizationId;
boolean locked = redisLock.tryLock(lockKey, SYNC_LOCK_MINUTES, TimeUnit.MINUTES);
if (!locked) {
throw new ServiceException("当前组织正在同步主数据,请稍后再试");
}
markSyncInProgress(organizationId);
asyncUserShipperMasterDataSyncService.syncMasterDataAsync(loginUser, lockKey);
new Thread(() -> {
String lockKey = LOCK_PREFIX + organizationId;
try {
boolean locked = redisLock.tryLock(lockKey, SYNC_LOCK_MINUTES, TimeUnit.MINUTES);
if (!locked) {
log.warn("当前组织正在同步主数据,跳过本次同步");
return;
}
markSyncInProgress(organizationId);
try {
ShipperMasterDataSyncResultVo resultVo = doSync(loginUser);
log.info("MDM同步完成: {}", resultVo);
} catch (Exception e) {
log.error("同步主数据失败, organizationId={}", organizationId, e);
markSyncFailed(organizationId, e.getMessage());
} finally {
redisLock.unlock(lockKey);
}
} catch (Exception e) {
log.error("获取同步锁失败", e);
}
}, "mdm-sync-thread").start();
}
public ShipperMasterDataSyncResultVo executeSync(LoginUser loginUser) {