|
|
@ -1,5 +1,6 @@ |
|
|
|
package com.yxt.wms.biz.func.basegoodsspu; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -21,11 +22,13 @@ import com.yxt.wms.biz.func.basemanufacturer.BaseManufacturer; |
|
|
|
import com.yxt.wms.biz.func.commonmethod.CommonMethod; |
|
|
|
import com.yxt.wms.biz.func.commonmethod.DataRule; |
|
|
|
import com.yxt.wms.feign.base.basebrandinfo.BaseBrandInfoFeign; |
|
|
|
import com.yxt.wms.feign.base.basegoodssku.BaseGoodsSkuFeign; |
|
|
|
import com.yxt.wms.feign.base.basegoodsspu.*; |
|
|
|
import com.yxt.wms.feign.base.basegoodstype.BaseGoodsTypeFeign; |
|
|
|
import com.yxt.wms.feign.base.basegoodsunit.BaseGoodsUnitFeign; |
|
|
|
import com.yxt.wms.feign.base.basemanufacturer.BaseManufacturerFeign; |
|
|
|
import com.yxt.wms.utils.ExcelUtil; |
|
|
|
import com.yxt.wms.utils.OrgPathQuery; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
@ -63,14 +66,16 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
@Autowired |
|
|
|
BaseGoodsSpuFeign baseGoodsSpuFeign; |
|
|
|
@Autowired |
|
|
|
BaseGoodsSkuFeign baseGoodsSkuFeign; |
|
|
|
@Autowired |
|
|
|
CommonMethod commonMethod; |
|
|
|
@Autowired |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean<PagerVo<BaseGoodsSpuVo>> listPage(PagerQuery<BaseGoodsSpuQuery> pq) { |
|
|
|
BaseGoodsSpuQuery query=pq.getParams(); |
|
|
|
DataRule dataRule=commonMethod.dataRule(query.getOrgPath(),query.getMenuUrl(),query.getUserSid()).getData(); |
|
|
|
BaseGoodsSpuQuery query = pq.getParams(); |
|
|
|
DataRule dataRule = commonMethod.dataRule(query.getOrgPath(), query.getMenuUrl(), query.getUserSid()).getData(); |
|
|
|
pq.getParams().setOrgLevelKey(dataRule.getDataRuleId()); |
|
|
|
pq.getParams().setIndex(dataRule.getIndex()); |
|
|
|
return baseGoodsSpuFeign.listPage(pq); |
|
|
@ -84,10 +89,10 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
for (UrlsVo url : baseGoodsSkus.getBaseGoodsSkuExtend().getUrls()) { |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
String path = url.getUrl().substring(urlPrefix.length()); |
|
|
|
if(StringUtils.isBlank(baseGoodsSkus.getBaseGoodsSkuExtend().getPicUrl())){ |
|
|
|
if (StringUtils.isBlank(baseGoodsSkus.getBaseGoodsSkuExtend().getPicUrl())) { |
|
|
|
baseGoodsSkus.getBaseGoodsSkuExtend().setPicUrl(path); |
|
|
|
}else{ |
|
|
|
baseGoodsSkus.getBaseGoodsSkuExtend().setPicUrl(baseGoodsSkus.getBaseGoodsSkuExtend().getPicUrl()+","+path); |
|
|
|
} else { |
|
|
|
baseGoodsSkus.getBaseGoodsSkuExtend().setPicUrl(baseGoodsSkus.getBaseGoodsSkuExtend().getPicUrl() + "," + path); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -96,11 +101,11 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
|
|
|
|
public ResultBean<BaseGoodsSpuVo> initialization(String sid) { |
|
|
|
ResultBean<BaseGoodsSpuVo> rb = ResultBean.fireFail(); |
|
|
|
ResultBean<BaseGoodsSpuVo> w=baseGoodsSpuFeign.initialization(sid); |
|
|
|
if(!w.getCode().equals("200")){ |
|
|
|
ResultBean<BaseGoodsSpuVo> w = baseGoodsSpuFeign.initialization(sid); |
|
|
|
if (!w.getCode().equals("200")) { |
|
|
|
return w; |
|
|
|
} |
|
|
|
BaseGoodsSpuVo baseGoodsSpuVo=w.getData(); |
|
|
|
BaseGoodsSpuVo baseGoodsSpuVo = w.getData(); |
|
|
|
for (BaseGoodsSkuVo baseGoodsSkus : baseGoodsSpuVo.getBaseGoodsSkus()) { |
|
|
|
for (UrlsVo url : baseGoodsSkus.getBaseGoodsSkuExtend().getUrls()) { |
|
|
|
url.setUrl(fileUploadComponent.getUrlPrefix() + url.getUrl()); |
|
|
@ -119,6 +124,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean delAll(String[] sids) { |
|
|
|
return baseGoodsSpuFeign.delBySids(sids); |
|
|
|
} |
|
|
@ -131,7 +137,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 { |
|
|
@ -158,92 +164,191 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean importExcel(MultipartFile file) throws IOException { |
|
|
|
// return baseGoodsSpuFeign.importExcel(file);
|
|
|
|
ResultBean rb=new ResultBean().fail(); |
|
|
|
//檢查excel
|
|
|
|
ExcelUtil.checkFile(file); |
|
|
|
//解析excel
|
|
|
|
List<String[]> list = ExcelUtil.readExcel(file); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
List tt = new ArrayList(); |
|
|
|
List<BaseGoodsSpuDto> tt1 = new ArrayList(); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
BaseGoodsSpuDto dto =new BaseGoodsSpuDto(); |
|
|
|
String taxRate = StringUtils.isEmpty(list.get(i)[10]) ? null : list.get(i)[10]; |
|
|
|
if(StringUtils.isNotBlank(taxRate)){ |
|
|
|
if(!taxRate.contains(".")){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行税率格式不正确!"); |
|
|
|
} |
|
|
|
if(taxRate.length()>4){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行税率长度不正确!"); |
|
|
|
} |
|
|
|
} |
|
|
|
public ResultBean<String> batchSave(List<BaseGoodsSpuDto> dtos, String orgPath) { |
|
|
|
return baseGoodsSpuFeign.batchSave(dtos, orgPath); |
|
|
|
} |
|
|
|
|
|
|
|
dto = this.packaging(list.get(i),dto); |
|
|
|
if (null == dto) { |
|
|
|
return rb.setMsg("导入失败,第" + (i + 1) + "行数据错误!"); |
|
|
|
} else { |
|
|
|
tt.add(dto); |
|
|
|
} |
|
|
|
public ResultBean importExcel(MultipartFile file, String orgPath) throws IOException { |
|
|
|
// return baseGoodsSpuFeign.importExcel(file);
|
|
|
|
ResultBean rb = new ResultBean().fail(); |
|
|
|
//檢查excel
|
|
|
|
ExcelUtil.checkFile(file); |
|
|
|
//解析excel
|
|
|
|
List<String[]> list = ExcelUtil.readExcel(file); |
|
|
|
OrgPathQuery q = new OrgPathQuery(); |
|
|
|
q.setOrgPath(orgPath); |
|
|
|
List<BaseGoodsSkuVo> vos1 = baseGoodsSkuFeign.listAllByOrg(q).getData(); |
|
|
|
if (!list.isEmpty()) { |
|
|
|
List<BaseGoodsSpuDto> tt = new ArrayList(); |
|
|
|
List<BaseGoodsImportVo> list1 = new ArrayList<>(); |
|
|
|
List<BaseGoodsSpuDto> tt1 = new ArrayList(); |
|
|
|
for (int i = 0; i < list.size(); i++) { |
|
|
|
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) + "商品编码为空!"); |
|
|
|
} |
|
|
|
tt1=a(tt); |
|
|
|
for (BaseGoodsSpuDto baseGoodsSpuDto : tt1) { |
|
|
|
String goodsTypeSid = StringUtils.isEmpty(baseGoodsSpuDto.getGoodsTypeSid()) ? null : baseGoodsSpuDto.getGoodsTypeSid(); |
|
|
|
if (StringUtils.isNotBlank(goodsTypeSid)) { |
|
|
|
BaseGoodsType baseGoodsType = baseGoodsTypeFeign.getTypeByName(goodsTypeSid).getData(); |
|
|
|
if (null != baseGoodsType) { |
|
|
|
baseGoodsSpuDto.setGoodsTypeSid(baseGoodsType.getSid()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("商品分类:" + goodsTypeSid + "不存在,请先添加"); |
|
|
|
} |
|
|
|
String spuName = StringUtils.isEmpty(list.get(i)[2]) ? null : list.get(i)[2]; |
|
|
|
if (StringUtils.isBlank(spuName)) { |
|
|
|
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) + "商品分类为空!"); |
|
|
|
} |
|
|
|
String brand = StringUtils.isEmpty(list.get(i)[7]) ? null : list.get(i)[7]; |
|
|
|
if (StringUtils.isBlank(brand)) { |
|
|
|
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) + "厂家为空!"); |
|
|
|
} |
|
|
|
String unit = StringUtils.isEmpty(list.get(i)[9]) ? null : list.get(i)[9]; |
|
|
|
if (StringUtils.isBlank(unit)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "商品单位为空!"); |
|
|
|
} |
|
|
|
String taxRate = StringUtils.isEmpty(list.get(i)[10]) ? null : list.get(i)[10]; |
|
|
|
if (!isNumeric(taxRate)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行税率不是数字!"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(taxRate)) { |
|
|
|
if (taxRate.contains("-")) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行税率不能为负数!"); |
|
|
|
} |
|
|
|
|
|
|
|
String brandSid = StringUtils.isEmpty(baseGoodsSpuDto.getBrandSid()) ? null : baseGoodsSpuDto.getBrandSid(); |
|
|
|
if (StringUtils.isNotBlank(brandSid)) { |
|
|
|
BaseBrandInfo brand = baseBrandInfoFeign.getBrandByName(brandSid).getData(); |
|
|
|
if (null != brand) { |
|
|
|
baseGoodsSpuDto.setBrandSid(brand.getSid()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("商品品牌:" + brandSid + "不存在,请先添加"); |
|
|
|
} |
|
|
|
if (!taxRate.contains(".")) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行税率不是小数!"); |
|
|
|
} |
|
|
|
|
|
|
|
String manufacturerSid = StringUtils.isEmpty(baseGoodsSpuDto.getManufacturerSid()) ? null : baseGoodsSpuDto.getManufacturerSid(); |
|
|
|
if (StringUtils.isNotBlank(manufacturerSid)) { |
|
|
|
BaseManufacturer baseManufacturer = baseManufacturerFeign.getManufacturerByName(manufacturerSid).getData(); |
|
|
|
if (null != baseManufacturer) { |
|
|
|
baseGoodsSpuDto.setManufacturerSid(baseManufacturer.getSid()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("商品厂家:" + manufacturerSid + "不存在,请先添加"); |
|
|
|
} |
|
|
|
if (taxRate.length() > 4) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行税率长度不正确!"); |
|
|
|
} |
|
|
|
} else { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行税率为空!"); |
|
|
|
} |
|
|
|
String bzq = StringUtils.isEmpty(list.get(i)[11]) ? null : list.get(i)[11]; |
|
|
|
if (!isNumeric(bzq)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行保质期(天)不是数字!"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(bzq)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行保质期(天)为空!"); |
|
|
|
} |
|
|
|
String ggdm = StringUtils.isEmpty(list.get(i)[18]) ? null : list.get(i)[18]; |
|
|
|
boolean b=vos1.stream().anyMatch(o->o.getGoodsSkuCode().equals(ggdm)); |
|
|
|
if(b){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行规格代码已存在!"); |
|
|
|
} |
|
|
|
BaseGoodsImportVo vo = new BaseGoodsImportVo(); |
|
|
|
vo.setXh(String.valueOf(i + 1)); |
|
|
|
vo.setXpdm(ggdm); |
|
|
|
list1.add(vo); |
|
|
|
if (StringUtils.isBlank(ggdm)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行规格代码不正确!"); |
|
|
|
} |
|
|
|
String ggxh = StringUtils.isEmpty(list.get(i)[20]) ? null : list.get(i)[20]; |
|
|
|
if (StringUtils.isBlank(ggxh)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行规格型号为空!"); |
|
|
|
} |
|
|
|
String cgj = StringUtils.isEmpty(list.get(i)[21]) ? null : list.get(i)[21]; |
|
|
|
if (!isNumeric(cgj)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行最后采购价不是数字!"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(cgj)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行最后采购价为空!"); |
|
|
|
} |
|
|
|
String aqts = StringUtils.isEmpty(list.get(i)[22]) ? null : list.get(i)[22]; |
|
|
|
if (!isNumeric(aqts)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行库存安全天数不是数字!"); |
|
|
|
} |
|
|
|
String jjsx = StringUtils.isEmpty(list.get(i)[25]) ? null : list.get(i)[25]; |
|
|
|
if (!isNumeric(jjsx)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行库存警戒上线不是数字!"); |
|
|
|
} |
|
|
|
String jjxx = StringUtils.isEmpty(list.get(i)[26]) ? null : list.get(i)[26]; |
|
|
|
if (!isNumeric(jjxx)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行库存警戒下线不是数字!"); |
|
|
|
} |
|
|
|
String cbj = StringUtils.isEmpty(list.get(i)[27]) ? null : list.get(i)[27]; |
|
|
|
if (!isNumeric(cbj)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行成本价不是数字!"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(cbj)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行成本价为空!"); |
|
|
|
} |
|
|
|
String dpj = StringUtils.isEmpty(list.get(i)[28]) ? null : list.get(i)[28]; |
|
|
|
if (!isNumeric(dpj)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行吊牌价不是数字!"); |
|
|
|
} |
|
|
|
String xsdj = StringUtils.isEmpty(list.get(i)[29]) ? null : list.get(i)[29]; |
|
|
|
if(!isNumeric(xsdj)){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行销售单价不是数字!"); |
|
|
|
} |
|
|
|
if (StringUtils.isBlank(xsdj)) { |
|
|
|
return rb.setMsg("第" + (i + 1) + "行销售单价为空!"); |
|
|
|
} |
|
|
|
|
|
|
|
String goodsUnitSid = StringUtils.isEmpty(baseGoodsSpuDto.getGoodsUnitName()) ? null : baseGoodsSpuDto.getGoodsUnitName(); |
|
|
|
if (StringUtils.isNotBlank(goodsUnitSid)) { |
|
|
|
BaseGoodsUnit baseGoodsUnit = baseGoodsUnitFeign.getUnitByName(goodsUnitSid).getData(); |
|
|
|
if (null != baseGoodsUnit) { |
|
|
|
baseGoodsSpuDto.setGoodsUnitSid(baseGoodsUnit.getSid()); |
|
|
|
String bzjj = StringUtils.isEmpty(list.get(i)[30]) ? null : list.get(i)[30]; |
|
|
|
if(!isNumeric(bzjj)){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行标准进价不是数字!"); |
|
|
|
} |
|
|
|
String dlj = StringUtils.isEmpty(list.get(i)[31]) ? null : list.get(i)[31]; |
|
|
|
if(!isNumeric(dlj)){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行代理价不是数字!"); |
|
|
|
} |
|
|
|
String zk = StringUtils.isEmpty(list.get(i)[32]) ? null : list.get(i)[32]; |
|
|
|
if(!isNumeric(zk)){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行折扣不是数字!"); |
|
|
|
} |
|
|
|
String zdls = StringUtils.isEmpty(list.get(i)[33]) ? null : list.get(i)[33]; |
|
|
|
if(!isNumeric(zdls)){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行最低零售价不是数字!"); |
|
|
|
} |
|
|
|
String jf = StringUtils.isEmpty(list.get(i)[36]) ? null : list.get(i)[36]; |
|
|
|
if(!isNumeric(jf)){ |
|
|
|
return rb.setMsg("第" + (i + 1) + "行积分不是数字!"); |
|
|
|
} |
|
|
|
dto = this.packaging(list.get(i), dto); |
|
|
|
if (null == dto) { |
|
|
|
return rb.setMsg("导入失败,第" + (i + 1) + "行数据错误!"); |
|
|
|
} else { |
|
|
|
tt.add(dto); |
|
|
|
} |
|
|
|
} |
|
|
|
Map<String, Long> nameCountMap = list1.stream() |
|
|
|
.collect(Collectors.groupingBy(BaseGoodsImportVo::getXpdm, Collectors.counting())); |
|
|
|
List<BaseGoodsImportVo> vos = list1.stream().filter(a -> nameCountMap.getOrDefault(a.getXpdm(), 0L) > 1).collect(Collectors.toList()); |
|
|
|
if (vos.size() != 0) { |
|
|
|
String a = ""; |
|
|
|
for (BaseGoodsImportVo vo : vos) { |
|
|
|
if (vo.getXpdm().equals(vos.get(0).getXpdm())) { |
|
|
|
if (StringUtils.isBlank(a)) { |
|
|
|
a = vo.getXh(); |
|
|
|
} else { |
|
|
|
return rb.setMsg("商品单位:" + goodsUnitSid + "不存在,请先添加"); |
|
|
|
a = a + "," + vo.getXh(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
baseGoodsSpuFeign.batchSave(tt1); |
|
|
|
return rb.success().setMsg("导入成功"); |
|
|
|
|
|
|
|
} else { |
|
|
|
return rb.setMsg("导入文件没有有效数据"); |
|
|
|
return rb.setMsg("导入失败,第" + a + "行规格代码数据重复!"); |
|
|
|
} |
|
|
|
tt1 = a(tt); |
|
|
|
return rb.success().setMsg("导入成功").setData(tt1); |
|
|
|
} else { |
|
|
|
return rb.setMsg("导入文件没有有效数据"); |
|
|
|
} |
|
|
|
} |
|
|
|
public static boolean isNumeric(String strNum) { |
|
|
|
if (strNum == null) { |
|
|
|
return false; |
|
|
|
} |
|
|
|
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) { |
|
|
@ -251,10 +356,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()); |
|
|
@ -303,7 +408,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;
|
|
|
@ -312,47 +417,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
|
|
|
|
|
|
|
@ -364,9 +465,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); |
|
|
@ -375,18 +476,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); |
|
|
@ -414,7 +513,8 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
} |
|
|
|
return baseGoodsSpuDto; |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean updateIsEnablebySku(String sid, String isEnable) { |
|
|
|
return baseGoodsSpuFeign.updateIsEnablebySku(sid,isEnable); |
|
|
|
return baseGoodsSpuFeign.updateIsEnablebySku(sid, isEnable); |
|
|
|
} |
|
|
|
} |
|
|
|