|
@@ -2750,449 +2750,454 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- @Async
|
|
|
@Transactional(isolation = Isolation.READ_COMMITTED, propagation = Propagation.REQUIRED)
|
|
|
public R importTree(MultipartFile file, Long pkeyId) throws IOException {
|
|
|
- InputStream inputStream = file.getInputStream();
|
|
|
- org.apache.poi.ss.usermodel.Workbook workbook = new XSSFWorkbook(inputStream);
|
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
- unmergeCells(sheet);
|
|
|
- List<ImportTreeDto> list = new ArrayList<>();
|
|
|
- for (int i = 2; i <= sheet.getLastRowNum(); i++) {
|
|
|
- Row row = sheet.getRow(i);
|
|
|
- if (row == null) continue;
|
|
|
- // 获取每一列的值
|
|
|
- String unitCode = getCellValue(row.getCell(0)); // A列:单位工程编号
|
|
|
- String unitName = getCellValue(row.getCell(1)); // B列:单位工程名称
|
|
|
- String subUnitCode = getCellValue(row.getCell(2)); // C列:子单位工程编号
|
|
|
- String subUnitName = getCellValue(row.getCell(3)); // D列:子单位工程名称
|
|
|
- String divisionCode = getCellValue(row.getCell(4)); // E列:分部工程编号
|
|
|
- String divisionName = getCellValue(row.getCell(5)); // F列:分部工程名称
|
|
|
- String subDivisionCode = getCellValue(row.getCell(6)); // G列:子分部工程编号
|
|
|
- String subDivisionName = getCellValue(row.getCell(7)); // H列:子分部工程名称
|
|
|
- String itemCode = getCellValue(row.getCell(8)); // I列:分项工程编号
|
|
|
- String itemName = getCellValue(row.getCell(9)); // J列:分项工程名称
|
|
|
- String subItemCode = getCellValue(row.getCell(10));// K列:子分项工程编号
|
|
|
- String subItemName = getCellValue(row.getCell(11)); // L列:子分项工程名称
|
|
|
- ImportTreeDto dto = new ImportTreeDto(unitName, unitCode, 1, StringUtils.isEmpty(unitName), subUnitName, subUnitCode, 18, StringUtils.isEmpty(subUnitName), divisionName, divisionCode, 2, StringUtils.isEmpty(divisionName), subDivisionName, subDivisionCode, 3, StringUtils.isEmpty(subDivisionName), itemName, itemCode, 4, StringUtils.isEmpty(itemName), subItemName, subItemCode, 5, StringUtils.isEmpty(subItemName));
|
|
|
- list.add(dto);
|
|
|
- }
|
|
|
- if (list.isEmpty()) {
|
|
|
- throw new ServiceException("导入模版为空,请先填写数据");
|
|
|
- }
|
|
|
- //过滤出空节点
|
|
|
- list = list.stream().filter(o -> !o.getIsUnit() || !o.getIsSubUnit() || !o.getIsDivision() || !o.getIsSubDivision() || !o.getIsItem() || !o.getIsSubItem()).collect(Collectors.toList());
|
|
|
+ //最高节点
|
|
|
+ WbsTreeContract wbsTreeContractRoot = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
+ bladeRedis.set("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), "0");
|
|
|
+ try (InputStream inputStream = file.getInputStream()) {
|
|
|
+ // 立即处理文件流
|
|
|
+ Workbook workbook = new XSSFWorkbook(inputStream);
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ // 处理Excel数据...
|
|
|
+ unmergeCells(sheet);
|
|
|
+ List<ImportTreeDto> list = new ArrayList<>();
|
|
|
+ for (int i = 2; i <= sheet.getLastRowNum(); i++) {
|
|
|
+ Row row = sheet.getRow(i);
|
|
|
+ if (row == null) continue;
|
|
|
+ // 获取每一列的值
|
|
|
+ String unitCode = getCellValue(row.getCell(0)); // A列:单位工程编号
|
|
|
+ String unitName = getCellValue(row.getCell(1)); // B列:单位工程名称
|
|
|
+ String subUnitCode = getCellValue(row.getCell(2)); // C列:子单位工程编号
|
|
|
+ String subUnitName = getCellValue(row.getCell(3)); // D列:子单位工程名称
|
|
|
+ String divisionCode = getCellValue(row.getCell(4)); // E列:分部工程编号
|
|
|
+ String divisionName = getCellValue(row.getCell(5)); // F列:分部工程名称
|
|
|
+ String subDivisionCode = getCellValue(row.getCell(6)); // G列:子分部工程编号
|
|
|
+ String subDivisionName = getCellValue(row.getCell(7)); // H列:子分部工程名称
|
|
|
+ String itemCode = getCellValue(row.getCell(8)); // I列:分项工程编号
|
|
|
+ String itemName = getCellValue(row.getCell(9)); // J列:分项工程名称
|
|
|
+ String subItemCode = getCellValue(row.getCell(10));// K列:子分项工程编号
|
|
|
+ String subItemName = getCellValue(row.getCell(11)); // L列:子分项工程名称
|
|
|
+ ImportTreeDto dto = new ImportTreeDto(unitName, unitCode, 1, StringUtils.isEmpty(unitName), subUnitName, subUnitCode, 18, StringUtils.isEmpty(subUnitName), divisionName, divisionCode, 2, StringUtils.isEmpty(divisionName), subDivisionName, subDivisionCode, 3, StringUtils.isEmpty(subDivisionName), itemName, itemCode, 4, StringUtils.isEmpty(itemName), subItemName, subItemCode, 5, StringUtils.isEmpty(subItemName));
|
|
|
+ list.add(dto);
|
|
|
+ }
|
|
|
+ if (list.isEmpty()) {
|
|
|
+ throw new ServiceException("导入模版为空,请先填写数据");
|
|
|
+ }
|
|
|
+ //过滤出空节点
|
|
|
+ list = list.stream().filter(o -> !o.getIsUnit() || !o.getIsSubUnit() || !o.getIsDivision() || !o.getIsSubDivision() || !o.getIsItem() || !o.getIsSubItem()).collect(Collectors.toList());
|
|
|
// //过滤出相同节点但是编号不同的情况
|
|
|
// if(hasConflictingCodes(list)){
|
|
|
// throw new ServiceException("导入模版存在相同节点但不同编号,请修改");
|
|
|
// }
|
|
|
- //最高节点
|
|
|
- WbsTreeContract wbsTreeContractRoot = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda().eq(WbsTreeContract::getPKeyId, pkeyId));
|
|
|
- //获取当前节点下所有子节点
|
|
|
- List<WbsTreeContractVO> wbsTreeContractVOS = contractInfoMapper.tree4(wbsTreeContractRoot.getContractId(), String.valueOf(wbsTreeContractRoot.getPKeyId()));
|
|
|
- // 定义 nodeType 的优先级顺序 18是子单位工程,后期加上去的,不敢动原本的顺序
|
|
|
- List<Integer> priorityOrder = Arrays.asList(1, 18, 2, 3, 4, 5);
|
|
|
- // 自定义 Comparator
|
|
|
- Comparator<WbsTreeContractVO> comparator = (vo1, vo2) -> {
|
|
|
- int index1 = priorityOrder.indexOf(vo1.getNodeType());
|
|
|
- int index2 = priorityOrder.indexOf(vo2.getNodeType());
|
|
|
- return Integer.compare(index1, index2);
|
|
|
- };
|
|
|
- // 对集合进行排序
|
|
|
- wbsTreeContractVOS.sort(comparator);
|
|
|
- if (wbsTreeContractVOS.size() <= 0) {
|
|
|
- throw new ServiceException("未查询到当前合同段的wbs树,请先分配该合同的合同段wsb树");
|
|
|
- }
|
|
|
- //本次新增的节点
|
|
|
- List<WbsTreeContract> insertList = new ArrayList<>();
|
|
|
- //本次修改的节点
|
|
|
- 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) {
|
|
|
- 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;
|
|
|
+ //获取当前节点下所有子节点
|
|
|
+ List<WbsTreeContractVO> wbsTreeContractVOS = contractInfoMapper.tree4(wbsTreeContractRoot.getContractId(), String.valueOf(wbsTreeContractRoot.getPKeyId()));
|
|
|
+ // 定义 nodeType 的优先级顺序 18是子单位工程,后期加上去的,不敢动原本的顺序
|
|
|
+ List<Integer> priorityOrder = Arrays.asList(1, 18, 2, 3, 4, 5);
|
|
|
+ // 自定义 Comparator
|
|
|
+ Comparator<WbsTreeContractVO> comparator = (vo1, vo2) -> {
|
|
|
+ int index1 = priorityOrder.indexOf(vo1.getNodeType());
|
|
|
+ int index2 = priorityOrder.indexOf(vo2.getNodeType());
|
|
|
+ return Integer.compare(index1, index2);
|
|
|
+ };
|
|
|
+ // 对集合进行排序
|
|
|
+ wbsTreeContractVOS.sort(comparator);
|
|
|
+ if (wbsTreeContractVOS.size() <= 0) {
|
|
|
+ throw new ServiceException("未查询到当前合同段的wbs树,请先分配该合同的合同段wsb树");
|
|
|
+ }
|
|
|
+ //本次新增的节点
|
|
|
+ List<WbsTreeContract> insertList = new ArrayList<>();
|
|
|
+ //本次修改的节点
|
|
|
+ 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) {
|
|
|
+ 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);
|
|
|
}
|
|
|
- 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;
|
|
|
}
|
|
|
- continue;
|
|
|
}
|
|
|
- }
|
|
|
- //wbs节点和子单位工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- if (vo.getNodeName().equals(dto.getSubUnitName()) && vo.getNodeType() == 18) {
|
|
|
- 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()));
|
|
|
+ //wbs节点和子单位工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
+ if (vo.getNodeName().equals(dto.getSubUnitName()) && vo.getNodeType() == 18) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //wbs节点和分部工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
+ if (vo.getNodeName().equals(dto.getDivisionName()) && vo.getNodeType() == 2 && (vo.getPartitionCode() == null || 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.setIsSubUnit(true);
|
|
|
+ dto.setIsDivision(true);
|
|
|
}
|
|
|
|
|
|
+ continue;
|
|
|
}
|
|
|
- continue;
|
|
|
}
|
|
|
- }
|
|
|
- //wbs节点和分部工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- if (vo.getNodeName().equals(dto.getDivisionName()) && vo.getNodeType() == 2 && (vo.getPartitionCode() == null || 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);
|
|
|
- }
|
|
|
+ //wbs节点和子分部工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
+ 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;
|
|
|
- }
|
|
|
- }
|
|
|
- //wbs节点和子分部工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- 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;
|
|
|
}
|
|
|
+ }
|
|
|
+ //wbs节点和分项工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
+ 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;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- //wbs节点和分项工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- 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);
|
|
|
+ //wbs节点和子分项工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
+ 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;
|
|
|
}
|
|
|
|
|
|
- continue;
|
|
|
}
|
|
|
}
|
|
|
- //wbs节点和子分项工程的名称类型能对应上,并且编号不一样,并且祖级节点也都能对应上,就修改编号
|
|
|
- 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);
|
|
|
+ }
|
|
|
+ int i = 0;
|
|
|
+ int size = list.size();
|
|
|
+ try{
|
|
|
+ for (ImportTreeDto dto : list) {
|
|
|
+ String progressStr = String.format("%.2f", ((double) ++i / size) * 100);
|
|
|
+ bladeRedis.set("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), progressStr);
|
|
|
+ //新增
|
|
|
+ String sqlList1 = "Select parent_id,node_name,p_id 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++;
|
|
|
+ //单位工程:如果没有被处理过,说明需要新增
|
|
|
+ if (!dto.getIsUnit()) {
|
|
|
+ //检测是否已经存在,如果存在,就不需要新增了
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 1, wbsTreeContractRoot);
|
|
|
+ if (!exist) {
|
|
|
+ WbsTreeContract unit = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(wbsTreeContractRoot, unit);
|
|
|
+ unit.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ unit.setId(SnowFlakeUtil.getId());
|
|
|
+ unit.setParentId(wbsTreeContractRoot.getId());
|
|
|
+ unit.setAncestors("0," + wbsTreeContractRoot.getPKeyId() + "," + unit.getPKeyId());
|
|
|
+ unit.setIsCustom(1);
|
|
|
+ unit.setPartitionCode(dto.getUnitCode());
|
|
|
+ unit.setNodeType(1);
|
|
|
+ unit.setNodeName(dto.getUnitName());
|
|
|
+ unit.setFullName(dto.getUnitName());
|
|
|
+ unit.setIsTypePrivatePid(null);
|
|
|
+ unit.setSort(i);
|
|
|
+ unit.setTreePId(null);
|
|
|
+ unit.setDateIsComplete(null);
|
|
|
+ unit.setPId(wbsTreeContractRoot.getPKeyId());
|
|
|
+ unit.setAncestorsPId(wbsTreeContractRoot.getAncestorsPId() + "," + wbsTreeContractRoot.getPKeyId());
|
|
|
+ baseMapper.insert(unit);
|
|
|
+ insertList.add(unit);
|
|
|
}
|
|
|
- break;
|
|
|
}
|
|
|
+ //子单位工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。单位工程不会有相同的,所以直接根据名称查找
|
|
|
+ if (!dto.getIsSubUnit()) {
|
|
|
+ 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"));
|
|
|
+ WbsTreeContract subUnit = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(fatherNode, subUnit);
|
|
|
+ subUnit.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ subUnit.setId(SnowFlakeUtil.getId());
|
|
|
+ subUnit.setParentId(fatherNode.getId());
|
|
|
+ subUnit.setAncestors(fatherNode.getAncestors() + "," + subUnit.getPKeyId());
|
|
|
+ subUnit.setIsCustom(1);
|
|
|
+ subUnit.setPartitionCode(dto.getSubUnitCode());
|
|
|
+ subUnit.setNodeType(18);
|
|
|
+ subUnit.setNodeName(dto.getSubUnitName());
|
|
|
+ subUnit.setFullName(dto.getSubUnitName());
|
|
|
+ subUnit.setIsTypePrivatePid(null);
|
|
|
+ subUnit.setSort(i);
|
|
|
+ subUnit.setTreePId(null);
|
|
|
+ subUnit.setDateIsComplete(null);
|
|
|
+ subUnit.setPId(fatherNode.getPKeyId());
|
|
|
+ subUnit.setAncestorsPId(fatherNode.getAncestorsPId() + "," + fatherNode.getPKeyId());
|
|
|
+ baseMapper.insert(subUnit);
|
|
|
+ insertList.add(subUnit);
|
|
|
+ }
|
|
|
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- int i = 0;
|
|
|
- int size = list.size();
|
|
|
- try{
|
|
|
- for (ImportTreeDto dto : list) {
|
|
|
- String progressStr = String.format("%.2f", ((double) ++i / size) * 100) + "%";
|
|
|
- bladeRedis.set("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), progressStr);
|
|
|
- //新增
|
|
|
- String sqlList1 = "Select parent_id,node_name,p_id 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++;
|
|
|
- //单位工程:如果没有被处理过,说明需要新增
|
|
|
- if (!dto.getIsUnit()) {
|
|
|
- //检测是否已经存在,如果存在,就不需要新增了
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 1, wbsTreeContractRoot);
|
|
|
- if (!exist) {
|
|
|
- WbsTreeContract unit = new WbsTreeContract();
|
|
|
- BeanUtil.copy(wbsTreeContractRoot, unit);
|
|
|
- unit.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- unit.setId(SnowFlakeUtil.getId());
|
|
|
- unit.setParentId(wbsTreeContractRoot.getId());
|
|
|
- unit.setAncestors("0," + wbsTreeContractRoot.getPKeyId() + "," + unit.getPKeyId());
|
|
|
- unit.setIsCustom(1);
|
|
|
- unit.setPartitionCode(dto.getUnitCode());
|
|
|
- unit.setNodeType(1);
|
|
|
- unit.setNodeName(dto.getUnitName());
|
|
|
- unit.setFullName(dto.getUnitName());
|
|
|
- unit.setIsTypePrivatePid(null);
|
|
|
- unit.setSort(i);
|
|
|
- unit.setTreePId(null);
|
|
|
- unit.setDateIsComplete(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, 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"));
|
|
|
- WbsTreeContract subUnit = new WbsTreeContract();
|
|
|
- BeanUtil.copy(fatherNode, subUnit);
|
|
|
- subUnit.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- subUnit.setId(SnowFlakeUtil.getId());
|
|
|
- subUnit.setParentId(fatherNode.getId());
|
|
|
- subUnit.setAncestors(fatherNode.getAncestors() + "," + subUnit.getPKeyId());
|
|
|
- subUnit.setIsCustom(1);
|
|
|
- subUnit.setPartitionCode(dto.getSubUnitCode());
|
|
|
- subUnit.setNodeType(18);
|
|
|
- subUnit.setNodeName(dto.getSubUnitName());
|
|
|
- subUnit.setFullName(dto.getSubUnitName());
|
|
|
- subUnit.setIsTypePrivatePid(null);
|
|
|
- subUnit.setSort(i);
|
|
|
- subUnit.setTreePId(null);
|
|
|
- subUnit.setDateIsComplete(null);
|
|
|
- subUnit.setPId(fatherNode.getPKeyId());
|
|
|
- subUnit.setAncestorsPId(fatherNode.getAncestorsPId() + "," + fatherNode.getPKeyId());
|
|
|
- baseMapper.insert(subUnit);
|
|
|
- insertList.add(subUnit);
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- //分部工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
- if (!dto.getIsDivision()) {
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 3, wbsTreeContractRoot);
|
|
|
- if (!exist) {
|
|
|
- String fatherNodeName = "";
|
|
|
- if (dto.getSubUnitName() != null && !dto.getSubUnitName().equals("")) {
|
|
|
- fatherNodeName = dto.getSubUnitName();
|
|
|
- } else if (dto.getUnitName() != null && !dto.getUnitName().equals("")) {
|
|
|
- fatherNodeName = dto.getUnitName();
|
|
|
- }
|
|
|
- List<WbsTreeContract> list1 = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, fatherNodeName).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
- .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
- if (list1.size() > 0) {
|
|
|
- for (WbsTreeContract contract : list1) {
|
|
|
- String[] ids = contract.getAncestorsPId().split(",");
|
|
|
- ids = Arrays.stream(ids)
|
|
|
- .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
- .toArray(String[]::new);
|
|
|
- String sql = "Select node_name from m_wbs_tree_contract where p_key_id in(" + String.join(",", ids) + ")";
|
|
|
- List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
- String result = String.join("", nodeNames);
|
|
|
- result = result + contract.getNodeName();
|
|
|
- String ancestorsName = wbsTreeContractRoot.getNodeName() + StringUtils.defaultString(dto.getUnitName())
|
|
|
- + StringUtils.defaultString(dto.getSubUnitName());
|
|
|
- if (result.equals(ancestorsName)) {
|
|
|
- WbsTreeContract division = new WbsTreeContract();
|
|
|
- BeanUtil.copy(contract, division);
|
|
|
- division.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- division.setId(SnowFlakeUtil.getId());
|
|
|
- division.setParentId(contract.getId());
|
|
|
- division.setAncestors(contract.getAncestors() + "," + division.getPKeyId());
|
|
|
- division.setIsCustom(1);
|
|
|
- division.setPartitionCode(dto.getDivisionCode());
|
|
|
- division.setNodeType(2);
|
|
|
- division.setNodeName(dto.getDivisionName());
|
|
|
- division.setFullName(dto.getDivisionName());
|
|
|
- division.setIsTypePrivatePid(null);
|
|
|
- division.setSort(i);
|
|
|
- division.setTreePId(null);
|
|
|
- division.setDateIsComplete(null);
|
|
|
- division.setPId(contract.getPKeyId());
|
|
|
- division.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
- baseMapper.insert(division);
|
|
|
- insertList.add(division);
|
|
|
- break;
|
|
|
+ //分部工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
+ if (!dto.getIsDivision()) {
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 3, wbsTreeContractRoot);
|
|
|
+ if (!exist) {
|
|
|
+ String fatherNodeName = "";
|
|
|
+ if (dto.getSubUnitName() != null && !dto.getSubUnitName().equals("")) {
|
|
|
+ fatherNodeName = dto.getSubUnitName();
|
|
|
+ } else if (dto.getUnitName() != null && !dto.getUnitName().equals("")) {
|
|
|
+ fatherNodeName = dto.getUnitName();
|
|
|
+ }
|
|
|
+ List<WbsTreeContract> list1 = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, fatherNodeName).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
+ .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
+ if (list1.size() > 0) {
|
|
|
+ for (WbsTreeContract contract : list1) {
|
|
|
+ String[] ids = contract.getAncestorsPId().split(",");
|
|
|
+ ids = Arrays.stream(ids)
|
|
|
+ .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
+ .toArray(String[]::new);
|
|
|
+ String sql = "Select node_name from m_wbs_tree_contract where p_key_id in(" + String.join(",", ids) + ")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String result = String.join("", nodeNames);
|
|
|
+ result = result + contract.getNodeName();
|
|
|
+ String ancestorsName = wbsTreeContractRoot.getNodeName() + StringUtils.defaultString(dto.getUnitName())
|
|
|
+ + StringUtils.defaultString(dto.getSubUnitName());
|
|
|
+ if (result.equals(ancestorsName)) {
|
|
|
+ WbsTreeContract division = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(contract, division);
|
|
|
+ division.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ division.setId(SnowFlakeUtil.getId());
|
|
|
+ division.setParentId(contract.getId());
|
|
|
+ division.setAncestors(contract.getAncestors() + "," + division.getPKeyId());
|
|
|
+ division.setIsCustom(1);
|
|
|
+ division.setPartitionCode(dto.getDivisionCode());
|
|
|
+ division.setNodeType(2);
|
|
|
+ division.setNodeName(dto.getDivisionName());
|
|
|
+ division.setFullName(dto.getDivisionName());
|
|
|
+ division.setIsTypePrivatePid(null);
|
|
|
+ division.setSort(i);
|
|
|
+ division.setTreePId(null);
|
|
|
+ division.setDateIsComplete(null);
|
|
|
+ division.setPId(contract.getPKeyId());
|
|
|
+ division.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
+ baseMapper.insert(division);
|
|
|
+ insertList.add(division);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- //子分部工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
- if (!dto.getIsSubDivision()) {
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 4, wbsTreeContractRoot);
|
|
|
- if (!exist) {
|
|
|
- String fatherNodeName = "";
|
|
|
- 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();
|
|
|
- }
|
|
|
- List<WbsTreeContract> list1 = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, fatherNodeName).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
- .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
- if (list1.size() > 0) {
|
|
|
- for (WbsTreeContract contract : list1) {
|
|
|
- String[] ids = contract.getAncestorsPId().split(",");
|
|
|
- ids = Arrays.stream(ids)
|
|
|
- .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
- .toArray(String[]::new);
|
|
|
- String sql = "Select node_name from m_wbs_tree_contract where p_key_id in(" + String.join(",", ids) + ")";
|
|
|
- List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
- String result = String.join("", nodeNames);
|
|
|
- result = result + contract.getNodeName();
|
|
|
- String ancestorsName = wbsTreeContractRoot.getNodeName() + StringUtils.defaultString(dto.getUnitName())
|
|
|
- + StringUtils.defaultString(dto.getSubUnitName())
|
|
|
- + StringUtils.defaultString(dto.getDivisionName());
|
|
|
- if (result.equals(ancestorsName)) {
|
|
|
- WbsTreeContract subDivision = new WbsTreeContract();
|
|
|
- BeanUtil.copy(contract, subDivision);
|
|
|
- subDivision.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- subDivision.setId(SnowFlakeUtil.getId());
|
|
|
- subDivision.setParentId(contract.getId());
|
|
|
- subDivision.setAncestors(contract.getAncestors() + "," + subDivision.getPKeyId());
|
|
|
- subDivision.setIsCustom(1);
|
|
|
- subDivision.setPartitionCode(dto.getDivisionCode());
|
|
|
- subDivision.setNodeType(3);
|
|
|
- subDivision.setNodeName(dto.getSubDivisionName());
|
|
|
- subDivision.setFullName(dto.getSubDivisionName());
|
|
|
- subDivision.setIsTypePrivatePid(null);
|
|
|
- subDivision.setSort(i);
|
|
|
- subDivision.setTreePId(null);
|
|
|
- subDivision.setDateIsComplete(null);
|
|
|
- subDivision.setPId(contract.getPKeyId());
|
|
|
- subDivision.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
- baseMapper.insert(subDivision);
|
|
|
- insertList.add(subDivision);
|
|
|
- break;
|
|
|
+ }
|
|
|
+ //子分部工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
+ if (!dto.getIsSubDivision()) {
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 4, wbsTreeContractRoot);
|
|
|
+ if (!exist) {
|
|
|
+ String fatherNodeName = "";
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ List<WbsTreeContract> list1 = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, fatherNodeName).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
+ .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
+ if (list1.size() > 0) {
|
|
|
+ for (WbsTreeContract contract : list1) {
|
|
|
+ String[] ids = contract.getAncestorsPId().split(",");
|
|
|
+ ids = Arrays.stream(ids)
|
|
|
+ .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
+ .toArray(String[]::new);
|
|
|
+ String sql = "Select node_name from m_wbs_tree_contract where p_key_id in(" + String.join(",", ids) + ")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String result = String.join("", nodeNames);
|
|
|
+ result = result + contract.getNodeName();
|
|
|
+ String ancestorsName = wbsTreeContractRoot.getNodeName() + StringUtils.defaultString(dto.getUnitName())
|
|
|
+ + StringUtils.defaultString(dto.getSubUnitName())
|
|
|
+ + StringUtils.defaultString(dto.getDivisionName());
|
|
|
+ if (result.equals(ancestorsName)) {
|
|
|
+ WbsTreeContract subDivision = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(contract, subDivision);
|
|
|
+ subDivision.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ subDivision.setId(SnowFlakeUtil.getId());
|
|
|
+ subDivision.setParentId(contract.getId());
|
|
|
+ subDivision.setAncestors(contract.getAncestors() + "," + subDivision.getPKeyId());
|
|
|
+ subDivision.setIsCustom(1);
|
|
|
+ subDivision.setPartitionCode(dto.getDivisionCode());
|
|
|
+ subDivision.setNodeType(3);
|
|
|
+ subDivision.setNodeName(dto.getSubDivisionName());
|
|
|
+ subDivision.setFullName(dto.getSubDivisionName());
|
|
|
+ subDivision.setIsTypePrivatePid(null);
|
|
|
+ subDivision.setSort(i);
|
|
|
+ subDivision.setTreePId(null);
|
|
|
+ subDivision.setDateIsComplete(null);
|
|
|
+ subDivision.setPId(contract.getPKeyId());
|
|
|
+ subDivision.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
+ baseMapper.insert(subDivision);
|
|
|
+ insertList.add(subDivision);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- //分项节点:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
- if (!dto.getIsItem()) {
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 5, wbsTreeContractRoot);
|
|
|
- if (!exist) {
|
|
|
- String fatherNodeName = "";
|
|
|
- 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();
|
|
|
- }
|
|
|
- List<WbsTreeContract> list1 = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, fatherNodeName).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
- .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
- if (list1.size() > 0) {
|
|
|
- for (WbsTreeContract contract : list1) {
|
|
|
- String[] ids = contract.getAncestorsPId().split(",");
|
|
|
- ids = Arrays.stream(ids)
|
|
|
- .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
- .toArray(String[]::new);
|
|
|
- String sql = "Select node_name from m_wbs_tree_contract where p_key_id in(" + String.join(",", ids) + ")";
|
|
|
- List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
- String result = String.join("", nodeNames);
|
|
|
- result = result + contract.getNodeName();
|
|
|
- String ancestorsName = wbsTreeContractRoot.getNodeName() + StringUtils.defaultString(dto.getUnitName())
|
|
|
- + StringUtils.defaultString(dto.getSubUnitName())
|
|
|
- + StringUtils.defaultString(dto.getDivisionName())
|
|
|
- + StringUtils.defaultString(dto.getSubDivisionName());
|
|
|
- if (result.equals(ancestorsName)) {
|
|
|
- WbsTreeContract item = new WbsTreeContract();
|
|
|
- BeanUtil.copy(contract, item);
|
|
|
- item.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- item.setId(SnowFlakeUtil.getId());
|
|
|
- item.setParentId(contract.getId());
|
|
|
- item.setAncestors(contract.getAncestors() + "," + item.getPKeyId());
|
|
|
- item.setIsCustom(1);
|
|
|
- item.setPartitionCode(dto.getItemCode());
|
|
|
- item.setNodeType(4);
|
|
|
- item.setNodeName(dto.getItemName());
|
|
|
- item.setFullName(dto.getItemName());
|
|
|
- item.setIsTypePrivatePid(null);
|
|
|
- item.setSort(i);
|
|
|
- item.setTreePId(null);
|
|
|
- item.setDateIsComplete(null);
|
|
|
- item.setPId(contract.getPKeyId());
|
|
|
- item.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
- baseMapper.insert(item);
|
|
|
- insertList.add(item);
|
|
|
- break;
|
|
|
+ }
|
|
|
+ //分项节点:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
+ if (!dto.getIsItem()) {
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 5, wbsTreeContractRoot);
|
|
|
+ if (!exist) {
|
|
|
+ String fatherNodeName = "";
|
|
|
+ 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();
|
|
|
+ }
|
|
|
+ List<WbsTreeContract> list1 = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, fatherNodeName).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
+ .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
+ if (list1.size() > 0) {
|
|
|
+ for (WbsTreeContract contract : list1) {
|
|
|
+ String[] ids = contract.getAncestorsPId().split(",");
|
|
|
+ ids = Arrays.stream(ids)
|
|
|
+ .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
+ .toArray(String[]::new);
|
|
|
+ String sql = "Select node_name from m_wbs_tree_contract where p_key_id in(" + String.join(",", ids) + ")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String result = String.join("", nodeNames);
|
|
|
+ result = result + contract.getNodeName();
|
|
|
+ String ancestorsName = wbsTreeContractRoot.getNodeName() + StringUtils.defaultString(dto.getUnitName())
|
|
|
+ + StringUtils.defaultString(dto.getSubUnitName())
|
|
|
+ + StringUtils.defaultString(dto.getDivisionName())
|
|
|
+ + StringUtils.defaultString(dto.getSubDivisionName());
|
|
|
+ if (result.equals(ancestorsName)) {
|
|
|
+ WbsTreeContract item = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(contract, item);
|
|
|
+ item.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ item.setId(SnowFlakeUtil.getId());
|
|
|
+ item.setParentId(contract.getId());
|
|
|
+ item.setAncestors(contract.getAncestors() + "," + item.getPKeyId());
|
|
|
+ item.setIsCustom(1);
|
|
|
+ item.setPartitionCode(dto.getItemCode());
|
|
|
+ item.setNodeType(4);
|
|
|
+ item.setNodeName(dto.getItemName());
|
|
|
+ item.setFullName(dto.getItemName());
|
|
|
+ item.setIsTypePrivatePid(null);
|
|
|
+ item.setSort(i);
|
|
|
+ item.setTreePId(null);
|
|
|
+ item.setDateIsComplete(null);
|
|
|
+ item.setPId(contract.getPKeyId());
|
|
|
+ item.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
+ baseMapper.insert(item);
|
|
|
+ insertList.add(item);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
- }
|
|
|
- //子分项节点:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
- if (!dto.getIsSubItem()) {
|
|
|
- Boolean exist = this.isExist(dto, WbsTreeContractList, 6, wbsTreeContractRoot);
|
|
|
- if (!exist) {
|
|
|
- String fatherNodeName = "";
|
|
|
- if (dto.getItemName() != null && !dto.getItemName().equals("")) {
|
|
|
- fatherNodeName = dto.getItemName();
|
|
|
- } 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();
|
|
|
- }
|
|
|
- List<WbsTreeContract> list1 = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, fatherNodeName).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
- .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
- if (list1.size() > 0) {
|
|
|
- for (WbsTreeContract contract : list1) {
|
|
|
- String[] ids = contract.getAncestorsPId().split(",");
|
|
|
- ids = Arrays.stream(ids)
|
|
|
- .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
- .toArray(String[]::new);
|
|
|
- String sql = "Select node_name from m_wbs_tree_contract where p_key_id in(" + String.join(",", ids) + ")";
|
|
|
- List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
- String result = String.join("", nodeNames);
|
|
|
- result = result + contract.getNodeName();
|
|
|
- String ancestorsName = wbsTreeContractRoot.getNodeName() + StringUtils.defaultString(dto.getUnitName())
|
|
|
- + StringUtils.defaultString(dto.getSubUnitName())
|
|
|
- + StringUtils.defaultString(dto.getDivisionName())
|
|
|
- + StringUtils.defaultString(dto.getSubDivisionName())
|
|
|
- + StringUtils.defaultString(dto.getItemName());
|
|
|
- if (result.equals(ancestorsName)) {
|
|
|
- WbsTreeContract subItem = new WbsTreeContract();
|
|
|
- BeanUtil.copy(contract, subItem);
|
|
|
- subItem.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- subItem.setId(SnowFlakeUtil.getId());
|
|
|
- subItem.setParentId(contract.getId());
|
|
|
- subItem.setAncestors(contract.getAncestors() + "," + subItem.getPKeyId());
|
|
|
- subItem.setIsCustom(1);
|
|
|
- subItem.setPartitionCode(dto.getSubItemCode());
|
|
|
- subItem.setNodeType(5);
|
|
|
- subItem.setNodeName(dto.getSubItemName());
|
|
|
- subItem.setFullName(dto.getSubItemName());
|
|
|
- subItem.setIsTypePrivatePid(null);
|
|
|
- subItem.setSort(i);
|
|
|
- subItem.setTreePId(null);
|
|
|
- subItem.setDateIsComplete(null);
|
|
|
- subItem.setPId(contract.getPKeyId());
|
|
|
- subItem.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
- baseMapper.insert(subItem);
|
|
|
- insertList.add(subItem);
|
|
|
- break;
|
|
|
+ }
|
|
|
+ //子分项节点:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
+ if (!dto.getIsSubItem()) {
|
|
|
+ Boolean exist = this.isExist(dto, WbsTreeContractList, 6, wbsTreeContractRoot);
|
|
|
+ if (!exist) {
|
|
|
+ String fatherNodeName = "";
|
|
|
+ if (dto.getItemName() != null && !dto.getItemName().equals("")) {
|
|
|
+ fatherNodeName = dto.getItemName();
|
|
|
+ } 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();
|
|
|
+ }
|
|
|
+ List<WbsTreeContract> list1 = baseMapper.selectList(Wrappers.<WbsTreeContract>lambdaQuery().eq(WbsTreeContract::getNodeName, fatherNodeName).eq(WbsTreeContract::getProjectId, wbsTreeContractRoot.getProjectId())
|
|
|
+ .eq(WbsTreeContract::getContractId, wbsTreeContractRoot.getContractId()).eq(WbsTreeContract::getIsDeleted, 0));
|
|
|
+ if (list1.size() > 0) {
|
|
|
+ for (WbsTreeContract contract : list1) {
|
|
|
+ String[] ids = contract.getAncestorsPId().split(",");
|
|
|
+ ids = Arrays.stream(ids)
|
|
|
+ .filter(id -> !id.equals("0")) // 过滤掉值为 "0" 的元素
|
|
|
+ .toArray(String[]::new);
|
|
|
+ String sql = "Select node_name from m_wbs_tree_contract where p_key_id in(" + String.join(",", ids) + ")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String result = String.join("", nodeNames);
|
|
|
+ result = result + contract.getNodeName();
|
|
|
+ String ancestorsName = wbsTreeContractRoot.getNodeName() + StringUtils.defaultString(dto.getUnitName())
|
|
|
+ + StringUtils.defaultString(dto.getSubUnitName())
|
|
|
+ + StringUtils.defaultString(dto.getDivisionName())
|
|
|
+ + StringUtils.defaultString(dto.getSubDivisionName())
|
|
|
+ + StringUtils.defaultString(dto.getItemName());
|
|
|
+ if (result.equals(ancestorsName)) {
|
|
|
+ WbsTreeContract subItem = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(contract, subItem);
|
|
|
+ subItem.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ subItem.setId(SnowFlakeUtil.getId());
|
|
|
+ subItem.setParentId(contract.getId());
|
|
|
+ subItem.setAncestors(contract.getAncestors() + "," + subItem.getPKeyId());
|
|
|
+ subItem.setIsCustom(1);
|
|
|
+ subItem.setPartitionCode(dto.getSubItemCode());
|
|
|
+ subItem.setNodeType(5);
|
|
|
+ subItem.setNodeName(dto.getSubItemName());
|
|
|
+ subItem.setFullName(dto.getSubItemName());
|
|
|
+ subItem.setIsTypePrivatePid(null);
|
|
|
+ subItem.setSort(i);
|
|
|
+ subItem.setTreePId(null);
|
|
|
+ subItem.setDateIsComplete(null);
|
|
|
+ subItem.setPId(contract.getPKeyId());
|
|
|
+ subItem.setAncestorsPId(contract.getAncestorsPId() + "," + contract.getPKeyId());
|
|
|
+ baseMapper.insert(subItem);
|
|
|
+ insertList.add(subItem);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+ bladeRedis.setEx("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), "100%",5L);
|
|
|
+ } catch (Exception e) {
|
|
|
+ bladeRedis.del("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId());
|
|
|
+ }finally {
|
|
|
+ bladeRedis.del("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId());
|
|
|
}
|
|
|
- bladeRedis.setEx("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId(), "100%",5L);
|
|
|
- } catch (Exception e) {
|
|
|
- bladeRedis.del("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId());
|
|
|
- }finally {
|
|
|
- bladeRedis.del("import:projectId:"+wbsTreeContractRoot.getProjectId()+"contractId:"+wbsTreeContractRoot.getContractId());
|
|
|
+ return R.success("新增了" + insertList.size() + "个节点" + "," + String.join(",", updateList) + "节点编号已被修改");
|
|
|
+ } catch (IOException e) {
|
|
|
+ return R.fail("文件处理失败: " + e.getMessage());
|
|
|
}
|
|
|
- return R.success("新增了" + insertList.size() + "个节点" + "," + String.join(",", updateList) + "节点编号已被修改");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -4647,12 +4652,12 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public R getIsImport(Long projectId, Long contractId) {
|
|
|
+ public Boolean getIsImport(Long projectId, Long contractId) {
|
|
|
Object o = bladeRedis.get("import:projectId:" + projectId + "contractId:" + contractId);
|
|
|
if(o!=null){
|
|
|
- return R.status(false);
|
|
|
+ return true;
|
|
|
}else {
|
|
|
- return R.status(true);
|
|
|
+ return false;
|
|
|
}
|
|
|
}
|
|
|
|