master:系统调优;

pull/1121/head
liujiang 2025-09-24 23:15:13 +08:00
parent 767e9d35c7
commit e7cbfd4a2f
6 changed files with 67 additions and 52 deletions

View File

@ -57,6 +57,20 @@ public class FhbController extends BaseController {
return R.ok();
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PostMapping("/colors/cache/{supplierId}")
public R<Integer> createColorsCache(@PathVariable Integer supplierId) {
// 先从redis中获取列表数据
List<FhbProdVO.SMIVO> cacheList = ObjectUtils.defaultIfNull(redisCache
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_KEY + supplierId), new ArrayList<>());
if (CollectionUtils.isEmpty(cacheList)) {
throw new ServiceException("FHB商品列表为空", HttpStatus.ERROR);
}
List<String> colorNameList = cacheList.stream().map(FhbProdVO.SMIVO::getColor).distinct().collect(Collectors.toList());
return R.ok();
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PostMapping("/cus/cache")
public R<Integer> createCusCache(@Validated @RequestBody FhbCusVO cusVO) {
@ -115,13 +129,7 @@ public class FhbController extends BaseController {
return R.ok();
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PostMapping("/colors/cache/{supplierId}")
public R<Integer> createColorsCache(@PathVariable Integer supplierId, @Validated @RequestBody FhbColorVO colorVO) {
// 存到redis中
redisCache.setCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_COLOR_KEY + supplierId, colorVO.getData(), 5, TimeUnit.DAYS);
return R.ok();
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@GetMapping("/prod/cache/{supplierId}")

View File

@ -5,6 +5,7 @@ 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.DateUtils;
@ -26,6 +27,7 @@ import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -60,11 +62,6 @@ public class GtAndFhbBizController extends BaseController {
final StoreProductServiceMapper prodSvcMapper;
final StoreProductCategoryAttributeMapper prodCateAttrMapper;
// TODO 档口注册的时候,会创建现金客户,在插入客户时,需要注意
// TODO 档口注册的时候,会创建现金客户,在插入客户时,需要注意
// TODO 档口注册的时候,会创建现金客户,在插入客户时,需要注意
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PutMapping("/sync-es/{storeId}")
public void syncToEs(@PathVariable("storeId") Long storeId) {
@ -207,7 +204,10 @@ public class GtAndFhbBizController extends BaseController {
*
*/
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PutMapping("/save")
@PutMapping("/init")
@Transactional
public void initToDB(@Validated @RequestBody GtAndFHBInitVO initVO) {
final Store store = Optional.ofNullable(this.storeMapper.selectOne(new LambdaQueryWrapper<Store>()
.eq(Store::getId, initVO.getStoreId()).eq(Store::getDelFlag, Constants.UNDELETED)))
@ -220,7 +220,7 @@ public class GtAndFhbBizController extends BaseController {
// c. 库存初始化
// d. 服务承诺初始化
// e. 类目属性初始化
this.initStoreProdList(initVO, storeColorMap);
this.init(initVO, storeColorMap);
@ -238,7 +238,7 @@ public class GtAndFhbBizController extends BaseController {
*
* @param storeColorMap map
*/
private void initStoreProdList(GtAndFHBInitVO initVO, Map<String, StoreColor> storeColorMap) {
private R<Integer> init(GtAndFHBInitVO initVO, Map<String, StoreColor> storeColorMap) {
// 步骤2: GT 和 FHB 货号对应关系然后直接copy 对应的属性关系
// a. 商品与颜色对应关系
// b. 商品颜色尺码 + 价格 对应关系
@ -346,12 +346,13 @@ public class GtAndFhbBizController extends BaseController {
StoreColor storeColor = Optional.ofNullable(storeColorMap.get(fhbMatchSkuList.get(i).getColor()))
.orElseThrow(() -> new ServiceException("没有FHB商品颜色!" + fhbArtNo, HttpStatus.ERROR));
// 该商品的颜色
prodColorList.add(new StoreProductColor().setStoreId(storeProd.getStoreId()).setStoreProdId(storeProd.getId())
prodColorList.add(new StoreProductColor().setStoreId(storeProd.getStoreId()).setStoreProdId(storeProd.getId()).setOrderNum(i + 1)
.setColorName(storeColor.getColorName()).setStoreColorId(storeColor.getId()).setProdStatus(EProductStatus.ON_SALE.getValue()));
// 该颜色所有的尺码
for (int j = 0; j < Constants.SIZE_LIST.size(); j++) {
// FHB系统条码前缀
final String otherSnPrefix = fhbMatchSkuList.get(i).getSupplierId() + String.format("%05d", fhbMatchSkuList.get(i).getSupplierSkuId());
final String otherSnPrefix = fhbMatchSkuList.get(i).getSupplierId()
+ String.format("%05d", fhbMatchSkuList.get(i).getSupplierSkuId()) + Constants.SIZE_LIST.get(j);
prodColorSizeList.add(new StoreProductColorSize().setSize(Constants.SIZE_LIST.get(j)).setStoreColorId(storeColor.getId())
.setStoreProdId(storeProd.getId()).setPrice(minPrice).setOtherSnPrefix(otherSnPrefix).setNextSn(0)
.setStandard(gtStandardSizeList.contains(Constants.SIZE_LIST.get(j)) ? 1 : 0));
@ -366,6 +367,7 @@ public class GtAndFhbBizController extends BaseController {
// 初始化商品的类目属性
StoreProductCategoryAttribute cateAttr = Optional.ofNullable(prodAttrMap.get(gtMatchSkuList.get(0).getProduct_id()))
.orElseThrow(() -> new ServiceException("没有GT商品类目属性!" + storeProd.getProdArtNum(), HttpStatus.ERROR));
cateAttr.setStoreId(storeProd.getStoreId()).setStoreProdId(storeProd.getId());
prodAttrList.add(cateAttr);
});
// 插入商品颜色及颜色对应的尺码,档口服务承诺
@ -390,6 +392,8 @@ public class GtAndFhbBizController extends BaseController {
// 步骤4: 客户与货号的优惠关系
this.initStoreCusProdDiscList(initVO, storeProdList, storeCusList, prodColorList, multiSameFhbMap, fhbProdGroupMap);
return R.ok();
}
@ -423,33 +427,27 @@ public class GtAndFhbBizController extends BaseController {
List<StoreCustomerProductDiscount> prodCusDiscList = new ArrayList<>();
// 依次遍历商品列表找到货号和FHB货号对应关系然后用颜色进行匹配建立客户优惠关系
storeProdList.forEach(storeProd -> {
// 当前商品颜色列表
// 当前商品颜色列表 key 颜色中文名称
Map<String, StoreProductColor> buJuProdColorMap = Optional.ofNullable(prodColorGroupMap.get(storeProd.getId())).orElseThrow(() -> new ServiceException("没有商品颜色!" + storeProd.getProdArtNum(), HttpStatus.ERROR));
// FHB货号下颜色优惠列表
Map<String, List<FhbCusDiscountVO.SMCDRecordVO>> fhbColorCusDiscMap = Optional.ofNullable(fhbCusDiscGroupMap.get(storeProd.getProdArtNum())).orElseThrow(() -> new ServiceException("没有FHB货号对应的颜色的客户优惠!" + storeProd.getProdArtNum(), HttpStatus.ERROR));
// 根据步橘货号 找到FHB对应的货号可能是列表
List<String> fhbAtrNoList = Optional.ofNullable(multiSameFhbMap.get(storeProd.getProdArtNum())).orElseThrow(() -> new ServiceException("没有FHB货号!" + storeProd.getProdArtNum(), HttpStatus.ERROR));
fhbAtrNoList.forEach(fhbAtrNo -> {
// 找到FHB货号对应的颜色
List<FhbProdVO.SMIVO> fhbProdColorList = Optional.ofNullable(fhbProdGroupMap.get(fhbAtrNo)).orElseThrow(() -> new ServiceException("没有FHB货号对应的颜色!" + fhbAtrNo, HttpStatus.ERROR));
fhbProdColorList.forEach(fhbProdColor -> {
// 获取FHB颜色有哪些客户优惠
List<FhbCusDiscountVO.SMCDRecordVO> fhbCurColorCusDiscList = fhbColorCusDiscMap.get(fhbProdColor.getColor());
if (CollectionUtils.isEmpty(fhbCurColorCusDiscList)) {
return;
}
fhbCurColorCusDiscList.forEach(fhbCusDisc -> {
StoreProductColor buJuProdColor = Optional.ofNullable(buJuProdColorMap.get(fhbProdColor.getColor())).orElseThrow(() -> new ServiceException("没有步橘系统对应的颜色!" + fhbProdColor.getColor(), HttpStatus.ERROR));
StoreCustomer storeCus = Optional.ofNullable(buJuStoreCusMap.get(fhbCusDisc.getCustomerName())).orElseThrow(() -> new ServiceException("没有步橘系统对应的客户!" + fhbCusDisc.getCustomerName(), HttpStatus.ERROR));
// 将FHB客户优惠 转为步橘系统优惠
prodCusDiscList.add(new StoreCustomerProductDiscount().setStoreId(storeProd.getStoreId()).setStoreProdId(storeProd.getId()).setStoreCusId(storeCus.getId())
.setStoreCusName(storeCus.getCusName()).setStoreProdColorId(buJuProdColor.getId()).setDiscount(fhbCusDisc.getDiscount()));
});
});
// FHB货号下有哪些颜色存在客户优惠
Map<String, List<FhbCusDiscountVO.SMCDRecordVO>> fhbColorCusDiscMap = fhbCusDiscGroupMap.get(fhbAtrNo);
if (MapUtils.isEmpty(fhbColorCusDiscMap)) {
return;
}
// 依次遍历存在优惠的颜色,设置步橘系统客户优惠关系
fhbColorCusDiscMap.forEach((fhbColor, fhbCusDiscList) -> fhbCusDiscList.forEach(fhbCusDisc -> {
StoreProductColor buJuProdColor = Optional.ofNullable(buJuProdColorMap.get(fhbColor)).orElseThrow(() -> new ServiceException("没有步橘系统对应的颜色!" + fhbColor, HttpStatus.ERROR));
StoreCustomer storeCus = Optional.ofNullable(buJuStoreCusMap.get(fhbCusDisc.getCustomerName())).orElseThrow(() -> new ServiceException("没有步橘系统对应的客户!" + fhbCusDisc.getCustomerName(), HttpStatus.ERROR));
// 将FHB客户优惠 转为步橘系统优惠
prodCusDiscList.add(new StoreCustomerProductDiscount().setStoreId(storeProd.getStoreId()).setStoreProdId(storeProd.getId()).setStoreCusId(storeCus.getId())
.setStoreCusName(storeCus.getCusName()).setStoreProdColorId(buJuProdColor.getId()).setDiscount(fhbCusDisc.getDiscount()));
}));
});
this.storeCusProdDiscMapper.insert(prodCusDiscList);
});
this.storeCusProdDiscMapper.insert(prodCusDiscList);
}
/**
@ -505,8 +503,8 @@ public class GtAndFhbBizController extends BaseController {
prodAttr.setShoeUpperLiningMaterial(attrMap.get(Constants.SHOE_UPPER_LINING_MATERIAL_NAME));
}
// 5. 靴款品名
if (attrMap.containsKey(Constants.SHOE_STYLE_NAME)) {
prodAttr.setShoeStyleName(attrMap.get(Constants.SHOE_STYLE_NAME));
if (attrMap.containsKey(Constants.SHOE_STYLE_NAME_NAME)) {
prodAttr.setShoeStyleName(attrMap.get(Constants.SHOE_STYLE_NAME_NAME));
}
// 6. 筒高
if (attrMap.containsKey(Constants.SHAFT_HEIGHT_NAME)) {
@ -516,7 +514,7 @@ public class GtAndFhbBizController extends BaseController {
if (attrMap.containsKey(Constants.INSOLE_MATERIAL_NAME)) {
prodAttr.setInsoleMaterial(attrMap.get(Constants.INSOLE_MATERIAL_NAME));
}
// 8. 上市季节年份
// 8. 上市年份季节
if (attrMap.containsKey(Constants.RELEASE_YEAR_SEASON_NAME)) {
prodAttr.setReleaseYearSeason(attrMap.get(Constants.RELEASE_YEAR_SEASON_NAME));
}
@ -610,10 +608,12 @@ public class GtAndFhbBizController extends BaseController {
* @param supplierId ID
*/
private Map<String, StoreColor> initStoreColorList(Long storeId, Integer supplierId) {
List<String> gtColorList = this.redisCache.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_COLOR_KEY + supplierId);
if (CollectionUtils.isEmpty(gtColorList)) {
throw new ServiceException("没有颜色数据!", HttpStatus.ERROR);
List<FhbProdVO.SMIVO> cacheList = ObjectUtils.defaultIfNull(redisCache
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_KEY + supplierId), new ArrayList<>());
if (CollectionUtils.isEmpty(cacheList)) {
throw new ServiceException("FHB商品列表为空", HttpStatus.ERROR);
}
List<String> gtColorList = cacheList.stream().map(FhbProdVO.SMIVO::getColor).distinct().collect(Collectors.toList());
List<StoreColor> storeColorList = new ArrayList<>();
for (int i = 0; i < gtColorList.size(); i++) {
storeColorList.add(new StoreColor().setStoreId(storeId).setColorName(gtColorList.get(i)).setOrderNum(i + 1));

View File

@ -109,6 +109,16 @@ 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());
// 步橘网获取所有的分类

View File

@ -328,10 +328,6 @@ public class CacheConstants {
* FHB
*/
public static final String MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY = "mig_fhb_cus_discount:";
/**
* FHB
*/
public static final String MIGRATION_SUPPLIER_PROD_COLOR_KEY = "mig_fhb_prod_color:";
/**
* GT
*/

View File

@ -337,7 +337,7 @@ public class Constants
public static final String INSOLE_MATERIAL = "insoleMaterial";
public static final String INSOLE_MATERIAL_NAME = "鞋垫材质";
public static final String RELEASE_YEAR_SEASON = "releaseYearSeason";
public static final String RELEASE_YEAR_SEASON_NAME = "上市季节年份";
public static final String RELEASE_YEAR_SEASON_NAME = "上市年份季节";
public static final String HEEL_HEIGHT = "heelHeight";
public static final String HEEL_HEIGHT_NAME = "后跟高";
public static final String HEEL_TYPE = "heelType";
@ -357,7 +357,7 @@ public class Constants
public static final String LEATHER_FEATURES = "leatherFeatures";
public static final String LEATHER_FEATURES_NAME = "皮质特征";
public static final String MANUFACTURING_PROCESS = "manufacturingProcess";
public static final String MANUFACTURING_PROCESS_NAME = "制作工艺";
public static final String MANUFACTURING_PROCESS_NAME = "制作工艺";
public static final String PATTERN = "pattern";
public static final String PATTERN_NAME = "图案";
public static final String CLOSURE_TYPE = "closureType";

View File

@ -7,8 +7,6 @@ import com.ruoyi.common.core.domain.XktBaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import java.math.BigDecimal;
import java.util.Date;
@ -106,18 +104,21 @@ public class StoreProduct extends XktBaseEntity {
/**
*
*
* @return
*/
private Long recommendWeight;
/**
*
*
* @return
*/
private Long saleWeight;
/**
*
*
* @return
*/
private Long popularityWeight;