同步数据库新增双向同步选择

This commit is contained in:
liyj 2025-06-17 09:42:00 +08:00
parent fe8ff2ab33
commit 17cb6509b7
6 changed files with 18 additions and 0 deletions

View File

@ -90,6 +90,9 @@ public class DynamicTaskScheduler {
commentModel =sxDataService.getCommentModel();
}
DataBaseInfo dataBaseInfo=sxDataService.getDataBaseInfo(commentModel);
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
}
sxDataService.syncStoreData(dataBaseInfo,commentModel);
sxDataService.SyncBranchList(dataBaseInfo,commentModel);
sxDataService.SyncCategory(dataBaseInfo,commentModel);

View File

@ -24,6 +24,8 @@ public class DataBaseInfo {
private String cronExpression;
@ApiModelProperty(value = "同步模式(1:定时同步,2:间隔同步)")
private String syncMode;
@ApiModelProperty(value = "是否双向同步(0:否,1:是)")
private String isTowSync="1";
@ApiModelProperty(value = "商品分类")
private String categoryName;

View File

@ -65,4 +65,7 @@ public class StoreDbConfig implements Serializable {
@ApiModelProperty(value = "刷新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date refreshTime;
@ApiModelProperty(value = "是否双向同步(0:否,1:是)")
private String isTowSync="1";
}

View File

@ -653,6 +653,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
dataBaseInfo.setCronExpression(storeDbConfig.getCronExpression());
dataBaseInfo.setCategoryName(storeDbConfig.getCategoryName());
dataBaseInfo.setRefreshTime(storeDbConfig.getRefreshTime());
dataBaseInfo.setIsTowSync(storeDbConfig.getIsTowSync());
return dataBaseInfo;
}
return new DataBaseInfo();
@ -660,6 +661,10 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
@Override
public void syncStoreData(DataBaseInfo dataBaseInfo,CommentModel commentModel) {
if(dataBaseInfo.getIsTowSync().equals("0")){
log.info("不做双向同步数据库");
return;
}
JSONObject jsonObject= restTemplate.getForObject(remoteIp+HttpUtils.URL_SYNC_GET_STOR_DATA_RELEASE
+"?appKey="+commentModel.getAppKey()
+"&sign="+commentModel.getSign(),JSONObject.class);

View File

@ -89,4 +89,8 @@ public class StoreDbConfig implements Serializable {
@ApiModelProperty(value = "刷新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date refreshTime;
@TableField("is_two_sync")
@ApiModelProperty(value = "是否双向同步(0:否,1:是)")
private String isTowSync="1";
}

View File

@ -0,0 +1 @@
alter table store_db_config add column is_two_sync char(1) NOT NULL DEFAULT '1' COMMENT '是否双向同步(0:否,1:是)';