产品 excel导入

This commit is contained in:
袁锋 2025-11-23 07:49:42 +08:00
parent c5e78f8521
commit 70f355232e
1 changed files with 23 additions and 22 deletions

View File

@ -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);
}