master:系统优化;

pull/1121/head
liujiang 2025-09-23 16:19:11 +08:00
parent 90934154fe
commit 4f613aaae4
7 changed files with 124 additions and 14 deletions

View File

@ -4,10 +4,7 @@ import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.redis.RedisCache;
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.web.controller.xkt.migartion.vo.fhb.*;
import com.ruoyi.xkt.service.shipMaster.IShipMasterService;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections4.CollectionUtils;
@ -101,6 +98,14 @@ 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}")
public R<Integer> getProdCache(@PathVariable Integer supplierId) {

View File

@ -33,8 +33,8 @@ import java.util.stream.Collectors;
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/rest/v1/compare")
public class CompareBizController extends BaseController {
@RequestMapping("/rest/v1/gt-fhb")
public class GtAndFhbBizController extends BaseController {
final IShipMasterService shipMasterService;
final RedisCache redisCache;
@ -45,7 +45,7 @@ public class CompareBizController extends BaseController {
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PutMapping("/double/ship/{userId}/{supplierId}")
@PutMapping("/compare/{userId}/{supplierId}")
public void compare(HttpServletResponse response, @PathVariable("userId") Integer userId, @PathVariable("supplierId") Integer supplierId) throws UnsupportedEncodingException {
Map<String, List<String>> multiSaleSameGoMap = new HashMap<>();
Map<String, List<String>> multiOffSaleSameGoMap = new HashMap<>();
@ -150,16 +150,42 @@ public class CompareBizController extends BaseController {
String encodedFileName = URLEncoder.encode("GT与FHB差异" + DateUtils.getDate(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename=" + encodedFileName + ".xlsx");
util.exportExcel(response, downloadList, "差异");
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PutMapping("/save/{userId}/{supplierId}")
public void autoSaveToDB(@PathVariable("userId") Integer userId, @PathVariable("supplierId") Integer supplierId) throws UnsupportedEncodingException {
// 步骤1: 准备数据,新建颜色
// 步骤2: 准备数据,新建客户
// 步骤3: GT 和 FHB 货号对应关系然后直接copy 对应的属性关系
// a. 商品与颜色对应关系
// b. 库存初始化
// c. 商品颜色尺码对应关系
// d. 同步到ES中 这步还不能做 因为没有 商品主图
// e.
// 步骤4: 客户与货号的优惠关系
// 步骤5: 货号的初始库存
}
/**
*
* : z1104 -> 1104, z1087 -> 1087, z1003-1 -> 1003, 922- -> 922, -8072 -> 8072
*
* @param articleNumber
* @return
*/
/**
*
* : z1104 -> 1104, z1087 -> 1087, z1003-1 -> 1003, 922- -> 922, -8072 -> 8072
*
* @param articleNumber
* @return
*/
private String extractCoreArticleNumber(String articleNumber) {
if (articleNumber == null || articleNumber.isEmpty()) {
return "";

View File

@ -1,14 +1,20 @@
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;
import org.apache.commons.collections4.CollectionUtils;
@ -17,8 +23,11 @@ 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.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
@ -33,6 +42,7 @@ public class GtController extends BaseController {
final IShipMasterService shipMasterService;
final RedisCache redisCache;
final SysProductCategoryMapper prodCateMapper;
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PostMapping("/sale/cache")
@ -95,6 +105,28 @@ 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, MultipartFile file) throws IOException {
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()));
});
// 放到缓存中
redisCache.setCacheObject(CacheConstants.MIGRATION_GT_SALE_CATE_KEY + user_id, artNoCateList, 5, TimeUnit.DAYS);
return R.ok();
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@GetMapping("/cache/{userId}")

View File

@ -0,0 +1,16 @@
package com.ruoyi.web.controller.xkt.migartion.vo.fhb;
import lombok.Data;
import java.util.List;
/**
* @author liangyq
* @date 2025-05-11 23:46
*/
@Data
public class FhbColorVO {
private List<String> data;
}

View File

@ -0,0 +1,22 @@
package com.ruoyi.web.controller.xkt.migartion.vo.gt;
import com.ruoyi.common.annotation.Excel;
import lombok.Data;
import lombok.experimental.Accessors;
/**
* @author liangyq
* @date 2025-05-11 23:46
*/
@Data
@Accessors(chain = true)
public class GtCateVO {
@Excel(name = "货号")
private String article_number;
@Excel(name = "分类")
private String cate_name;
// 步橘的分类id
private Long buju_cate_id;
}

View File

@ -23,6 +23,7 @@ public class GtProdVO {
private Integer id;
private Integer user_id;
private String article_number;
private String characters;
private List<GtProdSkuVO> skus;
}

View File

@ -328,6 +328,10 @@ 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
*/
@ -340,5 +344,9 @@ public class CacheConstants {
* GT
*/
public static final String MIGRATION_GT_SALE_ATTR_KEY = "mig_gt_sale_attr:";
/**
* GT
*/
public static final String MIGRATION_GT_SALE_CATE_KEY = "mig_gt_sale_cate:";
}