|
|
@ -6,7 +6,10 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.goods.apiadmin.GoodsBrandRest; |
|
|
|
import com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfo; |
|
|
|
import com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfoDto; |
|
|
|
import com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfoService; |
|
|
|
import com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfoVo; |
|
|
|
import com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturerDto; |
|
|
|
import com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturerVo; |
|
|
|
import com.yxt.goods.biz.goodssku.GoodsSku; |
|
|
|
import com.yxt.goods.biz.goodssku.GoodsSkuDto; |
|
|
@ -20,12 +23,15 @@ import com.yxt.goods.biz.goodsspudetail.GoodsSpuDetailDto; |
|
|
|
import com.yxt.goods.biz.goodsspudetail.BaseGoodsSpuDetailService; |
|
|
|
import com.yxt.goods.biz.goodsspudetail.BaseGoodsSpuDetailVo; |
|
|
|
import com.yxt.goods.biz.goodstype.GoodsType; |
|
|
|
import com.yxt.goods.biz.goodstype.GoodsTypeDto; |
|
|
|
import com.yxt.goods.biz.goodstype.GoodsTypeService; |
|
|
|
import com.yxt.goods.biz.goodstype.GoodsTypeVo; |
|
|
|
import com.yxt.goods.biz.goodsunit.GoodsUnit; |
|
|
|
import com.yxt.goods.biz.goodsunit.GoodsUnitDto; |
|
|
|
import com.yxt.goods.biz.goodsunit.GoodsUnitService; |
|
|
|
import com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturer; |
|
|
|
import com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturerService; |
|
|
|
import com.yxt.goods.biz.goodsunit.GoodsUnitVo; |
|
|
|
import com.yxt.goods.utils.ExcelUtil; |
|
|
|
import com.yxt.goods.utils.OrgPathQuery; |
|
|
|
import com.yxt.goods.utils.PinYinUtils; |
|
|
@ -103,7 +109,21 @@ public class GoodsSpuService extends MybatisBaseService<GoodsSpuMapper, GoodsSpu |
|
|
|
if (StringUtils.isNotBlank(query.getName())) { |
|
|
|
qw.like("s.goodsName", query.getName()); |
|
|
|
} |
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(query.getGoodsCode())) { |
|
|
|
qw.like("s.goodsCode", query.getGoodsCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBarCode())) { |
|
|
|
qw.like("s.barCode", query.getBarCode()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getBrandName())) { |
|
|
|
qw.eq("s.brandSid", query.getBrandName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getTypeName())) { |
|
|
|
qw.eq("s.typeSid", query.getTypeName()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(query.getManufacturerName())) { |
|
|
|
qw.eq("s.manufacturerSid", query.getManufacturerName()); |
|
|
|
} |
|
|
|
qw.ne("s.isDelete","1"); |
|
|
|
IPage<GoodsSpu> page = PagerUtil.queryToPage(pq); |
|
|
|
IPage<GoodsSpuVo> pagging = baseMapper.listPage(page, qw); |
|
|
@ -201,23 +221,58 @@ public class GoodsSpuService extends MybatisBaseService<GoodsSpuMapper, GoodsSpu |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional |
|
|
|
public ResultBean<String> batchSave(List<GoodsSpuDto> dtos) { |
|
|
|
public ResultBean<String> batchSave(List<GoodsSpuDto> dtos,String orgPath) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<GoodsSpu> spus = new ArrayList<>(); |
|
|
|
List<GoodsSku> skus=new ArrayList<>(); |
|
|
|
List<GoodsSpu> spus1 = new ArrayList<>(); |
|
|
|
List<GoodsSpuDto> dtos1=new ArrayList<>(); |
|
|
|
|
|
|
|
List<GoodsSpuDto>types=dtos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(GoodsSpuDto::getGoodsTypeName))),ArrayList::new)); |
|
|
|
goodsTypeService.saveType(types,orgPath); |
|
|
|
List<GoodsSpuDto> ma=dtos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(GoodsSpuDto::getManufacturerName))),ArrayList::new)); |
|
|
|
baseManufacturerService.saveManufacturer(ma,orgPath); |
|
|
|
List<GoodsSpuDto> brand=dtos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(GoodsSpuDto::getBrandName))),ArrayList::new)); |
|
|
|
baseBrandInfoService.saveBrand(brand,orgPath); |
|
|
|
List<GoodsSpuDto> unit=dtos.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(GoodsSpuDto::getGoodsUnitName))),ArrayList::new)); |
|
|
|
goodsUnitService.saveUnit(unit,orgPath); |
|
|
|
OrgPathQuery query =new OrgPathQuery(); |
|
|
|
query.setOrgPath(orgPath); |
|
|
|
for (GoodsSpuDto dto : dtos) { |
|
|
|
List<GoodsSkuVo>all=goodsSkuService.listAllByOrg(query).getData(); |
|
|
|
for (GoodsSkuDto baseGoodsSkus : dto.getBaseGoodsSkus()) { |
|
|
|
boolean b =all.stream().anyMatch(o->o.getGoodsSkuCode().equals(baseGoodsSkus.getGoodsSkuCode())); |
|
|
|
if(b) { |
|
|
|
return rb.setMsg("规格代码"+baseGoodsSkus.getGoodsSkuCode()+"已存在!"); |
|
|
|
} |
|
|
|
} |
|
|
|
GoodsSpu wmsGoods = new GoodsSpu(); |
|
|
|
// skus.addAll(dto.getBaseGoodsSkus());
|
|
|
|
List<GoodsTypeVo> types1=goodsTypeService.listAll(query).getData(); |
|
|
|
dto.setGoodsTypeSid(types1.stream().filter(o->o.getGoodsTypeName().equals(dto.getGoodsTypeName())).collect(Collectors.toList()).get(0).getSid()); |
|
|
|
List<GoodsUnitVo> goodsUnits=goodsUnitService.listAll(query).getData(); |
|
|
|
dto.setGoodsUnitSid(goodsUnits.stream().filter(o-> o.getUnitName().equals(dto.getGoodsUnitName())).collect(Collectors.toList()).get(0).getSid()); |
|
|
|
List<GoodsBrandInfoVo> brandInfos=baseBrandInfoService.listAll(query).getData(); |
|
|
|
dto.setBrandSid(brandInfos.stream().filter(o-> o.getBrandName().equals(dto.getBrandName())).collect(Collectors.toList()).get(0).getSid()); |
|
|
|
List<GoodsManufacturerVo> manufacturers=baseManufacturerService.listAll(query).getData(); |
|
|
|
dto.setManufacturerSid(manufacturers.stream().filter(o-> o.getManufacturerName().equals(dto.getManufacturerName())).collect(Collectors.toList()).get(0).getSid()); |
|
|
|
BeanUtil.copyProperties(dto, wmsGoods, "id"); |
|
|
|
wmsGoods.setCreateTime(new DateTime()); |
|
|
|
// skus.addAll(dto.getBaseGoodsSkus());
|
|
|
|
wmsGoods.setUseOrgSid(orgPath); |
|
|
|
wmsGoods.setCreateOrgSid(orgPath); |
|
|
|
GoodsSpuVo vo=baseMapper.getGoodsByOrgAndCode(orgPath,dto.getGoodsCode()); |
|
|
|
if(null==vo){ |
|
|
|
spus.add(wmsGoods); |
|
|
|
dtos1.add(dto); |
|
|
|
} |
|
|
|
for (GoodsSkuDto baseGoodsSkus : dto.getBaseGoodsSkus()) { |
|
|
|
baseGoodsSkus.setGoodsSpuSid(vo.getSid()); |
|
|
|
} |
|
|
|
} |
|
|
|
this.saveBatch(spus); |
|
|
|
baseGoodsSpuDetailService.batchSave(dtos); |
|
|
|
baseGoodsSpuDetailService.batchSave(dtos1); |
|
|
|
goodsSkuService.skuBatchSave(dtos); |
|
|
|
return rb.success().setMsg("成功"); |
|
|
|
} |
|
|
|
|
|
|
|
public ResultBean<GoodsSpuVo> initialization(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
GoodsSpuVo vo = baseMapper.initialization(sid); |
|
|
@ -332,7 +387,8 @@ public class GoodsSpuService extends MybatisBaseService<GoodsSpuMapper, GoodsSpu |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
this.batchSave(tt1); |
|
|
|
String orgPath=""; |
|
|
|
this.batchSave(tt1,orgPath); |
|
|
|
return rb.success().setMsg("导入成功"); |
|
|
|
|
|
|
|
} else { |
|
|
|