master:系统调优,storeProductColorSize去掉store_id;
parent
7ac5794d37
commit
00af05ab1b
|
|
@ -6,7 +6,10 @@ 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.web.controller.xkt.migartion.vo.fhb.*;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.fhb.FhbCusDiscountVO;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.fhb.FhbCusVO;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.fhb.FhbProdStockVO;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.fhb.FhbProdVO;
|
||||
import com.ruoyi.xkt.service.shipMaster.IShipMasterService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
|
|
@ -48,10 +51,15 @@ public class FhbController extends BaseController {
|
|||
throw new ServiceException("同一货号中存在相同的颜色" + artNo, HttpStatus.ERROR);
|
||||
}
|
||||
}));
|
||||
// 去除空格
|
||||
List<FhbProdVO.SMIVO> fhbProdList = prodVO.getData().getRecords().stream()
|
||||
.map(x -> x.setArtNo(x.getArtNo().trim()).setColor(x.getColor().trim()).setSize(x.getSize().trim())
|
||||
.setAddPriceSize(x.getAddPriceSize().trim()).setSnPrefix(x.getSnPrefix().trim()))
|
||||
.collect(Collectors.toList());
|
||||
// 先从redis中获取列表数据
|
||||
List<FhbProdVO.SMIVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_KEY + supplierId), new ArrayList<>());
|
||||
CollectionUtils.addAll(cacheList, prodVO.getData().getRecords());
|
||||
CollectionUtils.addAll(cacheList, fhbProdList);
|
||||
// 存到redis中
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_KEY + supplierId, cacheList, 5, TimeUnit.DAYS);
|
||||
return R.ok();
|
||||
|
|
|
|||
|
|
@ -356,7 +356,7 @@ public class GtAndFhbBizController extends BaseController {
|
|||
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).setStoreId(storeProd.getStoreId())
|
||||
.setStoreProdId(storeProd.getId()).setPrice(minPrice).setOtherSnPrefix(otherSnPrefix).setNextSn(0)
|
||||
.setStandard(gtStandardSizeList.contains(Constants.SIZE_LIST.get(j)) ? 1 : 0));
|
||||
}
|
||||
}
|
||||
|
|
@ -618,10 +618,10 @@ public class GtAndFhbBizController extends BaseController {
|
|||
if (CollectionUtils.isEmpty(cacheList)) {
|
||||
throw new ServiceException("FHB商品列表为空", HttpStatus.ERROR);
|
||||
}
|
||||
List<String> gtColorList = cacheList.stream().map(FhbProdVO.SMIVO::getColor).distinct().collect(Collectors.toList());
|
||||
List<String> fhbColorList = 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));
|
||||
for (int i = 0; i < fhbColorList.size(); i++) {
|
||||
storeColorList.add(new StoreColor().setStoreId(storeId).setColorName(fhbColorList.get(i)).setOrderNum(i + 1));
|
||||
}
|
||||
this.storeColorMapper.insert(storeColorList);
|
||||
return storeColorList.stream().collect(Collectors.toMap(StoreColor::getColorName, x -> x));
|
||||
|
|
|
|||
|
|
@ -55,8 +55,8 @@ public class GtController extends BaseController {
|
|||
// 只处理近3年商品
|
||||
.stream().filter(x -> x.getCreate_time().after(threeYearsBefore) || x.getUpdate_time().after(threeYearsBefore))
|
||||
.forEach(artNoInfo -> {
|
||||
artNoInfo.getSkus().forEach(x -> x.setColor(this.decodeUnicode(x.getColor())).setCharacters(artNoInfo.getCharacters())
|
||||
.setArticle_number(artNoInfo.getArticle_number()).setProduct_id(artNoInfo.getId()).setCategory_nid(artNoInfo.getCategory_nid()));
|
||||
artNoInfo.getSkus().forEach(x -> x.setColor(this.decodeUnicode(x.getColor().trim())).setCharacters(artNoInfo.getCharacters().trim())
|
||||
.setArticle_number(artNoInfo.getArticle_number().trim()).setProduct_id(artNoInfo.getId()).setCategory_nid(artNoInfo.getCategory_nid()));
|
||||
cacheList.addAll(artNoInfo.getSkus());
|
||||
});
|
||||
// 存到redis中
|
||||
|
|
@ -74,7 +74,7 @@ public class GtController extends BaseController {
|
|||
.getCacheObject(CacheConstants.MIGRATION_GT_OFF_SALE_BASIC_KEY + userId), new ArrayList<>());
|
||||
artNoList.forEach(artNoInfo -> {
|
||||
artNoInfo.getSkus().forEach(x -> x.setColor(this.decodeUnicode(x.getColor()))
|
||||
.setArticle_number(artNoInfo.getArticle_number()).setProduct_id(artNoInfo.getId()));
|
||||
.setArticle_number(artNoInfo.getArticle_number().trim()).setProduct_id(artNoInfo.getId()));
|
||||
cacheList.addAll(artNoInfo.getSkus());
|
||||
});
|
||||
// 存到redis中
|
||||
|
|
|
|||
|
|
@ -1,13 +1,18 @@
|
|||
package com.ruoyi.web.controller.xkt.migartion;
|
||||
|
||||
import com.ruoyi.common.constant.CacheConstants;
|
||||
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.ty.TyCusDiscImportVO;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.ty.TyCusImportVO;
|
||||
import com.ruoyi.web.controller.xkt.migartion.vo.ty.TyProdImportVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
|
@ -16,8 +21,11 @@ import org.springframework.web.bind.annotation.RestController;
|
|||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
|
@ -38,6 +46,9 @@ public class TyController extends BaseController {
|
|||
public R<Integer> createProdCache(@PathVariable Integer userId, MultipartFile file) throws IOException {
|
||||
ExcelUtil<TyProdImportVO> util = new ExcelUtil<>(TyProdImportVO.class);
|
||||
List<TyProdImportVO> tyProdVOList = util.importExcel(file.getInputStream());
|
||||
// 去掉空格
|
||||
tyProdVOList.forEach(x -> x.setProdArtNum(x.getProdArtNum().trim()).setColorName(x.getColorName().trim())
|
||||
.setOtherSnPrefix(x.getOtherSnPrefix().trim()));
|
||||
Map<String, List<TyProdImportVO>> prodMap = tyProdVOList.stream().collect(Collectors.groupingBy(TyProdImportVO::getProdArtNum));
|
||||
prodMap.forEach((k, v) -> {
|
||||
System.err.println(k + ":" + v);
|
||||
|
|
@ -53,11 +64,48 @@ public class TyController extends BaseController {
|
|||
public R<Integer> createCusCache(@PathVariable Integer userId, MultipartFile file) throws IOException {
|
||||
ExcelUtil<TyCusImportVO> util = new ExcelUtil<>(TyCusImportVO.class);
|
||||
List<TyCusImportVO> tyProdVOList = util.importExcel(file.getInputStream());
|
||||
tyProdVOList.forEach(x -> x.setCusName(x.getCusName().trim()));
|
||||
// 存到redis中
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_TY_CUS_KEY + userId, tyProdVOList, 5, TimeUnit.DAYS);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/cus/disc/cache/{cusName}/{userId}")
|
||||
public R<Integer> createCusDiscCache(@PathVariable(value = "userId") Integer userId, @PathVariable(value = "cusName") String cusName,
|
||||
MultipartFile file) throws IOException {
|
||||
// 从redis中获取已存在的客户优惠数据
|
||||
List<TyCusDiscImportVO> cacheList = redisCache.getCacheObject(CacheConstants.MIGRATION_TY_CUS_DISCOUNT_KEY + userId);
|
||||
cacheList = Optional.ofNullable(cacheList).orElse(new ArrayList<>());
|
||||
// 判断当前客户是否已导入过,若是则直接报错
|
||||
Map<String, List<TyCusDiscImportVO>> cusDiscMap = cacheList.stream().collect(Collectors.groupingBy(TyCusDiscImportVO::getCusName));
|
||||
if (cusDiscMap.containsKey(cusName)) {
|
||||
throw new ServiceException("客户已导入过优惠数据", HttpStatus.ERROR);
|
||||
}
|
||||
ExcelUtil<TyCusDiscImportVO> util = new ExcelUtil<>(TyCusDiscImportVO.class);
|
||||
List<TyCusDiscImportVO> tyProdVOList = util.importExcel(file.getInputStream());
|
||||
// 因为是采用的截图转excel方式,所以每个张图会冗余部分数据长度,导入是需要判断是否已存在
|
||||
Map<String, TyCusDiscImportVO> importCusDiscMap = new ConcurrentHashMap<>();
|
||||
List<TyCusDiscImportVO> importList = new ArrayList<>();
|
||||
tyProdVOList.stream()
|
||||
// 只设置有优惠的存货及颜色
|
||||
.filter(x -> ObjectUtils.isNotEmpty(x.getBasicPrice()) && ObjectUtils.isNotEmpty(x.getCustomerPrice()))
|
||||
.forEach(x -> {
|
||||
if (importCusDiscMap.containsKey(x.getProdArtNum() + ":" + x.getColorName())) {
|
||||
System.err.println(x.getProdArtNum() + ":" + x.getColorName());
|
||||
} else {
|
||||
x.setColorName(x.getColorName().trim()).setCusName(cusName).setProdArtNum(x.getProdArtNum().trim());
|
||||
importCusDiscMap.put(x.getProdArtNum() + ":" + x.getColorName(), x);
|
||||
importList.add(x);
|
||||
}
|
||||
});
|
||||
// 加到总的客户优惠上
|
||||
CollectionUtils.addAll(cacheList, importList);
|
||||
// 存到redis中
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_TY_CUS_DISCOUNT_KEY + userId, cacheList, 5, TimeUnit.DAYS);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.web.controller.xkt.migartion.vo.fhb;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
|
@ -20,6 +21,7 @@ public class FhbProdVO {
|
|||
}
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public static class SMIVO {
|
||||
private Integer supplierId;
|
||||
private Integer supplierSkuId;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,31 @@
|
|||
package com.ruoyi.web.controller.xkt.migartion.vo.ty;
|
||||
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* @author liujiang
|
||||
* @version v1.0
|
||||
* @date 2025/3/27 15:12
|
||||
*/
|
||||
@ApiModel
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
public class TyCusDiscImportVO {
|
||||
|
||||
// 客户名称
|
||||
private String cusName;
|
||||
@Excel(name = "货号")
|
||||
private String prodArtNum;
|
||||
@Excel(name = "颜色")
|
||||
private String colorName;
|
||||
@Excel(name = "基础价格")
|
||||
private BigDecimal basicPrice;
|
||||
@Excel(name = "客户价格")
|
||||
private BigDecimal customerPrice;
|
||||
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@ public class TyProdImportVO {
|
|||
private String colorName;
|
||||
@Excel(name = "jg")
|
||||
private Integer price;
|
||||
@Excel(name = "HPBM")
|
||||
@Excel(name = "SN")
|
||||
private String otherSnPrefix;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -352,5 +352,9 @@ public class CacheConstants {
|
|||
* TY客户缓存
|
||||
*/
|
||||
public static final String MIGRATION_TY_CUS_KEY = "mig_ty_cus:";
|
||||
/**
|
||||
* TY客户优惠缓存
|
||||
*/
|
||||
public static final String MIGRATION_TY_CUS_DISCOUNT_KEY = "mig_ty_cus_discount:";
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3526,7 +3526,6 @@ CREATE TABLE `store_product_color_size`
|
|||
`id` bigint UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '档口商品颜色尺码ID',
|
||||
`store_color_id` bigint UNSIGNED NOT NULL COMMENT '档口商品颜色ID',
|
||||
`store_prod_id` bigint UNSIGNED NOT NULL COMMENT '档口商品ID',
|
||||
`store_id` bigint UNSIGNED NOT NULL COMMENT '档口ID',
|
||||
`size` int UNSIGNED NOT NULL COMMENT '商品尺码',
|
||||
`price` decimal(10, 2) UNSIGNED NOT NULL COMMENT '档口商品定价',
|
||||
`sn_prefix` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '档口商品颜色尺码的前缀',
|
||||
|
|
|
|||
|
|
@ -38,10 +38,6 @@ public class StoreProductColorSize extends XktBaseEntity {
|
|||
*/
|
||||
@Excel(name = "档口商品ID")
|
||||
private Long storeProdId;
|
||||
/**
|
||||
* 档口ID
|
||||
*/
|
||||
private Long storeId;
|
||||
/**
|
||||
* 商品尺码
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -405,7 +405,7 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
// 不存在则新增
|
||||
dbProdColorSizeList.add(new StoreProductColorSize().setSize(updateColorSize.getSize()).setStoreProdId(storeProdId)
|
||||
.setStandard(updateColorSize.getStandard()).setStoreColorId(storeColorMap.get(updateColorSize.getColorName()))
|
||||
.setPrice(updateColorSize.getPrice()).setNextSn(0).setStoreId(storeId));
|
||||
.setPrice(updateColorSize.getPrice()).setNextSn(0));
|
||||
}
|
||||
});
|
||||
this.storeProdColorSizeMapper.insertOrUpdate(dbProdColorSizeList);
|
||||
|
|
@ -496,7 +496,7 @@ public class StoreProductServiceImpl implements IStoreProductService {
|
|||
this.storeProdColorMapper.insert(prodColorList);
|
||||
// 新增档口颜色尺码对应价格
|
||||
List<StoreProductColorSize> prodColorSizeList = createDTO.getSizeList().stream().map(x -> new StoreProductColorSize().setSize(x.getSize()).setStoreProdId(storeProdId)
|
||||
.setStandard(x.getStandard()).setStoreColorId(storeColorMap.get(x.getColorName())).setPrice(x.getPrice()).setNextSn(0).setStoreId(storeId))
|
||||
.setStandard(x.getStandard()).setStoreColorId(storeColorMap.get(x.getColorName())).setPrice(x.getPrice()).setNextSn(0))
|
||||
.collect(Collectors.toList());
|
||||
this.storeProdColorSizeMapper.insert(prodColorSizeList);
|
||||
// 设置档口商品价格尺码的barcode_prefix
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE
|
||||
spcs.del_flag = 0
|
||||
AND spcs.sn_prefix = #{snPrefix}
|
||||
AND spcs.store_id = #{storeId}
|
||||
AND sp.store_id = #{storeId}
|
||||
</select>
|
||||
|
||||
<select id="selectOtherSn" resultType="com.ruoyi.xkt.dto.storeProdColorSize.StoreSaleSnResDTO">
|
||||
|
|
@ -63,7 +63,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
WHERE
|
||||
spcs.del_flag = 0
|
||||
AND spcs.other_sn_prefix = #{snPrefix}
|
||||
AND spcs.store_id = #{storeId}
|
||||
AND sp.store_id = #{storeId}
|
||||
</select>
|
||||
|
||||
<select id="selectStorageBuJuSnList">
|
||||
|
|
@ -82,7 +82,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
|
||||
WHERE
|
||||
spcs.del_flag = 0
|
||||
AND spcs.store_id = #{storeId}
|
||||
AND sp.store_id = #{storeId}
|
||||
<if test="buJuPrefixSnList != null and buJuPrefixSnList.size() > 0">
|
||||
AND spcs.sn_prefix IN
|
||||
<foreach item="item" index="index" collection="buJuPrefixSnList" separator="," open="(" close=")" >
|
||||
|
|
@ -107,7 +107,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
|
||||
WHERE
|
||||
spcs.del_flag = 0
|
||||
AND spcs.store_id = #{storeId}
|
||||
AND sp.store_id = #{storeId}
|
||||
<if test="otherPrefixSnList != null and otherPrefixSnList.size() > 0">
|
||||
AND spcs.other_sn_prefix IN
|
||||
<foreach item="item" index="index" collection="otherPrefixSnList" separator="," open="(" close=")" >
|
||||
|
|
@ -129,7 +129,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
|
||||
WHERE
|
||||
spcs.del_flag = 0
|
||||
AND spcs.store_id = #{storeId}
|
||||
AND sp.store_id = #{storeId}
|
||||
<if test="buJuPrefixSnList != null and buJuPrefixSnList.size() > 0">
|
||||
AND spcs.sn_prefix IN
|
||||
<foreach item="item" index="index" collection="buJuPrefixSnList" separator="," open="(" close=")" >
|
||||
|
|
@ -151,7 +151,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
JOIN store_product_color spc ON spcs.store_color_id = spc.store_color_id AND spcs.store_prod_id = spc.store_prod_id AND spc.del_flag = 0
|
||||
WHERE
|
||||
spcs.del_flag = 0
|
||||
AND spcs.store_id = #{storeId}
|
||||
AND sp.store_id = #{storeId}
|
||||
<if test="otherPrefixSnList != null and otherPrefixSnList.size() > 0">
|
||||
AND spcs.other_sn_prefix IN
|
||||
<foreach item="item" index="index" collection="otherPrefixSnList" separator="," open="(" close=")" >
|
||||
|
|
|
|||
Loading…
Reference in New Issue