Merge remote-tracking branch 'origin/main'

This commit is contained in:
Jack 2025-06-17 11:38:05 +08:00
commit 397634d57d
8 changed files with 73 additions and 4 deletions

View File

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

View File

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

View File

@ -65,4 +65,7 @@ public class StoreDbConfig implements Serializable {
@ApiModelProperty(value = "刷新时间") @ApiModelProperty(value = "刷新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date refreshTime; 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.setCronExpression(storeDbConfig.getCronExpression());
dataBaseInfo.setCategoryName(storeDbConfig.getCategoryName()); dataBaseInfo.setCategoryName(storeDbConfig.getCategoryName());
dataBaseInfo.setRefreshTime(storeDbConfig.getRefreshTime()); dataBaseInfo.setRefreshTime(storeDbConfig.getRefreshTime());
dataBaseInfo.setIsTowSync(storeDbConfig.getIsTowSync());
return dataBaseInfo; return dataBaseInfo;
} }
return new DataBaseInfo(); return new DataBaseInfo();
@ -660,6 +661,10 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
@Override @Override
public void syncStoreData(DataBaseInfo dataBaseInfo,CommentModel commentModel) { 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 JSONObject jsonObject= restTemplate.getForObject(remoteIp+HttpUtils.URL_SYNC_GET_STOR_DATA_RELEASE
+"?appKey="+commentModel.getAppKey() +"?appKey="+commentModel.getAppKey()
+"&sign="+commentModel.getSign(),JSONObject.class); +"&sign="+commentModel.getSign(),JSONObject.class);

View File

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

View File

@ -0,0 +1,53 @@
package com.suisung.mall.common.utils;
import com.github.promeg.pinyinhelper.Pinyin;
public class TinyPinyinUtils{
/**
* 获取汉字全拼
* @param chinese 中文字符串
* @return 拼音字符串小写
*/
public static String getFullPinyin(String chinese) {
if (chinese == null || chinese.trim().isEmpty()) {
return "";
}
return Pinyin.toPinyin(chinese, " ").toLowerCase();
}
/**
* 获取汉字首字母
* @param chinese 中文字符串
* @return 首字母字符串大写
*/
public static String getFirstLetters(String chinese) {
if (chinese == null || chinese.trim().isEmpty()) {
return "";
}
StringBuilder firstLetters = new StringBuilder();
for (char c : chinese.toCharArray()) {
if (Pinyin.isChinese(c)) {
String pinyin = Pinyin.toPinyin(c);
if (!pinyin.isEmpty()) {
firstLetters.append(pinyin.charAt(0));
}
} else {
firstLetters.append(c);
}
}
return firstLetters.toString();
}
public static void main(String[] args) {
String text = "其他品牌";
System.out.println("全拼: " + getFullPinyin(text));
// 输出: SHANGPINSHUJUQUANXIANKONGZHI
System.out.println("首字母: " + getFirstLetters(text));
System.out.println("首字母: " + getFullPinyin(text).charAt(0));
// 输出: SPSJQXKZ
}
}

View File

@ -15,6 +15,7 @@ import com.suisung.mall.common.modules.base.ShopBaseProductCategory;
import com.suisung.mall.common.utils.CheckUtil; import com.suisung.mall.common.utils.CheckUtil;
import com.suisung.mall.common.utils.FilterUtils; import com.suisung.mall.common.utils.FilterUtils;
import com.suisung.mall.common.utils.I18nUtil; import com.suisung.mall.common.utils.I18nUtil;
import com.suisung.mall.common.utils.TinyPinyinUtils;
import com.suisung.mall.core.web.service.impl.BaseServiceImpl; import com.suisung.mall.core.web.service.impl.BaseServiceImpl;
import com.suisung.mall.shop.base.mapper.ShopBaseProductBrandMapper; import com.suisung.mall.shop.base.mapper.ShopBaseProductBrandMapper;
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService; import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
@ -118,11 +119,8 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl<ShopBasePro
@Transactional @Transactional
@Override @Override
public boolean saveOrUpdateBrand(ShopBaseProductBrand shopBaseProductBrand) { public boolean saveOrUpdateBrand(ShopBaseProductBrand shopBaseProductBrand) {
shopBaseProductBrand.setBrand_name_pinyin(TinyPinyinUtils.getFullPinyin(shopBaseProductBrand.getBrand_name()));
//shopBaseProductBrand.setBrand_name_pinyin("qi ta pin pai");
shopBaseProductBrand.setBrand_name_pinyin(PinyinUtil.getPinyin(shopBaseProductBrand.getBrand_name()));
shopBaseProductBrand.setBrand_initial(Convert.toStr(shopBaseProductBrand.getBrand_name_pinyin().charAt(0))); shopBaseProductBrand.setBrand_initial(Convert.toStr(shopBaseProductBrand.getBrand_name_pinyin().charAt(0)));
//shopBaseProductBrand.setBrand_initial("q");
Integer store_id = shopBaseProductBrand.getStore_id(); Integer store_id = shopBaseProductBrand.getStore_id();
boolean isPlatform = true; boolean isPlatform = true;

View File

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