From fe8ff2ab33050ba8a7bc8418d55b69dd57f703ce Mon Sep 17 00:00:00 2001 From: liyj <1617420630@qq.com> Date: Mon, 16 Jun 2025 17:39:25 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E5=93=81=E7=89=8C=E7=9A=84=E6=8B=BC?= =?UTF-8?q?=E9=9F=B3=E7=94=9F=E6=88=90=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= =?UTF-8?q?=E8=A7=A3=E5=86=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mall/common/utils/TinyPinyinUtils.java | 53 +++++++++++++++++++ .../impl/ShopBaseProductBrandServiceImpl.java | 6 +-- 2 files changed, 55 insertions(+), 4 deletions(-) create mode 100644 mall-common/src/main/java/com/suisung/mall/common/utils/TinyPinyinUtils.java diff --git a/mall-common/src/main/java/com/suisung/mall/common/utils/TinyPinyinUtils.java b/mall-common/src/main/java/com/suisung/mall/common/utils/TinyPinyinUtils.java new file mode 100644 index 00000000..7b55ec54 --- /dev/null +++ b/mall-common/src/main/java/com/suisung/mall/common/utils/TinyPinyinUtils.java @@ -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 + } +} diff --git a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductBrandServiceImpl.java b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductBrandServiceImpl.java index db14fb44..a27bf765 100644 --- a/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductBrandServiceImpl.java +++ b/mall-shop/src/main/java/com/suisung/mall/shop/base/service/impl/ShopBaseProductBrandServiceImpl.java @@ -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.FilterUtils; 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.shop.base.mapper.ShopBaseProductBrandMapper; import com.suisung.mall.shop.base.service.ShopBaseProductBrandService; @@ -118,11 +119,8 @@ public class ShopBaseProductBrandServiceImpl extends BaseServiceImpl Date: Tue, 17 Jun 2025 09:42:00 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E5=BA=93=E6=96=B0=E5=A2=9E=E5=8F=8C=E5=90=91=E5=90=8C=E6=AD=A5?= =?UTF-8?q?=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/small/client/Schedule/DynamicTaskScheduler.java | 3 +++ client/src/main/java/com/small/client/dto/DataBaseInfo.java | 2 ++ client/src/main/java/com/small/client/dto/StoreDbConfig.java | 3 +++ .../java/com/small/client/service/imp/SxDataServiceImp.java | 5 +++++ .../com/suisung/mall/common/modules/sync/StoreDbConfig.java | 4 ++++ sql/shop/dev/202506017_ddl.sql | 1 + 6 files changed, 18 insertions(+) create mode 100644 sql/shop/dev/202506017_ddl.sql diff --git a/client/src/main/java/com/small/client/Schedule/DynamicTaskScheduler.java b/client/src/main/java/com/small/client/Schedule/DynamicTaskScheduler.java index a0d65a11..a5a5c0ab 100644 --- a/client/src/main/java/com/small/client/Schedule/DynamicTaskScheduler.java +++ b/client/src/main/java/com/small/client/Schedule/DynamicTaskScheduler.java @@ -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); diff --git a/client/src/main/java/com/small/client/dto/DataBaseInfo.java b/client/src/main/java/com/small/client/dto/DataBaseInfo.java index 9ac5ed19..78177f5b 100644 --- a/client/src/main/java/com/small/client/dto/DataBaseInfo.java +++ b/client/src/main/java/com/small/client/dto/DataBaseInfo.java @@ -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; diff --git a/client/src/main/java/com/small/client/dto/StoreDbConfig.java b/client/src/main/java/com/small/client/dto/StoreDbConfig.java index d60fa1b4..1bfd8b52 100644 --- a/client/src/main/java/com/small/client/dto/StoreDbConfig.java +++ b/client/src/main/java/com/small/client/dto/StoreDbConfig.java @@ -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"; } diff --git a/client/src/main/java/com/small/client/service/imp/SxDataServiceImp.java b/client/src/main/java/com/small/client/service/imp/SxDataServiceImp.java index 95288d93..b237f28e 100644 --- a/client/src/main/java/com/small/client/service/imp/SxDataServiceImp.java +++ b/client/src/main/java/com/small/client/service/imp/SxDataServiceImp.java @@ -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); diff --git a/mall-common/src/main/java/com/suisung/mall/common/modules/sync/StoreDbConfig.java b/mall-common/src/main/java/com/suisung/mall/common/modules/sync/StoreDbConfig.java index 65ee871c..9512f995 100644 --- a/mall-common/src/main/java/com/suisung/mall/common/modules/sync/StoreDbConfig.java +++ b/mall-common/src/main/java/com/suisung/mall/common/modules/sync/StoreDbConfig.java @@ -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"; } \ No newline at end of file diff --git a/sql/shop/dev/202506017_ddl.sql b/sql/shop/dev/202506017_ddl.sql new file mode 100644 index 00000000..f9169519 --- /dev/null +++ b/sql/shop/dev/202506017_ddl.sql @@ -0,0 +1 @@ +alter table store_db_config add column is_two_sync char(1) NOT NULL DEFAULT '1' COMMENT '是否双向同步(0:否,1:是)'; \ No newline at end of file