|
@@ -652,10 +652,17 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
// 如果 sort 相同,比较 nodeName
|
|
|
String name1 = o1.getNodeName();
|
|
|
String name2 = o2.getNodeName();
|
|
|
-
|
|
|
+ boolean flag=false;
|
|
|
boolean hasUnderscore1 = name1.contains("__");
|
|
|
boolean hasUnderscore2 = name2.contains("__");
|
|
|
-
|
|
|
+ if(name1.contains("PL")&&name2.contains("PL")){
|
|
|
+ flag=true;
|
|
|
+ }
|
|
|
+ if(flag){
|
|
|
+ int number1 = getPLNumberAfterUnderscore(name1);
|
|
|
+ int number2 = getPLNumberAfterUnderscore(name2);
|
|
|
+ return Integer.compare(number1, number2);
|
|
|
+ }
|
|
|
if (!hasUnderscore1 && !hasUnderscore2) {
|
|
|
// 两个都不包含 __,按字母顺序排序
|
|
|
return name1.compareTo(name2);
|
|
@@ -665,7 +672,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else if (!hasUnderscore2) {
|
|
|
// 第二个不包含 __,排在前面
|
|
|
return 1;
|
|
|
- } else {
|
|
|
+ }
|
|
|
+ else {
|
|
|
// 两个都包含 __,按 __ 后面的数字排序
|
|
|
int number1 = getNumberAfterUnderscore(name1);
|
|
|
int number2 = getNumberAfterUnderscore(name2);
|
|
@@ -680,6 +688,25 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
return Integer.MAX_VALUE;
|
|
|
}
|
|
|
+
|
|
|
+ private int getPLNumberAfterUnderscore(String name) {
|
|
|
+ if (!name.isEmpty()) {
|
|
|
+ int lastIndex = name.lastIndexOf("_"); // 找到最后一个 '_' 的位置
|
|
|
+ //如果有_
|
|
|
+ if (lastIndex != -1 && lastIndex < name.length() - 1) {
|
|
|
+ String result = name.substring(lastIndex + 1); // 截取 '_' 后面的内容
|
|
|
+ if (result.matches("\\d")) { // 判断是否为数字字符
|
|
|
+ return Integer.parseInt(result);
|
|
|
+ } else {
|
|
|
+ return Integer.MAX_VALUE;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Integer.MAX_VALUE;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return Integer.MAX_VALUE;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
@@ -2359,77 +2386,108 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
//本次修改的节点
|
|
|
List<String> updateList=new ArrayList<>();
|
|
|
|
|
|
+ //新增
|
|
|
+ String sqlList="Select parent_id,node_name from m_wbs_tree_contract where contract_id="+wbsTreeContractRoot.getContractId()+" and wbs_id="+wbsTreeContractRoot.getWbsId()+" and is_deleted=0";
|
|
|
+ List<WbsTreeContract> WbsTreeContractListupdate = jdbcTemplate.query(sqlList, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
//导入节点与现有节点进行比较。进行修改编号
|
|
|
+ List<String>updateUnitNames=new ArrayList<>();
|
|
|
for (ImportTreeDto dto : list) {
|
|
|
for (WbsTreeContractVO vo : wbsTreeContractVOS) {
|
|
|
//wbs节点和单位工程的名称类型能对应上,并且编号不一样,就修改编号
|
|
|
if(vo.getNodeName().equals(dto.getUnitName())&&vo.getNodeType()==1){
|
|
|
- if(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getUnitCode())){
|
|
|
- baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getUnitCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
|
|
|
- updateList.add(vo.getNodeName());
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractListupdate, 1, wbsTreeContractRoot);
|
|
|
+ if(exist){
|
|
|
+ if(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getUnitCode())){
|
|
|
+ if(updateUnitNames.size()>=1&&updateUnitNames.contains(vo.getNodeName())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getUnitCode()).eq(WbsTreeContract::getPKeyId,vo.getPKeyId()));
|
|
|
+ updateList.add(vo.getNodeName());
|
|
|
+ updateUnitNames.add(vo.getNodeName());
|
|
|
+ dto.setIsUnit(true);
|
|
|
+ }
|
|
|
+ continue;
|
|
|
}
|
|
|
- dto.setIsUnit(true);
|
|
|
- continue;
|
|
|
}
|
|
|
//wbs节点和子单位工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
if(vo.getNodeName().equals(dto.getSubUnitName())&&vo.getNodeType()==18){
|
|
|
- if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName()),vo)){
|
|
|
- if(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getSubUnitCode())){
|
|
|
- baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubUnitCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
|
|
|
- updateList.add(vo.getNodeName());
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractListupdate, 2, wbsTreeContractRoot);
|
|
|
+ if(exist){
|
|
|
+ if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName()),vo)){
|
|
|
+ if(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getSubUnitCode())){
|
|
|
+ baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubUnitCode()).eq(WbsTreeContract::getPKeyId,vo.getPKeyId()));
|
|
|
+ updateList.add(vo.getNodeName());
|
|
|
+ dto.setIsSubUnit(true);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- dto.setIsSubUnit(true);
|
|
|
+ continue;
|
|
|
}
|
|
|
- continue;
|
|
|
}
|
|
|
//wbs节点和分部工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- if(vo.getNodeName().equals(dto.getDivisionName())&&vo.getNodeType()==2&&!vo.getPartitionCode().equals(dto.getDivisionName())){
|
|
|
- if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName()),vo)){
|
|
|
- baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getDivisionCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
|
|
|
- updateList.add(vo.getNodeName());
|
|
|
+ if(vo.getNodeName().equals(dto.getDivisionName())&&vo.getNodeType()==2&&!vo.getPartitionCode().equals(dto.getDivisionCode())){
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractListupdate, 3, wbsTreeContractRoot);
|
|
|
+ if(exist){
|
|
|
+ if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName()),vo)){
|
|
|
+ baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getDivisionCode()).eq(WbsTreeContract::getPKeyId,vo.getPKeyId()));
|
|
|
+ updateList.add(vo.getNodeName());
|
|
|
+ dto.setIsDivision(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ continue;
|
|
|
}
|
|
|
- dto.setIsDivision(true);
|
|
|
- continue;
|
|
|
}
|
|
|
//wbs节点和子分部工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- if(vo.getNodeName().equals(dto.getSubDivisionName())&&vo.getNodeType()==3&&(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getSubDivisionName()))){
|
|
|
- if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName()),vo)){
|
|
|
- baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubDivisionCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
|
|
|
- updateList.add(vo.getNodeName());
|
|
|
+ if(vo.getNodeName().equals(dto.getSubDivisionName())&&vo.getNodeType()==3&&(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getSubDivisionCode()))){
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractListupdate, 4, wbsTreeContractRoot);
|
|
|
+ if(exist){
|
|
|
+ if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName()),vo)){
|
|
|
+ baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubDivisionCode()).eq(WbsTreeContract::getPKeyId,vo.getPKeyId()));
|
|
|
+ updateList.add(vo.getNodeName());
|
|
|
+ dto.setIsSubDivision(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ continue;
|
|
|
}
|
|
|
- dto.setIsSubDivision(true);
|
|
|
- continue;
|
|
|
}
|
|
|
//wbs节点和分项工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- if(vo.getNodeName().equals(dto.getItemName())&&vo.getNodeType()==4&&(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getItemName()))){
|
|
|
- if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName(),dto.getItemName()),vo)){
|
|
|
- baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getItemCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
|
|
|
- updateList.add(vo.getNodeName());
|
|
|
+ if(vo.getNodeName().equals(dto.getItemName())&&vo.getNodeType()==4&&(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getItemCode()))){
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractListupdate, 5, wbsTreeContractRoot);
|
|
|
+ if(exist){
|
|
|
+ if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName(),dto.getItemName()),vo)){
|
|
|
+ baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getItemCode()).eq(WbsTreeContract::getPKeyId,vo.getPKeyId()));
|
|
|
+ updateList.add(vo.getNodeName());
|
|
|
+ dto.setIsItem(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ continue;
|
|
|
}
|
|
|
- dto.setIsItem(true);
|
|
|
- continue;
|
|
|
}
|
|
|
//wbs节点和子分项工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- if(vo.getNodeName().equals(dto.getSubItemName())&&vo.getNodeType()==5&&(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getSubItemName()))){
|
|
|
- if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName(),dto.getItemName(),dto.getSubItemName()),vo)){
|
|
|
- baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubItemCode()).eq(WbsTreeContract::getPKeyId,vo.getPrimaryKeyId()));
|
|
|
- updateList.add(vo.getNodeName());
|
|
|
+ if(vo.getNodeName().equals(dto.getSubItemName())&&vo.getNodeType()==5&&(vo.getPartitionCode()==null||!vo.getPartitionCode().equals(dto.getSubItemCode()))){
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractListupdate, 6, wbsTreeContractRoot);
|
|
|
+ if(exist){
|
|
|
+ if(isTrueNode(Arrays.asList(dto.getUnitName(),dto.getSubUnitName(),dto.getDivisionName(),dto.getSubDivisionName(),dto.getItemName(),dto.getSubItemName()),vo)){
|
|
|
+ baseMapper.update(null,Wrappers.<WbsTreeContract>lambdaUpdate().set(WbsTreeContract::getPartitionCode,dto.getSubItemCode()).eq(WbsTreeContract::getPKeyId,vo.getPKeyId()));
|
|
|
+ updateList.add(vo.getNodeName());
|
|
|
+ dto.setIsSubItem(true);
|
|
|
+ }
|
|
|
+ break;
|
|
|
}
|
|
|
- dto.setIsSubItem(true);
|
|
|
- break;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
int i=0;
|
|
|
- //新增
|
|
|
for (ImportTreeDto dto : list) {
|
|
|
+ //新增
|
|
|
+ String sqlList1="Select parent_id,node_name from m_wbs_tree_contract where contract_id="+wbsTreeContractRoot.getContractId()+" and wbs_id="+wbsTreeContractRoot.getWbsId()+" and is_deleted=0";
|
|
|
+ List<WbsTreeContract> WbsTreeContractList = jdbcTemplate.query(sqlList1, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
i++;
|
|
|
//单位工程:如果没有被处理过,说明需要新增
|
|
|
- String sqlList="Select * from m_wbs_tree_contract where contract_id="+wbsTreeContractRoot.getContractId()+" and wbs_id="+wbsTreeContractRoot.getWbsId()+" and is_deleted=0";
|
|
|
- List<WbsTreeContract> WbsTreeContractList = jdbcTemplate.query(sqlList, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
if (!dto.getIsUnit()){
|
|
|
//检测是否已经存在,如果存在,就不需要新增了
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 1, Long.valueOf(wbsTreeContractRoot.getContractId()));
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 1, wbsTreeContractRoot);
|
|
|
if(!exist){
|
|
|
WbsTreeContract unit = new WbsTreeContract();
|
|
|
BeanUtil.copy(wbsTreeContractRoot,unit);
|
|
@@ -2444,14 +2502,16 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
unit.setFullName(dto.getUnitName());
|
|
|
unit.setIsTypePrivatePid(null);
|
|
|
unit.setSort(i);
|
|
|
+ unit.setTreePId(null);
|
|
|
+ unit.setPId(wbsTreeContractRoot.getPKeyId());
|
|
|
+ unit.setAncestorsPId(wbsTreeContractRoot.getAncestorsPId() + "," + wbsTreeContractRoot.getPKeyId());
|
|
|
baseMapper.insert(unit);
|
|
|
insertList.add(unit);
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
//子单位工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。单位工程不会有相同的,所以直接根据名称查找
|
|
|
if(!dto.getIsSubUnit()){
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 2, Long.valueOf(wbsTreeContractRoot.getContractId()));
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 2, wbsTreeContractRoot);
|
|
|
if(!exist){
|
|
|
WbsTreeContract fatherNode = baseMapper.selectOne(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, dto.getUnitName()).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
.eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0).last("LIMIT 1"));
|
|
@@ -2468,6 +2528,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
subUnit.setFullName(dto.getSubUnitName());
|
|
|
subUnit.setIsTypePrivatePid(null);
|
|
|
subUnit.setSort(i);
|
|
|
+ subUnit.setTreePId(null);
|
|
|
+ subUnit.setPId(fatherNode.getPKeyId());
|
|
|
+ subUnit.setAncestorsPId(fatherNode.getAncestorsPId() + "," + fatherNode.getPKeyId());
|
|
|
baseMapper.insert(subUnit);
|
|
|
insertList.add(subUnit);
|
|
|
}
|
|
@@ -2475,7 +2538,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
//分部工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
if(!dto.getIsDivision()){
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 3, Long.valueOf(wbsTreeContractRoot.getContractId()));
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 3, wbsTreeContractRoot);
|
|
|
if(!exist){
|
|
|
String fatherNodeName="";
|
|
|
if(dto.getSubUnitName()!=null&&!dto.getSubUnitName().equals("")){
|
|
@@ -2487,7 +2550,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
.eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
if(list1.size()>0){
|
|
|
for (WbsTreeContract contract : list1) {
|
|
|
- String[] ids = contract.getAncestors().split(",");
|
|
|
+ String[] ids = contract.getAncestorsPId().split(",");
|
|
|
ids=Arrays.stream(ids)
|
|
|
.filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
.toArray(String[]::new);
|
|
@@ -2510,6 +2573,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
division.setFullName(dto.getDivisionName());
|
|
|
division.setIsTypePrivatePid(null);
|
|
|
division.setSort(i);
|
|
|
+ division.setTreePId(null);
|
|
|
+ division.setPId(contract.getPKeyId());
|
|
|
+ division.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
baseMapper.insert(division);
|
|
|
insertList.add(division);
|
|
|
break;
|
|
@@ -2521,7 +2587,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
//子分部工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
if(!dto.getIsSubDivision()){
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 4, Long.valueOf(wbsTreeContractRoot.getContractId()));
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 4, wbsTreeContractRoot);
|
|
|
if(!exist){
|
|
|
String fatherNodeName="";
|
|
|
if(dto.getDivisionName()!=null&&!dto.getDivisionName().equals("")){
|
|
@@ -2535,7 +2601,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
.eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
if(list1.size()>0){
|
|
|
for (WbsTreeContract contract : list1) {
|
|
|
- String[] ids = contract.getAncestors().split(",");
|
|
|
+ String[] ids = contract.getAncestorsPId().split(",");
|
|
|
ids=Arrays.stream(ids)
|
|
|
.filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
.toArray(String[]::new);
|
|
@@ -2559,6 +2625,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
subDivision.setFullName(dto.getSubDivisionName());
|
|
|
subDivision.setIsTypePrivatePid(null);
|
|
|
subDivision.setSort(i);
|
|
|
+ subDivision.setTreePId(null);
|
|
|
+ subDivision.setPId(contract.getPKeyId());
|
|
|
+ subDivision.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
baseMapper.insert(subDivision);
|
|
|
insertList.add(subDivision);
|
|
|
break;
|
|
@@ -2570,7 +2639,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
//分项节点:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
if(!dto.getIsItem()){
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 5, Long.valueOf(wbsTreeContractRoot.getContractId()));
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 5, wbsTreeContractRoot);
|
|
|
if(!exist){
|
|
|
String fatherNodeName="";
|
|
|
if(dto.getSubDivisionName()!=null&&!dto.getSubDivisionName().equals("")){
|
|
@@ -2587,7 +2656,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
.eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
if(list1.size()>0){
|
|
|
for (WbsTreeContract contract : list1) {
|
|
|
- String[] ids = contract.getAncestors().split(",");
|
|
|
+ String[] ids = contract.getAncestorsPId().split(",");
|
|
|
ids=Arrays.stream(ids)
|
|
|
.filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
.toArray(String[]::new);
|
|
@@ -2612,6 +2681,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
item.setFullName(dto.getItemName());
|
|
|
item.setIsTypePrivatePid(null);
|
|
|
item.setSort(i);
|
|
|
+ item.setTreePId(null);
|
|
|
+ item.setPId(contract.getPKeyId());
|
|
|
+ item.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
baseMapper.insert(item);
|
|
|
insertList.add(item);
|
|
|
break;
|
|
@@ -2623,7 +2695,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
//子分项节点:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
if(!dto.getIsSubItem()){
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 6, Long.valueOf(wbsTreeContractRoot.getContractId()));
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 6, wbsTreeContractRoot);
|
|
|
if(!exist){
|
|
|
String fatherNodeName="";
|
|
|
if(dto.getItemName()!=null&&!dto.getItemName().equals("")){
|
|
@@ -2642,7 +2714,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
.eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
if(list1.size()>0){
|
|
|
for (WbsTreeContract contract : list1) {
|
|
|
- String[] ids = contract.getAncestors().split(",");
|
|
|
+ String[] ids = contract.getAncestorsPId().split(",");
|
|
|
ids=Arrays.stream(ids)
|
|
|
.filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
.toArray(String[]::new);
|
|
@@ -2668,6 +2740,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
subItem.setFullName(dto.getSubItemName());
|
|
|
subItem.setIsTypePrivatePid(null);
|
|
|
subItem.setSort(i);
|
|
|
+ subItem.setTreePId(null);
|
|
|
+ subItem.setPId(contract.getPKeyId());
|
|
|
+ subItem.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
baseMapper.insert(subItem);
|
|
|
insertList.add(subItem);
|
|
|
break;
|
|
@@ -2973,7 +3048,8 @@ public static boolean hasConflictingCodes(List<ImportTreeDto> list) {
|
|
|
Objects.equals(fatherNodeType1, fatherNodeType2) &&
|
|
|
!Objects.equals(dto1.getSubItemCode(), dto2.getSubItemCode());
|
|
|
}
|
|
|
- private Boolean isExist(ImportTreeDto dto, List<WbsTreeContract> wbsTreeContractList, int type,Long contractId) {
|
|
|
+ private Boolean isExist(ImportTreeDto dto, List<WbsTreeContract> wbsTreeContractList, int type,WbsTreeContract tree) {
|
|
|
+ Long contractId=Long.valueOf(tree.getContractId());
|
|
|
String nodeName="";
|
|
|
if(type==1){
|
|
|
nodeName=dto.getUnitName();
|
|
@@ -2996,7 +3072,7 @@ public static boolean hasConflictingCodes(List<ImportTreeDto> list) {
|
|
|
String finalNodeName = nodeName;
|
|
|
List<Long> list = wbsTreeContractList.stream()
|
|
|
.filter(item -> finalNodeName.equals(item.getNodeName()))
|
|
|
- .map(item -> item.getParentId())
|
|
|
+ .map(item -> item.getPId())
|
|
|
.collect(Collectors.toList());
|
|
|
if(list.size()==0){
|
|
|
return false;
|
|
@@ -3005,56 +3081,40 @@ public static boolean hasConflictingCodes(List<ImportTreeDto> list) {
|
|
|
return true;
|
|
|
}
|
|
|
//如果数据库中存在名称相同的节点,查询该节点的祖级节点
|
|
|
- String sql="select node_name from m_wbs_tree_contract where is_deleted=0 and contract_id="+contractId+" and id in ("+String.join(",", list.stream().map(String::valueOf).collect(Collectors.toList()))+")";
|
|
|
- List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String sql="select p_key_id,node_name from m_wbs_tree_contract where is_deleted=0 and contract_id="+contractId+" and p_key_id in ("+String.join(",", list.stream().map(String::valueOf).collect(Collectors.toList()))+")";
|
|
|
+ List<WbsTreeContract> wbsContracts = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
String fatherNodeName="";
|
|
|
if(type==2){
|
|
|
- fatherNodeName=dto.getUnitName();
|
|
|
+ fatherNodeName=tree.getNodeName()+dto.getUnitName();
|
|
|
}
|
|
|
else if(type==3){
|
|
|
- if(dto.getSubUnitName()!=null&&!dto.getSubUnitName().equals("")){
|
|
|
- fatherNodeName=dto.getSubUnitName();
|
|
|
- }else if(dto.getUnitName()!=null&&!dto.getUnitName().equals("")){
|
|
|
- fatherNodeName=dto.getUnitName();
|
|
|
- }
|
|
|
+ fatherNodeName=tree.getNodeName()+dto.getUnitName()+dto.getSubUnitName();
|
|
|
}
|
|
|
else if(type==4){
|
|
|
- if(dto.getDivisionName()!=null&&!dto.getDivisionName().equals("")){
|
|
|
- fatherNodeName=dto.getDivisionName();
|
|
|
- } else if(dto.getSubUnitName()!=null&&!dto.getSubUnitName().equals("")){
|
|
|
- fatherNodeName=dto.getSubUnitName();
|
|
|
- }else if(dto.getUnitName()!=null&&!dto.getUnitName().equals("")){
|
|
|
- fatherNodeName=dto.getUnitName();
|
|
|
- }
|
|
|
+ fatherNodeName=tree.getNodeName()+dto.getUnitName()+dto.getSubUnitName()+dto.getDivisionName();
|
|
|
}
|
|
|
else if(type==5){
|
|
|
- if(dto.getSubDivisionName()!=null&&!dto.getSubDivisionName().equals("")){
|
|
|
- fatherNodeName=dto.getSubDivisionName();
|
|
|
- }
|
|
|
- else if(dto.getDivisionName()!=null&&!dto.getDivisionName().equals("")){
|
|
|
- fatherNodeName=dto.getDivisionName();
|
|
|
- } else if(dto.getSubUnitName()!=null&&!dto.getSubUnitName().equals("")){
|
|
|
- fatherNodeName=dto.getSubUnitName();
|
|
|
- }else if(dto.getUnitName()!=null&&!dto.getUnitName().equals("")){
|
|
|
- fatherNodeName=dto.getUnitName();
|
|
|
- }
|
|
|
+ fatherNodeName=tree.getNodeName()+dto.getUnitName()+dto.getSubUnitName()+dto.getDivisionName()+dto.getSubDivisionName();
|
|
|
}
|
|
|
else if(type==6){
|
|
|
- if(dto.getItemName()!=null&&!dto.getItemName().equals("")){
|
|
|
- } else if(dto.getSubDivisionName()!=null&&!dto.getSubDivisionName().equals("")){
|
|
|
- fatherNodeName=dto.getSubDivisionName();
|
|
|
- }
|
|
|
- else if(dto.getDivisionName()!=null&&!dto.getDivisionName().equals("")){
|
|
|
- fatherNodeName=dto.getDivisionName();
|
|
|
- } else if(dto.getSubUnitName()!=null&&!dto.getSubUnitName().equals("")){
|
|
|
- fatherNodeName=dto.getSubUnitName();
|
|
|
- }else if(dto.getUnitName()!=null&&!dto.getUnitName().equals("")){
|
|
|
- fatherNodeName=dto.getUnitName();
|
|
|
+ fatherNodeName=tree.getNodeName()+dto.getUnitName()+dto.getSubUnitName()+dto.getDivisionName()+dto.getSubDivisionName()+dto.getItemName();
|
|
|
+ }
|
|
|
+ if(wbsContracts.size()>0){
|
|
|
+ for (WbsTreeContract wbsContract : wbsContracts) {
|
|
|
+ String Sql="select ancestors_p_id from m_wbs_tree_contract where p_key_id="+wbsContract.getPKeyId();
|
|
|
+ String ancestors = jdbcTemplate.queryForObject(Sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String[] ids = ancestors.split(",");
|
|
|
+ ids=Arrays.stream(ids)
|
|
|
+ .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
+ .toArray(String[]::new);
|
|
|
+ String sql1="Select node_name from m_wbs_tree_contract where p_key_id in("+String.join(",", ids)+")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql1, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String join = String.join("", nodeNames);
|
|
|
+ if(join.equals(fatherNodeName)){
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- if(nodeNames.size()>0&&nodeNames.contains(fatherNodeName)){
|
|
|
- return true;
|
|
|
+ return false;
|
|
|
}
|
|
|
return false;
|
|
|
}
|