master:获取档口库存系统接口,系统调优;

pull/1121/head
liujiang 2025-09-25 18:52:24 +08:00
parent b9530d76f6
commit becb581b34
10 changed files with 189 additions and 6 deletions

View File

@ -190,5 +190,11 @@ public class StoreController extends XktBaseController {
return R.ok(BeanUtil.toBean(storeService.getAppViewRank(), StoreAppViewRankResVO.class));
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin,store,seller,agent')||@ss.hasSupplierSubRole()")
@ApiOperation(value = "获取档口库存系统", httpMethod = "GET", response = R.class)
@GetMapping("/stock-sys/{storeId}")
public R<Integer> getStockSys(@PathVariable Long storeId) {
return R.ok(storeService.getStockSys(storeId));
}
}

View File

@ -20,7 +20,7 @@ import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* ShipMaster
* FHB
*
* @author ruoyi
*/

View File

@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -127,8 +128,8 @@ public class GtController extends BaseController {
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@GetMapping("/cache/{userId}")
public R<Integer> getCache(@PathVariable Integer userId) {
@GetMapping("/prod/cache/{userId}")
public R<Integer> getProdCache(@PathVariable Integer userId) {
// 从redis中获取数据
List<GtProdSkuVO> cacheList = ObjectUtils.defaultIfNull(redisCache
.getCacheObject(CacheConstants.MIGRATION_GT_SALE_BASIC_KEY + userId), new ArrayList<>());
@ -141,9 +142,9 @@ public class GtController extends BaseController {
.collect(Collectors
.groupingBy(GtProdSkuVO::getArticle_number, LinkedHashMap::new, Collectors.toList()));
// 货号 颜色 map
Map<String, List<String>> artNoColorMap = new LinkedHashMap<>();
Map<String, Set<String>> artNoColorMap = new LinkedHashMap<>();
artNoGroup.forEach((artNo, colorList) -> {
artNoColorMap.put(artNo, colorList.stream().map(GtProdSkuVO::getColor).collect(Collectors.toList()));
artNoColorMap.put(artNo, colorList.stream().map(GtProdSkuVO::getColor).collect(Collectors.toSet()));
});
artNoColorMap.forEach((k, v) -> {
@ -153,12 +154,14 @@ public class GtController extends BaseController {
// cacheList 按照货号分组,获取所有价格,价格去重
Map<String, Set<BigDecimal>> artNoPriceMap = cacheList.stream().collect(Collectors.groupingBy(
GtProdSkuVO::getArticle_number, Collectors.mapping(GtProdSkuVO::getPrice, Collectors.toSet())));
AtomicInteger count = new AtomicInteger();
artNoPriceMap.forEach((k, v) -> {
System.out.println(k + ":" + v);
if (v.size() > 1) {
count.addAndGet(1);
System.err.println(k + ":" + v);
}
});
System.err.println(count);
// Map<String, List<Integer>> artNoPriceMap =

View File

@ -0,0 +1,63 @@
package com.ruoyi.web.controller.xkt.migartion;
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.common.utils.poi.ExcelUtil;
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.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
/**
* TY
*
* @author ruoyi
*/
@RestController
@RequiredArgsConstructor
@RequestMapping("/rest/v1/ty")
public class TyController extends BaseController {
final RedisCache redisCache;
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@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());
Map<String, List<TyProdImportVO>> prodMap = tyProdVOList.stream().collect(Collectors.groupingBy(TyProdImportVO::getProdArtNum));
prodMap.forEach((k, v) -> {
System.err.println(k + ":" + v);
});
// 存到redis中
redisCache.setCacheObject(CacheConstants.MIGRATION_TY_PROD_KEY + userId, tyProdVOList, 5, TimeUnit.DAYS);
return R.ok();
}
@PreAuthorize("@ss.hasAnyRoles('admin,general_admin')")
@PostMapping("/cus/cache/{userId}")
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());
// 存到redis中
redisCache.setCacheObject(CacheConstants.MIGRATION_TY_CUS_KEY + userId, tyProdVOList, 5, TimeUnit.DAYS);
return R.ok();
}
}

View File

@ -0,0 +1,21 @@
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;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel
@Data
@Accessors(chain = true)
public class TyCusImportVO {
@Excel(name = "客户名称")
private String cusName;
}

View File

@ -0,0 +1,27 @@
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;
/**
* @author liujiang
* @version v1.0
* @date 2025/3/27 15:12
*/
@ApiModel
@Data
@Accessors(chain = true)
public class TyProdImportVO {
@Excel(name = "HUOH")
private String prodArtNum;
@Excel(name = "COL")
private String colorName;
@Excel(name = "jg")
private Integer price;
@Excel(name = "HPBM")
private String otherSnPrefix;
}

View File

@ -0,0 +1,34 @@
package com.ruoyi.web.controller.xkt.migartion.vo.ty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
/**
* @author liangyq
* @date 2025-05-11 23:46
*/
@Data
public class TyProdVO {
private SMIDataVO data;
@Data
public static class SMIDataVO {
private List<SMIVO> records;
}
@Data
public static class SMIVO {
private Integer supplierId;
private Integer supplierSkuId;
private String artNo;
private String color;
private String size;
private BigDecimal addPrice;
private String addPriceSize;
private String snPrefix;
}
}

View File

@ -344,5 +344,13 @@ public class CacheConstants {
* GT
*/
public static final String MIGRATION_GT_SALE_CATE_KEY = "mig_gt_sale_cate:";
/**
* TY
*/
public static final String MIGRATION_TY_PROD_KEY = "mig_ty_prod:";
/**
* TY
*/
public static final String MIGRATION_TY_CUS_KEY = "mig_ty_cus:";
}

View File

@ -197,4 +197,12 @@ public interface IStoreService {
* @return StoreAppViewRankResDTO
*/
StoreAppViewRankResDTO getAppViewRank();
/**
*
*
* @return
* @param storeId
*/
Integer getStockSys(Long storeId);
}

View File

@ -431,6 +431,19 @@ public class StoreServiceImpl implements IStoreService {
return redisAppViewRank;
}
/**
*
*
* @param storeId ID
* @return
*/
@Override
@Transactional(readOnly = true)
public Integer getStockSys(Long storeId) {
Store store = Optional.ofNullable(storeMapper.selectById(storeId)).orElseThrow(() -> new ServiceException("档口不存在!", HttpStatus.ERROR));
return store.getStockSys();
}
/**
*
*