es导入接口新增

This commit is contained in:
liyj 2025-07-19 14:19:25 +08:00
parent 0685e25efe
commit 8de5f463f8
11 changed files with 80 additions and 17 deletions

View File

@ -42,4 +42,9 @@ public interface SearchService {
@PostMapping("/esProductImage/searchProductImageList") @PostMapping("/esProductImage/searchProductImageList")
Map<String,List<ProductImageSearchDTO>> searchProductImageList(@RequestBody List<ProductImageSearchDTO> esProductImages,@RequestParam("esSearchType") String esSearchType); 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; private EsProductImageService esProductImageService;
@ApiOperation(value = "导入所有数据库中商品到ES") @ApiOperation(value = "导入所有数据库中商品到ES")
@RequestMapping(value = "/importAll", method = RequestMethod.POST) @RequestMapping(value = "/importAllProductImage", method = RequestMethod.POST)
public CommonResult importAllList() { public CommonResult importAllProductImage(@RequestParam(value = "updateTime",required = false) String updateTime) {
int count = esProductImageService.importAll(); int count = esProductImageService.importAll(updateTime);
return CommonResult.success(count); return CommonResult.success(count);
} }
@RequestMapping(value = "/search", method = RequestMethod.POST) @RequestMapping(value = "/search", method = RequestMethod.POST)

View File

@ -1,11 +1,11 @@
package com.suisung.mall.search.dao; package com.suisung.mall.search.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.suisung.mall.search.domain.EsProduct;
import com.suisung.mall.search.domain.EsProductImage; import com.suisung.mall.search.domain.EsProductImage;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
@ -25,7 +25,7 @@ public interface EsProductImageDao extends BaseMapper<EsProductImage> {
* @param row * @param row
* @return * @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 * 从数据库中导入所有商品到ES
*/ */
int importAll(); int importAll( String updateTime);
List<ProductImageSearchDTO> search(ProductImageSearchDTO productImageSearchDTO); List<ProductImageSearchDTO> search(ProductImageSearchDTO productImageSearchDTO);

View File

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

View File

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

View File

@ -275,4 +275,11 @@ public class ProductMappingController extends BaseControllerImpl {
return new ThirdApiRes().success("服务器已执行商品图库匹配数据操作"); 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); 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.enums.DicEnum;
import com.suisung.mall.common.exception.ApiException; import com.suisung.mall.common.exception.ApiException;
import com.suisung.mall.common.feignService.AccountService; 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.account.AccountUserBase;
import com.suisung.mall.common.modules.base.ShopBaseProductBrand; import com.suisung.mall.common.modules.base.ShopBaseProductBrand;
import com.suisung.mall.common.modules.base.ShopBaseProductCategory; 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.ShopBaseProductBrandService;
import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService; import com.suisung.mall.shop.base.service.ShopBaseProductCategoryService;
import com.suisung.mall.shop.base.service.ShopBaseProductSpecService; 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.number.service.ShopNumberSeqService;
import com.suisung.mall.shop.page.service.OssService; import com.suisung.mall.shop.page.service.OssService;
import com.suisung.mall.shop.product.service.ShopProductBaseService; import com.suisung.mall.shop.product.service.ShopProductBaseService;
@ -176,8 +176,9 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
@Autowired @Autowired
private ShopStoreActivityItemService shopStoreActivityItemService; private ShopStoreActivityItemService shopStoreActivityItemService;
@Autowired @Autowired
private ShopChainItemController item; private SearchService searchService;
/** /**
* 批量保存商品的分类 * 批量保存商品的分类
@ -969,8 +970,8 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
List<ShopStoreActivityBase> updateShopStoreActivityBaseList = new ArrayList<>(); List<ShopStoreActivityBase> updateShopStoreActivityBaseList = new ArrayList<>();
Map<String, String> stringIntegerMap = checkExistingActive(jsonArray, storeId); Map<String, String> stringIntegerMap = checkExistingActive(jsonArray, storeId);
AccountUserBase accountUserBase = new AccountUserBase(); AccountUserBase accountUserBase = new AccountUserBase();
accountUserBase.setUser_is_admin(1); accountUserBase.setUser_is_admin(2);
accountUserBase.setStore_ids("1"); accountUserBase.setStore_ids(String.valueOf(storeId));
AccountUserBase accountUserBases = accountService.findOneAccountUserBase(accountUserBase); AccountUserBase accountUserBases = accountService.findOneAccountUserBase(accountUserBase);
Integer userId = accountUserBases.getUser_id(); Integer userId = accountUserBases.getUser_id();
jsonArray.stream().parallel().forEach(object -> { jsonArray.stream().parallel().forEach(object -> {
@ -1322,4 +1323,11 @@ public class SyncThirdDataServiceImpl extends SyncBaseThirdSxAbstract implements
} }
return new ThirdApiRes().success("时间同步完成"); 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');