From 42616da7e895a7fb6dfee95af8fc7607410c374e Mon Sep 17 00:00:00 2001 From: yf <770153798@qq.com> Date: Sun, 26 Oct 2025 08:54:05 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=20=E4=BA=A7=E5=93=81?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E9=80=BB=E8=BE=91=EF=BC=8C=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=9B=B8=E5=90=8C=E7=BC=96=E7=A0=81=E8=A6=86=E7=9B=96=E6=95=B0?= =?UTF-8?q?=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../productinfo/ProductInfoServiceImpl.java | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/productinfo/ProductInfoServiceImpl.java b/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/productinfo/ProductInfoServiceImpl.java index 384984d..0677a59 100644 --- a/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/productinfo/ProductInfoServiceImpl.java +++ b/hangtag-module-oms/hangtag-module-oms-biz/src/main/java/cn/hangtag/module/oms/service/productinfo/ProductInfoServiceImpl.java @@ -290,6 +290,7 @@ public class ProductInfoServiceImpl implements ProductInfoService { @Override public String importExcel(List list) { List newList = new ArrayList<>(); + List updateList = new ArrayList<>(); LambdaQueryWrapper brandDOLambdaQueryWrapper = new LambdaQueryWrapper<>(); brandDOLambdaQueryWrapper.select(BrandDO::getName,BrandDO::getId,BrandDO::getCode); @@ -309,9 +310,47 @@ public class ProductInfoServiceImpl implements ProductInfoService { String code = excelVO.getCode(); if(FuncUtil.isNotEmpty(code)){ try { - checkCode(productInfo.getId(),code); + + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(ProductInfoDO::getCode, code); + lambdaQueryWrapper.eq(ProductInfoDO::getDeleted,false); + lambdaQueryWrapper.last("limit 1"); + ProductInfoDO dos = productInfoMapper.selectOne(lambdaQueryWrapper); + if(FuncUtil.isNotEmpty(dos)){ + // 合并属性 + BeanUtil.copyProperties(dos, productInfo); + productInfo.setId(dos.getId()); + String brandName = excelVO.getBrandName(); + productInfo.setCode(code); + productInfo.setTemplateType("2"); + + productInfo.setSpecSizeWidth(FuncUtil.toDouble(excelVO.getSpecWidth())); + productInfo.setSpecSizeHeight(FuncUtil.toDouble(excelVO.getSpecHeight())); + productInfo.setSpecSizeThk(FuncUtil.toDouble(excelVO.getSpecThickness())); + productInfo.setSpecMaterial(excelVO.getMaterial()); + productInfo.setRemark(excelVO.getRemarks()); + + Long productTypeId = toProductTypeId(excelVO.getProductType()); + productInfo.setProductTypeId(productTypeId); + + if(FuncUtil.isNotEmpty(brandName)){ + Long brandId = brandIdCache.get(brandName); + if(FuncUtil.isNotEmpty(brandId)){ + productInfo.setBrandId(brandId); + }else { + BrandDO brandDO = brandService.getBrandByName(brandName); + if(FuncUtil.isNotEmpty(brandDO)){ + productInfo.setBrandId(brandDO.getId()); + brandIdCache.put(brandName,brandDO.getId()); + } + } + } + + updateList.add(productInfo); + continue; + } }catch (Exception e){ - return "第"+(i+1)+"行编码重复:"+code; + return "第"+(i+1)+"行覆盖失败:"+code+e.getMessage(); } }else { code = productInfo.getCode(); @@ -347,9 +386,14 @@ public class ProductInfoServiceImpl implements ProductInfoService { } newList.add(productInfo); } + if(FuncUtil.isNotEmpty(newList)){ + productInfoMapper.insertBatch(newList); + } + if(FuncUtil.isNotEmpty(updateList)){ + updateList.forEach(productInfoMapper::updateById); + } - productInfoMapper.insertBatch(newList); - return ""; + return (newList.size()+updateList.size())+""; } public boolean isAllFieldsEmpty(ProductInfoExcelVO excelVO) {