Merge remote-tracking branch 'origin/master'
# Conflicts: # src/main/java/com/yxt/goods/biz/base/basebrandinfo/BaseBrandInfoService.java
This commit is contained in:
@@ -57,4 +57,9 @@ public class BaseGoodsBrandRest {
|
|||||||
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) {
|
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) {
|
||||||
return baseBrandInfoService.updateIsEnable(sid,isEnable);
|
return baseBrandInfoService.updateIsEnable(sid,isEnable);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("根据品牌名查询")
|
||||||
|
@GetMapping("/getBrandByName/{name}")
|
||||||
|
public ResultBean<BaseBrandInfo> getBrandByName(@PathVariable("name") String name) {
|
||||||
|
return baseBrandInfoService.getBrandByName(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.yxt.goods.apiadmin;
|
package com.yxt.goods.apiadmin;
|
||||||
|
|
||||||
|
import com.yxt.goods.biz.base.basegoodssku.BaseGoodsSkuDto;
|
||||||
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendDto;
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendDto;
|
||||||
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendQuery;
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendQuery;
|
||||||
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendService;
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendService;
|
||||||
@@ -7,11 +8,14 @@ import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendVo;
|
|||||||
import com.yxt.common.core.query.PagerQuery;
|
import com.yxt.common.core.query.PagerQuery;
|
||||||
import com.yxt.common.core.result.ResultBean;
|
import com.yxt.common.core.result.ResultBean;
|
||||||
import com.yxt.common.core.vo.PagerVo;
|
import com.yxt.common.core.vo.PagerVo;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpuDto;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangpengfei
|
* @author wangpengfei
|
||||||
* @date 2024/3/11 15:05
|
* @date 2024/3/11 15:05
|
||||||
@@ -35,7 +39,11 @@ public class BaseGoodsSkuExtendRest {
|
|||||||
public ResultBean<String> saveOrUpdate(@RequestBody BaseGoodsSkuExtendDto dto) {
|
public ResultBean<String> saveOrUpdate(@RequestBody BaseGoodsSkuExtendDto dto) {
|
||||||
return baseGoodsSkuExtendService.saveOrUpdate(dto);
|
return baseGoodsSkuExtendService.saveOrUpdate(dto);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("保存")
|
||||||
|
@PostMapping("/batchSave")
|
||||||
|
public ResultBean<String> batchSave(@RequestBody List<BaseGoodsSkuDto> dtos) {
|
||||||
|
return baseGoodsSkuExtendService.skuEBatchSave(dtos);
|
||||||
|
}
|
||||||
@ApiOperation("初始化")
|
@ApiOperation("初始化")
|
||||||
@GetMapping("/initialization/{sid}")
|
@GetMapping("/initialization/{sid}")
|
||||||
public ResultBean<BaseGoodsSkuExtendVo> initialization(@PathVariable("sid") String sid) {
|
public ResultBean<BaseGoodsSkuExtendVo> initialization(@PathVariable("sid") String sid) {
|
||||||
|
|||||||
@@ -4,11 +4,14 @@ import com.yxt.goods.biz.base.basegoodssku.*;
|
|||||||
import com.yxt.common.core.query.PagerQuery;
|
import com.yxt.common.core.query.PagerQuery;
|
||||||
import com.yxt.common.core.result.ResultBean;
|
import com.yxt.common.core.result.ResultBean;
|
||||||
import com.yxt.common.core.vo.PagerVo;
|
import com.yxt.common.core.vo.PagerVo;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpuDto;
|
||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangpengfei
|
* @author wangpengfei
|
||||||
* @date 2024/3/11 14:27
|
* @date 2024/3/11 14:27
|
||||||
@@ -31,7 +34,11 @@ public class BaseGoodsSkuRest {
|
|||||||
public ResultBean<String> saveOrUpdate(@RequestBody BaseGoodsSkuDto dto) {
|
public ResultBean<String> saveOrUpdate(@RequestBody BaseGoodsSkuDto dto) {
|
||||||
return baseGoodsSkuService.saveOrUpdate(dto);
|
return baseGoodsSkuService.saveOrUpdate(dto);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("保存")
|
||||||
|
@PostMapping("/batchSave")
|
||||||
|
public ResultBean<String> batchSave(@RequestBody List<BaseGoodsSpuDto> dtos) {
|
||||||
|
return baseGoodsSkuService.skuBatchSave(dtos);
|
||||||
|
}
|
||||||
@ApiOperation("初始化")
|
@ApiOperation("初始化")
|
||||||
@GetMapping("/initialization/{sid}")
|
@GetMapping("/initialization/{sid}")
|
||||||
public ResultBean<BaseGoodsSkuVo> initialization(@PathVariable("sid") String sid) {
|
public ResultBean<BaseGoodsSkuVo> initialization(@PathVariable("sid") String sid) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.yxt.goods.apiadmin;
|
package com.yxt.goods.apiadmin;
|
||||||
|
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpuDto;
|
||||||
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailDto;
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailDto;
|
||||||
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailQuery;
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailQuery;
|
||||||
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailService;
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailService;
|
||||||
@@ -12,6 +13,8 @@ import io.swagger.annotations.ApiOperation;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangpengfei
|
* @author wangpengfei
|
||||||
* @date 2024/3/21 16:58
|
* @date 2024/3/21 16:58
|
||||||
@@ -36,7 +39,11 @@ public class BaseGoodsSpuDetailRest {
|
|||||||
public ResultBean<String> saveOrUpdate(@RequestBody BaseGoodsSpuDetailDto dto) {
|
public ResultBean<String> saveOrUpdate(@RequestBody BaseGoodsSpuDetailDto dto) {
|
||||||
return baseGoodsSpuDetailService.saveOrUpdate(dto);
|
return baseGoodsSpuDetailService.saveOrUpdate(dto);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("保存")
|
||||||
|
@PostMapping("/batchSave")
|
||||||
|
public ResultBean<String> batchSave(@RequestBody List<BaseGoodsSpuDto> dtos) {
|
||||||
|
return baseGoodsSpuDetailService.batchSave(dtos);
|
||||||
|
}
|
||||||
@ApiOperation("初始化")
|
@ApiOperation("初始化")
|
||||||
@GetMapping("/initialization/{sid}")
|
@GetMapping("/initialization/{sid}")
|
||||||
public ResultBean<BaseGoodsSpuDetailVo> initialization(@PathVariable("sid") String sid) {
|
public ResultBean<BaseGoodsSpuDetailVo> initialization(@PathVariable("sid") String sid) {
|
||||||
|
|||||||
@@ -10,7 +10,12 @@ import com.yxt.common.core.vo.PagerVo;
|
|||||||
import io.swagger.annotations.Api;
|
import io.swagger.annotations.Api;
|
||||||
import io.swagger.annotations.ApiOperation;
|
import io.swagger.annotations.ApiOperation;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.MediaType;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangpengfei
|
* @author wangpengfei
|
||||||
@@ -34,6 +39,11 @@ public class BaseGoodsSpuRest {
|
|||||||
public ResultBean<String> saveOrUpdate(@RequestBody BaseGoodsSpuDto dto) {
|
public ResultBean<String> saveOrUpdate(@RequestBody BaseGoodsSpuDto dto) {
|
||||||
return baseGoodsSpuService.saveOrUpdate(dto);
|
return baseGoodsSpuService.saveOrUpdate(dto);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("保存")
|
||||||
|
@PostMapping("/batchSave")
|
||||||
|
public ResultBean<String> batchSave(@RequestBody List<BaseGoodsSpuDto> dtos) {
|
||||||
|
return baseGoodsSpuService.batchSave(dtos);
|
||||||
|
}
|
||||||
// @ApiOperation("保存商品信息及sku")
|
// @ApiOperation("保存商品信息及sku")
|
||||||
// @PostMapping("/save")
|
// @PostMapping("/save")
|
||||||
// public ResultBean<String> save(@RequestBody BaseGoodsSpuDto dto) {
|
// public ResultBean<String> save(@RequestBody BaseGoodsSpuDto dto) {
|
||||||
@@ -55,4 +65,9 @@ public class BaseGoodsSpuRest {
|
|||||||
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) {
|
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) {
|
||||||
return baseGoodsSpuService.updateIsEnable(sid,isEnable);
|
return baseGoodsSpuService.updateIsEnable(sid,isEnable);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("导入excel")
|
||||||
|
@PostMapping(value ="/importExcel" ,consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||||
|
public ResultBean importExcel(@RequestParam("file") MultipartFile file) throws IOException {
|
||||||
|
return baseGoodsSpuService.importExcel(file);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,4 +58,9 @@ public class BaseGoodsTypeRest {
|
|||||||
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) {
|
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) {
|
||||||
return baseGoodsTypeService.updateIsEnable(sid,isEnable);
|
return baseGoodsTypeService.updateIsEnable(sid,isEnable);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("根据类型名查询")
|
||||||
|
@GetMapping("/getTypeByName/{name}")
|
||||||
|
public ResultBean<BaseGoodsType> getTypeByName(@PathVariable("name") String name) {
|
||||||
|
return baseGoodsTypeService.getTypeByName(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,4 +58,9 @@ public class BaseGoodsUnitRest {
|
|||||||
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) {
|
public ResultBean updateIsEnable(@PathVariable("sid") String sid,@PathVariable("isEnable")String isEnable) {
|
||||||
return baseGoodsUnitService.updateIsEnable(sid,isEnable);
|
return baseGoodsUnitService.updateIsEnable(sid,isEnable);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("根据单位名查询")
|
||||||
|
@GetMapping("/getUnitByName/{name}")
|
||||||
|
public ResultBean<BaseGoodsUnit> getUnitByName(@PathVariable("name") String name) {
|
||||||
|
return baseGoodsUnitService.getUnitByName(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -65,5 +65,9 @@ public class BaseManufacturerRest {
|
|||||||
public ResultBean<List<BaseManufacturerVo>> getAllTypeByUseOrgSid(@RequestParam("useOrgSid") String useOrgSid) {
|
public ResultBean<List<BaseManufacturerVo>> getAllTypeByUseOrgSid(@RequestParam("useOrgSid") String useOrgSid) {
|
||||||
return baseManufacturerService.getAllTypeByUseOrgSid(useOrgSid);
|
return baseManufacturerService.getAllTypeByUseOrgSid(useOrgSid);
|
||||||
}
|
}
|
||||||
|
@ApiOperation("根据厂家名查询")
|
||||||
|
@GetMapping("/getManufacturerByName/{name}")
|
||||||
|
public ResultBean<BaseManufacturer> getManufacturerByName(@PathVariable("name") String name) {
|
||||||
|
return baseManufacturerService.getManufacturerByName(name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ import com.yxt.common.base.utils.StringUtils;
|
|||||||
import com.yxt.common.core.query.PagerQuery;
|
import com.yxt.common.core.query.PagerQuery;
|
||||||
import com.yxt.common.core.result.ResultBean;
|
import com.yxt.common.core.result.ResultBean;
|
||||||
import com.yxt.common.core.vo.PagerVo;
|
import com.yxt.common.core.vo.PagerVo;
|
||||||
|
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsType;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
@@ -33,8 +34,8 @@ public class BaseBrandInfoService extends MybatisBaseService<BaseBrandInfoMapper
|
|||||||
BaseBrandInfoQuery query = pq.getParams();
|
BaseBrandInfoQuery query = pq.getParams();
|
||||||
QueryWrapper<BaseBrandInfo> qw = new QueryWrapper<>();
|
QueryWrapper<BaseBrandInfo> qw = new QueryWrapper<>();
|
||||||
|
|
||||||
if (StringUtils.isNotBlank(query.getName())) {
|
if(StringUtils.isNotBlank(query.getName())){
|
||||||
qw.like("brandName", query.getName());
|
qw.like("brandName",query.getName());
|
||||||
}
|
}
|
||||||
IPage<BaseBrandInfo> page = PagerUtil.queryToPage(pq);
|
IPage<BaseBrandInfo> page = PagerUtil.queryToPage(pq);
|
||||||
IPage<BaseBrandInfoVo> pagging = baseMapper.listPage(page, qw);
|
IPage<BaseBrandInfoVo> pagging = baseMapper.listPage(page, qw);
|
||||||
@@ -50,13 +51,11 @@ public class BaseBrandInfoService extends MybatisBaseService<BaseBrandInfoMapper
|
|||||||
// }
|
// }
|
||||||
return rb.success().setData(p);
|
return rb.success().setData(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultBean<List<BaseBrandInfo>> listAll() {
|
public ResultBean<List<BaseBrandInfo>> listAll() {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
List<BaseBrandInfo> pagging = baseMapper.selectList(new QueryWrapper<BaseBrandInfo>().eq("isEnable", 1));
|
List<BaseBrandInfo> pagging = baseMapper.selectList(new QueryWrapper<BaseBrandInfo>().eq("isEnable",1));
|
||||||
return rb.success().setData(pagging);
|
return rb.success().setData(pagging);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultBean<String> saveOrUpdate(BaseBrandInfoDto dto) {
|
public ResultBean<String> saveOrUpdate(BaseBrandInfoDto dto) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
String sid = "";
|
String sid = "";
|
||||||
@@ -72,8 +71,8 @@ public class BaseBrandInfoService extends MybatisBaseService<BaseBrandInfoMapper
|
|||||||
wmsGoodsBrand.setModifyTime(new Date());
|
wmsGoodsBrand.setModifyTime(new Date());
|
||||||
baseMapper.updateById(wmsGoodsBrand);
|
baseMapper.updateById(wmsGoodsBrand);
|
||||||
} else {
|
} else {
|
||||||
BaseBrandInfo goods = baseMapper.selectOne(new QueryWrapper<BaseBrandInfo>().eq("name", dto.getBrandName()));
|
BaseBrandInfo goods=baseMapper.selectOne(new QueryWrapper<BaseBrandInfo>().eq("brandName",dto.getBrandName()));
|
||||||
if (null != goods) {
|
if(null!=goods){
|
||||||
return rb.setMsg("商品名不能重复");
|
return rb.setMsg("商品名不能重复");
|
||||||
}
|
}
|
||||||
BaseBrandInfo wmsGoodsBrand = new BaseBrandInfo();
|
BaseBrandInfo wmsGoodsBrand = new BaseBrandInfo();
|
||||||
@@ -107,6 +106,7 @@ public class BaseBrandInfoService extends MybatisBaseService<BaseBrandInfoMapper
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ResultBean delete(String sid) {
|
public ResultBean delete(String sid) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseBrandInfo wmsGoodsBrand = fetchBySid(sid);
|
BaseBrandInfo wmsGoodsBrand = fetchBySid(sid);
|
||||||
@@ -115,8 +115,7 @@ public class BaseBrandInfoService extends MybatisBaseService<BaseBrandInfoMapper
|
|||||||
}
|
}
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
public ResultBean updateIsEnable(String sid,String isEnable) {
|
||||||
public ResultBean updateIsEnable(String sid, String isEnable) {
|
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseBrandInfo wmsGoodsBrand = fetchBySid(sid);
|
BaseBrandInfo wmsGoodsBrand = fetchBySid(sid);
|
||||||
if (null != wmsGoodsBrand) {
|
if (null != wmsGoodsBrand) {
|
||||||
@@ -125,5 +124,9 @@ public class BaseBrandInfoService extends MybatisBaseService<BaseBrandInfoMapper
|
|||||||
}
|
}
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
public ResultBean<BaseBrandInfo> getBrandByName(String name) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
BaseBrandInfo type=baseMapper.selectOne(new QueryWrapper<BaseBrandInfo>().eq("brandName",name));
|
||||||
|
return rb.success().setData(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||||||
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendService;
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendService;
|
||||||
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendVo;
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendVo;
|
||||||
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpu;
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpu;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpuDto;
|
||||||
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpuService;
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpuService;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetail;
|
||||||
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailService;
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailService;
|
||||||
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsType;
|
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsType;
|
||||||
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsTypeService;
|
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsTypeService;
|
||||||
@@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -77,6 +80,24 @@ public class BaseGoodsSkuService extends MybatisBaseService<BaseGoodsSkuMapper,
|
|||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
@Transactional
|
@Transactional
|
||||||
|
public ResultBean<String> skuBatchSave(List<BaseGoodsSpuDto> dtos) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
List<BaseGoodsSku> skus = new ArrayList<>();
|
||||||
|
List<BaseGoodsSkuDto> dtos1=new ArrayList<>();
|
||||||
|
for (BaseGoodsSpuDto dto : dtos) {
|
||||||
|
for (BaseGoodsSkuDto baseGoodsSkus : dto.getBaseGoodsSkus()) {
|
||||||
|
BaseGoodsSku sku = new BaseGoodsSku();
|
||||||
|
BeanUtil.copyProperties(baseGoodsSkus, sku, "id");
|
||||||
|
sku.setCreateTime(new DateTime());
|
||||||
|
skus.add(sku);
|
||||||
|
dtos1.add(baseGoodsSkus);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.saveBatch(skus);
|
||||||
|
baseGoodsSkuExtendService.skuEBatchSave(dtos1);
|
||||||
|
return rb.success().setMsg("成功");
|
||||||
|
}
|
||||||
|
@Transactional
|
||||||
public ResultBean<String> saveOrUpdate(List<BaseGoodsSkuDto> dtos) {
|
public ResultBean<String> saveOrUpdate(List<BaseGoodsSkuDto> dtos) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
for (BaseGoodsSkuDto dto : dtos) {
|
for (BaseGoodsSkuDto dto : dtos) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
|||||||
import com.yxt.common.core.dto.Dto;
|
import com.yxt.common.core.dto.Dto;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -42,5 +43,7 @@ public class BaseGoodsSkuExtendDto implements Dto {
|
|||||||
private String sortNo;//排序
|
private String sortNo;//排序
|
||||||
private String picUrl;//商品的图片,多个图片以‘,’分割
|
private String picUrl;//商品的图片,多个图片以‘,’分割
|
||||||
// private String [] Urls={};//图片数组
|
// private String [] Urls={};//图片数组
|
||||||
private List<UrlsVo> urls;//图片数组
|
private List<UrlsVo> urls=new ArrayList<>();//图片数组
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import cn.hutool.core.date.DateTime;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.yxt.goods.biz.base.basebrandinfo.BaseBrandInfoService;
|
import com.yxt.goods.biz.base.basebrandinfo.BaseBrandInfoService;
|
||||||
|
import com.yxt.goods.biz.base.basegoodssku.BaseGoodsSkuDto;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpu;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpuDto;
|
||||||
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailService;
|
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailService;
|
||||||
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsTypeService;
|
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsTypeService;
|
||||||
import com.yxt.goods.biz.base.basemanufacturer.BaseManufacturerService;
|
import com.yxt.goods.biz.base.basemanufacturer.BaseManufacturerService;
|
||||||
@@ -19,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -92,20 +96,37 @@ public class BaseGoodsSkuExtendService extends MybatisBaseService<BaseGoodsSkuEx
|
|||||||
sid = wmsGoods.getSid();
|
sid = wmsGoods.getSid();
|
||||||
BeanUtil.copyProperties(dto, wmsGoods);
|
BeanUtil.copyProperties(dto, wmsGoods);
|
||||||
wmsGoods.setCreateTime(new DateTime());
|
wmsGoods.setCreateTime(new DateTime());
|
||||||
for (UrlsVo url : dto.getUrls()) {
|
if(dto.getUrls()!=null){
|
||||||
String urlPrefix = fileUploadComponent.getUrlPrefix();
|
for (UrlsVo url : dto.getUrls()) {
|
||||||
String path = url.getUrl().substring(urlPrefix.length());
|
String urlPrefix = fileUploadComponent.getUrlPrefix();
|
||||||
if(StringUtils.isBlank(dto.getPicUrl())){
|
String path = url.getUrl().substring(urlPrefix.length());
|
||||||
wmsGoods.setPicUrl(path);
|
if(StringUtils.isBlank(dto.getPicUrl())){
|
||||||
}else{
|
wmsGoods.setPicUrl(path);
|
||||||
wmsGoods.setPicUrl(wmsGoods.getPicUrl()+","+path);
|
}else{
|
||||||
|
wmsGoods.setPicUrl(wmsGoods.getPicUrl()+","+path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
baseMapper.insert(wmsGoods);
|
baseMapper.insert(wmsGoods);
|
||||||
}
|
}
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public ResultBean<String> skuEBatchSave(List<BaseGoodsSkuDto> dtos) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
List<BaseGoodsSkuExtend> spus = new ArrayList<>();
|
||||||
|
for (BaseGoodsSkuDto dto : dtos) {
|
||||||
|
BaseGoodsSkuExtend extend = new BaseGoodsSkuExtend();
|
||||||
|
BeanUtil.copyProperties(dto.getBaseGoodsSkuExtend(), extend, "id");
|
||||||
|
extend.setCreateTime(new DateTime());
|
||||||
|
spus.add(extend);
|
||||||
|
}
|
||||||
|
this.saveBatch(spus);
|
||||||
|
return rb.success().setMsg("成功");
|
||||||
|
}
|
||||||
|
|
||||||
public ResultBean<BaseGoodsSkuExtendVo> initialization(String sid) {
|
public ResultBean<BaseGoodsSkuExtendVo> initialization(String sid) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseGoodsSkuExtendVo vo = baseMapper.getExtendBySid(sid);
|
BaseGoodsSkuExtendVo vo = baseMapper.getExtendBySid(sid);
|
||||||
|
|||||||
@@ -4,15 +4,27 @@ import cn.hutool.core.bean.BeanUtil;
|
|||||||
import cn.hutool.core.date.DateTime;
|
import cn.hutool.core.date.DateTime;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
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.BaseGoodsSkuService;
|
||||||
import com.yxt.goods.biz.base.basegoodssku.BaseGoodsSkuVo;
|
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.BaseGoodsSkuExtendService;
|
||||||
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendVo;
|
import com.yxt.goods.biz.base.basegoodsskuextend.BaseGoodsSkuExtendVo;
|
||||||
import com.yxt.goods.biz.base.basegoodsskuextend.UrlsVo;
|
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.BaseGoodsSpuDetailService;
|
||||||
import com.yxt.goods.biz.base.basegoodsspudetail.BaseGoodsSpuDetailVo;
|
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.BaseGoodsUnit;
|
||||||
import com.yxt.goods.biz.base.basegoodsunit.BaseGoodsUnitService;
|
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.goods.utils.PinYinUtils;
|
||||||
import com.yxt.common.base.config.component.FileUploadComponent;
|
import com.yxt.common.base.config.component.FileUploadComponent;
|
||||||
import com.yxt.common.base.service.MybatisBaseService;
|
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.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.*;
|
||||||
import java.util.Date;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.List;
|
import java.util.function.Function;
|
||||||
|
import java.util.function.Predicate;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangpengfei
|
* @author wangpengfei
|
||||||
@@ -46,14 +61,20 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper,
|
|||||||
BaseGoodsUnitService baseGoodsUnitService;
|
BaseGoodsUnitService baseGoodsUnitService;
|
||||||
@Autowired
|
@Autowired
|
||||||
BaseGoodsSkuExtendService baseGoodsSkuExtendService;
|
BaseGoodsSkuExtendService baseGoodsSkuExtendService;
|
||||||
|
@Autowired
|
||||||
|
BaseManufacturerService baseManufacturerService;
|
||||||
|
@Autowired
|
||||||
|
BaseGoodsTypeService baseGoodsTypeService;
|
||||||
|
@Autowired
|
||||||
|
BaseBrandInfoService baseBrandInfoService;
|
||||||
|
|
||||||
|
|
||||||
public ResultBean<PagerVo<BaseGoodsSpuVo>> listPage(PagerQuery<BaseGoodsSpuQuery> pq) {
|
public ResultBean<PagerVo<BaseGoodsSpuVo>> listPage(PagerQuery<BaseGoodsSpuQuery> pq) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseGoodsSpuQuery query = pq.getParams();
|
BaseGoodsSpuQuery query = pq.getParams();
|
||||||
QueryWrapper<BaseGoodsSpu> qw = new QueryWrapper<>();
|
QueryWrapper<BaseGoodsSpu> qw = new QueryWrapper<>();
|
||||||
if(StringUtils.isNotBlank(query.getName())){
|
if (StringUtils.isNotBlank(query.getName())) {
|
||||||
qw.like("goodsName",query.getName());
|
qw.like("goodsName", query.getName());
|
||||||
}
|
}
|
||||||
IPage<BaseGoodsSpu> page = PagerUtil.queryToPage(pq);
|
IPage<BaseGoodsSpu> page = PagerUtil.queryToPage(pq);
|
||||||
IPage<BaseGoodsSpuVo> pagging = baseMapper.listPage(page, qw);
|
IPage<BaseGoodsSpuVo> pagging = baseMapper.listPage(page, qw);
|
||||||
@@ -69,37 +90,39 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper,
|
|||||||
// }
|
// }
|
||||||
return rb.success().setData(p);
|
return rb.success().setData(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
public ResultBean<String> saveOrUpdate(BaseGoodsSpuDto dto) {
|
public ResultBean<String> saveOrUpdate(BaseGoodsSpuDto dto) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
String sid = "";
|
String sid = "";
|
||||||
BaseGoodsSpu spun= baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("sid",dto.getSid()));
|
BaseGoodsSpu spun = baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("sid", dto.getSid()));
|
||||||
BaseGoodsUnit baseGoodsUnit=baseGoodsUnitService.getOne(new QueryWrapper<BaseGoodsUnit>().eq("sid",dto.getGoodsUnitSid()));
|
BaseGoodsUnit baseGoodsUnit = baseGoodsUnitService.getOne(new QueryWrapper<BaseGoodsUnit>().eq("sid", dto.getGoodsUnitSid()));
|
||||||
if(null!=baseGoodsUnit){
|
if (null != baseGoodsUnit) {
|
||||||
dto.setGoodsUnitName(baseGoodsUnit.getUnitName());
|
dto.setGoodsUnitName(baseGoodsUnit.getUnitName());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spun!=null) {
|
if (spun != null) {
|
||||||
if(!spun.getSid().equals(dto.getSid())){
|
if (!spun.getSid().equals(dto.getSid())) {
|
||||||
return rb.setMsg("商品编码重复");
|
return rb.setMsg("商品编码重复");
|
||||||
}
|
}
|
||||||
sid = dto.getSid();
|
sid = dto.getSid();
|
||||||
BaseGoodsSpu wmsGoods = fetchBySid(dto.getSid());
|
BaseGoodsSpu wmsGoods = fetchBySid(dto.getSid());
|
||||||
BeanUtil.copyProperties(dto, wmsGoods);
|
BeanUtil.copyProperties(dto, wmsGoods);
|
||||||
wmsGoods.setModifyTime(new Date());
|
wmsGoods.setModifyTime(new Date());
|
||||||
wmsGoods.setGoodsPY(PinYinUtils.getPinYinName(wmsGoods.getGoodsName()));;
|
wmsGoods.setGoodsPY(PinYinUtils.getPinYinName(wmsGoods.getGoodsName()));
|
||||||
|
;
|
||||||
baseMapper.updateById(wmsGoods);
|
baseMapper.updateById(wmsGoods);
|
||||||
//spu详情
|
//spu详情
|
||||||
dto.getBaseGoodsSpuDetail().setGoodSpuSid(wmsGoods.getSid());
|
dto.getBaseGoodsSpuDetail().setGoodSpuSid(wmsGoods.getSid());
|
||||||
baseGoodsSpuDetailService.saveOrUpdate(dto.getBaseGoodsSpuDetail());
|
baseGoodsSpuDetailService.saveOrUpdate(dto.getBaseGoodsSpuDetail());
|
||||||
//商品sku
|
//商品sku
|
||||||
dto.getBaseGoodsSkus().forEach(s->{
|
dto.getBaseGoodsSkus().forEach(s -> {
|
||||||
s.setGoodsSpuSid(wmsGoods.getSid());
|
s.setGoodsSpuSid(wmsGoods.getSid());
|
||||||
});
|
});
|
||||||
baseGoodsSkuService.saveOrUpdate(dto.getBaseGoodsSkus());
|
baseGoodsSkuService.saveOrUpdate(dto.getBaseGoodsSkus());
|
||||||
} else {
|
} else {
|
||||||
BaseGoodsSpu spu=baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("goodsCode",dto.getGoodsCode()));
|
BaseGoodsSpu spu = baseMapper.selectOne(new QueryWrapper<BaseGoodsSpu>().eq("goodsCode", dto.getGoodsCode()));
|
||||||
if(spu!=null){
|
if (spu != null) {
|
||||||
return rb.setMsg("商品编码重复");
|
return rb.setMsg("商品编码重复");
|
||||||
}
|
}
|
||||||
BaseGoodsSpu wmsGoods = new BaseGoodsSpu();
|
BaseGoodsSpu wmsGoods = new BaseGoodsSpu();
|
||||||
@@ -111,7 +134,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper,
|
|||||||
dto.getBaseGoodsSpuDetail().setGoodSpuSid(wmsGoods.getSid());
|
dto.getBaseGoodsSpuDetail().setGoodSpuSid(wmsGoods.getSid());
|
||||||
baseGoodsSpuDetailService.saveOrUpdate(dto.getBaseGoodsSpuDetail());
|
baseGoodsSpuDetailService.saveOrUpdate(dto.getBaseGoodsSpuDetail());
|
||||||
//商品sku
|
//商品sku
|
||||||
dto.getBaseGoodsSkus().forEach(s->{
|
dto.getBaseGoodsSkus().forEach(s -> {
|
||||||
s.setGoodsSpuSid(wmsGoods.getSid());
|
s.setGoodsSpuSid(wmsGoods.getSid());
|
||||||
});
|
});
|
||||||
baseGoodsSkuService.saveOrUpdate(dto.getBaseGoodsSkus());
|
baseGoodsSkuService.saveOrUpdate(dto.getBaseGoodsSkus());
|
||||||
@@ -119,19 +142,38 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper,
|
|||||||
return rb.success().setMsg("成功");
|
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) {
|
public ResultBean<BaseGoodsSpuVo> initialization(String sid) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseGoodsSpuVo vo = baseMapper.initialization(sid);
|
BaseGoodsSpuVo vo = baseMapper.initialization(sid);
|
||||||
BaseGoodsSpuDetailVo vo1=baseGoodsSpuDetailService.getSpuDetailsBySpuSid(vo.getSid()).getData();
|
BaseGoodsSpuDetailVo vo1 = baseGoodsSpuDetailService.getSpuDetailsBySpuSid(vo.getSid()).getData();
|
||||||
vo.setBaseGoodsSpuDetail(vo1);
|
vo.setBaseGoodsSpuDetail(vo1);
|
||||||
List<BaseGoodsSkuVo> vos=baseGoodsSkuService.getSkusBySpuSid(vo.getSid()).getData();
|
List<BaseGoodsSkuVo> vos = baseGoodsSkuService.getSkusBySpuSid(vo.getSid()).getData();
|
||||||
for (BaseGoodsSkuVo baseGoodsSkuVo : vos) {
|
for (BaseGoodsSkuVo baseGoodsSkuVo : vos) {
|
||||||
List<UrlsVo> ur=new ArrayList<>();
|
List<UrlsVo> ur = new ArrayList<>();
|
||||||
BaseGoodsSkuExtendVo vo2=baseGoodsSkuExtendService.getExtendBySkuSid(baseGoodsSkuVo.getSid()).getData();
|
BaseGoodsSkuExtendVo vo2 = baseGoodsSkuExtendService.getExtendBySkuSid(baseGoodsSkuVo.getSid()).getData();
|
||||||
if(StringUtils.isNotBlank(vo2.getPicUrl())){
|
if (StringUtils.isNotBlank(vo2.getPicUrl())) {
|
||||||
for (String url : vo2.getPicUrl().split(",")) {
|
for (String url : vo2.getPicUrl().split(",")) {
|
||||||
url=fileUploadComponent.getUrlPrefix()+url;
|
url = fileUploadComponent.getUrlPrefix() + url;
|
||||||
UrlsVo vo3=new UrlsVo();vo3.setUrl(url);
|
UrlsVo vo3 = new UrlsVo();
|
||||||
|
vo3.setUrl(url);
|
||||||
ur.add(vo3);
|
ur.add(vo3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -143,7 +185,6 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public ResultBean delete(String sid) {
|
public ResultBean delete(String sid) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseGoodsSpu wmsGoods = fetchBySid(sid);
|
BaseGoodsSpu wmsGoods = fetchBySid(sid);
|
||||||
@@ -153,7 +194,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper,
|
|||||||
return rb.success();
|
return rb.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ResultBean updateIsEnable(String sid,String isEnable) {
|
public ResultBean updateIsEnable(String sid, String isEnable) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseGoodsSpu wmsGoods = fetchBySid(sid);
|
BaseGoodsSpu wmsGoods = fetchBySid(sid);
|
||||||
if (null != wmsGoods) {
|
if (null != wmsGoods) {
|
||||||
@@ -162,4 +203,241 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper,
|
|||||||
}
|
}
|
||||||
return rb.success().setMsg("成功");
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import cn.hutool.core.date.DateTime;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.yxt.goods.biz.base.basebrandinfo.BaseBrandInfoService;
|
import com.yxt.goods.biz.base.basebrandinfo.BaseBrandInfoService;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpu;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsspu.BaseGoodsSpuDto;
|
||||||
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsTypeService;
|
import com.yxt.goods.biz.base.basegoodstype.BaseGoodsTypeService;
|
||||||
import com.yxt.goods.biz.base.basemanufacturer.BaseManufacturerService;
|
import com.yxt.goods.biz.base.basemanufacturer.BaseManufacturerService;
|
||||||
import com.yxt.common.base.config.component.FileUploadComponent;
|
import com.yxt.common.base.config.component.FileUploadComponent;
|
||||||
@@ -16,9 +18,12 @@ import com.yxt.common.core.result.ResultBean;
|
|||||||
import com.yxt.common.core.vo.PagerVo;
|
import com.yxt.common.core.vo.PagerVo;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author wangpengfei
|
* @author wangpengfei
|
||||||
@@ -68,7 +73,19 @@ public class BaseGoodsSpuDetailService extends MybatisBaseService<BaseGoodsSpuDe
|
|||||||
}
|
}
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
@Transactional
|
||||||
|
public ResultBean<String> batchSave(List<BaseGoodsSpuDto> dtos) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
List<BaseGoodsSpuDetail> spus = new ArrayList<>();
|
||||||
|
for (BaseGoodsSpuDto dto : dtos) {
|
||||||
|
BaseGoodsSpuDetail detail = new BaseGoodsSpuDetail();
|
||||||
|
BeanUtil.copyProperties(dto.getBaseGoodsSpuDetail(), detail, "id");
|
||||||
|
detail.setCreateTime(new DateTime());
|
||||||
|
spus.add(detail);
|
||||||
|
}
|
||||||
|
this.saveBatch(spus);
|
||||||
|
return rb.success().setMsg("成功");
|
||||||
|
}
|
||||||
public ResultBean<BaseGoodsSpuDetailVo> initialization(String sid) {
|
public ResultBean<BaseGoodsSpuDetailVo> initialization(String sid) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseGoodsSpuDetailVo vo = new BaseGoodsSpuDetailVo();
|
BaseGoodsSpuDetailVo vo = new BaseGoodsSpuDetailVo();
|
||||||
@@ -77,6 +94,18 @@ public class BaseGoodsSpuDetailService extends MybatisBaseService<BaseGoodsSpuDe
|
|||||||
BeanUtil.copyProperties(wmsGoods, vo);
|
BeanUtil.copyProperties(wmsGoods, vo);
|
||||||
return rb.success().setData(vo);
|
return rb.success().setData(vo);
|
||||||
}
|
}
|
||||||
|
public ResultBean<String> importSave(BaseGoodsSpuDetailDto dto) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
// BaseGoodsSpuDetail detail=baseMapper.selectOne(new QueryWrapper<BaseGoodsSpuDetail>().eq("sid",dto.getSid()));
|
||||||
|
String sid = "";
|
||||||
|
BaseGoodsSpuDetail baseGoodsSpuDetail = new BaseGoodsSpuDetail();
|
||||||
|
sid = baseGoodsSpuDetail.getSid();
|
||||||
|
BeanUtil.copyProperties(dto, baseGoodsSpuDetail,"id","sid");
|
||||||
|
baseGoodsSpuDetail.setCreateTime(new DateTime());
|
||||||
|
baseMapper.insert(baseGoodsSpuDetail);
|
||||||
|
return rb.success().setMsg("成功");
|
||||||
|
}
|
||||||
|
|
||||||
public ResultBean<BaseGoodsSpuDetailVo> getSpuDetailsBySpuSid(String sid) {
|
public ResultBean<BaseGoodsSpuDetailVo> getSpuDetailsBySpuSid(String sid) {
|
||||||
ResultBean rb = ResultBean.fireFail();
|
ResultBean rb = ResultBean.fireFail();
|
||||||
BaseGoodsSpuDetailVo vo = baseMapper.getSpuDetailsBySpuSid(sid);
|
BaseGoodsSpuDetailVo vo = baseMapper.getSpuDetailsBySpuSid(sid);
|
||||||
|
|||||||
@@ -117,4 +117,10 @@ public class BaseGoodsTypeService extends MybatisBaseService<BaseGoodsTypeMapper
|
|||||||
}
|
}
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
public ResultBean<BaseGoodsType> getTypeByName(String name) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
BaseGoodsType type=baseMapper.selectOne(new QueryWrapper<BaseGoodsType>().eq("goodsTypeName",name));
|
||||||
|
return rb.success().setData(type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.yxt.common.base.utils.StringUtils;
|
|||||||
import com.yxt.common.core.query.PagerQuery;
|
import com.yxt.common.core.query.PagerQuery;
|
||||||
import com.yxt.common.core.result.ResultBean;
|
import com.yxt.common.core.result.ResultBean;
|
||||||
import com.yxt.common.core.vo.PagerVo;
|
import com.yxt.common.core.vo.PagerVo;
|
||||||
|
import com.yxt.goods.biz.base.basebrandinfo.BaseBrandInfo;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -104,4 +105,9 @@ public class BaseGoodsUnitService extends MybatisBaseService<BaseGoodsUnitMapper
|
|||||||
}
|
}
|
||||||
return rb.success().setMsg("成功");
|
return rb.success().setMsg("成功");
|
||||||
}
|
}
|
||||||
|
public ResultBean<BaseGoodsUnit> getUnitByName(String name) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
BaseGoodsUnit type=baseMapper.selectOne(new QueryWrapper<BaseGoodsUnit>().eq("unitName",name));
|
||||||
|
return rb.success().setData(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import com.yxt.common.base.utils.StringUtils;
|
|||||||
import com.yxt.common.core.query.PagerQuery;
|
import com.yxt.common.core.query.PagerQuery;
|
||||||
import com.yxt.common.core.result.ResultBean;
|
import com.yxt.common.core.result.ResultBean;
|
||||||
import com.yxt.common.core.vo.PagerVo;
|
import com.yxt.common.core.vo.PagerVo;
|
||||||
|
import com.yxt.goods.biz.base.basegoodsunit.BaseGoodsUnit;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
@@ -108,4 +109,9 @@ public class BaseManufacturerService extends MybatisBaseService<BaseManufacturer
|
|||||||
List<BaseManufacturerVo> list = baseMapper.getAllTypeByUseOrgSid(useOrgSid);
|
List<BaseManufacturerVo> list = baseMapper.getAllTypeByUseOrgSid(useOrgSid);
|
||||||
return rb.success().setData(list);
|
return rb.success().setData(list);
|
||||||
}
|
}
|
||||||
|
public ResultBean<BaseManufacturer> getManufacturerByName(String name) {
|
||||||
|
ResultBean rb = ResultBean.fireFail();
|
||||||
|
BaseManufacturer type=baseMapper.selectOne(new QueryWrapper<BaseManufacturer>().eq("manufacturerName",name));
|
||||||
|
return rb.success().setData(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
170
src/main/java/com/yxt/goods/utils/ExcelUtil.java
Normal file
170
src/main/java/com/yxt/goods/utils/ExcelUtil.java
Normal file
@@ -0,0 +1,170 @@
|
|||||||
|
package com.yxt.goods.utils;
|
||||||
|
|
||||||
|
|
||||||
|
//import org.apache.log4j.Logger;
|
||||||
|
import com.yxt.common.core.result.ResultBean;
|
||||||
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
|
import org.apache.poi.ss.usermodel.Sheet;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.apache.poi.ss.usermodel.CellType.NUMERIC;
|
||||||
|
import static org.apache.poi.ss.usermodel.CellType.STRING;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author wangpengfei
|
||||||
|
* @date 2024/4/23 13:53
|
||||||
|
*/
|
||||||
|
public class ExcelUtil {
|
||||||
|
// private static Logger logger = Logger.getLogger(ExcelUtil.class);
|
||||||
|
private final static String xls = "xls";
|
||||||
|
private final static String xlsx = "xlsx";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 读入excel文件,解析后返回
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static List<String[]> readExcel(MultipartFile file) throws IOException {
|
||||||
|
//检查文件
|
||||||
|
checkFile(file);
|
||||||
|
//获得Workbook工作薄对象
|
||||||
|
Workbook workbook = getWorkBook(file);
|
||||||
|
//创建返回对象,把每行中的值作为一个数组,所有行作为一个集合返回
|
||||||
|
List<String[]> list = new ArrayList<String[]>();
|
||||||
|
if (workbook != null) {
|
||||||
|
for (int sheetNum = 0; sheetNum < workbook.getNumberOfSheets(); sheetNum++) {
|
||||||
|
//获得当前sheet工作表
|
||||||
|
Sheet sheet = workbook.getSheetAt(sheetNum);
|
||||||
|
if (sheet == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//获得当前sheet的开始行
|
||||||
|
int firstRowNum = sheet.getFirstRowNum();
|
||||||
|
//获得当前sheet的结束行
|
||||||
|
int lastRowNum = sheet.getLastRowNum();
|
||||||
|
int arrLength = sheet.getRow(firstRowNum).getPhysicalNumberOfCells();
|
||||||
|
//循环除了第一行的所有行
|
||||||
|
for (int rowNum = firstRowNum + 1; rowNum <= lastRowNum; rowNum++) {
|
||||||
|
//获得当前行
|
||||||
|
Row row = sheet.getRow(rowNum);
|
||||||
|
if (row == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
//获得当前行的开始列
|
||||||
|
int firstCellNum = row.getFirstCellNum();
|
||||||
|
//获得当前行的列数
|
||||||
|
int lastCellNum = row.getPhysicalNumberOfCells();
|
||||||
|
String[] cells = new String[arrLength];
|
||||||
|
//循环当前行
|
||||||
|
for(int i =0 ;i<arrLength;i++){ Cell cell = row.getCell(i);cells[i] = getCellValue(cell); }
|
||||||
|
list.add(cells);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
workbook.close();
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查文件
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public static void checkFile(MultipartFile file) throws IOException {
|
||||||
|
ResultBean rb=new ResultBean().fail();
|
||||||
|
//判断文件是否存在
|
||||||
|
if (null == file) {
|
||||||
|
throw new FileNotFoundException("文件不存在!");
|
||||||
|
}
|
||||||
|
//获得文件名
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
//判断文件是否是excel文件
|
||||||
|
if (!fileName.endsWith(xls) && !fileName.endsWith(xlsx)) {
|
||||||
|
// logger.error(fileName + "不是excel文件");
|
||||||
|
throw new IOException(fileName + "不是excel文件");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回工作簿
|
||||||
|
*
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static Workbook getWorkBook(MultipartFile file) {
|
||||||
|
//获得文件名
|
||||||
|
String fileName = file.getOriginalFilename();
|
||||||
|
//创建Workbook工作薄对象,表示整个excel
|
||||||
|
Workbook workbook = null;
|
||||||
|
try {
|
||||||
|
//获取excel文件的io流
|
||||||
|
InputStream is = file.getInputStream();
|
||||||
|
//根据文件后缀名不同(xls和xlsx)获得不同的Workbook实现类对象
|
||||||
|
if (fileName.endsWith(xls)) {
|
||||||
|
//2003
|
||||||
|
workbook = new HSSFWorkbook(is);
|
||||||
|
} else if (fileName.endsWith(xlsx)) {
|
||||||
|
//2007
|
||||||
|
workbook = new XSSFWorkbook(is);
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
// logger.info(e.getMessage());
|
||||||
|
}
|
||||||
|
return workbook;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理单元格样式 获取数据
|
||||||
|
*
|
||||||
|
* @param cell
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public static String getCellValue(Cell cell) {
|
||||||
|
String cellValue = "";
|
||||||
|
if (cell == null) {
|
||||||
|
return cellValue;
|
||||||
|
}
|
||||||
|
//把数字当成String来读,避免出现1读成1.0的情况
|
||||||
|
if (cell.getCellType() == NUMERIC) {
|
||||||
|
cell.setCellType(STRING);
|
||||||
|
}
|
||||||
|
//判断数据的类型
|
||||||
|
switch (cell.getCellType()) {
|
||||||
|
case NUMERIC: //数字
|
||||||
|
cellValue = String.valueOf(cell.getNumericCellValue());
|
||||||
|
break;
|
||||||
|
case STRING: //字符串
|
||||||
|
cellValue = String.valueOf(cell.getStringCellValue());
|
||||||
|
break;
|
||||||
|
case BOOLEAN: //Boolean
|
||||||
|
cellValue = String.valueOf(cell.getBooleanCellValue());
|
||||||
|
break;
|
||||||
|
case FORMULA: //公式
|
||||||
|
cellValue = String.valueOf(cell.getCellFormula());
|
||||||
|
break;
|
||||||
|
case BLANK: //空值
|
||||||
|
cellValue = "";
|
||||||
|
break;
|
||||||
|
case ERROR: //故障
|
||||||
|
cellValue = "非法字符";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
cellValue = "未知类型";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return cellValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user