|
|
@ -4,15 +4,27 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
|
import cn.hutool.core.date.DateTime; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.goods.apiadmin.base.BaseGoodsBrandRest; |
|
|
|
import com.yxt.goods.biz.base.basebrandinfo.BaseBrandInfo; |
|
|
|
import com.yxt.goods.biz.base.basebrandinfo.BaseBrandInfoService; |
|
|
|
import com.yxt.goods.biz.base.basegoodssku.BaseGoodsSku; |
|
|
|
import com.yxt.goods.biz.base.basegoodssku.BaseGoodsSkuDto; |
|
|
|
import com.yxt.goods.biz.base.basegoodssku.BaseGoodsSkuService; |
|
|
|
import com.yxt.goods.biz.base.basegoodssku.BaseGoodsSkuVo; |
|
|
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendDto; |
|
|
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendService; |
|
|
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendVo; |
|
|
|
import com.yxt.goods.biz.base.basegoodsskuextend.UrlsVo; |
|
|
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailDto; |
|
|
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailService; |
|
|
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailVo; |
|
|
|
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsType; |
|
|
|
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsTypeService; |
|
|
|
import com.yxt.goods.biz.base.basegoodsunit.BaseGoodsUnit; |
|
|
|
import com.yxt.goods.biz.base.basegoodsunit.BaseGoodsUnitService; |
|
|
|
import com.yxt.goods.biz.base.basemanufacturer.BaseManufacturer; |
|
|
|
import com.yxt.goods.biz.base.basemanufacturer.BaseManufacturerService; |
|
|
|
import com.yxt.goods.utils.ExcelUtil; |
|
|
|
import com.yxt.goods.utils.PinYinUtils; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.service.MybatisBaseService; |
|
|
@ -24,11 +36,14 @@ import com.yxt.common.core.vo.PagerVo; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Collections; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.io.IOException; |
|
|
|
import java.util.*; |
|
|
|
import java.util.concurrent.ConcurrentHashMap; |
|
|
|
import java.util.function.Function; |
|
|
|
import java.util.function.Predicate; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
/** |
|
|
|
* @author wangpengfei |
|
|
@ -46,14 +61,20 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
BaseGoodsUnitService baseGoodsUnitService; |
|
|
|
@Autowired |
|
|
|
BaseGoodsSkuExtendService baseGoodsSkuExtendService; |
|
|
|
@Autowired |
|
|
|
BaseManufacturerService baseManufacturerService; |
|
|
|
@Autowired |
|
|
|
BaseGoodsTypeService baseGoodsTypeService; |
|
|
|
@Autowired |
|
|
|
BaseBrandInfoService baseBrandInfoService; |
|
|
|
|
|
|
|
|
|
|
|
public ResultBean<PagerVo<BaseGoodsSpuVo>> listPage(PagerQuery<BaseGoodsSpuQuery> pq) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpuQuery query = pq.getParams(); |
|
|
|
QueryWrapper<BaseGoodsSpu> qw = new QueryWrapper<>(); |
|
|
|
if(StringUtils.isNotBlank(query.getName())){ |
|
|
|
qw.like("goodsName",query.getName()); |
|
|
|
if (StringUtils.isNotBlank(query.getName())) { |
|
|
|
qw.like("goodsName", query.getName()); |
|
|
|
} |
|
|
|
IPage<BaseGoodsSpu> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<BaseGoodsSpuVo> pagging = baseMapper.listPage(page, qw); |
|
|
@ -69,37 +90,39 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
// }
|
|
|
|
return rb.success().setData(p); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public ResultBean<String> saveOrUpdate(BaseGoodsSpuDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = ""; |
|
|
|
BaseGoodsSpu spun= baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("sid",dto.getSid())); |
|
|
|
BaseGoodsUnit baseGoodsUnit=baseGoodsUnitService.getOne(new QueryWrapper<BaseGoodsUnit>().eq("sid",dto.getGoodsUnitSid())); |
|
|
|
if(null!=baseGoodsUnit){ |
|
|
|
BaseGoodsSpu spun = baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("sid", dto.getSid())); |
|
|
|
BaseGoodsUnit baseGoodsUnit = baseGoodsUnitService.getOne(new QueryWrapper<BaseGoodsUnit>().eq("sid", dto.getGoodsUnitSid())); |
|
|
|
if (null != baseGoodsUnit) { |
|
|
|
dto.setGoodsUnitName(baseGoodsUnit.getUnitName()); |
|
|
|
} |
|
|
|
|
|
|
|
if (spun!=null) { |
|
|
|
if(!spun.getSid().equals(dto.getSid())){ |
|
|
|
if (spun != null) { |
|
|
|
if (!spun.getSid().equals(dto.getSid())) { |
|
|
|
return rb.setMsg("商品编码重复"); |
|
|
|
} |
|
|
|
sid = dto.getSid(); |
|
|
|
BaseGoodsSpu wmsGoods = fetchBySid(dto.getSid()); |
|
|
|
BeanUtil.copyProperties(dto, wmsGoods); |
|
|
|
wmsGoods.setModifyTime(new Date()); |
|
|
|
wmsGoods.setGoodsPY(PinYinUtils.getPinYinName(wmsGoods.getGoodsName()));; |
|
|
|
wmsGoods.setGoodsPY(PinYinUtils.getPinYinName(wmsGoods.getGoodsName())); |
|
|
|
; |
|
|
|
baseMapper.updateById(wmsGoods); |
|
|
|
//spu详情
|
|
|
|
dto.getBaseGoodsSpuDetail().setGoodSpuSid(wmsGoods.getSid()); |
|
|
|
baseGoodsSpuDetailService.saveOrUpdate(dto.getBaseGoodsSpuDetail()); |
|
|
|
//商品sku
|
|
|
|
dto.getBaseGoodsSkus().forEach(s->{ |
|
|
|
dto.getBaseGoodsSkus().forEach(s -> { |
|
|
|
s.setGoodsSpuSid(wmsGoods.getSid()); |
|
|
|
}); |
|
|
|
baseGoodsSkuService.saveOrUpdate(dto.getBaseGoodsSkus()); |
|
|
|
} else { |
|
|
|
BaseGoodsSpu spu=baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("goodsCode",dto.getGoodsCode())); |
|
|
|
if(spu!=null){ |
|
|
|
BaseGoodsSpu spu = baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("goodsCode", dto.getGoodsCode())); |
|
|
|
if (spu != null) { |
|
|
|
return rb.setMsg("商品编码重复"); |
|
|
|
} |
|
|
|
BaseGoodsSpu wmsGoods = new BaseGoodsSpu(); |
|
|
@ -111,7 +134,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
dto.getBaseGoodsSpuDetail().setGoodSpuSid(wmsGoods.getSid()); |
|
|
|
baseGoodsSpuDetailService.saveOrUpdate(dto.getBaseGoodsSpuDetail()); |
|
|
|
//商品sku
|
|
|
|
dto.getBaseGoodsSkus().forEach(s->{ |
|
|
|
dto.getBaseGoodsSkus().forEach(s -> { |
|
|
|
s.setGoodsSpuSid(wmsGoods.getSid()); |
|
|
|
}); |
|
|
|
baseGoodsSkuService.saveOrUpdate(dto.getBaseGoodsSkus()); |
|
|
@ -119,19 +142,38 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
return rb.success().setMsg("成功"); |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public ResultBean<String> batchSave(List<BaseGoodsSpuDto> dtos) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<BaseGoodsSpu> spus = new ArrayList<>(); |
|
|
|
List<BaseGoodsSku> skus=new ArrayList<>(); |
|
|
|
for (BaseGoodsSpuDto dto : dtos) { |
|
|
|
BaseGoodsSpu wmsGoods = new BaseGoodsSpu(); |
|
|
|
BeanUtil.copyProperties(dto, wmsGoods, "id"); |
|
|
|
wmsGoods.setCreateTime(new DateTime()); |
|
|
|
// skus.addAll(dto.getBaseGoodsSkus());
|
|
|
|
spus.add(wmsGoods); |
|
|
|
} |
|
|
|
this.saveBatch(spus); |
|
|
|
baseGoodsSpuDetailService.batchSave(dtos); |
|
|
|
baseGoodsSkuService.skuBatchSave(dtos); |
|
|
|
return rb.success().setMsg("成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<BaseGoodsSpuVo> initialization(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpuVo vo = baseMapper.initialization(sid); |
|
|
|
BaseGoodsSpuDetailVo vo1=baseGoodsSpuDetailService.getSpuDetailsBySpuSid(vo.getSid()).getData(); |
|
|
|
BaseGoodsSpuDetailVo vo1 = baseGoodsSpuDetailService.getSpuDetailsBySpuSid(vo.getSid()).getData(); |
|
|
|
vo.setBaseGoodsSpuDetail(vo1); |
|
|
|
List<BaseGoodsSkuVo> vos=baseGoodsSkuService.getSkusBySpuSid(vo.getSid()).getData(); |
|
|
|
List<BaseGoodsSkuVo> vos = baseGoodsSkuService.getSkusBySpuSid(vo.getSid()).getData(); |
|
|
|
for (BaseGoodsSkuVo baseGoodsSkuVo : vos) { |
|
|
|
List<UrlsVo> ur=new ArrayList<>(); |
|
|
|
BaseGoodsSkuExtendVo vo2=baseGoodsSkuExtendService.getExtendBySkuSid(baseGoodsSkuVo.getSid()).getData(); |
|
|
|
if(StringUtils.isNotBlank(vo2.getPicUrl())){ |
|
|
|
List<UrlsVo> ur = new ArrayList<>(); |
|
|
|
BaseGoodsSkuExtendVo vo2 = baseGoodsSkuExtendService.getExtendBySkuSid(baseGoodsSkuVo.getSid()).getData(); |
|
|
|
if (StringUtils.isNotBlank(vo2.getPicUrl())) { |
|
|
|
for (String url : vo2.getPicUrl().split(",")) { |
|
|
|
url=fileUploadComponent.getUrlPrefix()+url; |
|
|
|
UrlsVo vo3=new UrlsVo();vo3.setUrl(url); |
|
|
|
url = fileUploadComponent.getUrlPrefix() + url; |
|
|
|
UrlsVo vo3 = new UrlsVo(); |
|
|
|
vo3.setUrl(url); |
|
|
|
ur.add(vo3); |
|
|
|
} |
|
|
|
} |
|
|
@ -143,7 +185,6 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public ResultBean delete(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpu wmsGoods = fetchBySid(sid); |
|
|
@ -153,7 +194,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean updateIsEnable(String sid,String isEnable) { |
|
|
|
public ResultBean updateIsEnable(String sid, String isEnable) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
BaseGoodsSpu wmsGoods = fetchBySid(sid); |
|
|
|
if (null != wmsGoods) { |
|
|
@ -162,4 +203,241 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
} |
|
|
|
return rb.success().setMsg("成功"); |
|
|
|
} |
|
|
|
public ResultBean importExcel(MultipartFile file) throws IOException { |
|
|
|
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(); |
|
|
|
System.out.println(list.get(i)); |
|
|
|
dto = this.packaging(list.get(i),dto); |
|
|
|
if (null == dto) { |
|
|
|
return rb.setMsg("导入失败,第" + (i + 1) + "行数据错误!"); |
|
|
|
} else { |
|
|
|
tt.add(dto); |
|
|
|
} |
|
|
|
} |
|
|
|
tt1=a(tt); |
|
|
|
for (BaseGoodsSpuDto baseGoodsSpuDto : tt1) { |
|
|
|
String goodsTypeSid = StringUtils.isEmpty(baseGoodsSpuDto.getGoodsTypeSid()) ? null : baseGoodsSpuDto.getGoodsTypeSid(); |
|
|
|
if (StringUtils.isNotBlank(goodsTypeSid)) { |
|
|
|
BaseGoodsType baseGoodsType = baseGoodsTypeService.getTypeByName(goodsTypeSid).getData(); |
|
|
|
if (null != baseGoodsType) { |
|
|
|
baseGoodsSpuDto.setGoodsTypeSid(baseGoodsType.getSid()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("商品分类:" + goodsTypeSid + "不存在,请先添加"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String brandSid = StringUtils.isEmpty(baseGoodsSpuDto.getBrandSid()) ? null : baseGoodsSpuDto.getBrandSid(); |
|
|
|
if (StringUtils.isNotBlank(brandSid)) { |
|
|
|
BaseBrandInfo brand = baseBrandInfoService.getBrandByName(brandSid).getData(); |
|
|
|
if (null != brand) { |
|
|
|
baseGoodsSpuDto.setBrandSid(brand.getSid()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("商品品牌:" + brandSid + "不存在,请先添加"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String manufacturerSid = StringUtils.isEmpty(baseGoodsSpuDto.getManufacturerSid()) ? null : baseGoodsSpuDto.getManufacturerSid(); |
|
|
|
if (StringUtils.isNotBlank(manufacturerSid)) { |
|
|
|
BaseManufacturer baseManufacturer = baseManufacturerService.getManufacturerByName(manufacturerSid).getData(); |
|
|
|
if (null != baseManufacturer) { |
|
|
|
baseGoodsSpuDto.setManufacturerSid(baseManufacturer.getSid()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("商品厂家:" + manufacturerSid + "不存在,请先添加"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
String goodsUnitSid = StringUtils.isEmpty(baseGoodsSpuDto.getGoodsUnitSid()) ? null : baseGoodsSpuDto.getGoodsUnitSid(); |
|
|
|
if (StringUtils.isNotBlank(goodsUnitSid)) { |
|
|
|
BaseGoodsUnit baseGoodsUnit = baseGoodsUnitService.getUnitByName(goodsUnitSid).getData(); |
|
|
|
if (null != baseGoodsUnit) { |
|
|
|
baseGoodsSpuDto.setGoodsUnitSid(baseGoodsUnit.getSid()); |
|
|
|
} else { |
|
|
|
return rb.setMsg("商品单位:" + manufacturerSid + "不存在,请先添加"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.batchSave(tt1); |
|
|
|
return rb.success().setMsg("导入成功"); |
|
|
|
|
|
|
|
} else { |
|
|
|
return rb.setMsg("导入文件没有有效数据"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public List<BaseGoodsSpuDto> a(List<BaseGoodsSpuDto> dtos) { |
|
|
|
ResultBean rb=new ResultBean().fail(); |
|
|
|
List<BaseGoodsSpuDto> spus = new ArrayList<>();//spu list
|
|
|
|
spus = dtos.stream().filter(distinctByKey(BaseGoodsSpuDto::getGoodsCode)).collect(Collectors.toList()); |
|
|
|
for (BaseGoodsSpuDto baseGoodsSpuDto : spus) { |
|
|
|
|
|
|
|
BaseGoodsSpuDetailDto spuDetail = new BaseGoodsSpuDetailDto(); |
|
|
|
List<BaseGoodsSkuDto> skus = new ArrayList<>(); |
|
|
|
String sid = UUID.randomUUID().toString(); |
|
|
|
baseGoodsSpuDto.setSid(sid); |
|
|
|
List<BaseGoodsSpuDto> dtos1 = dtos.stream().filter(d -> d.getGoodsCode().equals(baseGoodsSpuDto.getGoodsCode())).collect(Collectors.toList()); |
|
|
|
spuDetail.setGoodsExplain(dtos1.get(0).getBaseGoodsSpuDetail().getGoodsExplain()); |
|
|
|
spuDetail.setGoodsDescription(dtos1.get(0).getBaseGoodsSpuDetail().getGoodsDescription()); |
|
|
|
spuDetail.setSid(UUID.randomUUID().toString()); |
|
|
|
spuDetail.setGoodSpuSid(baseGoodsSpuDto.getSid()); |
|
|
|
for (BaseGoodsSpuDto dto : dtos1) { |
|
|
|
BaseGoodsSkuDto sku = new BaseGoodsSkuDto(); |
|
|
|
String skuSid = UUID.randomUUID().toString(); |
|
|
|
sku.setGoodsSkuCode(dto.getBaseGoodsSkus().get(0).getGoodsSkuCode()); |
|
|
|
sku.setTitle(dto.getBaseGoodsSkus().get(0).getTitle()); |
|
|
|
sku.setExternalCode(dto.getBaseGoodsSkus().get(0).getExternalCode()); |
|
|
|
sku.setGoodsSpuSid(sid); |
|
|
|
sku.setSid(skuSid); |
|
|
|
BaseGoodsSkuExtendDto skuExtend = new BaseGoodsSkuExtendDto(); |
|
|
|
skuExtend.setSid(UUID.randomUUID().toString()); |
|
|
|
skuExtend.setGoodsSkuSid(skuSid); |
|
|
|
skuExtend.setSortNo("1"); |
|
|
|
skuExtend.setFinalPurchasePrice(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getFinalPurchasePrice()); |
|
|
|
skuExtend.setSafetyStockDays(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getSafetyStockDays()); |
|
|
|
skuExtend.setIsOriginalFactory(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getIsOriginalFactory()); |
|
|
|
skuExtend.setIsInventoryAlert(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getIsInventoryAlert()); |
|
|
|
skuExtend.setInventoryAlertUpperLimit(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getInventoryAlertUpperLimit()); |
|
|
|
skuExtend.setInventoryAlertLowerLimit(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getInventoryAlertLowerLimit()); |
|
|
|
skuExtend.setCostPrice(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getCostPrice()); |
|
|
|
skuExtend.setTagPrice(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getTagPrice()); |
|
|
|
skuExtend.setSalesPrice(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getSalesPrice()); |
|
|
|
skuExtend.setStandardPurchasePrice(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getStandardPurchasePrice()); |
|
|
|
skuExtend.setAgencyPrice(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getAgencyPrice()); |
|
|
|
skuExtend.setDiscount(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getDiscount()); |
|
|
|
skuExtend.setMinimumSalesPrice(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getMinimumSalesPrice()); |
|
|
|
skuExtend.setIsLockingSalesPrice(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getIsLockingSalesPrice()); |
|
|
|
skuExtend.setIsIntegralExchange(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getIsIntegralExchange()); |
|
|
|
skuExtend.setIntegralAmount(dto.getBaseGoodsSkus().get(0).getBaseGoodsSkuExtend().getIntegralAmount()); |
|
|
|
sku.setBaseGoodsSkuExtend(skuExtend); |
|
|
|
skus.add(sku); |
|
|
|
} |
|
|
|
baseGoodsSpuDto.setBaseGoodsSkus(skus); |
|
|
|
baseGoodsSpuDto.setBaseGoodsSpuDetail(spuDetail); |
|
|
|
} |
|
|
|
return spus; |
|
|
|
} |
|
|
|
|
|
|
|
private static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) { |
|
|
|
Set<Object> seen = ConcurrentHashMap.newKeySet(); |
|
|
|
return t -> seen.add(keyExtractor.apply(t)); |
|
|
|
} |
|
|
|
|
|
|
|
private BaseGoodsSpuDto packaging(String[] arr, BaseGoodsSpuDto baseGoodsSpuDto) { |
|
|
|
Map<String, Object> result = new HashMap<>(); |
|
|
|
//0四电名称1四电类别2规格3数量4单价5总价6单位7备注
|
|
|
|
// BaseGoodsSpuDto baseGoodsSpuDto =null;
|
|
|
|
try { |
|
|
|
String goodsCode = StringUtils.isEmpty(arr[0]) ? null : arr[0];//
|
|
|
|
String barCode = StringUtils.isEmpty(arr[1]) ? null : arr[1];//
|
|
|
|
String goodsName = StringUtils.isEmpty(arr[2]) ? null : arr[2];//
|
|
|
|
String subTitle = StringUtils.isEmpty(arr[3]) ? null : arr[3]; |
|
|
|
String goodsPY = StringUtils.isEmpty(arr[4]) ? null: arr[4]; |
|
|
|
String goodsShortName = StringUtils.isEmpty(arr[5]) ? null :arr[5]; |
|
|
|
String goodsTypeSid = StringUtils.isEmpty(arr[6]) ? null : arr[6]; |
|
|
|
String brandSid = StringUtils.isEmpty(arr[7]) ? null : arr[7]; |
|
|
|
String manufacturerSid = StringUtils.isEmpty(arr[8]) ? null : arr[8]; |
|
|
|
// String goodsUnitSid = StringUtils.isEmpty(arr[9]) ? null : arr[9];
|
|
|
|
String goodsUnitName = StringUtils.isEmpty(arr[9]) ? null : arr[9]; |
|
|
|
String taxRate = StringUtils.isEmpty(arr[10]) ? null : arr[10]; |
|
|
|
String shelfLife = StringUtils.isEmpty(arr[11]) ? null : arr[11]; |
|
|
|
String nationalStandardCode = StringUtils.isEmpty(arr[12]) ? null : arr[12]; |
|
|
|
String externalCode = StringUtils.isEmpty(arr[13]) ? null : arr[13]; |
|
|
|
String factoryCode = StringUtils.isEmpty(arr[14]) ? null : arr[14]; |
|
|
|
String isListed = (StringUtils.isEmpty(arr[15]) ? null : arr[15]).equals("是")? "1":"2"; |
|
|
|
String useOrgSid = StringUtils.isEmpty(arr[16]) ? null : arr[16]; |
|
|
|
String createOrgSid = StringUtils.isEmpty(arr[17]) ? null : arr[17]; |
|
|
|
|
|
|
|
// String goodSpuSid = StringUtils.isEmpty(arr[19]) ? null : arr[19];
|
|
|
|
String goodsExplain = StringUtils.isEmpty(arr[18]) ? null : arr[18]; |
|
|
|
String goodsDescription = StringUtils.isEmpty(arr[19]) ? null : arr[19]; |
|
|
|
|
|
|
|
String goodsSkuSid = ""; |
|
|
|
String goodsSkuCode = StringUtils.isEmpty(arr[20]) ? null : arr[20]; |
|
|
|
String title = StringUtils.isEmpty(arr[21]) ? null : arr[21]; |
|
|
|
String skuExternalCode = StringUtils.isEmpty(arr[22]) ? null : arr[22]; |
|
|
|
|
|
|
|
String finalPurchasePrice = StringUtils.isEmpty(arr[23]) ? null : arr[23]; |
|
|
|
String safetyStockDays = StringUtils.isEmpty(arr[24]) ? null : arr[24]; |
|
|
|
String isOriginalFactory = (StringUtils.isEmpty(arr[25]) ? null : arr[25]).equals("是")? "1":"2"; |
|
|
|
String isInventoryAlert = (StringUtils.isEmpty(arr[26]) ? null : arr[26]).equals("是")? "1":"2"; |
|
|
|
String inventoryAlertUpperLimit = StringUtils.isEmpty(arr[27]) ? null : arr[27]; |
|
|
|
String inventoryAlertLowerLimit = StringUtils.isEmpty(arr[28]) ? null : arr[28]; |
|
|
|
String costPrice = StringUtils.isEmpty(arr[29]) ? null : arr[29]; |
|
|
|
String tagPrice = StringUtils.isEmpty(arr[30]) ? null : arr[30]; |
|
|
|
String salesPrice = StringUtils.isEmpty(arr[31]) ? null : arr[31]; |
|
|
|
String standardPurchasePrice = StringUtils.isEmpty(arr[32]) ? null : arr[32]; |
|
|
|
String agencyPrice = StringUtils.isEmpty(arr[33]) ? null : arr[33]; |
|
|
|
String discount = StringUtils.isEmpty(arr[34]) ? null : arr[34]; |
|
|
|
String minimumSalesPrice = StringUtils.isEmpty(arr[35]) ? null : arr[35]; |
|
|
|
String isLockingSalesPrice = (StringUtils.isEmpty(arr[36]) ? null : arr[36]).equals("是")? "1":"2"; |
|
|
|
String isIntegralExchange = (StringUtils.isEmpty(arr[37]) ? null : arr[37]).equals("是")? "1":"2"; |
|
|
|
String integralAmount = StringUtils.isEmpty(arr[38]) ? null : arr[38]; |
|
|
|
|
|
|
|
//excel表中物资类别保存的是分类编号,插入数据库时 根据分类编号查询基础数据中 物资类别表的id
|
|
|
|
|
|
|
|
baseGoodsSpuDto.setSortNo("1"); |
|
|
|
baseGoodsSpuDto.setGoodsCode(goodsCode); |
|
|
|
baseGoodsSpuDto.setBarCode(barCode);//物资类别 保存物资类别表id
|
|
|
|
baseGoodsSpuDto.setGoodsName(goodsName); |
|
|
|
baseGoodsSpuDto.setSubTitle(subTitle); |
|
|
|
baseGoodsSpuDto.setGoodsPY(goodsPY); |
|
|
|
baseGoodsSpuDto.setGoodsShortName(goodsShortName); |
|
|
|
|
|
|
|
baseGoodsSpuDto.setGoodsTypeSid(goodsTypeSid); |
|
|
|
baseGoodsSpuDto.setBrandSid(brandSid); |
|
|
|
baseGoodsSpuDto.setManufacturerSid(manufacturerSid); |
|
|
|
// baseGoodsSpuDto.setGoodsUnitSid(goodsUnitSid);
|
|
|
|
baseGoodsSpuDto.setGoodsUnitName(goodsUnitName); |
|
|
|
baseGoodsSpuDto.setTaxRate(taxRate); |
|
|
|
baseGoodsSpuDto.setShelfLife(shelfLife); |
|
|
|
baseGoodsSpuDto.setNationalStandardCode(nationalStandardCode); |
|
|
|
baseGoodsSpuDto.setExternalCode(externalCode); |
|
|
|
baseGoodsSpuDto.setFactoryCode(factoryCode); |
|
|
|
baseGoodsSpuDto.setIsListed(isListed); |
|
|
|
baseGoodsSpuDto.setUseOrgSid(useOrgSid); |
|
|
|
baseGoodsSpuDto.setCreateOrgSid(createOrgSid); |
|
|
|
BaseGoodsSpuDetailDto dto=new BaseGoodsSpuDetailDto(); |
|
|
|
dto.setGoodsExplain(goodsExplain); |
|
|
|
dto.setGoodsDescription(goodsDescription); |
|
|
|
baseGoodsSpuDto.setBaseGoodsSpuDetail(dto); |
|
|
|
List<BaseGoodsSkuDto> dtos=new ArrayList<>(); |
|
|
|
BaseGoodsSkuDto dto1=new BaseGoodsSkuDto(); |
|
|
|
dto1.setGoodsSkuCode(goodsSkuCode); |
|
|
|
dto1.setTitle(title); |
|
|
|
dto1.setExternalCode(skuExternalCode); |
|
|
|
BaseGoodsSkuExtendDto dto2=new BaseGoodsSkuExtendDto(); |
|
|
|
dto2.setSortNo("1"); |
|
|
|
dto2.setFinalPurchasePrice(finalPurchasePrice); |
|
|
|
dto2.setSafetyStockDays(safetyStockDays); |
|
|
|
dto2.setIsOriginalFactory(isOriginalFactory); |
|
|
|
dto2.setIsInventoryAlert(isInventoryAlert); |
|
|
|
dto2.setInventoryAlertUpperLimit(inventoryAlertUpperLimit); |
|
|
|
dto2.setInventoryAlertLowerLimit(inventoryAlertLowerLimit); |
|
|
|
dto2.setCostPrice(costPrice); |
|
|
|
dto2.setTagPrice(tagPrice); |
|
|
|
dto2.setSalesPrice(salesPrice); |
|
|
|
dto2.setStandardPurchasePrice(standardPurchasePrice); |
|
|
|
dto2.setAgencyPrice(agencyPrice); |
|
|
|
dto2.setDiscount(discount); |
|
|
|
dto2.setMinimumSalesPrice(minimumSalesPrice); |
|
|
|
dto2.setIsLockingSalesPrice(isLockingSalesPrice); |
|
|
|
dto2.setIsIntegralExchange(isIntegralExchange); |
|
|
|
dto2.setIntegralAmount(integralAmount); |
|
|
|
dto1.setBaseGoodsSkuExtend(dto2); |
|
|
|
dtos.add(dto1); |
|
|
|
baseGoodsSpuDto.setBaseGoodsSkus(dtos); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
return null; |
|
|
|
} |
|
|
|
return baseGoodsSpuDto; |
|
|
|
} |
|
|
|
} |
|
|
|