|
@@ -53,6 +53,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedCaseInsensitiveMap;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
import java.io.*;
|
|
|
import java.math.BigInteger;
|
|
|
import java.util.*;
|
|
@@ -418,7 +419,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<AppWbsTreeContractVO> searchNodeAllTable(String primaryKeyId, String tableOwner, String contractId, String projectId) {
|
|
|
+ public List<AppWbsTreeContractVO> searchNodeAllTable(String primaryKeyId, String tableOwner, String contractId, String projectId, HttpServletRequest request) {
|
|
|
//由于Feign调用时,获取不到UserId
|
|
|
Long userId;
|
|
|
if (StringUtils.isNotEmpty(primaryKeyId) && primaryKeyId.contains(":")) {
|
|
@@ -431,7 +432,9 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else {
|
|
|
userId = AuthUtil.getUserId();
|
|
|
}
|
|
|
+
|
|
|
WbsTreeContract wbsTreeContract = baseMapper.selectOne(Wrappers.<WbsTreeContract>query().lambda()
|
|
|
+ .select(WbsTreeContract::getId, WbsTreeContract::getProjectId, WbsTreeContract::getContractId, WbsTreeContract::getContractIdRelation, WbsTreeContract::getWbsId)
|
|
|
.eq(WbsTreeContract::getPKeyId, primaryKeyId));
|
|
|
if (wbsTreeContract == null) {
|
|
|
return Collections.emptyList();
|
|
@@ -450,12 +453,13 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
throw new ServiceException("当前用户角色未授权,请先分配角色查看元素表相对应的权限");
|
|
|
}
|
|
|
|
|
|
- List<String> tableOwnerNumbers = wbsTableOwnerRoleList.stream().map(WbsTableOwnerRole::getTableOwnerNumber).collect(Collectors.toList());
|
|
|
+ //角色表单权限(后管权限配置)
|
|
|
+ Set<String> roleTableOwnerSets = wbsTableOwnerRoleList.stream().map(WbsTableOwnerRole::getTableOwnerNumber).collect(Collectors.toSet());
|
|
|
|
|
|
- List<String> tableOwnerList = null;
|
|
|
+ //接口请求表单类型(施工质检 或 监理抽检)
|
|
|
+ Set<String> tabTableOwnerSets = new HashSet<>();
|
|
|
if (StringUtils.isNotEmpty(tableOwner)) {
|
|
|
String tableOwners;
|
|
|
- //字典owner_type
|
|
|
if (tableOwner.equals("1")) {
|
|
|
tableOwners = "1,2,3";
|
|
|
} else if (tableOwner.equals("2")) {
|
|
@@ -463,14 +467,43 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else {
|
|
|
tableOwners = "7,8,9";
|
|
|
}
|
|
|
- tableOwnerList = Func.toStrList(tableOwners);
|
|
|
+ tabTableOwnerSets.addAll(Func.toStrList(tableOwners));
|
|
|
+ }
|
|
|
+ //取交集
|
|
|
+ roleTableOwnerSets.retainAll(tabTableOwnerSets);
|
|
|
+
|
|
|
+ //判断是客户端还是APP
|
|
|
+ List<AppWbsTreeContractVO> resultTabs;
|
|
|
+ if (ObjectUtil.isNotEmpty(request)) {
|
|
|
+ /*暂时通过获取请求头,不通过Auth获取clientId标识来判断是客户端或APP*/
|
|
|
+ String userAgent = request.getHeader("User-Agent");
|
|
|
+ if (userAgent != null && (userAgent.contains("Windows") || userAgent.contains("windows") || userAgent.contains("Mac") || userAgent.contains("mac"))) {
|
|
|
+ //客户端查询
|
|
|
+ resultTabs = baseMapper.selectWbsTreeContractListClient(roleTableOwnerSets,
|
|
|
+ wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(),
|
|
|
+ wbsTreeContract.getContractId(), wbsTreeContract.getId(),
|
|
|
+ wbsTreeContract.getContractIdRelation());
|
|
|
+ } else {
|
|
|
+ //APP查询
|
|
|
+ resultTabs = baseMapper.selectWbsTreeContractList(roleTableOwnerSets,
|
|
|
+ wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(),
|
|
|
+ wbsTreeContract.getContractId(), wbsTreeContract.getId(),
|
|
|
+ wbsTreeContract.getContractIdRelation());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ //其他接口调用默认保持原始调用方式的查询
|
|
|
+ resultTabs = baseMapper.selectWbsTreeContractList(roleTableOwnerSets,
|
|
|
+ wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(),
|
|
|
+ wbsTreeContract.getContractId(), wbsTreeContract.getId(),
|
|
|
+ wbsTreeContract.getContractIdRelation());
|
|
|
}
|
|
|
-
|
|
|
- List<AppWbsTreeContractVO> resultTabs = baseMapper.selectWbsTreeContractList(tableOwnerNumbers, wbsTreeContract.getProjectId(), wbsTreeContract.getWbsId(), wbsTreeContract.getContractId(), wbsTreeContract.getId(), wbsTreeContract.getContractIdRelation(), tableOwnerList);
|
|
|
|
|
|
//表单排序
|
|
|
- List<AppWbsTreeContractVO> resultTabsToCopy = this.sortTabs(resultTabs, "__"); //复制表排序
|
|
|
- return this.sortTabs(resultTabsToCopy, "_PL_"); //频率表排序
|
|
|
+ if (resultTabs.size() > 0) {
|
|
|
+ List<AppWbsTreeContractVO> resultTabsToCopy = this.sortTabs(resultTabs, "__"); //复制表排序
|
|
|
+ return this.sortTabs(resultTabsToCopy, "_PL_"); //频率表排序
|
|
|
+ }
|
|
|
+ return resultTabs;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -684,61 +717,20 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
@Override
|
|
|
public List<WbsTreeContractLazyVO> lazyQueryContractWbsTree(String id, String contractId, String contractIdRelation, String tableOwner) {
|
|
|
+ if (StringUtils.isEmpty(tableOwner)) {
|
|
|
+ throw new ServiceException("tableOwner is not null");
|
|
|
+ }
|
|
|
if (ObjectUtil.isNotEmpty(contractId)) {
|
|
|
ContractInfo contractInfo = contractInfoMapper.selectOne(Wrappers.<ContractInfo>lambdaQuery().select(ContractInfo::getContractName, ContractInfo::getContractType).eq(ContractInfo::getId, contractId));
|
|
|
if (contractInfo != null) {
|
|
|
- //TODO ************ 施工合同段 ************
|
|
|
+ /*施工合同段*/
|
|
|
if (new Integer(1).equals(contractInfo.getContractType())) {
|
|
|
- /*获取本地缓存*/
|
|
|
- List<WbsTreeContractLazyVO> nodesAll = localCacheNodes.get(contractId);
|
|
|
-
|
|
|
- if (nodesAll == null || nodesAll.size() == 0) {
|
|
|
-
|
|
|
- //获取当前合同段所有缓存节点信息
|
|
|
- Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
|
|
|
- if (data != null) {
|
|
|
- //从Redis获取数据
|
|
|
- nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
|
- /*更新本地缓存*/
|
|
|
- localCacheNodes.put(contractId, nodesAll);
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- long startTime1 = System.currentTimeMillis();
|
|
|
-
|
|
|
- nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
-
|
|
|
- long endTime1 = System.currentTimeMillis();
|
|
|
- long executionTime1 = endTime1 - startTime1;
|
|
|
- logger.info("查询合同段" + contractId + "所有树执行时间:" + executionTime1 + " ms");
|
|
|
-
|
|
|
- if (nodesAll.size() > 0) {
|
|
|
- //判断是否有子级,赋值
|
|
|
- Map<Long, List<WbsTreeContractLazyVO>> groupedByParentId = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
- for (WbsTreeContractLazyVO vo : nodesAll) {
|
|
|
- if (vo.getParentId() == 0) {
|
|
|
- vo.setHasChildren(1);
|
|
|
- }
|
|
|
- List<WbsTreeContractLazyVO> childNodes = groupedByParentId.getOrDefault(vo.getId(), null);
|
|
|
- if (childNodes != null && childNodes.size() > 0) {
|
|
|
- vo.setHasChildren(1);
|
|
|
- } else {
|
|
|
- vo.setHasChildren(0);
|
|
|
- }
|
|
|
- }
|
|
|
- /*更新本地缓存*/
|
|
|
- localCacheNodes.put(contractId, nodesAll);
|
|
|
-
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ //获取本地缓存节点信息
|
|
|
+ List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(contractId);
|
|
|
|
|
|
//获取当前层懒加载节点
|
|
|
List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id) AS drawingsId,id,parent_id,node_type,type,wbs_type,is_concrete,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + contractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
|
|
|
- //所有节点
|
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
|
.collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
@@ -751,37 +743,14 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
ArrayList::new
|
|
|
));
|
|
|
|
|
|
- //获取当前合同段所有填报资料缓存信息
|
|
|
+ //获取本地缓存资料信息
|
|
|
List<WbsTreeContractLazyQueryInfoVO> queryInfoList = this.getQueryInfoList(contractId, tableOwner);
|
|
|
- /*List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
- Object dataInformationQuery;
|
|
|
- if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1");
|
|
|
- } else {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner);
|
|
|
- }
|
|
|
- if (dataInformationQuery != null) {
|
|
|
- queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
- } else {
|
|
|
- if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
- if (queryInfoList.size() > 0) {
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1", JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- } else {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
- if (queryInfoList.size() > 0) {
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner, JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
+
|
|
|
Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
.collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
|
List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
|
|
|
- //TODO 处理数量
|
|
|
+ /*处理数量*/
|
|
|
//填报过的所有最底层节点
|
|
|
List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
@@ -811,7 +780,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
long startTime3 = System.currentTimeMillis();
|
|
|
|
|
|
- //TODO 处理颜色
|
|
|
+ /*处理颜色*/
|
|
|
//先将WbsTreeContractLazyVO转为NodeVO
|
|
|
List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
//转为Map<Long, NodeVO>
|
|
@@ -829,7 +798,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
long executionTime3 = endTime3 - startTime3;
|
|
|
logger.info("处理颜色执行时间:" + executionTime3 + " ms");
|
|
|
|
|
|
- //TODO 处理最终结果集
|
|
|
+ /*处理最终结果集*/
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
//处理填报数量
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
@@ -857,6 +826,11 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? 1 : 0));
|
|
|
|
|
|
//设置颜色
|
|
|
+ if (lazyNodeVO.getSubmitCounts().equals(0)) {
|
|
|
+ lazyNodeVO.setColorStatus(1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
Integer parentColorStatus = nodeColorStatusMap.get(lazyNodeVO.getPKeyId());
|
|
|
if (parentColorStatus != null) {
|
|
|
lazyNodeVO.setColorStatus(parentColorStatus);
|
|
@@ -871,7 +845,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return lazyNodes;
|
|
|
}
|
|
|
|
|
|
- //TODO ************ 监理、业主合同段 ************
|
|
|
+ /*监理、业主合同段*/
|
|
|
} else if (new Integer("2").equals(contractInfo.getContractType()) || new Integer("3").equals(contractInfo.getContractType())) {
|
|
|
List<WbsTreeContractLazyVO> lazyNodesAll = new ArrayList<>();
|
|
|
List<String> contractIds = new ArrayList<>();
|
|
@@ -888,128 +862,49 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
for (String sgContractId : contractIds) {
|
|
|
ContractInfo sgContractInfo = jdbcTemplate.query("select contract_name from m_contract_info where id = " + sgContractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
if (sgContractInfo != null) {
|
|
|
- /*获取本地缓存*/
|
|
|
- List<WbsTreeContractLazyVO> nodesAll = localCacheNodes.get(sgContractId);
|
|
|
+ List<WbsTreeContractLazyVO> nodesAll = this.getNodeAll(sgContractId);
|
|
|
|
|
|
- if (nodesAll == null || nodesAll.size() == 0) {
|
|
|
-
|
|
|
- //获取当前合同段所有缓存节点信息
|
|
|
- Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + sgContractId);
|
|
|
- if (data != null) {
|
|
|
- //从Redis获取数据
|
|
|
- nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
|
- /*更新本地缓存*/
|
|
|
- localCacheNodes.put(sgContractId, nodesAll);
|
|
|
-
|
|
|
- } else {
|
|
|
- nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
- if (nodesAll.size() > 0) {
|
|
|
- //判断是否有子级,赋值
|
|
|
- Map<Long, List<WbsTreeContractLazyVO>> groupedByParentId = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
- for (WbsTreeContractLazyVO vo : nodesAll) {
|
|
|
- if (vo.getParentId() == 0) {
|
|
|
- vo.setHasChildren(1);
|
|
|
- }
|
|
|
- List<WbsTreeContractLazyVO> childNodes = groupedByParentId.getOrDefault(vo.getId(), null);
|
|
|
- if (childNodes != null && childNodes.size() > 0) {
|
|
|
- vo.setHasChildren(1);
|
|
|
- } else {
|
|
|
- vo.setHasChildren(0);
|
|
|
- }
|
|
|
- }
|
|
|
- /*更新本地缓存*/
|
|
|
- localCacheNodes.put(sgContractId, nodesAll);
|
|
|
-
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + sgContractId, JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //获取当前层懒加载节点
|
|
|
List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,contract_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id) AS drawingsId,id,parent_id,node_type,type,wbs_type,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + sgContractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
|
|
|
- //所有节点
|
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
|
.collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
ArrayList::new
|
|
|
));
|
|
|
-
|
|
|
- //所有最底层节点
|
|
|
List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
ArrayList::new
|
|
|
));
|
|
|
|
|
|
- //获取当前合同段所有填报资料缓存信息
|
|
|
List<WbsTreeContractLazyQueryInfoVO> queryInfoList = this.getQueryInfoList(sgContractId, tableOwner);
|
|
|
- /*List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
- Object dataInformationQuery;
|
|
|
- if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_1");
|
|
|
- } else {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_" + tableOwner);
|
|
|
- }
|
|
|
- if (dataInformationQuery != null) {
|
|
|
- queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
- } else {
|
|
|
- if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId + " and classify = 1", new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
- if (queryInfoList.size() > 0) {
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_1", JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- } else {
|
|
|
- queryInfoList = jdbcTemplate.query("select wbs_id,status from u_information_query where type = 1 and contract_id = " + sgContractId + " and classify = " + tableOwner, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
- if (queryInfoList.size() > 0) {
|
|
|
- JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + sgContractId + "_" + tableOwner, JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
+
|
|
|
Map<Long, Integer> queryInfoMaps = queryInfoList.stream().filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
.collect(Collectors.toMap(WbsTreeContractLazyQueryInfoVO::getWbsId, WbsTreeContractLazyQueryInfoVO::getStatus, (existingValue, newValue) -> existingValue));
|
|
|
List<Long> pKeyIdList = new ArrayList<>(queryInfoMaps.keySet());
|
|
|
|
|
|
- //TODO 处理数量
|
|
|
- //填报过的所有最底层节点
|
|
|
List<WbsTreeContractLazyVO> lowestNodesTB = distinctLowestNodesAll.parallelStream().filter(f -> pKeyIdList.contains(f.getPKeyId())).collect(Collectors.toList());
|
|
|
List<Long> lowestNodeParentIdsTB = lowestNodesTB.parallelStream().map(WbsTreeContractLazyVO::getParentId).collect(Collectors.toList());
|
|
|
List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
|
|
- //最底层节点颜色构造后Map
|
|
|
Map<Long, WbsTreeContractLazyVO> lowestNodesMap = lowestNodesTB.stream()
|
|
|
.peek(vo -> {
|
|
|
Integer colorStatus = queryInfoMaps.get(vo.getPKeyId());
|
|
|
if (colorStatus != null) {
|
|
|
- //任务状态0=未上报=颜色2蓝色、任务状态1=待审批=颜色3橙色、任务状态2=已审批=颜色4绿色
|
|
|
- ///*任务状态3=已废除=颜色1黑色*/(2023年10月16日13:59:00 已废除改为=颜色2蓝色)
|
|
|
vo.setColorStatus(colorStatus == 0 ? 2 : (colorStatus == 1 ? 3 : (colorStatus == 2 ? 4 : 2)));
|
|
|
} else {
|
|
|
- //未填报的=颜色1黑色
|
|
|
vo.setColorStatus(1);
|
|
|
}
|
|
|
}).collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
|
|
|
- //TODO 处理颜色
|
|
|
- //先将WbsTreeContractLazyVO转为NodeVO
|
|
|
List<NodeVO> nodeVOList = distinctNodesAll.stream().map(this::convertToNodeVO).collect(Collectors.toList());
|
|
|
- //转为Map<Long, NodeVO>
|
|
|
Map<Long, NodeVO> nodeVOMap = nodeVOList.stream().collect(Collectors.toMap(NodeVO::getId, vo -> vo, (existing, replacement) -> existing));
|
|
|
- //把distinctNodesAll把所有节点转为树形结构,再转为List<NodeVO>对象
|
|
|
List<NodeVO> treeNodeVOList = this.buildNodeTreeByStream(distinctNodesAll, lowestNodesMap);
|
|
|
- //处理节点颜色
|
|
|
NodeVO.calculateStatusToDFS(treeNodeVOList, nodeVOMap);
|
|
|
- //把树形结构转为普通List集合
|
|
|
List<NodeVO> nodeVOS = this.flattenTree(treeNodeVOList);
|
|
|
- //获取所有节点颜色Map
|
|
|
Map<Long, Integer> nodeColorStatusMap = nodeVOS.stream().collect(Collectors.toMap(NodeVO::getPKeyId, NodeVO::getStatus, (existing, replacement) -> existing));
|
|
|
|
|
|
- //TODO 处理最终结果集
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
- //处理填报数量
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
|
Long key = node.getPKeyId();
|
|
@@ -1020,9 +915,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //返回最终结果集
|
|
|
for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
- lazyNodeVO.setType(lazyNodeVO.getNodeType()); //前端显示需要一样的,所以修改成一样的
|
|
|
+ lazyNodeVO.setType(lazyNodeVO.getNodeType());
|
|
|
lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
lazyNodeVO.setContractIdRelation(sgContractId);
|
|
@@ -1032,10 +926,12 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //设置数量
|
|
|
lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryInfoMaps.get(lazyNodeVO.getPKeyId())) ? 1 : 0));
|
|
|
+ if (lazyNodeVO.getSubmitCounts().equals(0)) {
|
|
|
+ lazyNodeVO.setColorStatus(1);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
|
|
|
- //设置颜色
|
|
|
Integer parentColorStatus = nodeColorStatusMap.get(lazyNodeVO.getPKeyId());
|
|
|
if (parentColorStatus != null) {
|
|
|
lazyNodeVO.setColorStatus(parentColorStatus);
|
|
@@ -1058,54 +954,91 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
- //构建资料查询缓存的key
|
|
|
- private String buildCacheKey(String contractId, String tableOwner) {
|
|
|
- if (StringUtils.isNotEmpty(tableOwner)) {
|
|
|
- return contractId + "_" + tableOwner;
|
|
|
- } else {
|
|
|
- return contractId + "_1";
|
|
|
+ //获取当前合同段所有节点缓存
|
|
|
+ public List<WbsTreeContractLazyVO> getNodeAll(String contractId) {
|
|
|
+ /*获取本地缓存*/
|
|
|
+ List<WbsTreeContractLazyVO> nodesAll = localCacheNodes.get(contractId);
|
|
|
+
|
|
|
+ if (nodesAll == null || nodesAll.size() == 0) {
|
|
|
+
|
|
|
+ //获取当前合同段所有缓存节点信息
|
|
|
+ Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
|
|
|
+ if (data != null) {
|
|
|
+ //从Redis获取数据
|
|
|
+ nodesAll = JSON.parseArray(data.toString(), WbsTreeContractLazyVO.class);
|
|
|
+ /*更新本地缓存*/
|
|
|
+ localCacheNodes.put(contractId, nodesAll);
|
|
|
+
|
|
|
+ } else {
|
|
|
+
|
|
|
+ long startTime1 = System.currentTimeMillis();
|
|
|
+
|
|
|
+ nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
+
|
|
|
+ long endTime1 = System.currentTimeMillis();
|
|
|
+ long executionTime1 = endTime1 - startTime1;
|
|
|
+ logger.info("查询合同段" + contractId + "所有树执行时间:" + executionTime1 + " ms");
|
|
|
+
|
|
|
+ if (nodesAll.size() > 0) {
|
|
|
+ //判断是否有子级,赋值
|
|
|
+ Map<Long, List<WbsTreeContractLazyVO>> groupedByParentId = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
+ for (WbsTreeContractLazyVO vo : nodesAll) {
|
|
|
+ if (vo.getParentId() == 0) {
|
|
|
+ vo.setHasChildren(1);
|
|
|
+ }
|
|
|
+ List<WbsTreeContractLazyVO> childNodes = groupedByParentId.getOrDefault(vo.getId(), null);
|
|
|
+ if (childNodes != null && childNodes.size() > 0) {
|
|
|
+ vo.setHasChildren(1);
|
|
|
+ } else {
|
|
|
+ vo.setHasChildren(0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /*更新本地缓存*/
|
|
|
+ localCacheNodes.put(contractId, nodesAll);
|
|
|
+
|
|
|
+ JSONArray array = JSONArray.parseArray(JSON.toJSONString(nodesAll));
|
|
|
+ redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ return nodesAll;
|
|
|
}
|
|
|
|
|
|
//获取当前合同段所有填报资料缓存信息
|
|
|
public List<WbsTreeContractLazyQueryInfoVO> getQueryInfoList(String contractId, String tableOwner) {
|
|
|
//从本地缓存获取
|
|
|
- String cacheKey = buildCacheKey(contractId, tableOwner);
|
|
|
+ String cacheKey = contractId + "_" + tableOwner;
|
|
|
List<WbsTreeContractLazyQueryInfoVO> cachedQueryInfoList = localCacheQueryInfos.get(cacheKey);
|
|
|
|
|
|
if (cachedQueryInfoList != null && !cachedQueryInfoList.isEmpty()) {
|
|
|
return cachedQueryInfoList;
|
|
|
}
|
|
|
|
|
|
- //根据需要更新localCacheQueryInfos
|
|
|
- Object dataInformationQuery;
|
|
|
- if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1");
|
|
|
- } else {
|
|
|
- dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner);
|
|
|
- }
|
|
|
+ //获取redis缓存
|
|
|
+ Object dataInformationQuery = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:byInformationQuery:" + cacheKey);
|
|
|
+
|
|
|
List<WbsTreeContractLazyQueryInfoVO> queryInfoList;
|
|
|
if (dataInformationQuery != null) {
|
|
|
//返回redis数据
|
|
|
queryInfoList = JSON.parseArray(dataInformationQuery.toString(), WbsTreeContractLazyQueryInfoVO.class);
|
|
|
- localCacheQueryInfos.put(cacheKey, queryInfoList); //更新本地缓存
|
|
|
+
|
|
|
+ //更新本地缓存
|
|
|
+ localCacheQueryInfos.put(cacheKey, queryInfoList);
|
|
|
|
|
|
} else {
|
|
|
//返回数据库数据
|
|
|
- String querySql = ObjectUtil.isEmpty(tableOwner) ?
|
|
|
- "select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify =1" :
|
|
|
- "select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner;
|
|
|
+ String querySql = "select wbs_id,status from u_information_query where type = 1 and contract_id = " + contractId + " and classify = " + tableOwner;
|
|
|
|
|
|
queryInfoList = jdbcTemplate.query(querySql, new BeanPropertyRowMapper<>(WbsTreeContractLazyQueryInfoVO.class));
|
|
|
|
|
|
if (!queryInfoList.isEmpty()) {
|
|
|
JSONArray array = JSONArray.parseArray(JSON.toJSONString(queryInfoList));
|
|
|
- if (ObjectUtil.isEmpty(tableOwner)) {
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_1", JSON.toJSON(array).toString());
|
|
|
- } else {
|
|
|
- redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + contractId + "_" + tableOwner, JSON.toJSON(array).toString());
|
|
|
- }
|
|
|
- localCacheQueryInfos.put(cacheKey, queryInfoList); //更新本地缓存
|
|
|
+
|
|
|
+ //存储redis
|
|
|
+ redisTemplate.opsForValue().set("blade-manager::contract:wbstree:byInformationQuery:" + cacheKey, JSON.toJSON(array).toString());
|
|
|
+
|
|
|
+ //更新本地缓存
|
|
|
+ localCacheQueryInfos.put(cacheKey, queryInfoList);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1118,9 +1051,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
if (ObjectUtil.isNotEmpty(contractId)) {
|
|
|
ContractInfo contractInfo = jdbcTemplate.query("select contract_name,contract_type from m_contract_info where id = " + contractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
if (contractInfo != null) {
|
|
|
- //TODO 施工合同段
|
|
|
+ /*质检施工合同段*/
|
|
|
if (new Integer(1).equals(contractInfo.getContractType())) {
|
|
|
- //获取当前合同段所有缓存节点信息
|
|
|
List<WbsTreeContractLazyVO> nodesAll;
|
|
|
Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + contractId);
|
|
|
if (data != null) {
|
|
@@ -1128,7 +1060,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else {
|
|
|
nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (nodesAll.size() > 0) {
|
|
|
- //判断是否有子级,赋值
|
|
|
Map<Long, List<WbsTreeContractLazyVO>> groupedByParentId = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
for (WbsTreeContractLazyVO vo : nodesAll) {
|
|
|
if (vo.getParentId() == 0) {
|
|
@@ -1145,24 +1076,21 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
redisTemplate.opsForValue().set("blade-manager::contract:wbstree:" + contractId, JSON.toJSON(array).toString());
|
|
|
}
|
|
|
}
|
|
|
- //获取当前层懒加载节点
|
|
|
List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id) AS drawingsId,id,parent_id,node_type,type,wbs_type,is_concrete,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + contractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + contractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
|
|
|
- //所有节点
|
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
|
.collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
ArrayList::new
|
|
|
));
|
|
|
|
|
|
- //所有最底层节点
|
|
|
List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
ArrayList::new
|
|
|
));
|
|
|
- //获取当前合同段所有影像文件信息
|
|
|
+
|
|
|
List<WbsTreeContractLazyFileVO> queryFileList = jdbcTemplate.query("select wbs_id,id from u_image_classification_file where status = 1 and is_deleted = 0 and contract_id = " + contractId + " and classify_id = " + classId, new BeanPropertyRowMapper<>(WbsTreeContractLazyFileVO.class));
|
|
|
- //最底层节点与存储文件数量map
|
|
|
+
|
|
|
Map<Long, Integer> queryFileMaps = queryFileList.stream()
|
|
|
.filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
.collect(Collectors.groupingBy(
|
|
@@ -1189,7 +1117,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
|
|
- //处理最终结果集
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
@@ -1201,7 +1128,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //返回最终结果集
|
|
|
for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
lazyNodeVO.setType(lazyNodeVO.getNodeType());
|
|
|
lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
@@ -1211,14 +1137,13 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
lazyNodeVO.setTitle(contractInfo.getContractName());
|
|
|
}
|
|
|
}
|
|
|
- //设置数量
|
|
|
lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryFileMaps.get(lazyNodeVO.getPKeyId())) ? queryFileMaps.get(lazyNodeVO.getPKeyId()) : 0));
|
|
|
}
|
|
|
}
|
|
|
return lazyNodes;
|
|
|
}
|
|
|
|
|
|
- //TODO 监理、业主合同段
|
|
|
+ /*监理、业主合同段*/
|
|
|
} else if (new Integer("2").equals(contractInfo.getContractType()) || new Integer("3").equals(contractInfo.getContractType())) {
|
|
|
List<WbsTreeContractLazyVO> lazyNodesAll = new ArrayList<>();
|
|
|
List<String> contractIds = new ArrayList<>();
|
|
@@ -1235,7 +1160,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
for (String sgContractId : contractIds) {
|
|
|
ContractInfo sgContractInfo = jdbcTemplate.query("select contract_name from m_contract_info where id = " + sgContractId, new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
if (sgContractInfo != null) {
|
|
|
- //获取当前合同段所有缓存节点信息
|
|
|
List<WbsTreeContractLazyVO> nodesAll;
|
|
|
Object data = redisTemplate.opsForValue().get("blade-manager::contract:wbstree:" + sgContractId);
|
|
|
if (data != null) {
|
|
@@ -1243,7 +1167,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
} else {
|
|
|
nodesAll = jdbcTemplate.query("select a.p_key_id,a.id,a.parent_id from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + sgContractId, new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (nodesAll.size() > 0) {
|
|
|
- //判断是否有子级,赋值
|
|
|
Map<Long, List<WbsTreeContractLazyVO>> groupedByParentId = nodesAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
for (WbsTreeContractLazyVO vo : nodesAll) {
|
|
|
if (vo.getParentId() == 0) {
|
|
@@ -1261,17 +1184,13 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //获取当前层懒加载节点
|
|
|
List<WbsTreeContractLazyVO> lazyNodes = jdbcTemplate.query("select p_key_id,(SELECT id FROM u_contract_tree_drawings where process_id = p_key_id) AS drawingsId,id,parent_id,node_type,type,wbs_type,major_data_type,partition_code,old_id,contract_id_relation,is_concealed_works_node,CASE (SELECT count(1) FROM u_tree_contract_first AS tcf WHERE tcf.is_deleted = 0 AND tcf.wbs_node_id = a.p_key_id) WHEN 0 THEN 'false' ELSE 'true' END AS isFirst,IFNULL(if(length(trim(full_name))>0,full_name,node_name),node_name) AS title,(SELECT CASE WHEN count(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.type = 1 and b.status = 1 AND b.contract_id = " + sgContractId + " AND b.is_deleted = 0 ) AS hasChildren from m_wbs_tree_contract a where a.node_type != 111 and a.type = 1 and a.status = 1 and a.is_deleted = 0 and parent_id = " + (StringUtils.isNotEmpty(id) ? id : 0) + " and contract_id = " + sgContractId + " ORDER BY a.sort,title,a.create_time", new BeanPropertyRowMapper<>(WbsTreeContractLazyVO.class));
|
|
|
if (lazyNodes.size() > 0 && nodesAll.size() > 0) {
|
|
|
- //所有节点
|
|
|
List<WbsTreeContractLazyVO> distinctNodesAll = nodesAll.stream()
|
|
|
.collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
ArrayList::new
|
|
|
));
|
|
|
-
|
|
|
- //所有最底层节点
|
|
|
List<WbsTreeContractLazyVO> distinctLowestNodesAll = distinctNodesAll.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.collectingAndThen(
|
|
|
Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContractLazyVO::getPKeyId))),
|
|
|
ArrayList::new
|
|
@@ -1279,7 +1198,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
|
|
|
//获取当前合同段所有影像文件信息(只查看监理自己的,资料填报是查看的施工合同段的,这里有区别)
|
|
|
List<WbsTreeContractLazyFileVO> queryFileList = jdbcTemplate.query("select wbs_id,id from u_image_classification_file where status = 1 and contract_id = " + contractId + " and classify_id = " + classId, new BeanPropertyRowMapper<>(WbsTreeContractLazyFileVO.class));
|
|
|
- //最底层节点与存储文件数量map
|
|
|
+
|
|
|
Map<Long, Integer> queryFileMaps = queryFileList.stream()
|
|
|
.filter(f -> ObjectUtil.isNotEmpty(f.getWbsId()))
|
|
|
.collect(Collectors.groupingBy(
|
|
@@ -1304,7 +1223,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
List<WbsTreeContractLazyVO> resultParentNodesTB = new ArrayList<>();
|
|
|
this.recursiveGetParentNodes(resultParentNodesTB, lowestNodeParentIdsTB, nodesAll);
|
|
|
|
|
|
- //处理最终结果集
|
|
|
if (lazyNodes.size() > 0) {
|
|
|
Map<Long, Integer> countMap = new HashMap<>();
|
|
|
for (WbsTreeContractLazyVO node : resultParentNodesTB) {
|
|
@@ -1316,9 +1234,8 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //返回最终结果集
|
|
|
for (WbsTreeContractLazyVO lazyNodeVO : lazyNodes) {
|
|
|
- lazyNodeVO.setType(lazyNodeVO.getNodeType()); //前端显示需要一样的,所以修改成一样的
|
|
|
+ lazyNodeVO.setType(lazyNodeVO.getNodeType());
|
|
|
lazyNodeVO.setNotExsitChild(!lazyNodeVO.getHasChildren().equals(1));
|
|
|
lazyNodeVO.setPrimaryKeyId(lazyNodeVO.getPKeyId());
|
|
|
lazyNodeVO.setContractIdRelation(sgContractId);
|
|
@@ -1327,7 +1244,6 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
lazyNodeVO.setTitle(sgContractInfo.getContractName());
|
|
|
}
|
|
|
}
|
|
|
- //设置数量
|
|
|
lazyNodeVO.setSubmitCounts(ObjectUtil.isNotEmpty(countMap.get(lazyNodeVO.getPKeyId())) ? countMap.get(lazyNodeVO.getPKeyId()) : (ObjectUtil.isNotEmpty(queryFileMaps.get(lazyNodeVO.getPKeyId())) ? queryFileMaps.get(lazyNodeVO.getPKeyId()) : 0));
|
|
|
}
|
|
|
}
|
|
@@ -1365,7 +1281,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
@Override
|
|
|
public List<AppWbsTreeContractVO> searchNodeAllTableAndFile(String primaryKeyId, String type, String
|
|
|
contractId, String projectId) {
|
|
|
- List<AppWbsTreeContractVO> vos = this.searchNodeAllTable(primaryKeyId, type, contractId, projectId);
|
|
|
+ List<AppWbsTreeContractVO> vos = this.searchNodeAllTable(primaryKeyId, type, contractId, projectId, null);
|
|
|
if (vos != null && vos.size() > 0) {
|
|
|
List<Long> list = vos.stream().map(AppWbsTreeContractVO::getPKeyId).collect(Collectors.toList());
|
|
|
List<TableFile> files = tableFileService.getAllFileByIds(list);
|