Browse Source

问题修改

master
wangpengfei 6 months ago
parent
commit
71ac618a24
  1. 2
      src/main/java/com/yxt/goods/apiadmin/GoodsBrandRest.java
  2. 2
      src/main/java/com/yxt/goods/apiadmin/GoodsManufacturerRest.java
  3. 4
      src/main/java/com/yxt/goods/apiadmin/GoodsSpuRest.java
  4. 4
      src/main/java/com/yxt/goods/apiadmin/GoodsTypeRest.java
  5. 4
      src/main/java/com/yxt/goods/apiadmin/GoodsUnitRest.java
  6. 3
      src/main/java/com/yxt/goods/biz/goodsbrandinfo/GoodsBrandInfoMapper.java
  7. 11
      src/main/java/com/yxt/goods/biz/goodsbrandinfo/GoodsBrandInfoMapper.xml
  8. 40
      src/main/java/com/yxt/goods/biz/goodsbrandinfo/GoodsBrandInfoService.java
  9. 2
      src/main/java/com/yxt/goods/biz/goodsmanufacturer/GoodsManufacturerMapper.java
  10. 11
      src/main/java/com/yxt/goods/biz/goodsmanufacturer/GoodsManufacturerMapper.xml
  11. 38
      src/main/java/com/yxt/goods/biz/goodsmanufacturer/GoodsManufacturerService.java
  12. 5
      src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuDto.java
  13. 1
      src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuMapper.java
  14. 10
      src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuMapper.xml
  15. 5
      src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuQuery.java
  16. 72
      src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuService.java
  17. 1
      src/main/java/com/yxt/goods/biz/goodstype/GoodsTypeMapper.java
  18. 11
      src/main/java/com/yxt/goods/biz/goodstype/GoodsTypeMapper.xml
  19. 36
      src/main/java/com/yxt/goods/biz/goodstype/GoodsTypeService.java
  20. 2
      src/main/java/com/yxt/goods/biz/goodsunit/GoodsUnitMapper.java
  21. 11
      src/main/java/com/yxt/goods/biz/goodsunit/GoodsUnitMapper.xml
  22. 37
      src/main/java/com/yxt/goods/biz/goodsunit/GoodsUnitService.java

2
src/main/java/com/yxt/goods/apiadmin/GoodsBrandRest.java

@ -32,7 +32,7 @@ public class GoodsBrandRest {
}
@ApiOperation("查询所有的品牌")
@PostMapping("/listAll")
public ResultBean<List<GoodsBrandInfo>> listAll(@RequestBody OrgPathQuery query) {
public ResultBean<List<GoodsBrandInfoVo>> listAll(@RequestBody OrgPathQuery query) {
return baseBrandInfoService.listAll(query);
}
@ApiOperation("保存修改")

2
src/main/java/com/yxt/goods/apiadmin/GoodsManufacturerRest.java

@ -33,7 +33,7 @@ public class GoodsManufacturerRest {
@ApiOperation("查询所有的厂家")
@PostMapping("/listAll")
public ResultBean<List<GoodsManufacturer>> listAll(@RequestBody OrgPathQuery query) {
public ResultBean<List<GoodsManufacturerVo>> listAll(@RequestBody OrgPathQuery query) {
return baseManufacturerService.listAll(query);
}

4
src/main/java/com/yxt/goods/apiadmin/GoodsSpuRest.java

@ -57,8 +57,8 @@ public class GoodsSpuRest {
}
@ApiOperation("保存")
@PostMapping("/batchSave")
public ResultBean<String> batchSave(@RequestBody List<GoodsSpuDto> dtos) {
return goodsSpuService.batchSave(dtos);
public ResultBean<String> batchSave(@RequestBody List<GoodsSpuDto> dtos,@RequestParam("orgPath") String orgPath) {
return goodsSpuService.batchSave(dtos,orgPath);
}
// @ApiOperation("保存商品信息及sku")
// @PostMapping("/save")

4
src/main/java/com/yxt/goods/apiadmin/GoodsTypeRest.java

@ -1,5 +1,6 @@
package com.yxt.goods.apiadmin;
import com.yxt.goods.biz.goodsspu.GoodsSpuDto;
import com.yxt.goods.biz.goodstype.*;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
@ -32,7 +33,7 @@ public class GoodsTypeRest {
}
@ApiOperation("查询所有的类别")
@PostMapping("/listAll")
public ResultBean<List<GoodsType>> listAll(@RequestBody OrgPathQuery query) {
public ResultBean<List<GoodsTypeVo>> listAll(@RequestBody OrgPathQuery query) {
return goodsTypeService.listAll(query);
}
@ -77,4 +78,5 @@ public class GoodsTypeRest {
public ResultBean updateIsGoodsID(@PathVariable("sid") String sid,@PathVariable("state")String state) {
return goodsTypeService.updateProductCode(sid,state);
}
}

4
src/main/java/com/yxt/goods/apiadmin/GoodsUnitRest.java

@ -1,5 +1,6 @@
package com.yxt.goods.apiadmin;
import com.yxt.goods.biz.goodsspu.GoodsSpuDto;
import com.yxt.goods.biz.goodsunit.*;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
@ -32,7 +33,7 @@ public class GoodsUnitRest {
}
@ApiOperation("查询所有的类别")
@PostMapping("/listAll")
public ResultBean<List<GoodsUnit>> listAll(@RequestBody OrgPathQuery query) {
public ResultBean<List<GoodsUnitVo>> listAll(@RequestBody OrgPathQuery query) {
return goodsUnitService.listAll(query);
}
@ -73,4 +74,5 @@ public class GoodsUnitRest {
public ResultBean<GoodsUnit> getUnitByName(@PathVariable("name") String name) {
return goodsUnitService.getUnitByName(name);
}
}

3
src/main/java/com/yxt/goods/biz/goodsbrandinfo/GoodsBrandInfoMapper.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturer;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -18,5 +19,5 @@ public interface GoodsBrandInfoMapper extends BaseMapper<GoodsBrandInfo> {
int updateBySidIsDelete(List<String> list);
IPage<GoodsBrandInfoVo> listPage(IPage<GoodsBrandInfo> page, @Param(Constants.WRAPPER) QueryWrapper<GoodsBrandInfo> qw);
List<GoodsBrandInfoVo> listAll(@Param("orgPath")String orgPath);
List<GoodsBrandInfo> selectBrandNotIn(@Param("names")List<String> names, @Param("orgPath")String orgPath);
}

11
src/main/java/com/yxt/goods/biz/goodsbrandinfo/GoodsBrandInfoMapper.xml

@ -30,4 +30,15 @@
#{item}
</foreach>
</update>
<select id="selectBrandNotIn" resultType="com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfo">
select a.* from goods_brand_info a
LEFT JOIN ss_user.sys_organization as s ON a.useOrgSid = s.sid
<where>
a.brandName in
<foreach collection="names" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and s.orgSidPath like concat('%',#{orgPath},'%')
</where>
</select>
</mapper>

40
src/main/java/com/yxt/goods/biz/goodsbrandinfo/GoodsBrandInfoService.java

@ -11,16 +11,15 @@ import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturer;
import com.yxt.goods.biz.goodsspu.GoodsSpuDto;
import com.yxt.goods.utils.OrgPathQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -71,7 +70,7 @@ public class GoodsBrandInfoService extends MybatisBaseService<GoodsBrandInfoMapp
records.removeAll(Collections.singleton(null));
return rb.success().setData(p);
}
public ResultBean<List<GoodsBrandInfo>> listAll( OrgPathQuery query) {
public ResultBean<List<GoodsBrandInfoVo>> listAll( OrgPathQuery query) {
ResultBean rb = ResultBean.fireFail();
List<GoodsBrandInfoVo> pagging = baseMapper.listAll(query.getOrgPath());
return rb.success().setData(pagging);
@ -145,4 +144,35 @@ public class GoodsBrandInfoService extends MybatisBaseService<GoodsBrandInfoMapp
GoodsBrandInfo type=baseMapper.selectOne(new QueryWrapper<GoodsBrandInfo>().eq("brandName",name));
return rb.success().setData(type);
}
public ResultBean saveBrand(List<GoodsSpuDto> dtos, String orgPath) {
ResultBean rb = ResultBean.fireFail();
List<GoodsSpuDto> dtos1=new ArrayList<>();
List<GoodsBrandInfo> goodsTypes=new ArrayList<>();
dtos1.addAll(dtos);
//查找已存在的
List<GoodsBrandInfo> goodsType=baseMapper.selectBrandNotIn(dtos.stream().map(GoodsSpuDto::getBrandName).collect(Collectors.toList()),orgPath);
if(goodsType.size()!=0){
for (GoodsSpuDto dto : dtos) {
for (GoodsBrandInfo type : goodsType) {
if(dto.getGoodsTypeName().equals(type.getBrandName())){
dtos1.remove(dto);
type.setIsEnable(1);
type.setIsDelete(0);
baseMapper.updateById(type);
}
}
}
}
for (GoodsSpuDto dto : dtos1) {
GoodsBrandInfo type=new GoodsBrandInfo();
type.setBrandName(dto.getBrandName());
type.setCreateOrgSid(orgPath);
type.setUseOrgSid(orgPath);
goodsTypes.add(type);
}
this.saveBatch(goodsTypes);
return rb.success().setMsg("成功");
}
}

2
src/main/java/com/yxt/goods/biz/goodsmanufacturer/GoodsManufacturerMapper.java

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfoVo;
import com.yxt.goods.biz.goodstype.GoodsType;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -21,4 +22,5 @@ public interface GoodsManufacturerMapper extends BaseMapper<GoodsManufacturer> {
List<GoodsManufacturerVo> getAllTypeByUseOrgSid(@Param("useOrgSid") String useOrgSid);
int updateBySidIsDelete(List<String> list);
List<GoodsManufacturerVo> listAll(@Param("orgPath")String orgPath);
List<GoodsManufacturer> selectManufacturerNotIn(@Param("names")List<String> names, @Param("orgPath")String orgPath);
}

11
src/main/java/com/yxt/goods/biz/goodsmanufacturer/GoodsManufacturerMapper.xml

@ -35,4 +35,15 @@
#{item}
</foreach>
</update>
<select id="selectManufacturerNotIn" resultType="com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturer">
select a.* from goods_manufacturer a
LEFT JOIN ss_user.sys_organization as s ON a.useOrgSid = s.sid
<where>
a.manufacturerName in
<foreach collection="names" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and s.orgSidPath like concat('%',#{orgPath},'%')
</where>
</select>
</mapper>

38
src/main/java/com/yxt/goods/biz/goodsmanufacturer/GoodsManufacturerService.java

@ -11,11 +11,16 @@ import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfoVo;
import com.yxt.goods.biz.goodsspu.GoodsSpuDto;
import com.yxt.goods.biz.goodstype.GoodsType;
import com.yxt.goods.biz.goodsunit.GoodsUnit;
import com.yxt.goods.utils.OrgPathQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -68,7 +73,7 @@ public class GoodsManufacturerService extends MybatisBaseService<GoodsManufactur
List<GoodsManufacturerVo> records = pagging.getRecords();
return rb.success().setData(p);
}
public ResultBean<List<GoodsManufacturer>> listAll(OrgPathQuery query) {
public ResultBean<List<GoodsManufacturerVo>> listAll(OrgPathQuery query) {
ResultBean rb = ResultBean.fireFail();
// List<GoodsManufacturer> pagging = baseMapper.selectList(new QueryWrapper<GoodsManufacturer>().eq("isEnable",1).ne("isDelete","1")
// .eq("userOrgSid",query.getUserOrgSid()));
@ -150,4 +155,35 @@ public class GoodsManufacturerService extends MybatisBaseService<GoodsManufactur
GoodsManufacturer type=baseMapper.selectOne(new QueryWrapper<GoodsManufacturer>().eq("manufacturerName",name));
return rb.success().setData(type);
}
public ResultBean saveManufacturer(List<GoodsSpuDto> dtos, String orgPath) {
ResultBean rb = ResultBean.fireFail();
List<GoodsSpuDto> dtos1=new ArrayList<>();
List<GoodsManufacturer> goodsTypes=new ArrayList<>();
dtos1.addAll(dtos);
//查找已存在的
List<GoodsManufacturer> goodsType=baseMapper.selectManufacturerNotIn(dtos.stream().map(GoodsSpuDto::getManufacturerName).collect(Collectors.toList()),orgPath);
if(goodsType.size()!=0){
for (GoodsSpuDto dto : dtos) {
for (GoodsManufacturer type : goodsType) {
if(dto.getGoodsTypeName().equals(type.getManufacturerName())){
dtos1.remove(dto);
type.setIsEnable(1);
type.setIsDelete(0);
baseMapper.updateById(type);
}
}
}
}
for (GoodsSpuDto dto : dtos1) {
GoodsManufacturer type=new GoodsManufacturer();
type.setManufacturerName(dto.getManufacturerName());
type.setCreateOrgSid(orgPath);
type.setUseOrgSid(orgPath);
goodsTypes.add(type);
}
this.saveBatch(goodsTypes);
return rb.success().setMsg("成功");
}
}

5
src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuDto.java

@ -29,8 +29,13 @@ public class GoodsSpuDto implements Dto {
private String goodsPY;//拼音缩写
private String goodsShortName;//商品简称
private String goodsTypeSid;//商品分类sid
private String goodsTypeName;//商品分类sid
private String brandSid;//品牌sid
private String brandName;//品牌sid
private String manufacturerSid;//厂家sid
private String manufacturerName;//厂家sid
private String goodsUnitSid;//商品单位sid
private String goodsUnitName;//商品单位名称
private String taxRate;//税率

1
src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuMapper.java

@ -21,6 +21,7 @@ public interface GoodsSpuMapper extends BaseMapper<GoodsSpu> {
GoodsSpuVo initialization(@Param("sid")String sid);
int updateBySidIsDelete(List<String> list);
List<GoodsSpuVo> listAll(@Param("orgPath")String orgPath);
GoodsSpuVo getGoodsByOrgAndCode(@Param("orgPath")String orgPath,@Param("goodsCode")String goodsCode);
IPage<SalesGoodsVo> getGoodsForSales(IPage<GoodsSpu> page, @Param(Constants.WRAPPER) QueryWrapper<GoodsSpu> qw);

10
src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuMapper.xml

@ -25,6 +25,7 @@
s.orgSidPath like concat('%',#{orgPath},'%') and a.isDelete !='1' and a.isEnable='1'
</where>
</select>
<select id="initialization" resultType="com.yxt.goods.biz.goodsspu.GoodsSpuVo">
select
s.*,a.goodsTypeName as typeName,b.brandName as brandName,c.manufacturerName as manufacturerName
@ -63,6 +64,15 @@
${ew.sqlSegment}
</where>
</select>
<select id="getGoodsByOrgAndCode" resultType="com.yxt.goods.biz.goodsspu.GoodsSpuVo">
select
*
from goods_spu a
LEFT JOIN ss_user.sys_organization as s ON a.useOrgSid = s.sid
<where>
s.orgSidPath like concat('%',#{orgPath},'%') and a.goodsCode=#{goodsCode}
</where>
</select>
<update id="updateBySidIsDelete">
UPDATE goods_spu
SET isDelete=1

5
src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuQuery.java

@ -11,6 +11,11 @@ import lombok.Data;
@Data
public class GoodsSpuQuery implements Query {
private String name;
private String goodsCode;
private String barCode;
private String brandName;
private String TypeName;
private String manufacturerName;
private String userOrgSid;
private String createOrgSid;//创建组织sid
private String orgLevelKey;//权限等级

72
src/main/java/com/yxt/goods/biz/goodsspu/GoodsSpuService.java

@ -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());
spus.add(wmsGoods);
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 {

1
src/main/java/com/yxt/goods/biz/goodstype/GoodsTypeMapper.java

@ -20,4 +20,5 @@ public interface GoodsTypeMapper extends BaseMapper<GoodsType> {
int updateBySidIsDelete(List<String> list);
IPage<GoodsTypeVo> listPage(IPage<GoodsType> page, @Param(Constants.WRAPPER) QueryWrapper<GoodsType> qw);
List<GoodsTypeVo> listAll(@Param("orgPath")String orgPath);
List<GoodsType> selectTypeNotIn(@Param("names")List<String> names,@Param("orgPath")String orgPath);
}

11
src/main/java/com/yxt/goods/biz/goodstype/GoodsTypeMapper.xml

@ -22,6 +22,17 @@
s.orgSidPath like concat('%',#{orgPath},'%') and a.isDelete !='1' and a.isEnable='1'
</where>
</select>
<select id="selectTypeNotIn" resultType="com.yxt.goods.biz.goodstype.GoodsType">
select a.* from goods_type a
LEFT JOIN ss_user.sys_organization as s ON a.useOrgSid = s.sid
<where>
a.goodsTypeName in
<foreach collection="names" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and s.orgSidPath like concat('%',#{orgPath},'%')
</where>
</select>
<update id="updateBySidIsDelete">
UPDATE goods_type
SET isDelete=1

36
src/main/java/com/yxt/goods/biz/goodstype/GoodsTypeService.java

@ -11,10 +11,14 @@ import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturerVo;
import com.yxt.goods.biz.goodsspu.GoodsSpuDto;
import com.yxt.goods.biz.goodsunit.GoodsUnit;
import com.yxt.goods.utils.OrgPathQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -95,7 +99,7 @@ public class GoodsTypeService extends MybatisBaseService<GoodsTypeMapper, GoodsT
}
return rb.success().setData(p);
}
public ResultBean<List<GoodsType>> listAll(OrgPathQuery query) {
public ResultBean<List<GoodsTypeVo>> listAll(OrgPathQuery query) {
ResultBean rb = ResultBean.fireFail();
List<GoodsTypeVo> pagging = baseMapper.listAll(query.getOrgPath());
return rb.success().setData(pagging);
@ -212,4 +216,34 @@ public class GoodsTypeService extends MybatisBaseService<GoodsTypeMapper, GoodsT
}
return rb.success().setMsg("成功");
}
public ResultBean saveType(List<GoodsSpuDto> dtos,String orgPath) {
ResultBean rb = ResultBean.fireFail();
List<GoodsSpuDto> dtos1=new ArrayList<>();
List<GoodsType> goodsTypes=new ArrayList<>();
dtos1.addAll(dtos);
//查找已存在的
List<GoodsType> goodsType=baseMapper.selectTypeNotIn(dtos.stream().map(GoodsSpuDto::getGoodsTypeName).collect(Collectors.toList()),orgPath);
if(goodsType.size()!=0){
for (GoodsSpuDto dto : dtos) {
for (GoodsType type : goodsType) {
if(dto.getGoodsTypeName().equals(type.getGoodsTypeName())){
dtos1.remove(dto);
type.setIsEnable(1);
type.setIsDelete(0);
baseMapper.updateById(type);
}
}
}
}
for (GoodsSpuDto dto : dtos1) {
GoodsType type=new GoodsType();
type.setGoodsTypeName(dto.getGoodsTypeName());
type.setCreateOrgSid(orgPath);
type.setUseOrgSid(orgPath);
goodsTypes.add(type);
}
this.saveBatch(goodsTypes);
return rb.success().setMsg("成功");
}
}

2
src/main/java/com/yxt/goods/biz/goodsunit/GoodsUnitMapper.java

@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.yxt.goods.biz.goodstype.GoodsType;
import com.yxt.goods.biz.goodstype.GoodsTypeVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -19,4 +20,5 @@ public interface GoodsUnitMapper extends BaseMapper<GoodsUnit> {
IPage<GoodsUnitVo> listPage(IPage<GoodsUnit> page, @Param(Constants.WRAPPER) QueryWrapper<GoodsUnit> qw);
int updateBySidIsDelete(List<String> list);
List<GoodsUnitVo> listAll(@Param("orgPath")String orgPath);
List<GoodsUnit> selectUnitNotIn(@Param("names")List<String> names, @Param("orgPath")String orgPath);
}

11
src/main/java/com/yxt/goods/biz/goodsunit/GoodsUnitMapper.xml

@ -30,4 +30,15 @@
#{item}
</foreach>
</update>
<select id="selectUnitNotIn" resultType="com.yxt.goods.biz.goodsunit.GoodsUnit">
select a.* from goods_unit a
LEFT JOIN ss_user.sys_organization as s ON a.useOrgSid = s.sid
<where>
a.unitName in
<foreach collection="names" item="item" index="index" open="(" separator="," close=")">
#{item}
</foreach>
and s.orgSidPath like concat('%',#{orgPath},'%')
</where>
</select>
</mapper>

37
src/main/java/com/yxt/goods/biz/goodsunit/GoodsUnitService.java

@ -10,12 +10,17 @@ import com.yxt.common.base.utils.StringUtils;
import com.yxt.common.core.query.PagerQuery;
import com.yxt.common.core.result.ResultBean;
import com.yxt.common.core.vo.PagerVo;
import com.yxt.goods.biz.goodsbrandinfo.GoodsBrandInfo;
import com.yxt.goods.biz.goodsmanufacturer.GoodsManufacturerVo;
import com.yxt.goods.biz.goodsspu.GoodsSpuDto;
import com.yxt.goods.biz.goodstype.GoodsType;
import com.yxt.goods.utils.OrgPathQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -66,7 +71,7 @@ public class GoodsUnitService extends MybatisBaseService<GoodsUnitMapper, GoodsU
PagerVo<GoodsUnitVo> p = PagerUtil.pageToVo(pagging, null);
List<GoodsUnitVo> records = pagging.getRecords();
return rb.success().setData(p);
} public ResultBean<List<GoodsUnit>> listAll( OrgPathQuery query) {
} public ResultBean<List<GoodsUnitVo>> listAll( OrgPathQuery query) {
ResultBean rb = ResultBean.fireFail();
// List<GoodsUnit> pagging = baseMapper.selectList(new QueryWrapper<GoodsUnit>().eq("isEnable",1).ne("isDelete","1")
// .eq("userOrgSid",query.getUserOrgSid()));
@ -146,4 +151,34 @@ public class GoodsUnitService extends MybatisBaseService<GoodsUnitMapper, GoodsU
GoodsUnit type=baseMapper.selectOne(new QueryWrapper<GoodsUnit>().eq("unitName",name));
return rb.success().setData(type);
}
public ResultBean saveUnit(List<GoodsSpuDto> dtos, String orgPath) {
ResultBean rb = ResultBean.fireFail();
List<GoodsSpuDto> dtos1=new ArrayList<>();
List<GoodsUnit> goodsTypes=new ArrayList<>();
dtos1.addAll(dtos);
//查找已存在的
List<GoodsUnit> goodsType=baseMapper.selectUnitNotIn(dtos.stream().map(GoodsSpuDto::getGoodsUnitName).collect(Collectors.toList()),orgPath);
if(goodsType.size()!=0){
for (GoodsSpuDto dto : dtos) {
for (GoodsUnit type : goodsType) {
if(dto.getGoodsTypeName().equals(type.getUnitName())){
dtos1.remove(dto);
type.setIsEnable(1);
type.setIsDelete(0);
baseMapper.updateById(type);
}
}
}
}
for (GoodsSpuDto dto : dtos1) {
GoodsUnit type=new GoodsUnit();
type.setUnitName(dto.getGoodsUnitName());
type.setCreateOrgSid(orgPath);
type.setUseOrgSid(orgPath);
goodsTypes.add(type);
}
this.saveBatch(goodsTypes);
return rb.success().setMsg("成功");
}
}

Loading…
Cancel
Save