|
|
@@ -1495,32 +1495,43 @@ public class ProjectLibManage { |
|
|
|
return res; |
|
|
|
} |
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public synchronized void bindSystemToBid(BindSystemToBidReq req) { |
|
|
|
List<ProjectGovSystemReplaceInfos> replaceInfos = systemReplaceInfosService.listByIds(req.getSystemReplaceInfoIds()); |
|
|
|
if (replaceInfos.isEmpty()) { |
|
|
|
throw ReturnException.wrap("系统替换信息不存在"); |
|
|
|
Wrapper<ProjectGovSystemReplaceInfos> query = Wrappers.lambdaQuery(ProjectGovSystemReplaceInfos.class) |
|
|
|
.in(CollUtil.isNotEmpty(req.getSystemReplaceInfoIds()), |
|
|
|
ProjectGovSystemReplaceInfos::getId, req.getSystemReplaceInfoIds()) |
|
|
|
.or(q -> q.eq(ProjectGovSystemReplaceInfos::getBidId, req.getBidId())); |
|
|
|
List<ProjectGovSystemReplaceInfos> replaceInfos = systemReplaceInfosService.list(query); |
|
|
|
if (CollUtil.isNotEmpty(req.getSystemReplaceInfoIds()) && CollUtil.isEmpty(replaceInfos)) { |
|
|
|
throw ReturnException.wrap("未找到相关数据"); |
|
|
|
} |
|
|
|
replaceInfos.removeIf(w -> req.getBidId().equals(w.getBidId())); |
|
|
|
if (!replaceInfos.isEmpty()) { |
|
|
|
replaceInfos.forEach(w -> { |
|
|
|
if (w.getBidId() != null) { |
|
|
|
throw ReturnException.wrap("已关联其他标项"); |
|
|
|
} |
|
|
|
w.setBidId(req.getBidId()); |
|
|
|
}); |
|
|
|
systemReplaceInfosService.updateBatchById(replaceInfos); |
|
|
|
if (CollUtil.contains(replaceInfos, w -> w.getBidId() != null && !w.getBidId().equals(req.getBidId()))) { |
|
|
|
throw ReturnException.wrap("存在已关联其他标项的系统"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void cancelSystemFromBid(BindSystemToBidReq req) { |
|
|
|
List<ProjectGovSystemReplaceInfos> replaceInfos = systemReplaceInfosService.listByIds(req.getSystemReplaceInfoIds()); |
|
|
|
if (replaceInfos.isEmpty()) { |
|
|
|
throw ReturnException.wrap("系统替换信息不存在"); |
|
|
|
replaceInfos.removeIf(w -> req.getBidId().equals(w.getBidId()) |
|
|
|
&& CollUtil.contains(req.getSystemReplaceInfoIds(), w.getId())); |
|
|
|
if (CollUtil.isEmpty(replaceInfos)) { |
|
|
|
return; |
|
|
|
} |
|
|
|
// 解绑的系统 |
|
|
|
Map<Boolean, List<Long>> relationMap = replaceInfos.stream() |
|
|
|
.collect(Collectors.groupingBy(w -> CollUtil.contains(req.getSystemReplaceInfoIds(), w.getId()), |
|
|
|
Collectors.mapping(ProjectGovSystemReplaceInfos::getId, Collectors.toList()))); |
|
|
|
List<Long> canceledIds = relationMap.get(Boolean.FALSE); |
|
|
|
if (CollUtil.isNotEmpty(canceledIds)) { |
|
|
|
Wrapper<ProjectGovSystemReplaceInfos> update = Wrappers.lambdaUpdate(ProjectGovSystemReplaceInfos.class) |
|
|
|
.set(ProjectGovSystemReplaceInfos::getBidId, null) |
|
|
|
.in(ProjectGovSystemReplaceInfos::getId, canceledIds); |
|
|
|
systemReplaceInfosService.update(update); |
|
|
|
} |
|
|
|
// 关联系统 |
|
|
|
List<Long> bindIds = relationMap.get(Boolean.TRUE); |
|
|
|
if (CollUtil.isNotEmpty(bindIds)) { |
|
|
|
Wrapper<ProjectGovSystemReplaceInfos> update = Wrappers.lambdaUpdate(ProjectGovSystemReplaceInfos.class) |
|
|
|
.set(ProjectGovSystemReplaceInfos::getBidId, req.getBidId()) |
|
|
|
.in(ProjectGovSystemReplaceInfos::getId, bindIds); |
|
|
|
systemReplaceInfosService.update(update); |
|
|
|
} |
|
|
|
Wrapper<ProjectGovSystemReplaceInfos> wrapper = Wrappers.lambdaUpdate(ProjectGovSystemReplaceInfos.class) |
|
|
|
.set(ProjectGovSystemReplaceInfos::getBidId, null) |
|
|
|
.in(ProjectGovSystemReplaceInfos::getId, req.getSystemReplaceInfoIds()); |
|
|
|
systemReplaceInfosService.update(wrapper); |
|
|
|
} |
|
|
|
|
|
|
|
} |