Browse Source

修改导入物料空数据

single_db
caoyizhong 1 year ago
parent
commit
162a859e0f
  1. 26
      blade-service/logpm-basic/src/main/java/com/logpm/basic/service/impl/BasicMaterialServiceImpl.java

26
blade-service/logpm-basic/src/main/java/com/logpm/basic/service/impl/BasicMaterialServiceImpl.java

@ -75,21 +75,25 @@ public class BasicMaterialServiceImpl extends BaseServiceImpl<BasicMaterialMappe
log.info("传入参数>>>>>>>>>>>>>>>>>>>>>>>{}",data);
ArrayList<BasicMaterialEntity> arrayList = new ArrayList<>();
for (BasicMaterialExcel datum : data) {
//去重
List<BasicMaterialEntity> basicMaterialEntities = baseMapper.selectList(new QueryWrapper<BasicMaterialEntity>().lambda()
.eq(BasicMaterialEntity::getProductCode,datum.getProductCode()));
if (!basicMaterialEntities.isEmpty()){
//更新数据,删除老数据
baseMapper.deleteBatchIds(basicMaterialEntities.stream().map(BasicMaterialEntity::getId).collect(Collectors.toList()));
if(ObjectUtils.isNotNull(datum) && ObjectUtils.isNotNull(datum.getProductCode())){
//去重
List<BasicMaterialEntity> basicMaterialEntities = baseMapper.selectList(new QueryWrapper<BasicMaterialEntity>().lambda()
.eq(BasicMaterialEntity::getProductCode,datum.getProductCode()));
if (!basicMaterialEntities.isEmpty()){
//更新数据,删除老数据
baseMapper.deleteBatchIds(basicMaterialEntities.stream().map(BasicMaterialEntity::getId).collect(Collectors.toList()));
}
BasicMaterialEntity copy = BeanUtil.copy(datum, BasicMaterialEntity.class);
assert copy != null;
copy.setHide(1);
arrayList.add(copy);
}
BasicMaterialEntity copy = BeanUtil.copy(datum, BasicMaterialEntity.class);
assert copy != null;
copy.setHide(1);
arrayList.add(copy);
}
// 根据对象的value属性进行去重
List<BasicMaterialEntity> collect = arrayList.stream().collect(Collectors.toMap(BasicMaterialEntity::getProductCode, Function.identity(), (oldValue, newValue) -> oldValue)).values().stream().collect(Collectors.toList());
this.saveBatch(collect);
if(!collect.isEmpty()){
this.saveBatch(collect);
}
}

Loading…
Cancel
Save