Commit c95878d0 by zhangxingmin

push

parent 7735a182
......@@ -183,38 +183,40 @@ public class ApiBeneficiaryServiceImpl implements ApiBeneficiaryService {
return Result.success();
}
//获取不为空的受益人信息表唯一业务ID列表
List<String> beneficiaryBizIdList = list.stream()
.filter(dto -> StringUtils.isNotBlank(dto.getBeneficiaryBizId()))
.map(ApiBeneficiaryInfoDto::getBeneficiaryBizId)
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(beneficiaryBizIdList)) {
//入参的受益人业务id列表至少一个不为空就走表数据校验,全部为空是全部新增操作,不走表数据校验
//根据受益人信息表唯一业务ID列表查询表里面的列表信息
List<Beneficiary> beneficiarys = iBeneficiaryService.queryList(BeneficiaryDto.builder()
.beneficiaryBizIdList(beneficiaryBizIdList).build());
//过滤入参的受益人列表信息在表里不存在的集合,然后抛出这些不存在的列表信息
// 提取 existingBeneficiaryBizIds:从 beneficiarys 中获取所有已存在的 beneficiaryBizId 集合
Set<String> existingBeneficiaryBizIds = beneficiarys.stream()
.map(Beneficiary::getBeneficiaryBizId)
.collect(Collectors.toSet());
// 过滤 list:保留 beneficiaryBizId 不在 existingBeneficiaryBizIds 中的对象
List<ApiBeneficiaryInfoDto> filteredList = list.stream()
.filter(dto -> StringUtils.isNotBlank(dto.getBeneficiaryBizId()) && !existingBeneficiaryBizIds.contains(dto.getBeneficiaryBizId()))
.collect(Collectors.toList());
if (!CollectionUtils.isEmpty(filteredList)) {
//入参对象列表中有传值的业务id在库中不存在的对象,提示
List<String> beneficiaryProductNameList = filteredList
.stream()
.map(ApiBeneficiaryInfoDto::getName)
.collect(Collectors.toList());
throw new BusinessException("以下是在库里不存在的受益人数据的名字:"+String.join(" ;",beneficiaryProductNameList));
}
}
// //获取不为空的受益人信息表唯一业务ID列表
// List<String> beneficiaryBizIdList = list.stream()
// .filter(dto -> StringUtils.isNotBlank(dto.getBeneficiaryBizId()))
// .map(ApiBeneficiaryInfoDto::getBeneficiaryBizId)
// .collect(Collectors.toList());
//
// if (!CollectionUtils.isEmpty(beneficiaryBizIdList)) {
// //入参的受益人业务id列表至少一个不为空就走表数据校验,全部为空是全部新增操作,不走表数据校验
//
// //根据受益人信息表唯一业务ID列表查询表里面的列表信息
// List<Beneficiary> beneficiarys = iBeneficiaryService.queryList(BeneficiaryDto.builder()
// .beneficiaryBizIdList(beneficiaryBizIdList).build());
//
// //过滤入参的受益人列表信息在表里不存在的集合,然后抛出这些不存在的列表信息
// // 提取 existingBeneficiaryBizIds:从 beneficiarys 中获取所有已存在的 beneficiaryBizId 集合
// Set<String> existingBeneficiaryBizIds = beneficiarys.stream()
// .map(Beneficiary::getBeneficiaryBizId)
// .collect(Collectors.toSet());
// // 过滤 list:保留 beneficiaryBizId 不在 existingBeneficiaryBizIds 中的对象
// List<ApiBeneficiaryInfoDto> filteredList = list.stream()
// .filter(dto -> StringUtils.isNotBlank(dto.getBeneficiaryBizId()) && !existingBeneficiaryBizIds.contains(dto.getBeneficiaryBizId()))
// .collect(Collectors.toList());
// if (!CollectionUtils.isEmpty(filteredList)) {
// //入参对象列表中有传值的业务id在库中不存在的对象,提示
// List<String> beneficiaryProductNameList = filteredList
// .stream()
// .map(ApiBeneficiaryInfoDto::getName)
// .collect(Collectors.toList());
// throw new BusinessException("以下是在库里不存在的受益人数据的名字:"+String.join(" ;",beneficiaryProductNameList));
// }
// }
//先删后增加
iBeneficiaryService.del(appointmentBizId);
//构造需要新增或者更新数据的对象集合
List<Beneficiary> updateList = list.stream().map(dto -> {
......@@ -228,6 +230,7 @@ public class ApiBeneficiaryServiceImpl implements ApiBeneficiaryService {
}
//地址列表(json串)
beneficiary.setAddressList(CommonUtil.getAddressListJsonStr(dto.getAddressList()));
beneficiary.setId(null);
return beneficiary;
}).collect(Collectors.toList());
......
......@@ -19,4 +19,6 @@ public interface IBeneficiaryService extends IService<Beneficiary> {
List<Beneficiary> queryList(BeneficiaryDto dto);
Beneficiary queryOne(String beneficiaryBizId);
Boolean del(String appointmentBizId);
}
......@@ -48,4 +48,9 @@ public class BeneficiaryServiceImpl extends ServiceImpl<BeneficiaryMapper, Benef
public Beneficiary queryOne(String beneficiaryBizId) {
return this.getOne(new LambdaQueryWrapper<Beneficiary>().eq(Beneficiary::getBeneficiaryBizId,beneficiaryBizId));
}
@Override
public Boolean del(String appointmentBizId) {
return this.remove(new LambdaQueryWrapper<Beneficiary>().eq(Beneficiary::getAppointmentBizId,appointmentBizId));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment