|
@@ -2,27 +2,32 @@ package org.springblade.manager.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
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.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.springblade.business.entity.InformationQuery;
|
|
|
import org.springblade.business.feign.InformationQueryClient;
|
|
|
import org.springblade.common.utils.BaiduApiUtil;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
+import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.BeanUtil;
|
|
|
import org.springblade.manager.dto.FindAllUserByConditionDTO;
|
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
|
import org.springblade.manager.entity.*;
|
|
|
+import org.springblade.manager.mapper.ContractInfoMapper;
|
|
|
import org.springblade.manager.mapper.ProjectContractAreaMapper;
|
|
|
import org.springblade.manager.mapper.SaveUserInfoByProjectMapper;
|
|
|
import org.springblade.manager.mapper.WbsTreeContractMapper;
|
|
|
-import org.springblade.manager.vo.*;
|
|
|
-import org.springblade.manager.mapper.ContractInfoMapper;
|
|
|
import org.springblade.manager.service.IContractInfoService;
|
|
|
-import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.manager.vo.*;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
import org.springblade.system.user.vo.UserContractInfoVO;
|
|
@@ -31,7 +36,6 @@ import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
@@ -206,10 +210,250 @@ public class ContractInfoServiceImpl extends BaseServiceImpl<ContractInfoMapper,
|
|
|
|
|
|
@Override
|
|
|
public List<ContractInfo> getContractListByProjectId(Long projectId) {
|
|
|
- List<ContractInfo> list=contractInfoMapper.getContractListByProjectId(projectId);
|
|
|
- return list;
|
|
|
+ return contractInfoMapper.getContractListByProjectId(projectId);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getTreeNodeByValueAndContractId(String queryValue, String contractId) {
|
|
|
+ List<WbsTreeContractTreeAllVO> resultList = new ArrayList<>();
|
|
|
+ Map<Long, List<WbsTreeContractTreeAllVO>> resultMaps = new LinkedHashMap<>();
|
|
|
+ if (StringUtils.isNotEmpty(queryValue) && StringUtils.isNotEmpty(contractId)) {
|
|
|
+ ContractInfo contractInfo = contractInfoMapper.selectById(contractId);
|
|
|
+ if (contractInfo != null) {
|
|
|
+ //质检
|
|
|
+ if (contractInfo.getContractType().equals(1)) {
|
|
|
+ //获取查询的有效节点信息,以及所有上级父级节点
|
|
|
+ LambdaQueryWrapper<WbsTreeContract> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.like(WbsTreeContract::getFullName, queryValue);
|
|
|
+ queryWrapper.eq(WbsTreeContract::getContractId, contractId);
|
|
|
+ queryWrapper.eq(WbsTreeContract::getType, 1);
|
|
|
+ List<WbsTreeContract> nodes = wbsTreeContractMapper.selectList(queryWrapper);
|
|
|
+ Set<WbsTreeContract> resultNodes = new LinkedHashSet<>();
|
|
|
+ this.recursiveGetParentNodes(resultNodes, nodes, contractId);
|
|
|
+ resultNodes.addAll(nodes);
|
|
|
+ List<String> nodePkeyIds = resultNodes.stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取填报过的资料信息Map
|
|
|
+ Set<InformationQuery> informationQuerySet = new HashSet<>();
|
|
|
+ List<List<String>> partition = Lists.partition(nodePkeyIds, 500);
|
|
|
+ for (List<String> wbsIds : partition) {
|
|
|
+ List<InformationQuery> informationQueryList = jdbcTemplate.query("select wbs_id,status from u_information_query where wbs_id in(" + org.apache.commons.lang.StringUtils.join(wbsIds, ",") + ")", new BeanPropertyRowMapper<>(InformationQuery.class));
|
|
|
+ informationQuerySet.addAll(informationQueryList);
|
|
|
+ }
|
|
|
+ Map<Long, Integer> informationQueryMaps = informationQuerySet.stream().collect(Collectors.toMap(InformationQuery::getWbsId, InformationQuery::getStatus, (v1, v2) -> v1));
|
|
|
+
|
|
|
+ //构造vo
|
|
|
+ List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = resultNodes.stream().map(node -> {
|
|
|
+ WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
|
|
|
+ if (vo != null) {
|
|
|
+ vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
|
|
|
+ vo.setTitle(node.getFullName());
|
|
|
+ vo.setPrimaryKeyId(node.getPKeyId());
|
|
|
+ if (ObjectUtils.isNotEmpty(informationQueryMaps.get(vo.getPrimaryKeyId()))) {
|
|
|
+ vo.setSubmitCounts(1L); //如果存在资料填报信息,那么计数
|
|
|
+ vo.setColorStatus(informationQueryMaps.get(vo.getPrimaryKeyId())); //颜色
|
|
|
+ } else {
|
|
|
+ vo.setSubmitCounts(0L);
|
|
|
+ vo.setColorStatus(null); //没填报就是null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //构造树形结构
|
|
|
+ List<WbsTreeContractTreeAllVO> reNodes = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
|
|
|
+
|
|
|
+ //获取构造完的List集合
|
|
|
+ LinkedList<WbsTreeContractTreeAllVO> resultNodesAll = new LinkedList<>();
|
|
|
+ this.getNodesAll(reNodes, resultNodesAll);
|
|
|
+ resultNodesAll.addAll(0, reNodes);
|
|
|
+
|
|
|
+ //处理父级节点计数、颜色问题
|
|
|
+ this.reSetSubmitCountsAndColorStatus(resultNodesAll);
|
|
|
+
|
|
|
+ //返回结果集
|
|
|
+ resultList.addAll(reNodes);
|
|
|
+ return R.data(resultList);
|
|
|
+
|
|
|
+ } else if (contractInfo.getContractType().equals(2) || contractInfo.getContractType().equals(3)) {
|
|
|
+ //监理、指挥部
|
|
|
+ List<ContractRelationJlyz> relationJLYZList = jdbcTemplate.query("select * from m_contract_relation_jlyz where contract_id_jlyz = " + contractId, new BeanPropertyRowMapper<>(ContractRelationJlyz.class));
|
|
|
+
|
|
|
+ for (ContractRelationJlyz contractRelationJlyz : relationJLYZList) {
|
|
|
+ //获取查询的有效节点信息,以及所有上级父级节点
|
|
|
+ LambdaQueryWrapper<WbsTreeContract> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.like(WbsTreeContract::getFullName, queryValue);
|
|
|
+ queryWrapper.eq(WbsTreeContract::getContractId, contractRelationJlyz.getContractIdSg());
|
|
|
+ queryWrapper.eq(WbsTreeContract::getType, 1);
|
|
|
+ List<WbsTreeContract> nodes = wbsTreeContractMapper.selectList(queryWrapper);
|
|
|
+ Set<WbsTreeContract> resultNodes = new LinkedHashSet<>();
|
|
|
+ this.recursiveGetParentNodes(resultNodes, nodes, contractRelationJlyz.getContractIdSg() + "");
|
|
|
+ resultNodes.addAll(nodes);
|
|
|
+ List<String> nodePkeyIds = resultNodes.stream().map(WbsTreeContract::getPKeyId).map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //获取填报过的资料信息Map
|
|
|
+ Set<InformationQuery> informationQuerySet = new HashSet<>();
|
|
|
+ List<List<String>> partition = Lists.partition(nodePkeyIds, 500);
|
|
|
+ for (List<String> wbsIds : partition) {
|
|
|
+ List<InformationQuery> informationQueryList = jdbcTemplate.query("select wbs_id,status from u_information_query where wbs_id in(" + org.apache.commons.lang.StringUtils.join(wbsIds, ",") + ")", new BeanPropertyRowMapper<>(InformationQuery.class));
|
|
|
+ informationQuerySet.addAll(informationQueryList);
|
|
|
+ }
|
|
|
+ Map<Long, Integer> informationQueryMaps = informationQuerySet.stream().collect(Collectors.toMap(InformationQuery::getWbsId, InformationQuery::getStatus, (v1, v2) -> v1));
|
|
|
+
|
|
|
+ //构造vo
|
|
|
+ List<WbsTreeContractTreeAllVO> wbsTreeContractTreeAllVOS = resultNodes.stream().map(node -> {
|
|
|
+ WbsTreeContractTreeAllVO vo = BeanUtil.copyProperties(node, WbsTreeContractTreeAllVO.class);
|
|
|
+ if (vo != null) {
|
|
|
+ vo.setType(ObjectUtils.isNotEmpty(node.getNodeType()) ? node.getNodeType() : 0);
|
|
|
+ vo.setTitle(node.getFullName());
|
|
|
+ vo.setPrimaryKeyId(node.getPKeyId());
|
|
|
+ if (ObjectUtils.isNotEmpty(informationQueryMaps.get(vo.getPrimaryKeyId()))) {
|
|
|
+ vo.setSubmitCounts(1L); //如果存在资料填报信息,那么计数
|
|
|
+ vo.setColorStatus(informationQueryMaps.get(vo.getPrimaryKeyId())); //颜色
|
|
|
+ } else {
|
|
|
+ vo.setSubmitCounts(0L);
|
|
|
+ vo.setColorStatus(null); //没填报就是null
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return vo;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //构造树形结构
|
|
|
+ List<WbsTreeContractTreeAllVO> reNodes = this.buildWbsTreeByStreamByTreeAll(wbsTreeContractTreeAllVOS);
|
|
|
+
|
|
|
+ //获取构造完的List集合
|
|
|
+ LinkedList<WbsTreeContractTreeAllVO> resultNodesAll = new LinkedList<>();
|
|
|
+ this.getNodesAll(reNodes, resultNodesAll);
|
|
|
+ resultNodesAll.addAll(0, reNodes);
|
|
|
+
|
|
|
+ //处理父级节点计数、颜色问题
|
|
|
+ this.reSetSubmitCountsAndColorStatus(resultNodesAll);
|
|
|
+ //返回结果集
|
|
|
+ resultMaps.put(contractRelationJlyz.getContractIdSg(), reNodes);
|
|
|
+ }
|
|
|
+ return R.data(resultMaps);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理submitCounts计数、colorStatus颜色问题
|
|
|
+ *
|
|
|
+ * @param reNodes 数据源
|
|
|
+ */
|
|
|
+ private void reSetSubmitCountsAndColorStatus(List<WbsTreeContractTreeAllVO> reNodes) {
|
|
|
+ //反向for循环解决顺序问题,最底层节点才是数据源
|
|
|
+ for (int i = reNodes.size() - 1; i >= 0; i--) {
|
|
|
+ WbsTreeContractTreeAllVO node = reNodes.get(i);
|
|
|
+ if (node.getChildren() != null && !node.getChildren().isEmpty()) {
|
|
|
+ long childSubmitCounts = 0L;
|
|
|
+ int colorStatus = 1;
|
|
|
+
|
|
|
+ boolean allChildStatusEquals3 = true;
|
|
|
+ boolean allChildStatusEquals4 = true;
|
|
|
+
|
|
|
+ //计数
|
|
|
+ for (WbsTreeContractTreeAllVO child : node.getChildren()) {
|
|
|
+ if (child.getSubmitCounts() == 1L) {
|
|
|
+ childSubmitCounts++;
|
|
|
+ } else if (child.getSubmitCounts() > 1L) {
|
|
|
+ childSubmitCounts = child.getSubmitCounts();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //颜色
|
|
|
+ for (WbsTreeContractTreeAllVO child : node.getChildren()) {
|
|
|
+ if (ObjectUtils.isNotEmpty(child.getColorStatus())) {
|
|
|
+ //只要有一个子级是已填报-未上报,那么上级默认已填报-未上报(蓝色)
|
|
|
+ if (child.getColorStatus().equals(2)) {
|
|
|
+ colorStatus = 2;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (child.getColorStatus().equals(3)) {
|
|
|
+ allChildStatusEquals4 = false;
|
|
|
+ colorStatus = 4;
|
|
|
+
|
|
|
+ } else if (child.getColorStatus().equals(4)) {
|
|
|
+ allChildStatusEquals3 = false;
|
|
|
+ colorStatus = 3;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ allChildStatusEquals3 = false;
|
|
|
+ allChildStatusEquals4 = false;
|
|
|
+ colorStatus = 1;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //父节点计数
|
|
|
+ node.setSubmitCounts(childSubmitCounts);
|
|
|
+
|
|
|
+ //父节点颜色
|
|
|
+ if (allChildStatusEquals3) {
|
|
|
+ node.setColorStatus(3);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (allChildStatusEquals4) {
|
|
|
+ node.setColorStatus(4);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ node.setColorStatus(colorStatus);
|
|
|
+
|
|
|
+ } else if (node.getSubmitCounts() == 1L) {
|
|
|
+ node.setSubmitCounts(1L);
|
|
|
+ //最底层颜色
|
|
|
+ if (ObjectUtils.isNotEmpty(node.getColorStatus())) {
|
|
|
+ if (node.getColorStatus().equals(0)) { //任务状态=0,未上报
|
|
|
+ node.setColorStatus(2); //蓝色
|
|
|
+ } else if (node.getColorStatus().equals(1)) { //任务状态=1,待审批
|
|
|
+ node.setColorStatus(3); //橙色
|
|
|
+ } else if (node.getColorStatus().equals(2)) { //任务状态=2,已审批
|
|
|
+ node.setColorStatus(4); //绿色
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (node.getSubmitCounts() == 0L && ObjectUtils.isEmpty(node.getColorStatus())) {
|
|
|
+ node.setColorStatus(1); //黑色 //任务状态=null,未填报
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取构造完的List集合
|
|
|
+ *
|
|
|
+ * @param reNodes 数据源
|
|
|
+ * @param result 结果集
|
|
|
+ */
|
|
|
+ private void getNodesAll(List<WbsTreeContractTreeAllVO> reNodes, LinkedList<WbsTreeContractTreeAllVO> result) {
|
|
|
+ for (WbsTreeContractTreeAllVO node : reNodes) {
|
|
|
+ if (node.getChildren() != null && !node.getChildren().isEmpty()) {
|
|
|
+ result.addAll(node.getChildren());
|
|
|
+ getNodesAll(node.getChildren(), result);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 反向递归获取父级
|
|
|
+ *
|
|
|
+ * @param resultNodes
|
|
|
+ * @param nodes
|
|
|
+ * @param contractId
|
|
|
+ */
|
|
|
+ private void recursiveGetParentNodes(Set<WbsTreeContract> resultNodes, List<WbsTreeContract> nodes, String contractId) {
|
|
|
+ Set<String> parentIds = nodes.stream().map(WbsTreeContract::getParentId).map(String::valueOf).filter(ObjectUtils::isNotEmpty).collect(Collectors.toSet());
|
|
|
+ List<WbsTreeContract> parentNodes = jdbcTemplate.query("select * from m_wbs_tree_contract where is_deleted = 0 and status = 1 and type = 1 and id in(" + org.apache.commons.lang.StringUtils.join(parentIds, ",") + ") and contract_id = " + contractId, new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ if (parentNodes.size() > 0) {
|
|
|
+ resultNodes.addAll(parentNodes);
|
|
|
+ this.recursiveGetParentNodes(resultNodes, parentNodes, contractId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
public List<WbsTreeContractVO> buildWbsTreeByStreamChildNodeTree(List<WbsTreeContractVO> nodes, WbsTreeContract parentNodeRoot) {
|
|
|
List<WbsTreeContractVO> list = nodes.stream().filter(f -> f.getId().equals(parentNodeRoot.getId())).collect(Collectors.toList());
|
|
|
Map<Long, List<WbsTreeContractVO>> map = nodes.stream().collect(Collectors.groupingBy(WbsTreeContractVO::getParentId));
|