|
|
@ -5,6 +5,7 @@ import cn.hutool.core.date.DateTime; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.yxt.base.biz.base.basebrandinfo.BaseBrandInfo; |
|
|
|
import com.yxt.base.biz.base.basebrandinfo.BaseBrandInfoDto; |
|
|
|
import com.yxt.base.biz.base.basebrandinfo.BaseBrandInfoService; |
|
|
|
import com.yxt.base.biz.base.basegoodssku.BaseGoodsSku; |
|
|
|
import com.yxt.base.biz.base.basegoodssku.BaseGoodsSkuService; |
|
|
@ -16,11 +17,16 @@ import com.yxt.base.biz.base.basegoodsskuextend.UrlsVo; |
|
|
|
import com.yxt.base.biz.base.basegoodsspudetail.BaseGoodsSpuDetailService; |
|
|
|
import com.yxt.base.biz.base.basegoodsspudetail.BaseGoodsSpuDetailVo; |
|
|
|
import com.yxt.base.biz.base.basegoodstype.BaseGoodsType; |
|
|
|
import com.yxt.base.biz.base.basegoodstype.BaseGoodsTypeDto; |
|
|
|
import com.yxt.base.biz.base.basegoodstype.BaseGoodsTypeService; |
|
|
|
import com.yxt.base.biz.base.basegoodsunit.BaseGoodsUnit; |
|
|
|
import com.yxt.base.biz.base.basegoodsunit.BaseGoodsUnitDto; |
|
|
|
import com.yxt.base.biz.base.basegoodsunit.BaseGoodsUnitService; |
|
|
|
import com.yxt.base.biz.base.basemanufacturer.BaseManufacturer; |
|
|
|
import com.yxt.base.biz.base.basemanufacturer.BaseManufacturerDto; |
|
|
|
import com.yxt.base.biz.base.basemanufacturer.BaseManufacturerService; |
|
|
|
import com.yxt.base.feign.portal.dictcommonfeign.DictCommonFeign; |
|
|
|
import com.yxt.base.feign.portal.dictcommonfeign.DictCommonVo; |
|
|
|
import com.yxt.base.feign.portal.privilege.PrivilegeQuery; |
|
|
|
import com.yxt.base.feign.portal.sysorganization.SysOrganizationFeign; |
|
|
|
import com.yxt.base.feign.portal.sysorganization.SysOrganizationVo; |
|
|
@ -80,6 +86,8 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
private BaseManufacturerService baseManufacturerService; |
|
|
|
@Autowired |
|
|
|
private SysUserFeign sysUserFeign; |
|
|
|
@Autowired |
|
|
|
private DictCommonFeign dictCommonFeign; |
|
|
|
|
|
|
|
public ResultBean<PagerVo<BaseGoodsSpuVo>> listPage(PagerQuery<BaseGoodsSpuQuery> pq) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
@ -317,7 +325,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
BeanUtil.copyProperties(dto, wmsGoods, "id", "sid"); |
|
|
|
wmsGoods.setModifyTime(new Date()); |
|
|
|
wmsGoods.setGoodsPY(PinYinUtils.sx(wmsGoods.getGoodsName())); |
|
|
|
BaseGoodsSpu spu = baseMapper.checkForUpdate(dto.getGoodsCode(), wmsGoods.getUseOrgSid(), sid); |
|
|
|
BaseGoodsSpu spu = baseMapper.checkForUpdate(dto.getGoodsCode(),dto.getManufacturerSid(), wmsGoods.getUseOrgSid(), sid); |
|
|
|
if (spu != null) { |
|
|
|
return rb.setMsg("商品编码重复"); |
|
|
|
} |
|
|
@ -444,7 +452,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
wmsGoods.setUseOrgSid(dto.getUseOrgSid()); |
|
|
|
wmsGoods.setCreateOrgSid(dto.getCreateOrgSid()); |
|
|
|
wmsGoods.setGoodsPY(PinYinUtils.sx(wmsGoods.getGoodsName())); |
|
|
|
BaseGoodsSpu spu = baseMapper.checkForInsert(dto.getGoodsCode(), dto.getUseOrgSid()); |
|
|
|
BaseGoodsSpu spu = baseMapper.checkForInsert(dto.getGoodsCode(),dto.getManufacturerSid(), dto.getUseOrgSid()); |
|
|
|
if (spu != null) { |
|
|
|
return rb.setMsg("商品编码重复"); |
|
|
|
} |
|
|
@ -654,15 +662,20 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
|
|
|
|
public ResultBean importGoodsSpuData(MultipartFile file, String orgPath, String userSid, HttpServletRequest request) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String useOrgSid = "";//部门sid
|
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
if (split.size() > 1) { |
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
useOrgSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
useOrgSid = sysOrganization.getSid(); |
|
|
|
String useOrgSid = ""; |
|
|
|
String createOrgSid = ""; |
|
|
|
if (StringUtils.isNotBlank(orgPath)) { |
|
|
|
List<String> split = Arrays.asList(orgPath.split("/")); |
|
|
|
if (split.size() > 1) { |
|
|
|
//获取本级sid获取本级部门信息
|
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(split.size() - 2)).getData(); |
|
|
|
SysOrganizationVo sysOrganization1 = sysOrganizationFeign.fetchBySid(split.get(split.size() - 1)).getData(); |
|
|
|
useOrgSid = sysOrganization1.getSid(); |
|
|
|
} else { |
|
|
|
SysOrganizationVo sysOrganization = sysOrganizationFeign.fetchBySid(split.get(0)).getData(); |
|
|
|
useOrgSid = sysOrganization.getSid(); |
|
|
|
} |
|
|
|
createOrgSid = sysStaffOrgFeign.getOrgSidByPath(orgPath).getData(); |
|
|
|
} |
|
|
|
|
|
|
|
int size = 0; |
|
|
@ -688,15 +701,10 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
wb = new XSSFWorkbook(is); |
|
|
|
} |
|
|
|
Sheet sheet = wb.getSheetAt(0); |
|
|
|
ReturnImportMsg returnMsg = getSleepSheetVal(sheet); |
|
|
|
ReturnImportMsg returnMsg = getSleepSheetVal(sheet, useOrgSid); |
|
|
|
Set<String> setMsg = returnMsg.getSetMsg(); |
|
|
|
StringBuffer sbMsg = new StringBuffer(); |
|
|
|
List<ImportDataVo> list = returnMsg.getList(); |
|
|
|
if (!list.isEmpty() && list.size() > 0) { |
|
|
|
for (ImportDataVo vo : list) { |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (null != setMsg && setMsg.size() > 0) { |
|
|
|
for (String s : setMsg) { |
|
|
|
sbMsg.append(s).append(","); |
|
|
@ -706,6 +714,153 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
return rb.setMsg(sbMsg.toString()); |
|
|
|
} |
|
|
|
} |
|
|
|
if (!list.isEmpty() && list.size() > 0) { |
|
|
|
for (ImportDataVo vo : list) { |
|
|
|
String sortNo = "";//排序号
|
|
|
|
if (StringUtils.isNotBlank(vo.getSortNo())) { |
|
|
|
sortNo = vo.getSortNo(); |
|
|
|
} |
|
|
|
String goodsName = "";//商品名称
|
|
|
|
if (StringUtils.isNotBlank(vo.getGoodsName())) { |
|
|
|
goodsName = vo.getGoodsName(); |
|
|
|
} |
|
|
|
String goodsCode = "";//图号
|
|
|
|
if (StringUtils.isNotBlank(vo.getGoodsCode())) { |
|
|
|
goodsCode = vo.getGoodsCode(); |
|
|
|
} |
|
|
|
String barCode = "";//条码
|
|
|
|
if (StringUtils.isNotBlank(vo.getBarCode())) { |
|
|
|
barCode = vo.getBarCode(); |
|
|
|
} |
|
|
|
String goodsType = "";//商品类别
|
|
|
|
String goodsTypeSid = "";//商品类别
|
|
|
|
if (StringUtils.isNotBlank(vo.getGoodsTypeName())) { |
|
|
|
goodsType = vo.getGoodsTypeName(); |
|
|
|
} |
|
|
|
String brandName = "";//品牌
|
|
|
|
String brandSid = "";//品牌
|
|
|
|
if (StringUtils.isNotBlank(vo.getBrandName())) { |
|
|
|
brandName = vo.getBrandName(); |
|
|
|
} |
|
|
|
String manufacturerName = "";//厂家
|
|
|
|
String manufacturerSid = "";//厂家
|
|
|
|
if (StringUtils.isNotBlank(vo.getManufacturerName())) { |
|
|
|
manufacturerName = vo.getManufacturerName(); |
|
|
|
} |
|
|
|
String guige = "";//规格
|
|
|
|
if (StringUtils.isNotBlank(vo.getIndexes())) { |
|
|
|
guige = vo.getIndexes(); |
|
|
|
} |
|
|
|
String unit = "";//计量单位
|
|
|
|
String unitSid = "";//计量单位
|
|
|
|
if (StringUtils.isNotBlank(vo.getGoodsUnitName())) { |
|
|
|
unit = vo.getGoodsUnitName(); |
|
|
|
} |
|
|
|
String upNum = "";//库存上限
|
|
|
|
if (StringUtils.isNotBlank(vo.getInventoryAlertUpperLimit())) { |
|
|
|
upNum = vo.getInventoryAlertUpperLimit(); |
|
|
|
} |
|
|
|
String lowNum = "";//库存下限
|
|
|
|
if (StringUtils.isNotBlank(vo.getInventoryAlertLowerLimit())) { |
|
|
|
lowNum = vo.getInventoryAlertLowerLimit(); |
|
|
|
} |
|
|
|
String level = "";//商品等级
|
|
|
|
String levelKey = "";//商品等级
|
|
|
|
if (StringUtils.isNotBlank(vo.getGoodsLevelValue())) { |
|
|
|
level = vo.getGoodsLevelValue(); |
|
|
|
levelKey = vo.getGoodsLevelKey(); |
|
|
|
} |
|
|
|
String classType = "";//商品类型
|
|
|
|
String classTypeKey = "";//商品类型
|
|
|
|
if (StringUtils.isNotBlank(vo.getGoodsClassValue())) { |
|
|
|
classType = vo.getGoodsClassValue(); |
|
|
|
classTypeKey = vo.getGoodsClassKey(); |
|
|
|
} |
|
|
|
//判断品牌是否存在
|
|
|
|
if (StringUtils.isNotBlank(brandName)) { |
|
|
|
String brandSelSid = baseMapper.selBrandSid(useOrgSid, brandName); |
|
|
|
if (StringUtils.isNotBlank(brandSelSid)) { |
|
|
|
brandSid = brandSelSid; |
|
|
|
} else { |
|
|
|
String brandCode = PinYinUtils.sx(brandName); |
|
|
|
BaseBrandInfoDto brandInfoDto = new BaseBrandInfoDto(); |
|
|
|
brandInfoDto.setBrandName(brandName); |
|
|
|
brandInfoDto.setBrandCode(brandCode); |
|
|
|
brandInfoDto.setOrgPath(orgPath); |
|
|
|
brandSid = baseBrandInfoService.saveOrUpdate(brandInfoDto).getData(); |
|
|
|
} |
|
|
|
} |
|
|
|
//判断商品类别是否存在
|
|
|
|
if (StringUtils.isNotBlank(goodsType)) { |
|
|
|
String goodsTypeSelSid = baseMapper.selGoodsTypeSid(useOrgSid, goodsType); |
|
|
|
if (StringUtils.isNotBlank(goodsTypeSelSid)) { |
|
|
|
goodsTypeSid = goodsTypeSelSid; |
|
|
|
} else { |
|
|
|
String goodsTypeCode = PinYinUtils.sx(goodsType); |
|
|
|
BaseGoodsTypeDto goodsTypeDto = new BaseGoodsTypeDto(); |
|
|
|
goodsTypeDto.setGoodsTypeName(goodsType); |
|
|
|
goodsTypeDto.setGoodsTypeCode(goodsTypeCode); |
|
|
|
goodsTypeDto.setOrgPath(orgPath); |
|
|
|
goodsTypeDto.setSortNo("1"); |
|
|
|
goodsTypeDto.setOutStockRule("0"); |
|
|
|
goodsTypeDto.setOutStockRuleValue("先进先出"); |
|
|
|
goodsTypeSid = baseGoodsTypeService.saveOrUpdate(goodsTypeDto).getData(); |
|
|
|
} |
|
|
|
} |
|
|
|
//判断厂家是否存在
|
|
|
|
if (StringUtils.isNotBlank(manufacturerName)) { |
|
|
|
String manufacturerSelSid = baseMapper.selManufacturerSid(useOrgSid, manufacturerName); |
|
|
|
if (StringUtils.isNotBlank(manufacturerSelSid)) { |
|
|
|
manufacturerSid = manufacturerSelSid; |
|
|
|
} else { |
|
|
|
String manufactNo = PinYinUtils.sx(manufacturerName); |
|
|
|
BaseManufacturerDto manufacturerDto = new BaseManufacturerDto(); |
|
|
|
manufacturerDto.setManufacturerName(manufacturerName); |
|
|
|
manufacturerDto.setManufacturerCode(manufactNo); |
|
|
|
manufacturerDto.setSortNo("1"); |
|
|
|
manufacturerDto.setOrgPath(orgPath); |
|
|
|
manufacturerSid = baseManufacturerService.saveOrUpdate(manufacturerDto).getData(); |
|
|
|
} |
|
|
|
} |
|
|
|
//判断计量单位是否存在
|
|
|
|
if (StringUtils.isNotBlank(unit)) { |
|
|
|
String unitSelSid = baseMapper.selUnitSid(useOrgSid, unit); |
|
|
|
if (StringUtils.isNotBlank(unitSelSid)) { |
|
|
|
unitSid = unitSelSid; |
|
|
|
} else { |
|
|
|
BaseGoodsUnitDto unitDto = new BaseGoodsUnitDto(); |
|
|
|
unitDto.setUnitName(unit); |
|
|
|
unitDto.setOrgPath(orgPath); |
|
|
|
unitSid = baseGoodsUnitService.saveOrUpdate(unitDto).getData(); |
|
|
|
} |
|
|
|
} |
|
|
|
BaseGoodsDetailsDto dto = new BaseGoodsDetailsDto(); |
|
|
|
dto.setUserSid(userSid); |
|
|
|
dto.setUseOrgSid(useOrgSid); |
|
|
|
dto.setCreateOrgSid(createOrgSid); |
|
|
|
dto.setOrgPath(orgPath); |
|
|
|
dto.setSortNo(sortNo); |
|
|
|
dto.setGoodsName(goodsName); |
|
|
|
dto.setGoodsCode(goodsCode); |
|
|
|
dto.setBarCode(barCode); |
|
|
|
dto.setGoodsTypeSid(goodsTypeSid); |
|
|
|
dto.setGoodsTypeName(goodsType); |
|
|
|
dto.setBrandSid(brandSid); |
|
|
|
dto.setBrandName(brandName); |
|
|
|
dto.setManufacturerSid(manufacturerSid); |
|
|
|
dto.setManufacturerName(manufacturerName); |
|
|
|
dto.setIndexes(guige); |
|
|
|
dto.setGoodsUnitSid(unitSid); |
|
|
|
dto.setGoodsUnitName(unit); |
|
|
|
dto.setInventoryAlertUpperLimit(upNum); |
|
|
|
dto.setInventoryAlertLowerLimit(lowNum); |
|
|
|
dto.setGoodsClassKey(classTypeKey); |
|
|
|
dto.setGoodsClassValue(classType); |
|
|
|
dto.setGoodsLevelKey(levelKey); |
|
|
|
dto.setGoodsLevelValue(level); |
|
|
|
saveOrUpdateGoods(dto); |
|
|
|
} |
|
|
|
} |
|
|
|
size = list.size(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
@ -713,7 +868,7 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
return rb.success().setMsg("成功导入" + size + "条数据"); |
|
|
|
} |
|
|
|
|
|
|
|
private ReturnImportMsg getSleepSheetVal(Sheet sheet) { |
|
|
|
private ReturnImportMsg getSleepSheetVal(Sheet sheet, String useOrgSid) { |
|
|
|
ReturnImportMsg returnMsg = new ReturnImportMsg(); |
|
|
|
List<ImportDataVo> voList = new ArrayList<>(); |
|
|
|
Set<String> setMsg = new HashSet<>(); |
|
|
@ -851,6 +1006,44 @@ public class BaseGoodsSpuService extends MybatisBaseService<BaseGoodsSpuMapper, |
|
|
|
} |
|
|
|
voList.add(info); |
|
|
|
} |
|
|
|
if (!voList.isEmpty()) { |
|
|
|
for (ImportDataVo v : voList) { |
|
|
|
String goodsCode = ""; |
|
|
|
String manufacturerName = ""; |
|
|
|
if (StringUtils.isNotBlank(v.getGoodsCode())) { |
|
|
|
goodsCode = v.getGoodsCode(); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(v.getManufacturerName())) { |
|
|
|
manufacturerName = v.getManufacturerName(); |
|
|
|
} |
|
|
|
int count = baseMapper.selGoodsSidForImport(goodsCode, manufacturerName, useOrgSid); |
|
|
|
if (StringUtils.isNotBlank(goodsCode)) { |
|
|
|
if (count > 0) { |
|
|
|
setMsg.add("图号" + goodsCode + "已存在,请勿重复添加"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(v.getGoodsLevelValue())) { |
|
|
|
String goodsLevelValue = v.getGoodsLevelValue(); |
|
|
|
ResultBean<DictCommonVo> voResultBean = dictCommonFeign.selectByDictTypeAndDictValue("goodsLevel", goodsLevelValue); |
|
|
|
if (voResultBean.getSuccess()) { |
|
|
|
DictCommonVo commonVo = voResultBean.getData(); |
|
|
|
v.setGoodsLevelKey(commonVo.getDictKey()); |
|
|
|
} else { |
|
|
|
setMsg.add("商品等级(" + v.getGoodsLevelValue() + ")不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(v.getGoodsClassValue())) { |
|
|
|
String goodsClassValue = v.getGoodsClassValue(); |
|
|
|
ResultBean<DictCommonVo> voResultBean = dictCommonFeign.selectByDictTypeAndDictValue("goodsClass", goodsClassValue); |
|
|
|
if (voResultBean.getSuccess()) { |
|
|
|
DictCommonVo commonVo = voResultBean.getData(); |
|
|
|
v.setGoodsClassKey(commonVo.getDictKey()); |
|
|
|
} else { |
|
|
|
setMsg.add("商品类型(" + v.getGoodsClassValue() + ")不存在"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
returnMsg.setList(voList); |
|
|
|
returnMsg.setSetMsg(setMsg); |
|
|
|
return returnMsg; |
|
|
|