From 70f355232e47e1771b4f1b756b815b1cb45a397f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=A2=81=E9=94=8B?= Date: Sun, 23 Nov 2025 07:49:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E5=93=81=20excel=E5=AF=BC=E5=85=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../productinfo/ProductInfoServiceImpl.java | 45 ++++++++++--------- 1 file changed, 23 insertions(+), 22 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 7b8879c..9e14de7 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 @@ -375,7 +375,6 @@ public class ProductInfoServiceImpl implements ProductInfoService { ProductInfoDO dos = productInfoMapper.selectOne(lambdaQueryWrapper); if(FuncUtil.isNotEmpty(dos)){ - // 合并属性 BeanUtil.copyProperties(dos, productInfo); productInfo.setName(excelVO.getName()); @@ -389,8 +388,11 @@ public class ProductInfoServiceImpl implements ProductInfoService { productInfo.setSpecMaterial(FuncUtil.toStr(excelVO.getMaterial(),null)); productInfo.setRemark(FuncUtil.toStr(excelVO.getRemarks(),null)); - Long productTypeId = toProductTypeId(excelVO.getProductType()); - productInfo.setProductTypeId(productTypeId); + if(FuncUtil.isNotEmpty(excelVO.getProductType())){ + Long productTypeId = toProductTypeId(excelVO.getProductType()); + productInfo.setProductTypeId(productTypeId); + } + if(FuncUtil.isNotEmpty(brandName)){ Long brandId = brandIdCache.get(brandName); @@ -417,44 +419,43 @@ public class ProductInfoServiceImpl implements ProductInfoService { if(FuncUtil.isEmpty(code)){ return "第"+(i+1)+"行编码 不能为空:"+code; } - String brandName = excelVO.getBrandName(); + String brandName = FuncUtil.toStr(excelVO.getBrandName(),"").trim(); if(FuncUtil.isEmpty(brandName)){ + return "第"+(i+1)+"行品牌名称 不能为空:"+brandName; } - String productType = excelVO.getProductType(); + String productType = FuncUtil.toStr(excelVO.getProductType(),"").trim(); if(FuncUtil.isEmpty(productType)){ - return "第"+(i+1)+"行品类(尺码唛,价钱卡,纸盒,主唛,挂卡,洗水唛) 不能为空:"+brandName; + return "第"+(i+1)+"行品类(尺码唛,价钱卡,纸盒,主唛,挂卡,洗水唛) 不能为空:"+productType; } - Long typeId = toProductTypeId(excelVO.getProductType().trim()); + Long typeId = toProductTypeId(productType); if(FuncUtil.isEmpty(typeId)){ ProductTypeIdCache.clear(); - return "第"+(i+1)+"行品类(尺码唛,价钱卡,纸盒,主唛,挂卡,洗水唛) 请维护该分类的的资料:"+excelVO.getProductType(); + return "第"+(i+1)+"行品类(尺码唛,价钱卡,纸盒,主唛,挂卡,洗水唛) 请维护该分类的的资料:"+productType; } productInfo.setProductTypeId(typeId); 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.setSpecSizeWidth(FuncUtil.toDouble(excelVO.getSpecWidth(),null)); + productInfo.setSpecSizeHeight(FuncUtil.toDouble(excelVO.getSpecHeight(),null)); + productInfo.setSpecSizeThk(FuncUtil.toDouble(excelVO.getSpecThickness(),null)); productInfo.setSpecMaterial(excelVO.getMaterial()); productInfo.setRemark(excelVO.getRemarks()); - if(FuncUtil.isNotEmpty(brandName)){ - Long brandId = brandIdCache.get(brandName); - if(FuncUtil.isNotEmpty(brandId)){ - productInfo.setBrandId(brandId); - }else { - BrandDO brandDO = brandService.getBrandByName(brandName); - if(FuncUtil.isEmpty(brandDO)){ - return "第"+(i+1)+"行品牌不存在,请维护该品牌的资料:"+brandName; - } - productInfo.setBrandId(brandDO.getId()); - brandIdCache.put(brandName,brandDO.getId()); + Long brandId = brandIdCache.get(brandName); + if(FuncUtil.isNotEmpty(brandId)){ + productInfo.setBrandId(brandId); + }else { + BrandDO brandDO = brandService.getBrandByName(brandName); + if(FuncUtil.isEmpty(brandDO)){ + return "第"+(i+1)+"行品牌不存在,请维护该品牌的资料:"+brandName; } + productInfo.setBrandId(brandDO.getId()); + brandIdCache.put(brandName,brandDO.getId()); } newList.add(productInfo); }