|
|
@ -106,7 +106,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
public void download(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
|
|
|
|
// 指定要下载的文件路径
|
|
|
|
String filePath = path + "商品导入模板.xls"; |
|
|
|
String filePath = path + "商享通商品导入明细模版.xls"; |
|
|
|
String fileName = new File(filePath).getName(); |
|
|
|
String encodedFileName = null; |
|
|
|
try { |
|
|
@ -152,27 +152,27 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
BaseGoodsSpuDto dto = new BaseGoodsSpuDto(); |
|
|
|
String spuCode = StringUtils.isEmpty(list.get(i)[0]) ? null : list.get(i)[0]; |
|
|
|
if (StringUtils.isBlank(spuCode)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "商品编码为空!"); |
|
|
|
return rb.setMsg("第" + (i + 1) + "行商品编码为空!"); |
|
|
|
} |
|
|
|
String spuName = StringUtils.isEmpty(list.get(i)[2]) ? null : list.get(i)[2]; |
|
|
|
if (StringUtils.isBlank(spuName)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "商品名称为空!"); |
|
|
|
return rb.setMsg("第" + (i + 1) + "行商品名称为空!"); |
|
|
|
} |
|
|
|
String type = StringUtils.isEmpty(list.get(i)[6]) ? null : list.get(i)[6]; |
|
|
|
if (StringUtils.isBlank(type)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "商品分类为空!"); |
|
|
|
return rb.setMsg("第" + (i + 1) + "行商品分类为空!"); |
|
|
|
} |
|
|
|
String brand = StringUtils.isEmpty(list.get(i)[7]) ? null : list.get(i)[7]; |
|
|
|
if (StringUtils.isBlank(brand)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "品牌为空!"); |
|
|
|
return rb.setMsg("第" + (i + 1) + "行品牌为空!"); |
|
|
|
} |
|
|
|
String cj = StringUtils.isEmpty(list.get(i)[8]) ? null : list.get(i)[8]; |
|
|
|
if (StringUtils.isBlank(cj)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "厂家为空!"); |
|
|
|
return rb.setMsg("第" + (i + 1) + "行厂家为空!"); |
|
|
|
} |
|
|
|
String unit = StringUtils.isEmpty(list.get(i)[9]) ? null : list.get(i)[9]; |
|
|
|
if (StringUtils.isBlank(unit)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "商品单位为空!"); |
|
|
|
return rb.setMsg("第" + (i + 1) + "行商品单位为空!"); |
|
|
|
} |
|
|
|
String taxRate = StringUtils.isEmpty(list.get(i)[10]) ? null : list.get(i)[10]; |
|
|
|
if (!isNumeric(taxRate)) { |
|
|
@ -311,12 +311,12 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
return strNum.matches("-?\\d+(\\.\\d+)?"); |
|
|
|
} |
|
|
|
public List<BaseGoodsSpuDto> a(List<BaseGoodsSpuDto> dtos) { |
|
|
|
ResultBean rb=new ResultBean().fail(); |
|
|
|
ResultBean rb = new ResultBean().fail(); |
|
|
|
List<BaseGoodsSpuDto> spus = new ArrayList<>();//spu list
|
|
|
|
int goodsCode =dtos.stream().filter(b->StringUtils.isEmpty(b.getGoodsCode())).collect(Collectors.toList()).size(); |
|
|
|
if(goodsCode==0){ |
|
|
|
int goodsCode = dtos.stream().filter(b -> StringUtils.isEmpty(b.getGoodsCode())).collect(Collectors.toList()).size(); |
|
|
|
if (goodsCode == 0) { |
|
|
|
spus = dtos.stream().filter(distinctByKey(BaseGoodsSpuDto::getGoodsCode)).collect(Collectors.toList()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
spus = dtos.stream().filter(distinctByKey(BaseGoodsSpuDto::getGoodsName)).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
for (BaseGoodsSpuDto baseGoodsSpuDto : spus) { |
|
|
@ -324,10 +324,10 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
List<BaseGoodsSkuDto> skus = new ArrayList<>(); |
|
|
|
String sid = UUID.randomUUID().toString(); |
|
|
|
baseGoodsSpuDto.setSid(sid); |
|
|
|
List<BaseGoodsSpuDto> dtos1=new ArrayList<>(); |
|
|
|
if(goodsCode==0){ |
|
|
|
List<BaseGoodsSpuDto> dtos1 = new ArrayList<>(); |
|
|
|
if (goodsCode == 0) { |
|
|
|
dtos1 = dtos.stream().filter(d -> d.getGoodsCode().equals(baseGoodsSpuDto.getGoodsCode())).collect(Collectors.toList()); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
dtos1 = dtos.stream().filter(d -> d.getGoodsName().equals(baseGoodsSpuDto.getGoodsName())).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
spuDetail.setGoodsExplain(dtos1.get(0).getBaseGoodsSpuDetail().getGoodsExplain()); |
|
|
@ -376,7 +376,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
return t -> seen.add(keyExtractor.apply(t)); |
|
|
|
} |
|
|
|
|
|
|
|
private BaseGoodsSpuDto packaging(String[] arr, BaseGoodsSpuDto baseGoodsSpuDto) { |
|
|
|
private BaseGoodsSpuDto packaging(String[] arr, BaseGoodsSpuDto baseGoodsSpuDto) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
//0四电名称1四电类别2规格3数量4单价5总价6单位7备注
|
|
|
|
// BaseGoodsSpuDto baseGoodsSpuDto =null;
|
|
|
@ -385,47 +385,43 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
String barCode = StringUtils.isEmpty(arr[1]) ? "" : arr[1];//
|
|
|
|
String goodsName = StringUtils.isEmpty(arr[2]) ? "" : arr[2];//
|
|
|
|
String subTitle = StringUtils.isEmpty(arr[3]) ? "" : arr[3]; |
|
|
|
String goodsPY = StringUtils.isEmpty(arr[4]) ? "": arr[4]; |
|
|
|
String goodsShortName = StringUtils.isEmpty(arr[5]) ? "" :arr[5]; |
|
|
|
String goodsTypeSid = StringUtils.isEmpty(arr[6]) ? "" : arr[6]; |
|
|
|
String brandSid = StringUtils.isEmpty(arr[7]) ? "" : arr[7]; |
|
|
|
String manufacturerSid = StringUtils.isEmpty(arr[8]) ? "" : arr[8]; |
|
|
|
// String goodsUnitSid = StringUtils.isEmpty(arr[9]) ? null : arr[9];
|
|
|
|
String goodsPY = StringUtils.isEmpty(arr[4]) ? "" : arr[4]; |
|
|
|
String goodsShortName = StringUtils.isEmpty(arr[5]) ? "" : arr[5]; |
|
|
|
String goodsType = StringUtils.isEmpty(arr[6]) ? "" : arr[6]; |
|
|
|
String brand = StringUtils.isEmpty(arr[7]) ? "" : arr[7]; |
|
|
|
String manufacturer = StringUtils.isEmpty(arr[8]) ? "" : arr[8]; |
|
|
|
String goodsUnitName = StringUtils.isEmpty(arr[9]) ? "" : arr[9]; |
|
|
|
String taxRate = StringUtils.isEmpty(arr[10]) ? "0" : arr[10]; |
|
|
|
String shelfLife = StringUtils.isEmpty(arr[11]) ? "0" : arr[11]; |
|
|
|
String nationalStandardCode = StringUtils.isEmpty(arr[12]) ? "" : arr[12]; |
|
|
|
String externalCode = StringUtils.isEmpty(arr[13]) ? "" : arr[13]; |
|
|
|
String factoryCode = StringUtils.isEmpty(arr[14]) ? "" : arr[14]; |
|
|
|
String isListed = (StringUtils.isEmpty(arr[15]) ? "1" : arr[15].equals("是")? "1":"2"); |
|
|
|
String useOrgSid = StringUtils.isEmpty(arr[16]) ? "" : arr[16]; |
|
|
|
String createOrgSid = StringUtils.isEmpty(arr[17]) ? "" : arr[17]; |
|
|
|
String isListed = (StringUtils.isEmpty(arr[15]) ? "1" : arr[15].equals("是") ? "1" : "2"); |
|
|
|
|
|
|
|
// String goodSpuSid = StringUtils.isEmpty(arr[19]) ? null : arr[19];
|
|
|
|
String goodsExplain = StringUtils.isEmpty(arr[18]) ? "" : arr[18]; |
|
|
|
String goodsDescription = StringUtils.isEmpty(arr[19]) ? "" : arr[19]; |
|
|
|
String goodsExplain = StringUtils.isEmpty(arr[16]) ? "" : arr[16]; |
|
|
|
String goodsDescription = StringUtils.isEmpty(arr[17]) ? "" : arr[17]; |
|
|
|
|
|
|
|
String goodsSkuSid = ""; |
|
|
|
String goodsSkuCode = StringUtils.isEmpty(arr[20]) ? "" : arr[20]; |
|
|
|
String title = StringUtils.isEmpty(arr[21]) ? "" : arr[21]; |
|
|
|
String skuExternalCode = StringUtils.isEmpty(arr[22]) ? "" : arr[22]; |
|
|
|
String goodsSkuCode = StringUtils.isEmpty(arr[18]) ? "" : arr[18]; |
|
|
|
String title = StringUtils.isEmpty(arr[19]) ? "" : arr[19]; |
|
|
|
String ownSpec = StringUtils.isEmpty(arr[20]) ? "" : arr[20]; |
|
|
|
|
|
|
|
String finalPurchasePrice = StringUtils.isEmpty(arr[23]) ? "" : arr[23]; |
|
|
|
String safetyStockDays = StringUtils.isEmpty(arr[24]) ? "" : arr[24]; |
|
|
|
String isOriginalFactory = (StringUtils.isEmpty(arr[25]) ? "1" : arr[25].equals("是")? "1":"2"); |
|
|
|
String isInventoryAlert = (StringUtils.isEmpty(arr[26]) ? "1" : arr[26].equals("是")? "1":"2"); |
|
|
|
String inventoryAlertUpperLimit = StringUtils.isEmpty(arr[27]) ? "0" : arr[27]; |
|
|
|
String inventoryAlertLowerLimit = StringUtils.isEmpty(arr[28]) ? "0" : arr[28]; |
|
|
|
String costPrice = StringUtils.isEmpty(arr[29]) ? "0" : arr[29]; |
|
|
|
String tagPrice = StringUtils.isEmpty(arr[30]) ? "0" : arr[30]; |
|
|
|
String salesPrice = StringUtils.isEmpty(arr[31]) ? "0" : arr[31]; |
|
|
|
String standardPurchasePrice = StringUtils.isEmpty(arr[32]) ? "0" : arr[32]; |
|
|
|
String agencyPrice = StringUtils.isEmpty(arr[33]) ? "0" : arr[33]; |
|
|
|
String discount = StringUtils.isEmpty(arr[34]) ? "0" : arr[34]; |
|
|
|
String minimumSalesPrice = StringUtils.isEmpty(arr[35]) ? "0" : arr[35]; |
|
|
|
String isLockingSalesPrice = (StringUtils.isEmpty(arr[36]) ? "1" : arr[36].equals("是")? "1":"2"); |
|
|
|
String isIntegralExchange = (StringUtils.isEmpty(arr[37]) ? "1" : arr[37].equals("是")? "1":"2"); |
|
|
|
String integralAmount = StringUtils.isEmpty(arr[38]) ? "0" : arr[38]; |
|
|
|
String finalPurchasePrice = StringUtils.isEmpty(arr[21]) ? "" : arr[21]; |
|
|
|
String safetyStockDays = StringUtils.isEmpty(arr[22]) ? "" : arr[22]; |
|
|
|
String isOriginalFactory = (StringUtils.isEmpty(arr[23]) ? "1" : arr[23].equals("是") ? "1" : "2"); |
|
|
|
String isInventoryAlert = (StringUtils.isEmpty(arr[24]) ? "1" : arr[24].equals("是") ? "1" : "2"); |
|
|
|
String inventoryAlertUpperLimit = StringUtils.isEmpty(arr[25]) ? "0" : arr[25]; |
|
|
|
String inventoryAlertLowerLimit = StringUtils.isEmpty(arr[26]) ? "0" : arr[26]; |
|
|
|
String costPrice = StringUtils.isEmpty(arr[27]) ? "0" : arr[27]; |
|
|
|
String tagPrice = StringUtils.isEmpty(arr[28]) ? "0" : arr[28]; |
|
|
|
String salesPrice = StringUtils.isEmpty(arr[29]) ? "0" : arr[29]; |
|
|
|
String standardPurchasePrice = StringUtils.isEmpty(arr[30]) ? "0" : arr[30]; |
|
|
|
String agencyPrice = StringUtils.isEmpty(arr[31]) ? "0" : arr[31]; |
|
|
|
String discount = StringUtils.isEmpty(arr[32]) ? "0" : arr[32]; |
|
|
|
String minimumSalesPrice = StringUtils.isEmpty(arr[33]) ? "0" : arr[33]; |
|
|
|
String isLockingSalesPrice = (StringUtils.isEmpty(arr[34]) ? "1" : arr[34].equals("是") ? "1" : "2"); |
|
|
|
String isIntegralExchange = (StringUtils.isEmpty(arr[35]) ? "1" : arr[35].equals("是") ? "1" : "2"); |
|
|
|
String integralAmount = StringUtils.isEmpty(arr[36]) ? "0" : arr[36]; |
|
|
|
|
|
|
|
//excel表中物资类别保存的是分类编号,插入数据库时 根据分类编号查询基础数据中 物资类别表的id
|
|
|
|
|
|
|
@ -437,9 +433,9 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
baseGoodsSpuDto.setGoodsPY(goodsPY); |
|
|
|
baseGoodsSpuDto.setGoodsShortName(goodsShortName); |
|
|
|
|
|
|
|
baseGoodsSpuDto.setGoodsTypeSid(goodsTypeSid); |
|
|
|
baseGoodsSpuDto.setBrandSid(brandSid); |
|
|
|
baseGoodsSpuDto.setManufacturerSid(manufacturerSid); |
|
|
|
baseGoodsSpuDto.setGoodsTypeName(goodsType); |
|
|
|
baseGoodsSpuDto.setBrandName(brand); |
|
|
|
baseGoodsSpuDto.setManufacturerName(manufacturer); |
|
|
|
// baseGoodsSpuDto.setGoodsUnitSid(goodsUnitSid);
|
|
|
|
baseGoodsSpuDto.setGoodsUnitName(goodsUnitName); |
|
|
|
baseGoodsSpuDto.setTaxRate(taxRate); |
|
|
@ -448,18 +444,16 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
baseGoodsSpuDto.setExternalCode(externalCode); |
|
|
|
baseGoodsSpuDto.setFactoryCode(factoryCode); |
|
|
|
baseGoodsSpuDto.setIsListed(isListed); |
|
|
|
baseGoodsSpuDto.setUseOrgSid(useOrgSid); |
|
|
|
baseGoodsSpuDto.setCreateOrgSid(createOrgSid); |
|
|
|
BaseGoodsSpuDetailDto dto=new BaseGoodsSpuDetailDto(); |
|
|
|
BaseGoodsSpuDetailDto dto = new BaseGoodsSpuDetailDto(); |
|
|
|
dto.setGoodsExplain(goodsExplain); |
|
|
|
dto.setGoodsDescription(goodsDescription); |
|
|
|
baseGoodsSpuDto.setBaseGoodsSpuDetail(dto); |
|
|
|
List<BaseGoodsSkuDto> dtos=new ArrayList<>(); |
|
|
|
BaseGoodsSkuDto dto1=new BaseGoodsSkuDto(); |
|
|
|
List<BaseGoodsSkuDto> dtos = new ArrayList<>(); |
|
|
|
BaseGoodsSkuDto dto1 = new BaseGoodsSkuDto(); |
|
|
|
dto1.setGoodsSkuCode(goodsSkuCode); |
|
|
|
dto1.setTitle(title); |
|
|
|
dto1.setExternalCode(skuExternalCode); |
|
|
|
BaseGoodsSkuExtendDto dto2=new BaseGoodsSkuExtendDto(); |
|
|
|
dto1.setOwnSpec(ownSpec); |
|
|
|
BaseGoodsSkuExtendDto dto2 = new BaseGoodsSkuExtendDto(); |
|
|
|
dto2.setSortNo("1"); |
|
|
|
dto2.setFinalPurchasePrice(finalPurchasePrice); |
|
|
|
dto2.setSafetyStockDays(safetyStockDays); |
|
|
|