|
@@ -2194,32 +2194,116 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
public void syncFormToContractNode(Long projectId, String nodeIds, Long primaryKeyId) {
|
|
|
try {
|
|
|
if (projectId == null || StringUtils.isBlank(nodeIds) || primaryKeyId == null){
|
|
|
throw new ServiceException("参数不能为空,请检查参数");
|
|
|
}
|
|
|
- //找到当前项目级的节点信息
|
|
|
- List<WbsTreePrivate> privates = this.list(new LambdaQueryWrapper<WbsTreePrivate>()
|
|
|
- .in(WbsTreePrivate::getPKeyId, Func.toLongList(nodeIds)));
|
|
|
- if (privates.size() == 0){
|
|
|
+ //找到当前项目级的节点信息,已经挂载表单数量
|
|
|
+ List<Long> longs = Func.toLongList(nodeIds);
|
|
|
+ List<WbsTreePrivateVO6> privates = baseMapper.getSelectNodes(longs,projectId);
|
|
|
+ if (privates.size() == 0 || privates.size() != longs.size()){
|
|
|
throw new ServiceException("未找到当前项目的节点信息,是确认是否选择节点");
|
|
|
}
|
|
|
+ //找到当前独立库表单信息
|
|
|
+ WbsTreePrivate form = this.getOne(new LambdaQueryWrapper<WbsTreePrivate>()
|
|
|
+ .eq(WbsTreePrivate::getPKeyId,primaryKeyId));
|
|
|
+ if (form == null){
|
|
|
+ throw new ServiceException("未找到当前表单信息,请联系管理员");
|
|
|
+ }
|
|
|
+ List<WbsTreePrivate> projectInsertForm = new ArrayList<>();
|
|
|
+ List<WbsTreeContract> contractInsertForm = new ArrayList<>();
|
|
|
//找到项目所有合同段下当前节点
|
|
|
- List<WbsTreeContract> list = wbsTreeContractService.list(new LambdaQueryWrapper<WbsTreeContract>()
|
|
|
- .eq(WbsTreeContract::getProjectId, projectId)
|
|
|
- .in(WbsTreeContract::getIsTypePrivatePid, Func.toLongList(nodeIds)));
|
|
|
- if (list.size() > 0){
|
|
|
- //循环保存
|
|
|
- for (WbsTreeContract wbsTreeContract : list) {
|
|
|
- this.addWbsTreeContractInfo(wbsTreeContract.getPKeyId()+"",primaryKeyId+"", Long.valueOf(wbsTreeContract.getContractId()));
|
|
|
+ List<WbsTreeContractVO7> list = baseMapper.getSelectContractNodes(longs,projectId);
|
|
|
+ Map<Long, List<WbsTreeContractVO7>> map = list.stream().collect(Collectors.groupingBy(WbsTreeContractVO7::getIsTypePrivatePid));
|
|
|
+ //构造项目级节点的表单 && 构造项目级节点对应合同节点的表单
|
|
|
+ for (WbsTreePrivateVO6 aPrivate : privates) {
|
|
|
+ //忽略已经存在的表单
|
|
|
+ if (aPrivate.getFormCount()>0 && aPrivate.getFormIds().contains(form.getId()+"")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ WbsTreePrivate pri = new WbsTreePrivate();
|
|
|
+ pri.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ pri.setId(form.getId());
|
|
|
+ pri.setWbsId(aPrivate.getWbsId());
|
|
|
+ pri.setWbsType(aPrivate.getWbsType());
|
|
|
+ pri.setProjectId(aPrivate.getProjectId());
|
|
|
+ pri.setTenantId(aPrivate.getTenantId());
|
|
|
+ pri.setParentId(aPrivate.getId());
|
|
|
+ pri.setAncestors(aPrivate.getAncestors()+","+aPrivate.getId());
|
|
|
+ pri.setNodeType(1);
|
|
|
+ pri.setNodeName(form.getNodeName());
|
|
|
+ pri.setFullName(form.getFullName());
|
|
|
+ pri.setSort(aPrivate.getFormCount()+1);
|
|
|
+ pri.setType(2);
|
|
|
+ pri.setTableType(form.getTableType());
|
|
|
+ pri.setTableOwner(form.getTableOwner());
|
|
|
+ pri.setInitTableName(form.getInitTableName());
|
|
|
+ if (form.getExcelId() != null){
|
|
|
+ pri.setIsLinkTable(2);
|
|
|
+ pri.setExcelId(form.getExcelId());
|
|
|
+ }else {
|
|
|
+ pri.setIsLinkTable(1);
|
|
|
+ }
|
|
|
+ pri.setIsExistForm(0);
|
|
|
+ pri.setHtmlUrl(form.getHtmlUrl());
|
|
|
+ pri.setFillRate(form.getFillRate());
|
|
|
+ pri.setInitTableId(form.getInitTableId());
|
|
|
+ pri.setIsTabPdf(form.getIsTabPdf());
|
|
|
+ pri.setTabFileType(form.getTabFileType());
|
|
|
+ pri.setStatus(1);
|
|
|
+ projectInsertForm.add(pri);
|
|
|
+ //获取合同段对应节点
|
|
|
+ List<WbsTreeContractVO7> contracts = map.get(aPrivate.getPKeyId());
|
|
|
+ if (contracts == null || contracts.size() == 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //构造项目级节点对应合同节点的表单
|
|
|
+ for (WbsTreeContractVO7 contract : contracts) {
|
|
|
+ //忽略已经存在的表单
|
|
|
+ if (contract.getFormCount()>0 && contract.getFormIds().contains(form.getId()+"")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ WbsTreeContract con = new WbsTreeContract();
|
|
|
+ con.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ con.setId(pri.getId());
|
|
|
+ con.setTableOwner(pri.getTableOwner());
|
|
|
+ con.setWbsId(pri.getWbsId());
|
|
|
+ con.setWbsType(Integer.valueOf(pri.getWbsType()));
|
|
|
+ con.setProjectId(contract.getProjectId());
|
|
|
+ con.setContractId(contract.getContractId());
|
|
|
+ con.setTenantId(pri.getTenantId());
|
|
|
+ con.setParentId(contract.getId());
|
|
|
+ con.setAncestors(contract.getAncestors()+","+contract.getId());
|
|
|
+ con.setNodeType(pri.getNodeType());
|
|
|
+ con.setNodeName(pri.getNodeName());
|
|
|
+ con.setFullName(pri.getFullName());
|
|
|
+ con.setSort(contract.getFormCount()+1);
|
|
|
+ con.setType(2);
|
|
|
+ con.setTableType(pri.getTableType());
|
|
|
+ con.setIsLinkTable(pri.getIsLinkTable());
|
|
|
+ con.setInitTableName(pri.getInitTableName());
|
|
|
+ con.setExcelId(pri.getExcelId());
|
|
|
+ con.setHtmlUrl(pri.getHtmlUrl());
|
|
|
+ con.setIsBussShow(1);
|
|
|
+ con.setTabFileType(pri.getTabFileType());
|
|
|
+ con.setIsTabPdf(pri.getIsTabPdf());
|
|
|
+ con.setIsTypePrivatePid(pri.getPKeyId());
|
|
|
+ con.setFillRate(pri.getFillRate());
|
|
|
+ con.setStatus(1);
|
|
|
+ contractInsertForm.add(con);
|
|
|
}
|
|
|
}
|
|
|
+ //批量保存
|
|
|
+ this.saveBatch(projectInsertForm);
|
|
|
+ wbsTreeContractService.saveBatch(contractInsertForm);
|
|
|
}catch (Exception e){
|
|
|
throw new ServiceException("分配失败,原因:"+e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
private List<WbsTreePrivateVO5> buildWbsTreeByStreamTrial(List<WbsTreePrivateVO5> wbsTreeVO2s) {
|
|
|
List<WbsTreePrivateVO5> list = wbsTreeVO2s.stream().filter(f -> f.getParentId() == 0L).collect(Collectors.toList());
|
|
|
Map<Long, List<WbsTreePrivateVO5>> map = wbsTreeVO2s.stream().collect(Collectors.groupingBy(WbsTreePrivateVO5::getParentId));
|