master:系统调优;
parent
76a5b334a4
commit
ba10adbf77
|
|
@ -35,6 +35,9 @@ public class FhbController extends BaseController {
|
|||
final IShipMasterService shipMasterService;
|
||||
final RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* step1
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/prod/cache")
|
||||
public R<Integer> createProdCache(@Validated @RequestBody FhbProdVO prodVO) {
|
||||
|
|
@ -51,34 +54,18 @@ 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, fhbProdList);
|
||||
CollectionUtils.addAll(cacheList, prodVO.getData().getRecords());
|
||||
// 存到redis中
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_KEY + supplierId, cacheList, 5, TimeUnit.DAYS);
|
||||
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();
|
||||
}
|
||||
|
||||
/**
|
||||
* step2
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/cus/cache")
|
||||
public R<Integer> createCusCache(@Validated @RequestBody FhbCusVO cusVO) {
|
||||
|
|
@ -95,6 +82,43 @@ public class FhbController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* step3
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/cus/discount/cache")
|
||||
public R<Integer> createCusDiscountCache(@Validated @RequestBody FhbCusDiscountVO cusDiscountVO) {
|
||||
final Integer supplierId = cusDiscountVO.getData().getRecords().get(0).getSupplierId();
|
||||
// 供应商ID
|
||||
if (ObjectUtils.isEmpty(cusDiscountVO.getData()) || ObjectUtils.isEmpty(cusDiscountVO.getData().getRecords())) {
|
||||
return R.ok();
|
||||
}
|
||||
// 错误的折扣列表
|
||||
List<String> errorCusDiscList = new ArrayList<>();
|
||||
// 设置优惠价格
|
||||
cusDiscountVO.getData().getRecords().forEach(record -> {
|
||||
final Integer supplyPrice = ObjectUtils.defaultIfNull(record.getSupplyPrice(), 0);
|
||||
final Integer customerPrice = ObjectUtils.defaultIfNull(record.getCustomerPrice(), 0);
|
||||
if (supplyPrice - customerPrice < 0) {
|
||||
errorCusDiscList.add(record.getArtNo() + ":" + record.getCustomerName() + ":" + record.getColor());
|
||||
}
|
||||
record.setDiscount(supplyPrice - customerPrice);
|
||||
});
|
||||
if (CollectionUtils.isNotEmpty(errorCusDiscList)) {
|
||||
throw new ServiceException("供应商商品价格有误!" + errorCusDiscList, HttpStatus.ERROR);
|
||||
}
|
||||
// 先从redis中获取列表数据
|
||||
List<FhbCusDiscountVO.SMCDRecordVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId), new ArrayList<>());
|
||||
CollectionUtils.addAll(cacheList, cusDiscountVO.getData().getRecords());
|
||||
// 存到redis中
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId, cacheList, 5, TimeUnit.DAYS);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* step4
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/prod/stock/cache/{supplierId}")
|
||||
public R<Integer> createProdStockCache(@PathVariable Integer supplierId, @Validated @RequestBody FhbProdStockVO stockVO) {
|
||||
|
|
@ -111,34 +135,28 @@ public class FhbController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// ======================================================================================================================================
|
||||
|
||||
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/cus/discount/cache")
|
||||
public R<Integer> createCusDiscountCache(@Validated @RequestBody FhbCusDiscountVO cusDiscountVO) {
|
||||
final Integer supplierId = cusDiscountVO.getData().getRecords().get(0).getSupplierId();
|
||||
// 供应商ID
|
||||
if (ObjectUtils.isEmpty(cusDiscountVO.getData()) || ObjectUtils.isEmpty(cusDiscountVO.getData().getRecords())) {
|
||||
return R.ok();
|
||||
}
|
||||
// 设置优惠价格
|
||||
cusDiscountVO.getData().getRecords().forEach(record -> {
|
||||
final Integer supplyPrice = ObjectUtils.defaultIfNull(record.getSupplyPrice(), 0);
|
||||
final Integer customerPrice = ObjectUtils.defaultIfNull(record.getCustomerPrice(), 0);
|
||||
if (supplyPrice - customerPrice < 0) {
|
||||
throw new ServiceException("供应商商品价格有误" + record.getArtNo(), HttpStatus.ERROR);
|
||||
}
|
||||
record.setDiscount(supplyPrice - customerPrice);
|
||||
});
|
||||
// 先从redis中获取列表数据
|
||||
List<FhbCusDiscountVO.SMCDRecordVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId), new ArrayList<>());
|
||||
CollectionUtils.addAll(cacheList, cusDiscountVO.getData().getRecords());
|
||||
// 存到redis中
|
||||
redisCache.setCacheObject(CacheConstants.MIGRATION_SUPPLIER_CUS_DISCOUNT_KEY + supplierId, cacheList, 5, TimeUnit.DAYS);
|
||||
@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);
|
||||
}*/
|
||||
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/prod/cache/{supplierId}")
|
||||
public R<Integer> getProdCache(@PathVariable Integer supplierId) {
|
||||
|
|
@ -191,6 +209,7 @@ public class FhbController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/cus/discount/cache/{supplierId}")
|
||||
public R<Integer> getCusDiscountCache(@PathVariable Integer supplierId) {
|
||||
|
|
|
|||
|
|
@ -104,7 +104,7 @@ public class GtAndFhbBizController extends BaseController {
|
|||
.getCacheObject(CacheConstants.MIGRATION_GT_SALE_BASIC_KEY + userId), new ArrayList<>());
|
||||
Map<String, String> articleNoColorMap = gtSaleBasicList.stream().collect(Collectors.groupingBy(GtProdSkuVO::getArticle_number,
|
||||
Collectors.collectingAndThen(Collectors.mapping(GtProdSkuVO::getColor, Collectors.toList()),
|
||||
list -> "(" + list.stream().distinct().collect(Collectors.joining(",")) + ")")));
|
||||
list -> "(" + list.stream().sorted(Comparator.naturalOrder()).distinct().collect(Collectors.joining(",")) + ")")));
|
||||
List<String> doubleRunSaleArtNoList = gtSaleBasicList.stream().map(GtProdSkuVO::getArticle_number)
|
||||
.distinct().collect(Collectors.toList());
|
||||
// 查看gt 在售的商品 这边有多少相似的货号
|
||||
|
|
@ -134,7 +134,7 @@ public class GtAndFhbBizController extends BaseController {
|
|||
.getCacheObject(CacheConstants.MIGRATION_SUPPLIER_PROD_KEY + supplierId), new ArrayList<>());
|
||||
Map<String, String> fhbArticleNoColorMap = fhbProdList.stream().collect(Collectors.groupingBy(FhbProdVO.SMIVO::getArtNo,
|
||||
Collectors.collectingAndThen(Collectors.mapping(FhbProdVO.SMIVO::getColor, Collectors.toList()),
|
||||
list -> "(" + list.stream().distinct().collect(Collectors.joining(",")) + ")")));
|
||||
list -> "(" + list.stream().sorted(Comparator.naturalOrder()).distinct().collect(Collectors.joining(",")) + ")")));
|
||||
List<String> shipArtNoList = fhbProdList.stream().map(FhbProdVO.SMIVO::getArtNo)
|
||||
.distinct().collect(Collectors.toList());
|
||||
shipArtNoList.forEach(artNo -> {
|
||||
|
|
|
|||
|
|
@ -41,7 +41,32 @@ public class GtController extends BaseController {
|
|||
final RedisCache redisCache;
|
||||
final SysProductCategoryMapper prodCateMapper;
|
||||
|
||||
/**
|
||||
* step1
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/cate/cache/{user_id}")
|
||||
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, cacheList);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* step2
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/sale/cache")
|
||||
public R<Integer> createSaleCache(@Validated @RequestBody GtProdVO doubleRunVO) {
|
||||
|
|
@ -51,7 +76,7 @@ public class GtController extends BaseController {
|
|||
List<GtProdSkuVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_GT_SALE_BASIC_KEY + userId), new ArrayList<>());
|
||||
// 已存入的map,增加个校验 如果已导入则不重复导入 避免误操作
|
||||
Map<String, String> cacheMap = cacheList.stream().collect(Collectors.toMap(GtProdSkuVO::getArticle_number, GtProdSkuVO::getArticle_number));
|
||||
Map<String, String> cacheMap = cacheList.stream().collect(Collectors.toMap(GtProdSkuVO::getArticle_number, GtProdSkuVO::getArticle_number, (v1, v2) -> v2));
|
||||
// 三年前的时间
|
||||
Date threeYearsBefore = java.sql.Date.valueOf(LocalDate.now().minusYears(3));
|
||||
artNoList.stream()
|
||||
|
|
@ -73,6 +98,9 @@ public class GtController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* step3
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/off-sale/cache")
|
||||
public R<Integer> createOffSaleCache(@Validated @RequestBody GtProdVO doubleRunVO) {
|
||||
|
|
@ -82,7 +110,7 @@ public class GtController extends BaseController {
|
|||
List<GtProdSkuVO> cacheList = ObjectUtils.defaultIfNull(redisCache
|
||||
.getCacheObject(CacheConstants.MIGRATION_GT_OFF_SALE_BASIC_KEY + userId), new ArrayList<>());
|
||||
// 已存入的map,增加个校验 如果已导入则不重复导入 避免误操作
|
||||
Map<String, String> cacheMap = cacheList.stream().collect(Collectors.toMap(GtProdSkuVO::getArticle_number, GtProdSkuVO::getArticle_number));
|
||||
Map<String, String> cacheMap = cacheList.stream().collect(Collectors.toMap(GtProdSkuVO::getArticle_number, GtProdSkuVO::getArticle_number, (v1, v2) -> v2));
|
||||
artNoList.stream()
|
||||
// 避免误操作
|
||||
.filter(x -> !cacheMap.containsKey(x.getArticle_number()))
|
||||
|
|
@ -98,6 +126,9 @@ public class GtController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* step4
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/attr/cache/{user_id}/{product_id}")
|
||||
public R<Integer> createAttrCache(@PathVariable(value = "user_id") Integer user_id, @PathVariable("product_id") Integer product_id,
|
||||
|
|
@ -123,25 +154,6 @@ public class GtController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/cate/cache/{user_id}")
|
||||
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, cacheList);
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@GetMapping("/prod/cache/{userId}")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,19 @@
|
|||
package com.ruoyi.web.controller.xkt.migartion;
|
||||
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 只有GT处理 相关
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/rest/v1/gt-only")
|
||||
public class GtOnlyBizController extends BaseController {
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -42,8 +42,11 @@ public class TyController extends BaseController {
|
|||
|
||||
final RedisCache redisCache;
|
||||
|
||||
/**
|
||||
* step1
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/-R/prod/cache/{userId}")
|
||||
@PostMapping("/prod/cache/{userId}")
|
||||
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());
|
||||
|
|
@ -72,6 +75,9 @@ public class TyController extends BaseController {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* step2
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/cus/cache/{userId}")
|
||||
public R<Integer> createCusCache(@PathVariable Integer userId, MultipartFile file) throws IOException {
|
||||
|
|
@ -83,8 +89,11 @@ public class TyController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* step3
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/-R/cus/disc/cache/{cusName}/{userId}")
|
||||
@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中获取已存在的客户优惠数据
|
||||
|
|
@ -133,8 +142,11 @@ public class TyController extends BaseController {
|
|||
return R.ok();
|
||||
}
|
||||
|
||||
/**
|
||||
* step4
|
||||
*/
|
||||
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
|
||||
@PostMapping("/-R/stock/cache/{userId}")
|
||||
@PostMapping("/stock/cache/{userId}")
|
||||
public R<Integer> createTyProdStockCache(@PathVariable Integer userId, MultipartFile file) throws IOException {
|
||||
ExcelUtil<TyProdStockVO> util = new ExcelUtil<>(TyProdStockVO.class);
|
||||
List<TyProdStockVO> tyStockList = util.importExcel(file.getInputStream());
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ public class FhbProdVO {
|
|||
private String size;
|
||||
private BigDecimal addPrice;
|
||||
private String addPriceSize;
|
||||
private String snPrefix;
|
||||
private BigDecimal salePrice;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue