|
@@ -1,19 +1,3 @@
|
|
|
-/*
|
|
|
- * Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
|
|
- *
|
|
|
- * Redistribution and use in source and binary forms, with or without
|
|
|
- * modification, are permitted provided that the following conditions are met:
|
|
|
- *
|
|
|
- * Redistributions of source code must retain the above copyright notice,
|
|
|
- * this list of conditions and the following disclaimer.
|
|
|
- * Redistributions in binary form must reproduce the above copyright
|
|
|
- * notice, this list of conditions and the following disclaimer in the
|
|
|
- * documentation and/or other materials provided with the distribution.
|
|
|
- * Neither the name of the dreamlu.net developer nor the names of its
|
|
|
- * contributors may be used to endorse or promote products derived from
|
|
|
- * this software without specific prior written permission.
|
|
|
- * Author: Chill 庄骞 (smallchill@163.com)
|
|
|
- */
|
|
|
package org.springblade.business.controller;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -46,10 +30,12 @@ import org.springblade.core.mp.support.Query;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.jackson.JsonUtil;
|
|
|
+import org.springblade.core.tool.node.ForestNodeMerger;
|
|
|
import org.springblade.core.tool.utils.Func;
|
|
|
import org.springblade.evisa.feign.EVisaClient;
|
|
|
import org.springblade.evisa.vo.CertBeanVO;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
+import org.springblade.manager.entity.ContractRelationJlyz;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
@@ -66,7 +52,6 @@ import org.springblade.business.service.IInformationQueryService;
|
|
|
import org.springblade.core.boot.ctrl.BladeController;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.atomic.AtomicReference;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -109,6 +94,14 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
private final RecycleBinClient recycleBinClient;
|
|
|
|
|
|
+ @PostMapping("/initMappingStructureTree")
|
|
|
+ @ApiOperationSupport(order = 27)
|
|
|
+ @ApiOperation(value = "初始化合同段导图树(只有接口,功能未写)")
|
|
|
+ public R<List<WbsTreeContractTreeVOS>> initMappingStructureTree(@RequestBody List<String> ids){
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 输入框查询合同段树
|
|
|
*/
|
|
@@ -116,89 +109,108 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
@ApiOperationSupport(order = 26)
|
|
|
@ApiOperation(value = "输入框查询合同段树")
|
|
|
public R<List<WbsTreeContractTreeVOS>> searchContractTree(@RequestParam String queryValue, @RequestParam String contractId){
|
|
|
+ //设置返回结果
|
|
|
+ List<WbsTreeContractTreeVOS> result = new ArrayList<>();
|
|
|
//获取合同段信息
|
|
|
ContractInfo contract = this.contractClient.getContractById(Long.parseLong(contractId));
|
|
|
if(new Integer("2").equals(contract.getContractType())){
|
|
|
//监理,需要获取监理合同段关联的施工方合同段ID
|
|
|
+ List<ContractRelationJlyz> jlyzList = this.wbsTreeContractClient.selectContractRelationInfo(contractId);
|
|
|
+ if(jlyzList != null && jlyzList.size() > 0){
|
|
|
+ //施工合同段子节点
|
|
|
+ List<WbsTreeContractTreeVOS> sgChildNodeList = new ArrayList<>();
|
|
|
+
|
|
|
+ for(ContractRelationJlyz jlkz : jlyzList){
|
|
|
+ List<WbsTreeContract> queryValueList = this.wbsTreeContractClient.selectQueryValueLikeNodeName(queryValue, jlkz.getContractIdSg().toString());
|
|
|
+ if(queryValueList != null && queryValueList.size() > 0){
|
|
|
+ //查询与当前节点相关联的数据
|
|
|
+ List<WbsTreeContractTreeVOS> associatedVONodeList = new ArrayList<>();
|
|
|
+ List<String> ids = JSONArray.parseArray(JSONObject.toJSONString(queryValueList.stream().map(WbsTreeContract::getId).distinct().collect(Collectors.toList())), String.class);
|
|
|
+ //查询相关联的数据
|
|
|
+ List<WbsTreeContract> associatedList = this.wbsTreeContractClient.selectQueryCurrentNodeByAncestors(ids, jlkz.getContractIdSg().toString());
|
|
|
+ if(associatedList != null){
|
|
|
+ queryValueList.addAll(associatedList);
|
|
|
+ }
|
|
|
+ //处理参数
|
|
|
+ this.queryContractTree(associatedVONodeList, queryValueList, 2);
|
|
|
+
|
|
|
+ if(associatedVONodeList.size() > 0){
|
|
|
+ List<WbsTreeContractTreeVOS> list = ForestNodeMerger.merge(associatedVONodeList);
|
|
|
+ list.removeIf(vos -> !"0".equals(vos.getParentId().toString()));
|
|
|
+ sgChildNodeList.addAll(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(sgChildNodeList.size() > 0){
|
|
|
+ //给个顶点
|
|
|
+ WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
|
|
|
+ vos.setTitle(contract.getContractName());
|
|
|
+ vos.setChildren(sgChildNodeList);
|
|
|
+ result.add(vos);
|
|
|
+ }
|
|
|
+ return R.data(result);
|
|
|
+ }
|
|
|
} else {
|
|
|
//施工,直接查询
|
|
|
//获取当前合同段下所有的数据
|
|
|
- List<WbsTreeContract> contractTreeList = this.wbsTreeContractClient.searchContractTree(contractId);
|
|
|
- Map<String, WbsTreeContractTreeVOS> nodeMap = new HashMap<>();
|
|
|
- Map<String, String> titleToIdMap = new HashMap<>();
|
|
|
- //根节点
|
|
|
- AtomicReference<WbsTreeContract> rootNode = new AtomicReference<>();
|
|
|
-
|
|
|
- contractTreeList.forEach(tree -> {
|
|
|
- if(Long.valueOf("0").equals(tree.getParentId())){
|
|
|
- //顺便找到根节点
|
|
|
- rootNode.set(tree);
|
|
|
+ List<WbsTreeContract> queryValueList = this.wbsTreeContractClient.selectQueryValueLikeNodeName(queryValue, contractId);
|
|
|
+ if(queryValueList != null && queryValueList.size() > 0){
|
|
|
+ //查询与当前节点相关联的数据
|
|
|
+ List<WbsTreeContractTreeVOS> associatedVONodeList = new ArrayList<>();
|
|
|
+ List<String> ids = JSONArray.parseArray(JSONObject.toJSONString(queryValueList.stream().map(WbsTreeContract::getId).distinct().collect(Collectors.toList())), String.class);
|
|
|
+ //查询相关联的数据
|
|
|
+ List<WbsTreeContract> associatedList = this.wbsTreeContractClient.selectQueryCurrentNodeByAncestors(ids, contractId);
|
|
|
+ if(associatedList != null && associatedList.size() > 0){
|
|
|
+ queryValueList.addAll(associatedList);
|
|
|
}
|
|
|
- //转换类型
|
|
|
- WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
|
|
|
- //设置参数
|
|
|
- vos.setId(tree.getId().toString());
|
|
|
- vos.setKey(tree.getId().toString());
|
|
|
- vos.setPrimaryKeyId(tree.getPKeyId().toString());
|
|
|
- vos.setParentId(tree.getParentId().toString());
|
|
|
- vos.setTitle(StringUtils.isNotEmpty(tree.getFullName()) ? tree.getFullName() : tree.getDeptName());
|
|
|
- vos.setType(tree.getType());
|
|
|
- vos.setWbsType(tree.getWbsType());
|
|
|
-
|
|
|
- nodeMap.put(tree.getId().toString(), vos);
|
|
|
- titleToIdMap.put(tree.getId().toString(), StringUtils.isNotEmpty(tree.getFullName()) ? tree.getFullName() : tree.getDeptName());
|
|
|
- });
|
|
|
- if(rootNode.get() == null){
|
|
|
- return R.data(300, null, "未找到相关数据");
|
|
|
- }
|
|
|
- //获得根节点
|
|
|
- WbsTreeContract rootTree = rootNode.get();
|
|
|
-
|
|
|
- //查询名称
|
|
|
- titleToIdMap.entrySet().removeIf(map -> !map.getValue().contains(queryValue));
|
|
|
-
|
|
|
- //处理后的titleToIdMap就是匹配的结果,向上获取父节点,向下获取所有子节点
|
|
|
- if(titleToIdMap.size() > 0){
|
|
|
- //循环剩下的数据,找到对应的节点
|
|
|
- Set<String> idMap = titleToIdMap.keySet();
|
|
|
- //记录哪些节点已经被获取了
|
|
|
- List<String> recordGetIds = new ArrayList<>();
|
|
|
- for(String nodeId : idMap){
|
|
|
- if(!recordGetIds.contains(nodeId)){
|
|
|
- //获取节点
|
|
|
- WbsTreeContractTreeVOS node = nodeMap.get(nodeId);
|
|
|
- //优先向下获取子节点
|
|
|
- this.foreachQueryChild(node, nodeMap, recordGetIds);
|
|
|
- //其次向上获取父节点
|
|
|
-
|
|
|
- int i = 0;
|
|
|
- }
|
|
|
+ //处理参数
|
|
|
+ this.queryContractTree(associatedVONodeList, queryValueList, 1);
|
|
|
+
|
|
|
+ if(associatedVONodeList.size() > 0){
|
|
|
+ List<WbsTreeContractTreeVOS> list = ForestNodeMerger.merge(associatedVONodeList);
|
|
|
+ list.removeIf(vos -> !"0".equals(vos.getParentId().toString()));
|
|
|
+ result.addAll(list);
|
|
|
}
|
|
|
+ return R.data(result);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
return R.data(300, null, "未找到相关数据");
|
|
|
}
|
|
|
|
|
|
- private void foreachQueryChild(WbsTreeContractTreeVOS parentNode, Map<String, WbsTreeContractTreeVOS> nodeMap, List<String> recordGetIds){
|
|
|
- //校验当前节点是否还有子节点
|
|
|
- Long count = this.wbsTreeContractClient.countChildByPrimaryKeyId(parentNode.getPrimaryKeyId());
|
|
|
- if(count > 0){
|
|
|
- //说明还有子节点
|
|
|
- Set<String> keySet = nodeMap.keySet();
|
|
|
- for(String key : keySet){
|
|
|
- if(!recordGetIds.contains(key)){
|
|
|
- WbsTreeContractTreeVOS child = nodeMap.get(key);
|
|
|
- if(child.getParentId().equals(parentNode.getId())){
|
|
|
- //继续向下获取子节点
|
|
|
- this.foreachQueryChild(child, nodeMap, recordGetIds);
|
|
|
- //添加记录
|
|
|
- recordGetIds.add(key);
|
|
|
- //设置进子节点集合中
|
|
|
- parentNode.getChildren().add(child);
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 转换参数
|
|
|
+ */
|
|
|
+ private void queryContractTree(List<WbsTreeContractTreeVOS> associatedVONodeList, List<WbsTreeContract> associatedList, Integer contractType) {
|
|
|
+ List<String> exsitList = new ArrayList<>();
|
|
|
+ for(WbsTreeContract tree : associatedList){
|
|
|
+ if(exsitList.contains(tree.getId().toString())){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ //转换类型
|
|
|
+ WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
|
|
|
+ //设置参数
|
|
|
+ vos.setId(new Integer("1").equals(contractType) ? tree.getId() : tree.getPKeyId());
|
|
|
+ vos.setKey(tree.getId().toString());
|
|
|
+ vos.setPrimaryKeyId(new Integer("1").equals(contractType) ? tree.getPKeyId().toString() : tree.getId().toString());
|
|
|
+ if(new Integer("2").equals(contractType)){
|
|
|
+ vos.setContractIdRelation(tree.getContractId());
|
|
|
+ }
|
|
|
+ vos.setParentId(tree.getParentId());
|
|
|
+ vos.setTitle(StringUtils.isNotEmpty(tree.getFullName()) ? tree.getFullName() : tree.getDeptName());
|
|
|
+ vos.setType(tree.getType());
|
|
|
+ vos.setWbsType(tree.getWbsType());
|
|
|
+
|
|
|
+ //判断当前节点是否存在子节点
|
|
|
+ for(WbsTreeContract treeNode : associatedList){
|
|
|
+ if(treeNode.getParentId().equals(tree.getId())){
|
|
|
+ //存在一个,即认为存在
|
|
|
+ vos.setNotExsitChild(false);
|
|
|
+ break;
|
|
|
}
|
|
|
}
|
|
|
+ associatedVONodeList.add(vos);
|
|
|
+ exsitList.add(tree.getId().toString());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -794,7 +806,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//获取当前父节点下所有工序节点及填报资料
|
|
|
List<QueryProcessDataVO> queryDataResult;
|
|
|
if(new Integer("2").equals(contractInfo.getContractType())){
|
|
|
- queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(parentId, 2, contractIdRelation);
|
|
|
+ queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(parentId, 1, contractIdRelation);
|
|
|
} else {
|
|
|
queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(parentId, 1, contractId);
|
|
|
}
|
|
@@ -872,7 +884,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
*/
|
|
|
private void foreachQueryChildNode(List<WbsTreeContractTreeVOS> result, String contractId){
|
|
|
result.forEach(vos -> {
|
|
|
- List<WbsTreeContractTreeVOS> child = this.wbsTreeContractClient.queryContractWbsTreeByContractIdAndType(contractId, 1, vos.getId());
|
|
|
+ List<WbsTreeContractTreeVOS> child = this.wbsTreeContractClient.queryContractWbsTreeByContractIdAndType(contractId, 1, vos.getId().toString());
|
|
|
if(child != null && child.size() == 1){
|
|
|
//如果子节点还是只有一个,则进一步向下查询
|
|
|
this.foreachQueryChildNode(child, contractId);
|
|
@@ -1196,10 +1208,10 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
WbsTreeContractTreeVOS vos = new WbsTreeContractTreeVOS();
|
|
|
WbsTreePrivate wbsTreePrivate = this.wbsTreePrivateClient.queryPeersNodeByProjectIdAndId(projectId, Long.parseLong(id));
|
|
|
//设置参数
|
|
|
- vos.setId(wbsTreePrivate.getId().toString());
|
|
|
+ vos.setId(wbsTreePrivate.getId());
|
|
|
vos.setKey(wbsTreePrivate.getId().toString());
|
|
|
vos.setPrimaryKeyId(wbsTreePrivate.getPKeyId().toString());
|
|
|
- vos.setParentId(wbsTreePrivate.getParentId().toString());
|
|
|
+ vos.setParentId(wbsTreePrivate.getParentId());
|
|
|
vos.setTitle(wbsTreePrivate.getDeptName());
|
|
|
vos.setType(wbsTreePrivate.getType());
|
|
|
vos.setWbsType(Integer.parseInt(wbsTreePrivate.getWbsType()));
|
|
@@ -1310,7 +1322,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
WbsTreeContract node = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(vo.getWbsId());
|
|
|
if(!new Integer("6").equals(node.getDeptCategory()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType().toString())){
|
|
|
//不是工序,则查询当前节点下的所有填报节点
|
|
|
- List<QueryProcessDataVO> queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(node.getId().toString(), vo.getClassify(), vo.getContractId().toString());
|
|
|
+ List<QueryProcessDataVO> queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(node.getId().toString(), 1, vo.getContractId().toString());
|
|
|
if(StringUtils.isNotEmpty(vo.getIsFirst())){
|
|
|
//如果是首件列表请求,则删掉没有标记为首件的数据
|
|
|
queryDataResult.removeIf(data -> StringUtils.isEmpty(data.getFirstId()));
|
|
@@ -1360,13 +1372,13 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//获取当前父节点下所有工序节点及填报资料
|
|
|
List<QueryProcessDataVO> queryDataResult;
|
|
|
if(new Integer("2").equals(contractInfo.getContractType())){
|
|
|
- queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(parentId, 2, contractIdRelation);
|
|
|
+ queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(parentId, 1, contractIdRelation);
|
|
|
} else {
|
|
|
queryDataResult = this.informationQueryService.queryProcessDataByParentIdAndContractId(parentId, 1, contractId);
|
|
|
}
|
|
|
|
|
|
rootTreeNode.forEach(vo -> {
|
|
|
- String primaryKeyId = new Integer("2").equals(contractInfo.getContractType()) ? vo.getId() : vo.getPrimaryKeyId();
|
|
|
+ String primaryKeyId = new Integer("2").equals(contractInfo.getContractType()) ? vo.getId().toString() : vo.getPrimaryKeyId();
|
|
|
|
|
|
if(new Integer("1").equals(contractInfo.getContractType())){
|
|
|
if(StringUtils.isEmpty(parentId) || "0".equals(parentId)){
|
|
@@ -1413,8 +1425,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
StringBuilder colorStatusValue = new StringBuilder();
|
|
|
while (iterator.hasNext()) {
|
|
|
QueryProcessDataVO query = iterator.next();
|
|
|
- if(StringUtils.isNotEmpty(query.getAncestors()) && StringUtils.isNotEmpty(vos.getId())){
|
|
|
- if(query.getAncestors().contains(vos.getId()) || query.getAncestors().startsWith(vos.getParentId() + ",") || query.getTreeId().equals(vos.getId())){
|
|
|
+ if(StringUtils.isNotEmpty(query.getAncestors()) && StringUtils.isNotEmpty(String.valueOf(vos.getId()))){
|
|
|
+ if(query.getAncestors().contains(vos.getId().toString()) || query.getAncestors().startsWith(vos.getParentId() + ",") || query.getTreeId().equals(vos.getId().toString())){
|
|
|
//如果为空,说明未填报
|
|
|
if(query.getStatus() == null || query.getStatus() == -1){
|
|
|
colorStatusValue.append("1");
|