|
|
@ -1,7 +1,9 @@ |
|
|
package com.zdxt.enforcementcode.businessdatasyn.resolver; |
|
|
package com.zdxt.enforcementcode.businessdatasyn.resolver; |
|
|
|
|
|
|
|
|
|
|
|
import com.zdxt.enforcementcode.businessdatasyn.config.SyncProperties; |
|
|
import com.zdxt.enforcementcode.businessdatasyn.config.SyncTableConfig; |
|
|
import com.zdxt.enforcementcode.businessdatasyn.config.SyncTableConfig; |
|
|
import com.zdxt.enforcementcode.businessdatasyn.domain.dto.*; |
|
|
import com.zdxt.enforcementcode.businessdatasyn.domain.dto.*; |
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
@ -13,8 +15,19 @@ import org.springframework.stereotype.Component; |
|
|
*/ |
|
|
*/ |
|
|
@Slf4j |
|
|
@Slf4j |
|
|
@Component |
|
|
@Component |
|
|
|
|
|
@RequiredArgsConstructor |
|
|
public class RowMergeResolver { |
|
|
public class RowMergeResolver { |
|
|
|
|
|
|
|
|
|
|
|
private final SyncProperties syncProperties; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 删除同步是否允许(全局总闸 + 表级 deleteMode) |
|
|
|
|
|
*/ |
|
|
|
|
|
private boolean deleteAllowed(SyncTableConfig config) { |
|
|
|
|
|
return syncProperties.isDeleteSyncEnabled() |
|
|
|
|
|
&& !"none".equalsIgnoreCase(config.getDeleteMode()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 解析同步决策 |
|
|
* 解析同步决策 |
|
|
* |
|
|
* |
|
|
@ -45,6 +58,14 @@ public class RowMergeResolver { |
|
|
if (v2Exists) { |
|
|
if (v2Exists) { |
|
|
if (ownerSide == OwnerSide.V1) { |
|
|
if (ownerSide == OwnerSide.V1) { |
|
|
// 场景 7:归属方(V1)删除 → 删除对侧(V2)
|
|
|
// 场景 7:归属方(V1)删除 → 删除对侧(V2)
|
|
|
|
|
|
if (!deleteAllowed(config)) { |
|
|
|
|
|
log.info("[BizSync] 归属方V1已删除但删除同步被禁用,跳过: {}", config.getConfigKey()); |
|
|
|
|
|
return SyncDecision.builder() |
|
|
|
|
|
.action(SyncActionEnum.SKIP) |
|
|
|
|
|
.ownerSide(ownerSide) |
|
|
|
|
|
.reason("归属方V1已删除,但删除同步被禁用,跳过") |
|
|
|
|
|
.build(); |
|
|
|
|
|
} |
|
|
return SyncDecision.builder() |
|
|
return SyncDecision.builder() |
|
|
.action(SyncActionEnum.DELETE_V2) |
|
|
.action(SyncActionEnum.DELETE_V2) |
|
|
.ownerSide(ownerSide) |
|
|
.ownerSide(ownerSide) |
|
|
@ -70,6 +91,14 @@ public class RowMergeResolver { |
|
|
if (v1Exists) { |
|
|
if (v1Exists) { |
|
|
if (ownerSide == OwnerSide.V2) { |
|
|
if (ownerSide == OwnerSide.V2) { |
|
|
// 场景 8:归属方(V2)删除 → 删除对侧(V1)
|
|
|
// 场景 8:归属方(V2)删除 → 删除对侧(V1)
|
|
|
|
|
|
if (!deleteAllowed(config)) { |
|
|
|
|
|
log.info("[BizSync] 归属方V2已删除但删除同步被禁用,跳过: {}", config.getConfigKey()); |
|
|
|
|
|
return SyncDecision.builder() |
|
|
|
|
|
.action(SyncActionEnum.SKIP) |
|
|
|
|
|
.ownerSide(ownerSide) |
|
|
|
|
|
.reason("归属方V2已删除,但删除同步被禁用,跳过") |
|
|
|
|
|
.build(); |
|
|
|
|
|
} |
|
|
return SyncDecision.builder() |
|
|
return SyncDecision.builder() |
|
|
.action(SyncActionEnum.DELETE_V1) |
|
|
.action(SyncActionEnum.DELETE_V1) |
|
|
.ownerSide(ownerSide) |
|
|
.ownerSide(ownerSide) |
|
|
|