Compare commits

...

3 Commits

Author SHA1 Message Date
1ca810ef1d es导入接口新增 2025-07-19 14:22:09 +08:00
e38dad6d81 防篡改问题修复 2025-07-19 14:21:54 +08:00
06e80c8995 es导入接口新增 2025-07-19 14:19:25 +08:00
16 changed files with 109 additions and 31 deletions

View File

@ -134,7 +134,6 @@ public class CommonUtil {
buf.append(Integer.toHexString(i));
}
return Base64.encodeBase64String(buf.toString().getBytes(StandardCharsets.UTF_8));
} catch (Exception e) {
log.error(e.getMessage());
return Strings.EMPTY;

View File

@ -95,12 +95,12 @@ public class CryptoUtils {
// 示例用法
public static void main(String[] args) throws Exception {
String appKey = "d68397c4fb671bc024e24e1964b067cc35388818";
String sign = "d68397c4fb671bc024e24e1964b067cc35388818";
String appKey = "ae1d3f9a-3b4c-4d6e-7f8a-9b0c1d2e3f6b";
String appSecret = "H2tH3gJ4kL2sP2wR8yU0iO4pL7cV2bN4c";
String storeId = "1";
// 打包加密
String encrypted = packAndEncrypt(appKey, sign, storeId);
String encrypted = packAndEncrypt(appKey, appSecret, storeId);
System.out.println("加密结果: " + encrypted);
// 解密解包

View File

@ -31,7 +31,16 @@ public class WebController {
public void synBrand(){
log.info("synBrand");
// sxDataService.getAppSign();
sxDataService.SyncBranchList(new DataBaseInfo(),sxDataService.getCommentModel());
CommentModel commentModel= sxDataService.getCommentModel();
DataBaseInfo dataBaseInfo=sxDataService.getDataBaseInfo(commentModel);
if(dataBaseInfo==null){
log.error("syncGoods dataBaseInfo is null");
return;
}
if(ObjectUtil.isNotEmpty(dataBaseInfo.getRefreshTime())){
commentModel.setSyncTime(DateUtil.formatDateTime(dataBaseInfo.getRefreshTime()));
}
sxDataService.SyncBranchList(dataBaseInfo,sxDataService.getCommentModel());
}
@RequestMapping("/syncCategory")

View File

@ -75,7 +75,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
*/
@Override
public void SyncCategory(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
dataBaseInfo= getDataBaseInfo(commentModel);
// dataBaseInfo= getDataBaseInfo(commentModel);
// 记录总数
Integer total = sxDataDao.getTBdItemClsTotal(dataBaseInfo);
if(total==0){
@ -100,7 +100,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
} catch (Exception e) {
throw new RuntimeException(e);
}
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppId(),commentModel.getAppKey());
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
log.info("sign:{}",sign);
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_CATEGORY
+"?appKey="+commentModel.getAppKey()
@ -150,7 +150,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
*/
@Override
public void SyncBranchList(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
dataBaseInfo= getDataBaseInfo(commentModel);
// dataBaseInfo= getDataBaseInfo(commentModel);
List<BrandModel> brandModels= sxDataDao.getBdBrandList(dataBaseInfo);
if(brandModels!=null&&brandModels.size()>0){
String jsonString ="";
@ -163,7 +163,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
} catch (Exception e) {
throw new RuntimeException(e);
}
String sign=CommonUtil.generateOpenSign(jsonArray.toString(),commentModel.getAppId(),commentModel.getAppKey());
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
log.info("sign={}",sign);
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_BRAND
+"?appKey="+commentModel.getAppKey()
@ -184,7 +184,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
*/
@Override
public void SyncVipList(DataBaseInfo dataBaseInfo, CommentModel commentModel) {
dataBaseInfo= getDataBaseInfo(commentModel);
// dataBaseInfo= getDataBaseInfo(commentModel);
String where="where mobile is not null and mobile <>'' ";
if(StringUtils.isNotEmpty(commentModel.getSyncTime())){
where+="and oper_date > '"+commentModel.getSyncTime()+"'";
@ -207,7 +207,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
memberList=ConverList(sxSyncVipList);
Gson gson=new Gson();
String jsonString = gson.toJson(memberList);
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppId(),commentModel.getAppKey());
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_MEMBER
+"?appKey="+commentModel.getAppKey()
+"&sign="+sign,memberList);//todo 后期改为文件传输
@ -386,7 +386,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
String fileName=fileUtils.getFileName(syncType,page,FileUtils.txtEnd);
String filePath=file.getAbsolutePath();
fileUtils.writeFile(filePath,fileName,content);
String sign=CommonUtil.generateOpenSign(content,commentModel.getAppId(),commentModel.getAppKey());
String sign=CommonUtil.generateOpenSign(content,commentModel.getAppKey(),commentModel.getAppId());
commentModel.setSign(sign);
return webClientService.uploudSxData(filePath+FileUtils.pathSeparator+fileName,commentModel,page.toString(),syncType);
}
@ -729,7 +729,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
.create();
String jsonString= gson.toJson(activeDtos);
JSONArray jsonArray = JSONUtil.parseArray(jsonString);
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppId(),commentModel.getAppKey());
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_ACTIVE
+"?appKey="+commentModel.getAppKey()
+"&sign="+sign, jsonArray);
@ -771,7 +771,7 @@ public class SxDataServiceImp extends SxDataAbstService implements SxDataService
.create();
String jsonString=gson.toJson(activeDtos);
JSONArray jsonArray = JSONUtil.parseArray(jsonString);
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppId(),commentModel.getAppKey());
String sign=CommonUtil.generateOpenSign(jsonString,commentModel.getAppKey(),commentModel.getAppId());
String code= HttpUtils.postData(restTemplate,remoteIp+HttpUtils.URL_SYNC_ACTIVE_SHOP
+"?appKey="+commentModel.getAppKey()
+"&sign="+sign, jsonArray);

View File

@ -42,4 +42,9 @@ public interface SearchService {
@PostMapping("/esProductImage/searchProductImageList")
Map<String,List<ProductImageSearchDTO>> searchProductImageList(@RequestBody List<ProductImageSearchDTO> esProductImages,@RequestParam("esSearchType") String esSearchType);
@PostMapping("/esProductImage/importAllProductImage")
CommonResult importAllProductImage(@RequestParam(value = "updateTime",required = false) String updateTime);
}

View File

@ -0,0 +1,36 @@
云计算 10 n
区块链 10 n
热门技术 8 n
牛肉 100 n
三鲜 800 n
饺子 1000 n
全棉 1000 n
被套 1000 n
糯黑米酒 1000 n
雪绒毯 1000 n
女凉鞋 1000 n
男凉鞋 1000 n
飞机玩具 1000 n
雅安利 1000 n
500L*10 1000 n
RSCW-1949 500 n
男凉拖 500 n
NIKE 500 n
PAMU 500 n
火鸡面 500 n
牛肉面 500 n
虫草花 500 n
日本豆腐 500 n
老婆饼 500 n
紫菜卷 500 n
肉松卷 500 n
热狗卷 500 n
紫薯卷 500 n
椰香酥卷 500 n
卷纸 500 n
妙芙 500 n
猪肉包 500 n
叉烧包 500 n
香菇青菜包 500 n
老鸭汤炖料 500 n
六指鼠 500 n

View File

@ -22,9 +22,9 @@ public class EsProductImageController {
private EsProductImageService esProductImageService;
@ApiOperation(value = "导入所有数据库中商品到ES")
@RequestMapping(value = "/importAll", method = RequestMethod.POST)
public CommonResult importAllList() {
int count = esProductImageService.importAll();
@RequestMapping(value = "/importAllProductImage", method = RequestMethod.POST)
public CommonResult importAllProductImage(@RequestParam(value = "updateTime",required = false) String updateTime) {
int count = esProductImageService.importAll(updateTime);
return CommonResult.success(count);
}
@RequestMapping(value = "/search", method = RequestMethod.POST)

View File

@ -1,11 +1,11 @@
package com.suisung.mall.search.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.suisung.mall.search.domain.EsProduct;
import com.suisung.mall.search.domain.EsProductImage;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
/**
@ -25,7 +25,7 @@ public interface EsProductImageDao extends BaseMapper<EsProductImage> {
* @param row
* @return
*/
List<EsProductImage> getPageEsProductList(@Param("start") Integer start,@Param("row") Integer row);
List<EsProductImage> getPageEsProductList(@Param("start") Integer start,@Param("row") Integer row,@Param("updateTime") Date updateTime);
Integer getPageTotal();
Integer getPageTotal(Date udateTime);
}

View File

@ -11,7 +11,7 @@ public interface EsProductImageService {
/**
* 从数据库中导入所有商品到ES
*/
int importAll();
int importAll( String updateTime);
List<ProductImageSearchDTO> search(ProductImageSearchDTO productImageSearchDTO);

View File

@ -1,7 +1,7 @@
package com.suisung.mall.search.service.impl;
import cn.hutool.core.util.PageUtil;
import cn.hutool.core.date.DateUtil;
import com.alibaba.csp.sentinel.util.StringUtil;
import com.suisung.mall.common.pojo.dto.ProductImageSearchDTO;
import com.suisung.mall.common.utils.JiebaUtils;
@ -54,15 +54,19 @@ public class EsProductImageServiceImpl implements EsProductImageService {
private static final Integer BATCH_SIZE=1000;
@Override
public int importAll() {
Integer total = esProductImageDao.getPageTotal();
public int importAll(String updateTime) {
Date findDate=null;
if(StringUtil.isNotEmpty(updateTime)){
findDate= DateUtil.parse(updateTime);
}
Integer total = esProductImageDao.getPageTotal(findDate);
if(Objects.isNull(total)||Objects.equals(total,0)){
return 0;
}
esProductImageRepository.deleteAll();
// esProductImageRepository.deleteAll();
Integer pages= CommonUtil.getPagesCount(total,BATCH_SIZE);
for (int i = 1; i <= pages; i++) {
List<EsProductImage> esProductList= esProductImageDao.getPageEsProductList((i-1)*BATCH_SIZE,BATCH_SIZE);
List<EsProductImage> esProductList= esProductImageDao.getPageEsProductList((i-1)*BATCH_SIZE,BATCH_SIZE,findDate);
esProductList.forEach(item->{
String cleanTitle=ProductTitleUtil.cleanTitle2(item.getProductName());
item.setCleanName(cleanTitle);//清理数据

View File

@ -46,6 +46,9 @@
WHERE product_id = lp.id
) AS merged_image_url
FROM library_product lp
<if test="updateTime!=null">
where lp.updated_at>=#{updateTime}
</if>
limit #{start},#{row}
</select>
@ -66,6 +69,10 @@
WHERE product_id = lp.id
) AS merged_image_url
FROM library_product lp
<if test="updateTime!=null">
where lp.updated_at>=#{updateTime}
</if>
)temp
</select>
</mapper>

View File

@ -23,7 +23,7 @@
},
"mappings": {
"properties": {
"id": { "type": "keyword" },
"libId": { "type": "keyword" },
"barcode": { "type": "keyword" },
"productName": {
"type": "text",

View File

@ -275,4 +275,11 @@ public class ProductMappingController extends BaseControllerImpl {
return new ThirdApiRes().success("服务器已执行商品图库匹配数据操作");
}
@ApiOperation(value = "导入图库数据到es", notes = "商品图库匹配")
@RequestMapping(value = "/importLibProductImg", method = RequestMethod.POST)
public CommonResult importLibProductImg() {
return CommonResult.success(syncThirdDataService.importLibProductImg(null));
}
}

View File

@ -167,4 +167,6 @@ public interface SyncThirdDataService {
* 刷新时间
*/
ThirdApiRes syncRefreshTime(@RequestParam String appKey, @RequestParam String sign);
CommonResult importLibProductImg(String updateTime);
}

View File

@ -31,6 +31,7 @@ import com.suisung.mall.common.api.StateCode;
import com.suisung.mall.common.enums.DicEnum;
import com.suisung.mall.common.exception.ApiException;
import com.suisung.mall.common.feignService.AccountService;
import com.suisung.mall.common.feignService.SearchService;
import com.suisung.mall.common.modules.account.AccountUserBase;
import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
import com.suisung.mall.common.modules.base.ShopBaseProductCategory;
@ -49,7 +50,6 @@ import com.suisung.mall.common.utils.StringUtils;
import com.suisung.mall.shop.base.service.ShopBaseProductBrandService;
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
import com.suisung.mall.shop.base.service.ShopBaseProductSpecService;
import com.suisung.mall.shop.chain.controller.admin.ShopChainItemController;
import com.suisung.mall.shop.number.service.ShopNumberSeqService;
import com.suisung.mall.shop.page.service.OssService;
import com.suisung.mall.shop.product.service.ShopProductBaseService;
@ -176,8 +176,9 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
@Autowired
private ShopStoreActivityItemService shopStoreActivityItemService;
@Autowired
private ShopChainItemController item;
private SearchService searchService;
/**
* 批量保存商品的分类
@ -969,8 +970,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
List<ShopStoreActivityBase> updateShopStoreActivityBaseList = new ArrayList<>();
Map<String, String> stringIntegerMap = checkExistingActive(jsonArray, storeId);
AccountUserBase accountUserBase = new AccountUserBase();
accountUserBase.setUser_is_admin(1);
accountUserBase.setStore_ids("1");
accountUserBase.setUser_is_admin(2);
accountUserBase.setStore_ids(String.valueOf(storeId));
AccountUserBase accountUserBases = accountService.findOneAccountUserBase(accountUserBase);
Integer userId = accountUserBases.getUser_id();
jsonArray.stream().parallel().forEach(object -> {
@ -1322,4 +1323,11 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
}
return new ThirdApiRes().success("时间同步完成");
}
@Override
public CommonResult importLibProductImg(String updateTime) {
return searchService.importAllProductImage(updateTime);
}
}

View File

@ -0,0 +1 @@
INSERT INTO `admin_base_protocol` (`ctl`, `met`, `db`, `rights_id`, `log`, `path`) VALUES ('/admin/shop/shop-sync-productMapper/importLibProductImg', 'index', 'master', '', '0', '/admin/shop/shop-sync-productMapper/importLibProductImg');