同步过滤逻辑修改3
This commit is contained in:
+22
-7
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user