|
|
@@ -36,6 +36,7 @@ import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
+import org.springblade.core.tool.utils.StringUtil;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -429,41 +430,43 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
|
|
|
@Override
|
|
|
public R importGoodsInfo(List<GoodsInfoExcel> data, Boolean isCovered) {
|
|
|
- if(org.springframework.util.CollectionUtils.isEmpty(data))
|
|
|
- {
|
|
|
+ if (org.springframework.util.CollectionUtils.isEmpty(data)) {
|
|
|
throw new SecurityException("导入数据不能为空");
|
|
|
}
|
|
|
- StringBuffer errMsg= new StringBuffer();
|
|
|
+ StringBuffer errMsg = new StringBuffer();
|
|
|
|
|
|
- for(int i=0;i<data.size();i++)
|
|
|
- {
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
GoodsInfoExcel goodsExcel = data.get(i);
|
|
|
String type = goodsExcel.getType();
|
|
|
GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId());
|
|
|
- if(goodsType==null)
|
|
|
- {
|
|
|
- errMsg.append("第"+i+"行未添加分类或者分类不存在,");
|
|
|
+ if (goodsType == null) {
|
|
|
+ errMsg.append("第" + i + "行未添加分类或者分类不存在,");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- data.forEach(e->{
|
|
|
+ data.forEach(e -> {
|
|
|
String type = e.getType();
|
|
|
GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId());
|
|
|
- if(goodsType!=null)
|
|
|
- {
|
|
|
- GoodsDesc goodsDesc=new GoodsDesc();
|
|
|
- BeanUtils.copyProperties(e,goodsDesc);
|
|
|
+ if (goodsType != null) {
|
|
|
+ GoodsDesc goodsDesc = new GoodsDesc();
|
|
|
+ BeanUtils.copyProperties(e, goodsDesc);
|
|
|
|
|
|
R<CorpsDesc> corpByName = corpsDescClient.getCorpByName(e.getCorpName(), AuthUtil.getTenantId());
|
|
|
- if(corpByName.isSuccess()&&corpByName.getData()!=null)
|
|
|
- {
|
|
|
+ if (corpByName.isSuccess() && corpByName.getData() != null) {
|
|
|
goodsDesc.setCorpName(e.getCorpName());
|
|
|
goodsDesc.setCorpId(corpByName.getData().getId());
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
+ } else {
|
|
|
throw new SecurityException("请输入正确的供应商");
|
|
|
}
|
|
|
+ if (StringUtil.isNotBlank(e.getArtsVisionName())) {
|
|
|
+ R<CorpsDesc> company = corpsDescClient.getCorpByName(e.getArtsVisionName(), AuthUtil.getTenantId());
|
|
|
+ if (company.isSuccess() && company.getData() != null) {
|
|
|
+ goodsDesc.setArtsVision(String.valueOf(corpByName.getData().getId()));
|
|
|
+ } else {
|
|
|
+ throw new SecurityException("请输入正确的所属公司");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//获取供应商
|
|
|
goodsDesc.setTypeno(e.getTypeNo());
|
|
|
goodsDesc.setCntrVolumn(e.getCntrVolumn());
|
|
|
@@ -474,30 +477,27 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
goodsDesc.setGoodsTypeId(String.valueOf(goodsType.getId()));
|
|
|
//如果名称相等 就认为重复
|
|
|
LambdaQueryWrapper<GoodsDesc> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.eq(GoodsDesc::getTenantId,AuthUtil.getTenantId());
|
|
|
- queryWrapper.eq(GoodsDesc::getCode,goodsDesc.getCode());
|
|
|
- queryWrapper.eq(GoodsDesc::getIsDeleted,0);
|
|
|
+ queryWrapper.eq(GoodsDesc::getTenantId, AuthUtil.getTenantId());
|
|
|
+ queryWrapper.eq(GoodsDesc::getCode, goodsDesc.getCode());
|
|
|
+ queryWrapper.eq(GoodsDesc::getIsDeleted, 0);
|
|
|
GoodsDesc one = goodsDescMapper.selectOne(queryWrapper);
|
|
|
|
|
|
- if(one==null)
|
|
|
- {
|
|
|
- goodsDesc.setIntegralMultiples(new BigDecimal(StringUtils.isBlank(e.getIntegralMultiples())?"0":e.getIntegralMultiples()));
|
|
|
+ if (one == null) {
|
|
|
+ goodsDesc.setIntegralMultiples(new BigDecimal(StringUtils.isBlank(e.getIntegralMultiples()) ? "0" : e.getIntegralMultiples()));
|
|
|
goodsDesc.setCreateTime(new Date());
|
|
|
goodsDesc.setCreateUser(AuthUtil.getUserId());
|
|
|
goodsDesc.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
goodsDescMapper.insert(goodsDesc);
|
|
|
|
|
|
- GoodsTypeDesc goodsTypeDes=new GoodsTypeDesc();
|
|
|
+ GoodsTypeDesc goodsTypeDes = new GoodsTypeDesc();
|
|
|
goodsTypeDes.setGoodsId(goodsDesc.getId());
|
|
|
goodsTypeDes.setGoodsTypeId(goodsType.getId());
|
|
|
goodsTypeDes.setCreateTime(new Date());
|
|
|
goodsTypeDes.setCreateUser(AuthUtil.getUserId());
|
|
|
goodsTypeDes.setCreateDept(Long.valueOf(AuthUtil.getDeptId()));
|
|
|
goodsTypeDescMapper.insert(goodsTypeDes);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- goodsDesc.setIntegralMultiples(new BigDecimal(StringUtils.isBlank(e.getIntegralMultiples())?"0":e.getIntegralMultiples()));
|
|
|
+ } else {
|
|
|
+ goodsDesc.setIntegralMultiples(new BigDecimal(StringUtils.isBlank(e.getIntegralMultiples()) ? "0" : e.getIntegralMultiples()));
|
|
|
goodsDesc.setId(one.getId());
|
|
|
goodsDesc.setUpdateTime(new Date());
|
|
|
goodsDesc.setUpdateUser(AuthUtil.getUserId());
|