|
@@ -321,23 +321,32 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
- @Transactional
|
|
|
|
|
public R importGoods(List<GoodsExcel> data, Boolean isCovered)
|
|
public R importGoods(List<GoodsExcel> data, Boolean isCovered)
|
|
|
{
|
|
{
|
|
|
- try {
|
|
|
|
|
|
|
+
|
|
|
if(org.springframework.util.CollectionUtils.isEmpty(data))
|
|
if(org.springframework.util.CollectionUtils.isEmpty(data))
|
|
|
{
|
|
{
|
|
|
throw new SecurityException("导入数据不能为空");
|
|
throw new SecurityException("导入数据不能为空");
|
|
|
}
|
|
}
|
|
|
- //统计正确数据行数
|
|
|
|
|
- List<Boolean> countList=new ArrayList<>();
|
|
|
|
|
|
|
+ StringBuffer errMsg= new StringBuffer();
|
|
|
|
|
+
|
|
|
|
|
+ for(int i=0;i<data.size();i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ GoodsExcel goodsExcel = data.get(i);
|
|
|
|
|
+ String type = goodsExcel.getType();
|
|
|
|
|
+ GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId());
|
|
|
|
|
+ if(goodsType==null)
|
|
|
|
|
+ {
|
|
|
|
|
+ errMsg.append("第"+i+"行未添加分类或者分类不存在,");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
data.forEach(e->{
|
|
data.forEach(e->{
|
|
|
String type = e.getType();
|
|
String type = e.getType();
|
|
|
GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId());
|
|
GoodsType goodsType = goodsTypeMapper.selectGoodsTypeCname(type, AuthUtil.getTenantId());
|
|
|
if(goodsType!=null)
|
|
if(goodsType!=null)
|
|
|
{
|
|
{
|
|
|
- countList.add(true);
|
|
|
|
|
GoodsDesc goodsDesc=new GoodsDesc();
|
|
GoodsDesc goodsDesc=new GoodsDesc();
|
|
|
goodsDesc.setCode(e.getCode());
|
|
goodsDesc.setCode(e.getCode());
|
|
|
goodsDesc.setCname(e.getCname());
|
|
goodsDesc.setCname(e.getCname());
|
|
@@ -390,10 +399,10 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
}
|
|
}
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
- countList.add(false);
|
|
|
|
|
|
|
+
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- List<Boolean> booleanList = countList.stream().filter(e -> e == true).collect(Collectors.toList());
|
|
|
|
|
|
|
+ /* List<Boolean> booleanList = countList.stream().filter(e -> e == true).collect(Collectors.toList());
|
|
|
if(data.size()>booleanList.size())
|
|
if(data.size()>booleanList.size())
|
|
|
{
|
|
{
|
|
|
return R.fail("导入中的数据,分类字段不存在或者未填分类字段");
|
|
return R.fail("导入中的数据,分类字段不存在或者未填分类字段");
|
|
@@ -405,13 +414,9 @@ public class GoodsDescServiceImpl extends ServiceImpl<GoodsDescMapper, GoodsDesc
|
|
|
else
|
|
else
|
|
|
{
|
|
{
|
|
|
throw new SecurityException("导入失败,请仔细检查导入数据");
|
|
throw new SecurityException("导入失败,请仔细检查导入数据");
|
|
|
- }
|
|
|
|
|
|
|
+ }*/
|
|
|
|
|
+ return R.success("ok");
|
|
|
|
|
|
|
|
- }
|
|
|
|
|
- catch (Exception e)
|
|
|
|
|
- {
|
|
|
|
|
- throw new SecurityException("导入失败,请仔细检查导入数据");
|
|
|
|
|
- }
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|