|
@@ -67,6 +67,7 @@ import org.springblade.manager.service.IWbsTreeContractService;
|
|
|
import org.springblade.manager.utils.CompositeKey;
|
|
|
import org.springblade.manager.vo.*;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
+import org.springblade.websocket.feign.WebSocketClient;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.core.io.ByteArrayResource;
|
|
|
import org.springframework.core.io.Resource;
|
|
@@ -78,6 +79,7 @@ import org.springframework.jdbc.BadSqlGrammarException;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.jdbc.core.SingleColumnRowMapper;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Isolation;
|
|
|
import org.springframework.transaction.annotation.Propagation;
|
|
@@ -2748,6 +2750,7 @@ 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();
|
|
@@ -2897,292 +2900,298 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
int i = 0;
|
|
|
- for (ImportTreeDto dto : list) {
|
|
|
- //新增
|
|
|
- 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);
|
|
|
+ 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.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();
|
|
|
+ //子单位工程:如果没有被处理过,说明需要新增,最重要是需要找到父节点。单位工程不会有相同的,所以直接根据名称查找
|
|
|
+ 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);
|
|
|
}
|
|
|
- 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());
|
|
|
}
|
|
|
- //entityManager.flush();
|
|
|
-// if(insertList.size()>0){
|
|
|
-// baseMapper.insertBatchSomeColumn(insertList);
|
|
|
-// }
|
|
|
return R.success("新增了" + insertList.size() + "个节点" + "," + String.join(",", updateList) + "节点编号已被修改");
|
|
|
}
|
|
|
|
|
@@ -4637,6 +4646,26 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return R.status(false);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R getIsImport(Long projectId, Long contractId) {
|
|
|
+ Object o = bladeRedis.get("import:projectId:" + projectId + "contractId:" + contractId);
|
|
|
+ if(o!=null){
|
|
|
+ return R.status(false);
|
|
|
+ }else {
|
|
|
+ return R.status(true);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getImportProgress(Long projectId, Long contractId) {
|
|
|
+ Object o = bladeRedis.get("import:projectId:" + projectId + "contractId:" + contractId);
|
|
|
+ if(o!=null){
|
|
|
+ return R.data(o.toString());
|
|
|
+ }else {
|
|
|
+ return R.data("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 检查单元格是否有效
|
|
|
*/
|