Commit 4d9c948f by kk

存储

parent 67a366b2
......@@ -3,6 +3,7 @@ package cn.kk.spring_simple_operation;
import cn.kk.spring_simple_operation.entity.*;
import cn.kk.spring_simple_operation.mapper.*;
import cn.kk.spring_simple_operation.model.dto.ImportExcelDto;
import cn.kk.spring_simple_operation.model.dto.RiskCheckAreaExportDTO;
import cn.kk.spring_simple_operation.model.dto.SkuImageDesignDTO;
import cn.kk.spring_simple_operation.model.vo.SkuAPlusImageAndVideoVO;
import cn.kk.spring_simple_operation.utils.ExcelUtil;
......@@ -278,6 +279,45 @@ public class MyTest2 {
@Test
public void exportWoolRiskCheckArea() {
List<VisualAPlusPlan> planList = visualAPlusPlanMapper.selectList(Wrappers.<VisualAPlusPlan>lambdaQuery()
.eq(VisualAPlusPlan::getIsDelete, 0)
.and(wrapper -> wrapper
.like(VisualAPlusPlan::getRiskCheckArea, "wool")
.or().like(VisualAPlusPlan::getRiskCheckArea, "Cashmere")
.or().like(VisualAPlusPlan::getRiskCheckArea, "kashmir")
.or().like(VisualAPlusPlan::getRiskCheckArea, "pashmina"))
.select(VisualAPlusPlan::getId, VisualAPlusPlan::getRiskCheckArea));
Map<Long, String> planRiskMap = planList.stream()
.collect(Collectors.toMap(VisualAPlusPlan::getId, VisualAPlusPlan::getRiskCheckArea, (a, b) -> a));
List<RiskCheckAreaExportDTO> resultList = new ArrayList<>();
Lists.partition(new ArrayList<>(planRiskMap.keySet()), 500).forEach(planIdList -> {
List<APlusProduct> aPlusProducts = aPlusProductMapper.selectList(Wrappers.<APlusProduct>lambdaQuery()
.in(APlusProduct::getAPlusPlanId, planIdList)
.eq(APlusProduct::getIsUploadBackstage, 2)
.eq(APlusProduct::getIsDelete, 0)
.select(APlusProduct::getSku, APlusProduct::getSite, APlusProduct::getAPlusPlanId, APlusProduct::getOptimizeType));
for (APlusProduct aPlusProduct : aPlusProducts) {
RiskCheckAreaExportDTO dto = new RiskCheckAreaExportDTO();
dto.setSku(aPlusProduct.getSku());
dto.setSite(aPlusProduct.getSite());
dto.setOptimizeType(aPlusProduct.getOptimizeType());
String riskCheckArea = planRiskMap.get(aPlusProduct.getAPlusPlanId());
dto.setRiskCheckArea(riskCheckArea);
dto.setKeywords(extractRiskKeywords(riskCheckArea));
resultList.add(dto);
}
});
ExcelUtil<RiskCheckAreaExportDTO> util = new ExcelUtil<>(RiskCheckAreaExportDTO.class);
util.exportExcelFile(resultList, "羊绒风险A+产品检测sku导出.xlsx");
log.info("导出完成,共 {} 条", resultList.size());
}
@Test
public void exportSkuIsMakePic() throws Exception {
ExcelUtil<SkuImageDesignDTO> util = new ExcelUtil<>(SkuImageDesignDTO.class);
List<SkuImageDesignDTO> list = util.importExcel(Files.newInputStream(new File("sku-是否作图.xlsx").toPath()));
......@@ -330,6 +370,22 @@ public class MyTest2 {
return cell;
}
private static final String[] RISK_KEYWORDS = {"wool", "Cashmere", "kashmir", "pashmina"};
private String extractRiskKeywords(String riskCheckArea) {
if (StringUtils.isEmpty(riskCheckArea)) {
return "";
}
String lower = riskCheckArea.toLowerCase(Locale.ROOT);
List<String> hit = new ArrayList<>();
for (String keyword : RISK_KEYWORDS) {
if (lower.contains(keyword.toLowerCase(Locale.ROOT))) {
hit.add(keyword);
}
}
return String.join(",", hit);
}
private String buildSkuSiteKey(String sku, String site) {
return (sku == null ? "" : sku.trim()) + "#" + (site == null ? "" : site.trim());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment