commit
This commit is contained in:
parent
13447953cb
commit
0366142229
|
|
@ -151,6 +151,7 @@ public class ConPurchaseServiceImpl implements IConPurchaseService {
|
|||
.collect(Collectors.groupingBy(ConPurchaseImportVO::getContractNumber));
|
||||
List<ConPurchaseImportVO> res = new ArrayList<>();
|
||||
// 遍历每个合同分组
|
||||
List<ConPurchaseBo> purchaseBoList = new ArrayList<>();
|
||||
for (Map.Entry<String, List<ConPurchaseImportVO>> entry : mapByContractNumber.entrySet()) {
|
||||
String contractNumber = entry.getKey();
|
||||
List<ConPurchaseImportVO> rows = entry.getValue();
|
||||
|
|
@ -236,31 +237,33 @@ public class ConPurchaseServiceImpl implements IConPurchaseService {
|
|||
return mediaBo;
|
||||
}).collect(Collectors.toList());
|
||||
purchaseBo.setPurchaseMediaBoList(mediaBoList);
|
||||
|
||||
this.insertByBo(purchaseBo);
|
||||
|
||||
purchaseBoList.add(purchaseBo);
|
||||
} else {
|
||||
// 合同已存在 -> 调用 updateByBo 追加媒体信息
|
||||
ConPurchaseVo existingVo = this.queryById(existingContract.getId());
|
||||
ConPurchaseBo purchaseBo = BeanUtil.toBean(existingVo, ConPurchaseBo.class);
|
||||
|
||||
// 获取已有的媒体信息
|
||||
List<ConPurchaseMediaBo> existingMedia = purchaseBo.getPurchaseMediaBoList();
|
||||
if (existingMedia == null) {
|
||||
existingMedia = new ArrayList<>();
|
||||
}
|
||||
|
||||
// 创建并添加本次导入的新媒体信息
|
||||
List<ConPurchaseMediaBo> newMediaList = rows.stream().map(row -> {
|
||||
ConPurchaseMediaBo mediaBo = new ConPurchaseMediaBo();
|
||||
this.mapRowToMediaBo(row, mediaBo);
|
||||
return mediaBo;
|
||||
}).collect(Collectors.toList());
|
||||
existingMedia.addAll(newMediaList);
|
||||
purchaseBo.setPurchaseMediaBoList(existingMedia);
|
||||
|
||||
this.updateByBo(purchaseBo);
|
||||
firstRow.setState("0" );
|
||||
firstRow.setNotes("合同已存在" );
|
||||
res.add(firstRow);
|
||||
return R.fail(res);
|
||||
// // 合同已存在 -> 调用 updateByBo 追加媒体信息
|
||||
// ConPurchaseVo existingVo = this.queryById(existingContract.getId());
|
||||
// ConPurchaseBo purchaseBo = BeanUtil.toBean(existingVo, ConPurchaseBo.class);
|
||||
//
|
||||
// // 获取已有的媒体信息
|
||||
// List<ConPurchaseMediaBo> existingMedia = purchaseBo.getPurchaseMediaBoList();
|
||||
// if (existingMedia == null) {
|
||||
// existingMedia = new ArrayList<>();
|
||||
// }
|
||||
//
|
||||
// // 创建并添加本次导入的新媒体信息
|
||||
// List<ConPurchaseMediaBo> newMediaList = rows.stream().map(row -> {
|
||||
// ConPurchaseMediaBo mediaBo = new ConPurchaseMediaBo();
|
||||
// this.mapRowToMediaBo(row, mediaBo);
|
||||
// return mediaBo;
|
||||
// }).collect(Collectors.toList());
|
||||
// existingMedia.addAll(newMediaList);
|
||||
// purchaseBo.setPurchaseMediaBoList(existingMedia);
|
||||
// this.updateByBo(purchaseBo);
|
||||
}
|
||||
purchaseBoList.forEach(this::insertByBo);
|
||||
}
|
||||
return R.ok(res);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user