master:系统调优;
parent
e7cbfd4a2f
commit
68b05b7063
|
|
@ -61,6 +61,7 @@ public class GtAndFhbBizController extends BaseController {
|
|||
final StoreMapper storeMapper;
|
||||
final StoreProductServiceMapper prodSvcMapper;
|
||||
final StoreProductCategoryAttributeMapper prodCateAttrMapper;
|
||||
final SysProductCategoryMapper prodCateMapper;
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PutMapping("/sync-es/{storeId}")
|
||||
|
|
@ -94,8 +95,8 @@ public class GtAndFhbBizController extends BaseController {
|
|||
List<GtProdSkuVO> doubleRunSaleBasicList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_GT_SALE_BASIC_KEY + userId), new ArrayList<>());
|
||||
Map<String, String> articleNoColorMap = doubleRunSaleBasicList.stream().collect(Collectors.groupingBy(GtProdSkuVO::getArticle_number,
|
||||
Collectors.collectingAndThen(Collectors.mapping(GtProdSkuVO::getColor, Collectors.toList()),
|
||||
list -> "(" + list.stream().distinct().collect(Collectors.joining(",")) + ")")));
|
||||
Collectors.collectingAndThen(Collectors.mapping(GtProdSkuVO::getColor, Collectors.toList()),
|
||||
list -> "(" + list.stream().distinct().collect(Collectors.joining(",")) + ")")));
|
||||
List<String> doubleRunSaleArtNoList = doubleRunSaleBasicList.stream().map(GtProdSkuVO::getArticle_number)
|
||||
.distinct().collect(Collectors.toList());
|
||||
// 查看double_run 在售的商品 这边有多少相似的货号
|
||||
|
|
@ -124,8 +125,8 @@ public class GtAndFhbBizController extends BaseController {
|
|||
List<FhbProdVO.SMIVO> shipMasterProdList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_KEY + supplierId), new ArrayList<>());
|
||||
Map<String, String> shipMasterArticleNoColorMap = shipMasterProdList.stream().collect(Collectors.groupingBy(FhbProdVO.SMIVO::getArtNo,
|
||||
Collectors.collectingAndThen(Collectors.mapping(FhbProdVO.SMIVO::getColor, Collectors.toList()),
|
||||
list -> "(" + list.stream().distinct().collect(Collectors.joining(",")) + ")")));
|
||||
Collectors.collectingAndThen(Collectors.mapping(FhbProdVO.SMIVO::getColor, Collectors.toList()),
|
||||
list -> "(" + list.stream().distinct().collect(Collectors.joining(",")) + ")")));
|
||||
List<String> shipArtNoList = shipMasterProdList.stream().map(FhbProdVO.SMIVO::getArtNo)
|
||||
.distinct().collect(Collectors.toList());
|
||||
shipArtNoList.forEach(artNo -> {
|
||||
|
|
@ -201,7 +202,6 @@ public class GtAndFhbBizController extends BaseController {
|
|||
* 步骤3: 准备数据,新建客户
|
||||
* 步骤4: 客户与货号的优惠关系
|
||||
* 步骤5: 批量创建数据到ES服务器
|
||||
*
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PutMapping("/init")
|
||||
|
|
@ -215,15 +215,14 @@ public class GtAndFhbBizController extends BaseController {
|
|||
// 步骤1: 准备数据,新建颜色
|
||||
Map<String, StoreColor> storeColorMap = this.initStoreColorList(initVO.getStoreId(), initVO.getSupplierId());
|
||||
// 步骤2: GT 和 FHB 货号对应关系,然后直接copy 对应的属性关系
|
||||
// a. 商品与颜色对应关系
|
||||
// b. 商品颜色尺码 + 价格 对应关系
|
||||
// c. 库存初始化
|
||||
// d. 服务承诺初始化
|
||||
// e. 类目属性初始化
|
||||
// a. 商品与颜色对应关系
|
||||
// b. 商品颜色尺码 + 价格 对应关系
|
||||
// c. 库存初始化
|
||||
// d. 服务承诺初始化
|
||||
// e. 类目属性初始化
|
||||
this.init(initVO, storeColorMap);
|
||||
|
||||
|
||||
|
||||
// 步骤x: 查看有哪些货号价格是有多个的,单独设置差异的价格
|
||||
|
||||
|
||||
|
|
@ -233,18 +232,18 @@ public class GtAndFhbBizController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 初始化档口商品列表
|
||||
*
|
||||
* @param storeColorMap 档口颜色map
|
||||
*/
|
||||
private R<Integer> init(GtAndFHBInitVO initVO, Map<String, StoreColor> storeColorMap) {
|
||||
// 步骤2: GT 和 FHB 货号对应关系,然后直接copy 对应的属性关系
|
||||
// a. 商品与颜色对应关系
|
||||
// b. 商品颜色尺码 + 价格 对应关系
|
||||
// c. 库存初始化
|
||||
// d. 服务承诺初始化
|
||||
// e. 类目属性初始化
|
||||
// a. 商品与颜色对应关系
|
||||
// b. 商品颜色尺码 + 价格 对应关系
|
||||
// c. 库存初始化
|
||||
// d. 服务承诺初始化
|
||||
// e. 类目属性初始化
|
||||
Map<String, List<String>> multiSaleSameGoMap = new HashMap<>();
|
||||
Map<String, List<String>> multiOffSaleSameGoMap = new HashMap<>();
|
||||
Map<String, List<String>> multiSameFhbMap = new HashMap<>();
|
||||
|
|
@ -283,17 +282,22 @@ public class GtAndFhbBizController extends BaseController {
|
|||
multiSameFhbMap.put(cleanArtNo, existList);
|
||||
});
|
||||
|
||||
// 商品所有的分类
|
||||
List<GtCateVO> artNoCateList = redisCache.getCacheObject(CacheConstants.MIGRATION_GT_SALE_CATE_KEY + initVO.getUserId());
|
||||
if (CollectionUtils.isEmpty(artNoCateList)) {
|
||||
throw new ServiceException("GT商品分类为空!", HttpStatus.ERROR);
|
||||
}
|
||||
Map<String, GtCateVO> artNoCateMap = artNoCateList.stream().collect(Collectors.toMap(GtCateVO::getArticle_number, x -> x));
|
||||
|
||||
|
||||
// gt按照货号分组
|
||||
Map<String, List<GtProdSkuVO>> gtSaleGroupMap = gtSaleBasicList.stream().collect(Collectors.groupingBy(GtProdSkuVO::getArticle_number));
|
||||
|
||||
// GT分类
|
||||
List<GtCateVO.GCIDataVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_GT_SALE_CATE_KEY + initVO.getUserId()), new ArrayList<>());
|
||||
List<SysProductCategory> prodCateList = this.prodCateMapper.selectList(new LambdaQueryWrapper<SysProductCategory>()
|
||||
.eq(SysProductCategory::getDelFlag, Constants.UNDELETED));
|
||||
Map<String, Long> dbCateNameMap = prodCateList.stream().collect(Collectors.toMap(SysProductCategory::getName, SysProductCategory::getId));
|
||||
// GT商品分类和步橘分类映射
|
||||
Map<Integer, Long> cateRelationMap = new HashMap<>();
|
||||
cacheList.forEach(gtCate -> {
|
||||
final Long cateId = Optional.ofNullable(dbCateNameMap.get(gtCate.getName())).orElseThrow(() -> new ServiceException("GT分类不存在!", HttpStatus.ERROR));
|
||||
cateRelationMap.put(gtCate.getId(), cateId);
|
||||
});
|
||||
|
||||
System.err.println("============ 两边系统“一致”的货号 ============");
|
||||
// 清洗后,相同货号映射
|
||||
Set<String> commonArtNos = new HashSet<>(multiSaleSameGoMap.keySet());
|
||||
|
|
@ -310,11 +314,8 @@ public class GtAndFhbBizController extends BaseController {
|
|||
.forEach(cleanArtNo -> {
|
||||
// 获取GT匹配的商品中的第一个商品
|
||||
List<GtProdSkuVO> gtMatchSkuList = this.getGtFirstSku(multiSaleSameGoMap, gtSaleGroupMap, cleanArtNo);
|
||||
// 商品分类
|
||||
final GtCateVO gtCateVO = Optional.ofNullable(artNoCateMap.get(gtMatchSkuList.get(0).getArticle_number()))
|
||||
.orElseThrow(() -> new ServiceException("没有GT商品分类!", HttpStatus.ERROR));
|
||||
// 初始化档口商品
|
||||
StoreProduct storeProd = new StoreProduct().setStoreId(initVO.getStoreId()).setProdCateId(gtCateVO.getBuju_cate_id())
|
||||
StoreProduct storeProd = new StoreProduct().setStoreId(initVO.getStoreId()).setProdCateId(cateRelationMap.get(gtMatchSkuList.get(0).getCategory_nid()))
|
||||
.setProdArtNum(cleanArtNo).setProdTitle(gtMatchSkuList.get(0).getCharacters()).setListingWay(ListingType.RIGHT_NOW.getValue())
|
||||
.setVoucherDate(voucherDate).setProdStatus(EProductStatus.ON_SALE.getValue()).setRecommendWeight(0L).setSaleWeight(0L).setPopularityWeight(0L);
|
||||
// 提前设置档口商品的类目属性
|
||||
|
|
@ -400,10 +401,10 @@ public class GtAndFhbBizController extends BaseController {
|
|||
/**
|
||||
* 新建档口客户对应产品的优惠
|
||||
*
|
||||
* @param initVO 入参
|
||||
* @param storeProdList 档口商品列表
|
||||
* @param storeCusList 档口客户列表
|
||||
* @param prodColorList 商品颜色列表
|
||||
* @param initVO 入参
|
||||
* @param storeProdList 档口商品列表
|
||||
* @param storeCusList 档口客户列表
|
||||
* @param prodColorList 商品颜色列表
|
||||
* @param multiSameFhbMap 步橘货号和FHB货号对应关系
|
||||
* @param fhbProdGroupMap FHB货号和颜色对应关系
|
||||
*/
|
||||
|
|
@ -452,6 +453,7 @@ public class GtAndFhbBizController extends BaseController {
|
|||
|
||||
/**
|
||||
* 初始化客户列表
|
||||
*
|
||||
* @param initVO 入参
|
||||
* @return List<StoreCustomer>
|
||||
*/
|
||||
|
|
@ -474,8 +476,9 @@ public class GtAndFhbBizController extends BaseController {
|
|||
|
||||
/**
|
||||
* 提前匹配类目属性
|
||||
* @param product_id GT商品ID
|
||||
* @param userId GT用户ID
|
||||
*
|
||||
* @param product_id GT商品ID
|
||||
* @param userId GT用户ID
|
||||
* @param prodAttrMap 类目属性
|
||||
*/
|
||||
private void preMatchAttr(Integer product_id, Integer userId, Map<Integer, StoreProductCategoryAttribute> prodAttrMap) {
|
||||
|
|
@ -587,6 +590,7 @@ public class GtAndFhbBizController extends BaseController {
|
|||
|
||||
/**
|
||||
* 取GT匹配的多个货号中的第一个商品
|
||||
*
|
||||
* @param multiSaleSameGoMap
|
||||
* @param gtSaleGroupMap
|
||||
* @param cleanArtNo
|
||||
|
|
@ -604,7 +608,7 @@ public class GtAndFhbBizController extends BaseController {
|
|||
/**
|
||||
* 初始化档口颜色
|
||||
*
|
||||
* @param storeId 档口ID
|
||||
* @param storeId 档口ID
|
||||
* @param supplierId 供应商ID
|
||||
*/
|
||||
private Map<String, StoreColor> initStoreColorList(Long storeId, Integer supplierId) {
|
||||
|
|
|
|||
|
|
@ -1,19 +1,15 @@
|
|||
package com.ruoyi.web.controller.xkt.migartion;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import com.ruoyi.common.constant.HttpStatus;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.R;
|
||||
import com.ruoyi.common.core.redis.RedisCache;
|
||||
import com.ruoyi.common.exception.ServiceException;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.gt.GtAttrVO;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.gt.GtCateVO;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.gt.GtProdSkuVO;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.gt.GtProdVO;
|
||||
import com.ruoyi.xkt.domain.SysProductCategory;
|
||||
import com.ruoyi.xkt.mapper.SysProductCategoryMapper;
|
||||
import com.ruoyi.xkt.service.shipMaster.IShipMasterService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
|
@ -23,12 +19,9 @@ import org.apache.commons.lang3.ObjectUtils;
|
|||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
|
|
@ -45,6 +38,7 @@ public class GtController extends BaseController {
|
|||
final RedisCache redisCache;
|
||||
final SysProductCategoryMapper prodCateMapper;
|
||||
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/sale/cache")
|
||||
public R<Integer> createSaleCache(@Validated @RequestBody GtProdVO doubleRunVO) {
|
||||
|
|
@ -55,7 +49,7 @@ public class GtController extends BaseController {
|
|||
.getCacheObject(CacheConstants.MIGRATION_GT_SALE_BASIC_KEY + userId), new ArrayList<>());
|
||||
artNoList.forEach(artNoInfo -> {
|
||||
artNoInfo.getSkus().forEach(x -> x.setColor(this.decodeUnicode(x.getColor())).setCharacters(artNoInfo.getCharacters())
|
||||
.setArticle_number(artNoInfo.getArticle_number()).setProduct_id(artNoInfo.getId()));
|
||||
.setArticle_number(artNoInfo.getArticle_number()).setProduct_id(artNoInfo.getId()).setCategory_nid(artNoInfo.getCategory_nid()));
|
||||
cacheList.addAll(artNoInfo.getSkus());
|
||||
});
|
||||
// 存到redis中
|
||||
|
|
@ -108,33 +102,20 @@ public class GtController extends BaseController {
|
|||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/cate/cache/{user_id}")
|
||||
public R<Integer> createCateCache(@PathVariable(value = "user_id") Integer user_id, MultipartFile file) throws IOException {
|
||||
|
||||
|
||||
// TODO GT分类基础数据导入,然后从商品属性那儿解决
|
||||
// TODO GT分类基础数据导入,然后从商品属性那儿解决
|
||||
// TODO GT分类基础数据导入,然后从商品属性那儿解决
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ExcelUtil<GtCateVO> util = new ExcelUtil<>(GtCateVO.class);
|
||||
List<GtCateVO> artNoCateList = util.importExcel(file.getInputStream());
|
||||
// 步橘网获取所有的分类
|
||||
List<SysProductCategory> cateList = this.prodCateMapper.selectList(new LambdaQueryWrapper<SysProductCategory>()
|
||||
.eq(SysProductCategory::getDelFlag, Constants.UNDELETED).ne(SysProductCategory::getId, Constants.TOPMOST_PRODUCT_CATEGORY_ID));
|
||||
Map<String, Long> cateNameMap = cateList.stream().collect(Collectors.toMap(SysProductCategory::getName, SysProductCategory::getId));
|
||||
artNoCateList.forEach(x -> {
|
||||
// 必须用trim()
|
||||
x.setArticle_number(x.getArticle_number().trim()).setCate_name(x.getCate_name().trim());
|
||||
if (!cateNameMap.containsKey(x.getCate_name())) {
|
||||
throw new ServiceException("分类不存在:" + x.getCate_name(), HttpStatus.ERROR);
|
||||
}
|
||||
x.setBuju_cate_id(cateNameMap.get(x.getCate_name().trim()));
|
||||
});
|
||||
public R<Integer> createCateCache(@PathVariable(value = "user_id") Integer user_id, @Validated @RequestBody GtCateVO cateInitVO) {
|
||||
if (CollectionUtils.isEmpty(cateInitVO.getData())) {
|
||||
throw new ServiceException("入参GT分类数据为空!", HttpStatus.ERROR);
|
||||
}
|
||||
List<GtCateVO.GCIDataVO> cateList = cateInitVO.getData().stream()
|
||||
.filter(x -> x.getHas_child() == 0)
|
||||
.map(x -> Objects.equals(x.getName(), "时尚雪地靴") ? x.setName("雪地靴") : x)
|
||||
.collect(Collectors.toList());
|
||||
// 先从redis中获取列表数据
|
||||
List<GtCateVO.GCIDataVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_GT_SALE_CATE_KEY + user_id), new ArrayList<>());
|
||||
CollectionUtils.addAll(cacheList, cateList);
|
||||
// 放到缓存中
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_GT_SALE_CATE_KEY + user_id, artNoCateList, 5, TimeUnit.DAYS);
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_GT_SALE_CATE_KEY + user_id, cacheList);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,10 @@
|
|||
package com.ruoyi.web.controller.xkt.migartion.vo.gt;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author liangyq
|
||||
* @date 2025-05-11 23:46
|
||||
|
|
@ -12,11 +13,13 @@ import lombok.experimental.Accessors;
|
|||
@Accessors(chain = true)
|
||||
public class GtCateVO {
|
||||
|
||||
@Excel(name = "货号")
|
||||
private String article_number;
|
||||
@Excel(name = "分类")
|
||||
private String cate_name;
|
||||
// 步橘的分类id
|
||||
private Long buju_cate_id;
|
||||
private List<GCIDataVO> data;
|
||||
|
||||
@Data
|
||||
public static class GCIDataVO {
|
||||
private Integer id;
|
||||
private Integer has_child;
|
||||
private String name;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ public class GtProdSkuVO {
|
|||
|
||||
private Integer product_id;
|
||||
private String article_number;
|
||||
private Integer category_nid;
|
||||
private String color;
|
||||
private Integer size;
|
||||
private String characters;
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ public class GtProdVO {
|
|||
public static class DRIArtNoVO {
|
||||
private Integer id;
|
||||
private Integer user_id;
|
||||
private Integer category_nid;
|
||||
private String article_number;
|
||||
private String characters;
|
||||
private List<GtProdSkuVO> skus;
|
||||
|
|
|
|||
Loading…
Reference in New Issue