|
@@ -7,7 +7,6 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.Update;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.google.common.collect.Lists;
|
|
@@ -41,7 +40,6 @@ import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.bean.NodeVO;
|
|
|
-import org.springblade.manager.controller.ExcelTabController;
|
|
|
import org.springblade.manager.dto.*;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
import org.springblade.manager.excel.WbsExcelBatchUtil;
|
|
@@ -56,7 +54,6 @@ import org.springblade.manager.utils.CompositeKey;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.data.redis.core.StringRedisTemplate;
|
|
|
import org.springframework.jdbc.BadSqlGrammarException;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@@ -72,7 +69,6 @@ import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
-import java.lang.reflect.Field;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.*;
|
|
@@ -2176,7 +2172,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return null;
|
|
|
}
|
|
|
@Override
|
|
|
- public void importTree(MultipartFile file, Long pkeyId) throws IOException {
|
|
|
+ @Transactional
|
|
|
+ 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);
|
|
@@ -2197,7 +2194,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
String itemCode = getCellValue(row.getCell(9)); // J列:分项工程编号
|
|
|
String subItemName = getCellValue(row.getCell(10)); // K列:子分项工程名称
|
|
|
String subItemCode = getCellValue(row.getCell(11));// L列:子分项工程编号
|
|
|
- ImportTreeDto dto=new ImportTreeDto(unitName,unitCode,1,false,subUnitName,subUnitCode,18,false,divisionName,divisionCode,2,false, subDivisionName,subDivisionCode,3,false,itemName,itemCode,4,false,subItemName,subItemCode,5,false);
|
|
|
+ ImportTreeDto dto=new ImportTreeDto(unitName,unitCode,1,unitName==null,subUnitName,subUnitCode,18,subUnitName==null,divisionName,divisionCode,2,divisionName==null, subDivisionName,subDivisionCode,3,subDivisionName==null,itemName,itemCode,4,itemName==null,subItemName,subItemCode,5,subItemName==null);
|
|
|
list.add(dto);
|
|
|
}
|
|
|
if(list.isEmpty()){
|
|
@@ -2287,28 +2284,209 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
//新增
|
|
|
for (ImportTreeDto dto : list) {
|
|
|
//单位工程:如果没有被处理过,说明需要新增
|
|
|
if (!dto.getIsUnit()){
|
|
|
- WbsTreeContract contract = new WbsTreeContract();
|
|
|
- BeanUtil.copy(wbsTreeContractRoot,contract);
|
|
|
- contract.setPKeyId(SnowFlakeUtil.getId());
|
|
|
- contract.setId(SnowFlakeUtil.getId());
|
|
|
- contract.setParentId(wbsTreeContractRoot.getId());
|
|
|
- contract.setAncestors(wbsTreeContractRoot.getAncestors()+","+contract.getId());
|
|
|
- contract.setIsCustom(1);
|
|
|
- contract.setIsTypePrivatePid(null);
|
|
|
- baseMapper.insert(contract);
|
|
|
+ WbsTreeContract unit = new WbsTreeContract();
|
|
|
+ BeanUtil.copy(wbsTreeContractRoot,unit);
|
|
|
+ unit.setPKeyId(SnowFlakeUtil.getId());
|
|
|
+ unit.setId(SnowFlakeUtil.getId());
|
|
|
+ unit.setParentId(wbsTreeContractRoot.getId());
|
|
|
+ unit.setAncestors(wbsTreeContractRoot.getAncestors()+","+unit.getId());
|
|
|
+ unit.setIsCustom(1);
|
|
|
+ unit.setIsTypePrivatePid(null);
|
|
|
+ unit.setNodeType(1);
|
|
|
+ insertList.add(unit);
|
|
|
}
|
|
|
//子单位工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。单位工程不会有相同的,所以直接根据名称查找
|
|
|
if(!dto.getIsSubUnit()){
|
|
|
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));
|
|
|
+ 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.getId());
|
|
|
+ subUnit.setIsCustom(1);
|
|
|
+ subUnit.setIsTypePrivatePid(null);
|
|
|
+ subUnit.setNodeType(18);
|
|
|
+ insertList.add(subUnit);
|
|
|
+ }
|
|
|
+ //分部工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
+ if(!dto.getIsDivision()){
|
|
|
+ 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.getAncestors().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 id in("+String.join("','", ids)+")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String result = String.join("",nodeNames);
|
|
|
+ String ancestorsName=dto.getUnitName()!=null?dto.getUnitName():""+dto.getSubUnitName()!=null?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.getId());
|
|
|
+ division.setIsCustom(1);
|
|
|
+ division.setIsTypePrivatePid(null);
|
|
|
+ division.setNodeType(2);
|
|
|
+ insertList.add(division);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //子分部工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
+ if(!dto.getIsSubDivision()){
|
|
|
+ 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.getAncestors().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 id in("+String.join("','", ids)+")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String result = String.join("",nodeNames);
|
|
|
+ String ancestorsName=dto.getUnitName()!=null?dto.getUnitName():""+dto.getSubUnitName()!=null?dto.getSubUnitName():""+dto.getDivisionName()!=null?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.getId());
|
|
|
+ subDivision.setIsCustom(1);
|
|
|
+ subDivision.setIsTypePrivatePid(null);
|
|
|
+ subDivision.setNodeType(3);
|
|
|
+ insertList.add(subDivision);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //分项节点:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
+ if(!dto.getIsItem()){
|
|
|
+ String fatherNodeName="";
|
|
|
+ if(dto.getItemName()!=null&&!dto.getItemName().equals("")){
|
|
|
+ fatherNodeName=dto.getItemName();
|
|
|
+ } 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.getAncestors().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 id in("+String.join("','", ids)+")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String result = String.join("",nodeNames);
|
|
|
+ String ancestorsName=dto.getUnitName()!=null?dto.getUnitName():""+dto.getSubUnitName()!=null?dto.getSubUnitName():""+dto.getDivisionName()!=null?dto.getDivisionName():""+dto.getSubUnitName()!=null?dto.getSubUnitName():"";
|
|
|
+ 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.getId());
|
|
|
+ item.setIsCustom(1);
|
|
|
+ item.setIsTypePrivatePid(null);
|
|
|
+ item.setNodeType(4);
|
|
|
+ insertList.add(item);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //子分项节点:如果没有被处理过,说明需要新增,最重要是需要找到父节点。现在的办法是(通过祖级节点名称拼接的方式来判断)。
|
|
|
+ if(!dto.getIsSubItem()){
|
|
|
+ String fatherNodeName="";
|
|
|
+ if(dto.getSubItemName()!=null&&!dto.getSubItemName().equals("")){
|
|
|
+ fatherNodeName=dto.getSubItemName();
|
|
|
+ }else if(dto.getItemName()!=null&&!dto.getItemName().equals("")){
|
|
|
+ fatherNodeName=dto.getItemName();
|
|
|
+ } 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.getAncestors().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 id in("+String.join("','", ids)+")";
|
|
|
+ List<String> nodeNames = jdbcTemplate.query(sql, new SingleColumnRowMapper<>(String.class));
|
|
|
+ String result = String.join("",nodeNames);
|
|
|
+ String ancestorsName=dto.getUnitName()!=null?dto.getUnitName():""+dto.getSubUnitName()!=null?dto.getSubUnitName():""+dto.getDivisionName()!=null?dto.getDivisionName():""+dto.getSubUnitName()!=null?dto.getSubUnitName():""+dto.getItemName()!=null?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.getId());
|
|
|
+ subItem.setIsCustom(1);
|
|
|
+ subItem.setIsTypePrivatePid(null);
|
|
|
+ subItem.setNodeType(5);
|
|
|
+ insertList.add(subItem);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ if(insertList.size()>0){
|
|
|
+ baseMapper.insertBatchSomeColumn(insertList);
|
|
|
+ }
|
|
|
+ return R.success("新增了"+insertList.size()+"个节点"+","+String.join(",",updateList)+"节点编号已被修改");
|
|
|
}
|
|
|
|
|
|
//判断名称是否都在wbs的祖级节点里面
|