|
@@ -2219,41 +2219,44 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
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());
|
|
|
+ //判断项目级节点下是否存在这样表单,如果项目级下存在这张表单,则项目级就不新增这样表单,但是合同段需要新增
|
|
|
+ if (aPrivate.getFormCount()>0 && aPrivate.getFormIds().contains(form.getId()+"")) {
|
|
|
+ //存在这张表单,则取出,为项目级信息赋值
|
|
|
+ WbsTreePrivate wtp = baseMapper.getThisForm(aPrivate.getProjectId(),aPrivate.getId(),form.getId());
|
|
|
+ BeanUtils.copyProperties(wtp,pri);
|
|
|
}else {
|
|
|
- pri.setIsLinkTable(1);
|
|
|
+ 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);
|
|
|
}
|
|
|
- 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){
|
|
@@ -2775,5 +2778,61 @@ public class WbsTreePrivateServiceImpl extends BaseServiceImpl<WbsTreePrivateMap
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ @Override
|
|
|
+ @Transactional
|
|
|
+ public void syncPid(Long projectId) {
|
|
|
+ // 根据项目id查询出所有的合同节点
|
|
|
+ List<WbsTreeContract> allNode = baseMapper.getcontractAllNode(projectId);
|
|
|
+ // 合同节点按照合同id转换为map
|
|
|
+ Map<String, List<WbsTreeContract>> listMap = allNode.stream().collect(Collectors.groupingBy(WbsTreeContract::getContractId));
|
|
|
+ Map<String,Map<Long,WbsTreeContract>> mapMap = new HashMap<>();
|
|
|
+ // map中为每个合同段的数据,
|
|
|
+ for (String s : listMap.keySet()) {
|
|
|
+ List<WbsTreeContract> list = listMap.get(s);
|
|
|
+ //为id去重
|
|
|
+ list = list.stream()
|
|
|
+ .collect(Collectors.collectingAndThen( Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContract::getId))),
|
|
|
+ ArrayList::new));
|
|
|
+ //转换为map key为id
|
|
|
+ Map<Long, WbsTreeContract> map = list.stream().collect(Collectors.toMap(l -> l.getId(), l -> l));
|
|
|
+ mapMap.put(s,map);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 1:先取出wbs_contract表按照项目id搜索,所有不带pid的节点
|
|
|
+ List<WbsTreeContract> contracts = baseMapper.getContractNode(projectId);
|
|
|
+ // 2:再取出wbs_private表按照项目id搜索,所有不带pid的节点
|
|
|
+ List<WbsTreePrivate> privates = baseMapper.getPrivateNode(projectId);
|
|
|
+ Map<SyncPidVO1, Long> map = privates.stream().collect(Collectors.toMap(l -> new SyncPidVO1(l.getId(), l.getWbsId()), l -> l.getPKeyId()));
|
|
|
+ // 3:拿contract的id和wbs_id去搜索private中的
|
|
|
+ for (WbsTreeContract contract : contracts) {
|
|
|
+ // 4:如果存在oldId,就把OldId赋值给id
|
|
|
+ // 如果存在oldId,则直接去map中先查合同段再查id
|
|
|
+ // 知道不存在oldId,然后把id = id
|
|
|
+ if (StringUtils.isNotBlank(contract.getOldId())){
|
|
|
+ Long aLong = Long.valueOf(contract.getOldId());
|
|
|
+ WbsTreeContract wbsTreeContract = mapMap.get(contract.getContractId()).get(aLong);
|
|
|
+ while (wbsTreeContract != null && StringUtils.isNotBlank(wbsTreeContract.getOldId())) {
|
|
|
+ aLong = Long.valueOf(wbsTreeContract.getOldId());
|
|
|
+ wbsTreeContract = mapMap.get(wbsTreeContract.getContractId()).get(aLong);
|
|
|
+ }
|
|
|
+ contract.setId(aLong);
|
|
|
+ }
|
|
|
+ // 5: 如果项目中存在,则把private的pId赋值给contract的isPid
|
|
|
+ Long aLong = map.get(new SyncPidVO1(contract.getId(), contract.getWbsId()));
|
|
|
+ if (aLong != null){
|
|
|
+ contract.setIsTypePrivatePid(aLong);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ contracts = contracts.stream().filter(l->l.getIsTypePrivatePid() != null && l.getIsTypePrivatePid() != -1).collect(Collectors.toList());
|
|
|
+ List<List<WbsTreeContract>> lists = CommonUtil.splitList(contracts, 1000);
|
|
|
+ int total=0;
|
|
|
+ for (List<WbsTreeContract> list : lists) {
|
|
|
+ int upTotal = baseMapper.updateContractByPId(list);
|
|
|
+ System.out.println("修改状态:"+upTotal);
|
|
|
+ total++;
|
|
|
+ }
|
|
|
+ System.out.println("总修改量:"+contracts.size());
|
|
|
+ System.out.println("总修改次数:"+total);
|
|
|
+ }
|
|
|
|
|
|
}
|