|
@@ -84,6 +84,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.function.BiFunction;
|
|
|
import java.util.function.BinaryOperator;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.function.Predicate;
|
|
|
import java.util.regex.Matcher;
|
|
|
import java.util.regex.Pattern;
|
|
@@ -5817,59 +5818,21 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if (FB02.TABLE_NAME.equals(wtcEva.getInitTableName())) {
|
|
|
FB02 fb02 = new FB02(processFds);
|
|
|
if (fb02.checked()) {
|
|
|
- /*swId是分项评定的父节点Id*/
|
|
|
-
|
|
|
- /// List<FormulaDataBlock> formulaDataBlocks = this.getSqlList("select DISTINCT a.id,a.type,a.sw_id swId,a.contract_id contractId,a.val from m_formula_data_block a,m_wbs_tree_contract b where a.sw_id=b.parent_id and b.contract_id ="+wtcEva.getContractId()+" and b.major_data_type=2 and b.is_deleted=0 and b.ancestors_p_id like '%"+wtcEva.getPId()+"%' ORDER BY b.sort ", FormulaDataBlock.class);
|
|
|
-
|
|
|
- // 每次需要依赖于treeCode值
|
|
|
- // List<FormulaDataBlock> formulaDataBlocks = this.getSqlList("select DISTINCT a.id,a.type,a.sw_id swId,a.contract_id contractId,a.val from m_formula_data_block a join (select parent_id from m_wbs_tree_contract where tree_code like '" + treeCode.getLast() + "%' and contract_id =" + wtcEva.getContractId() + " and major_data_type=2 and is_deleted=0 ORDER BY tree_code)b on a.sw_id=b.parent_id ", FormulaDataBlock.class);
|
|
|
- /*if (formulaDataBlocks != null && formulaDataBlocks.size() > 0) {
|
|
|
- *//*就是分项工程节点的父节点名称*//*
|
|
|
- String swIds = formulaDataBlocks.stream().map(FormulaDataBlock::getSwId).map(Objects::toString).collect(Collectors.joining(","));
|
|
|
- List<Map<String, Object>> listMaps = this.jdbcTemplate.queryForList("select id ,node_name nodeName,full_name fullName from m_wbs_tree_contract where is_deleted =0 and contract_id=" + wtcEva.getContractId() + " and id in(" + swIds + ")");
|
|
|
- Map<String, String> swNameMap = new HashMap<>();
|
|
|
- if (listMaps.size() > 0) {
|
|
|
- swNameMap.putAll(listMaps.stream().collect(Collectors.toMap(m -> m.get("id").toString(), m -> m.get("fullName").toString(), (v1, v2) -> v2)));
|
|
|
- }
|
|
|
- fb02.source(formulaDataBlocks, swNameMap);
|
|
|
-
|
|
|
- if (fb02.getDatas().size() > 0) {
|
|
|
- Map<String, String> tableKeysCoordsMap = FormulaUtils.getElementCell(wtcEva.getHtmlUrl());
|
|
|
- if (fb02.initFdCoords(tableKeysCoordsMap)) {
|
|
|
- *//*根据数据长度,增减页数*//*
|
|
|
- List<WbsTreeContract> wtcList = this.adjustPageSize(fb02.getPageNum(), wtcEva, processFds);
|
|
|
- if (fb02.flush(wtcList)) {
|
|
|
- this.jdbcTemplate.batchUpdate(fb02.getSql(), fb02.getParams());
|
|
|
- return R.success("成功");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }*/
|
|
|
-
|
|
|
- // 重新优化
|
|
|
- // String contSql = "SELECT p_key_id as pKeyId,node_name as fullName,init_table_name as initTableName,html_url as htmlUrl from m_wbs_tree_contract a where a.p_id in( select p_key_id from m_wbs_tree_contract b where b.contract_id ="+wtcEva.getContractId()+" and b.major_data_type=2 and b.is_deleted=0 and b.ancestors_p_id like '%"+wtcEva.getPId()+"%' ) and a.type=2 and node_name not like '%附表%' and LENGTH(a.html_url)>=10 and init_table_name is not null ";
|
|
|
String contSql = "SELECT p_key_id as pKeyId,p_id as pId,IFNULL(if(length(trim(full_name))>0, full_name, node_name), node_name) AS fullName,init_table_name as partitionCode,html_url as oldId,type,major_data_type as majorDataType from m_wbs_tree_contract where is_deleted=0 and ancestors_p_id like '%"+wtcEva.getPId()+"%' and contract_id ="+wtcEva.getContractId()+" ORDER BY sort ,full_name ";
|
|
|
List<WbsTreeContractLazyVO> allNode = this.getSqlList(contSql, WbsTreeContractLazyVO.class);
|
|
|
List<WbsTreeContractLazyVO> conNode= getAllChildNodesWithStream(wtcEva.getPId()+"",allNode);
|
|
|
//将conNode 转成Map对象
|
|
|
Map<Long, WbsTreeContractLazyVO> map = conNode.stream().collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, WbsTreeContractLazyVO -> WbsTreeContractLazyVO));
|
|
|
List<WbsTreeContractLazyVO> tableInfo = new ArrayList<>();
|
|
|
- // String nodeName = "";
|
|
|
for (WbsTreeContractLazyVO info : conNode) {
|
|
|
- /*if(info.getType()==1 && (info.getPId()+"").equals(wtcEva.getPId()+"") ){
|
|
|
- nodeName=info.getFullName();
|
|
|
- }*/
|
|
|
if(info.getType()==2){
|
|
|
WbsTreeContractLazyVO wbsTreeContractLazyVO = map.get(info.getPId());
|
|
|
- // if(wbsTreeContractLazyVO!=null && wbsTreeContractLazyVO.getMajorDataType()!=null && wbsTreeContractLazyVO.getMajorDataType()==2 && info.getFullName().indexOf("附表")<0 && (info.getPKeyId()+"").equals("1861674943318589443")){
|
|
|
if(wbsTreeContractLazyVO!=null && wbsTreeContractLazyVO.getMajorDataType()!=null && wbsTreeContractLazyVO.getMajorDataType()==2 && info.getFullName().indexOf("附表")<0 ){
|
|
|
WbsTreeContractLazyVO wbsTreeC = map.get(wbsTreeContractLazyVO.getPId());
|
|
|
info.setTitle(wbsTreeC.getFullName());
|
|
|
tableInfo.add(info);
|
|
|
- // System.out.println("---------"+nodeName+" "+info.getFullName());
|
|
|
}
|
|
|
}
|
|
|
- // System.out.println(info.getFullName());
|
|
|
}
|
|
|
System.out.println("tableInfo:"+tableInfo);
|
|
|
for (WbsTreeContractLazyVO info : tableInfo) {
|
|
@@ -6027,7 +5990,7 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
for (FormData e : fbFds) {
|
|
|
if (e.getEName().startsWith("分部工程名称")) {
|
|
|
fbName = e;
|
|
|
- } else if (e.getEName().startsWith("分部工程实测得分计算")) {
|
|
|
+ } else if (e.getEName().startsWith("分部工程评分") ) { //分部工程实测得分计算
|
|
|
passRate = e;
|
|
|
} else if (e.getEName().startsWith("质量等级")) {
|
|
|
fbLevel = e;
|
|
@@ -6036,10 +5999,38 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
if (!(fbName != null && passRate != null && fbLevel != null)) {
|
|
|
return R.fail("未能匹配分部评定节点");
|
|
|
}
|
|
|
+
|
|
|
String keys = Stream.of(fbName, passRate, fbLevel).map(FormData::getKey).map(StringUtils::handleNull).collect(Collectors.joining(",c.", "c.", ""));
|
|
|
- List<Map<String, Object>> mapList = jdbcTemplate.queryForList("select " + keys + " , a.tree_code from (select id,tree_code from m_wbs_tree_contract where tree_code like '" + treeCode.getLast() + "%' and contract_id =" + wtcEva.getContractId() + " and major_data_type=2 and is_deleted=0 and node_type=3 ORDER BY tree_code)a join m_wbs_tree_contract b on a.id=b.parent_id" +
|
|
|
- " join " + FB02.TABLE_NAME + " c on b.p_key_id=c.p_key_id where b.contract_id =" + wtcEva.getContractId() + " and b.is_deleted=0 and b.init_table_name='" + FB02.TABLE_NAME + "'" +
|
|
|
- "ORDER BY a.tree_code");
|
|
|
+ // String contSql = "SELECT p_key_id as pKeyId,p_id as pId,IFNULL(if(length(trim(full_name))>0, full_name, node_name), node_name) AS fullName,init_table_name as partitionCode,html_url as oldId,type,major_data_type as majorDataType from m_wbs_tree_contract where is_deleted=0 and (ancestors_p_id like '%"+wtcEva.getPId()+"%' or p_key_id="+wtcEva.getPId()+") and contract_id ="+wtcEva.getContractId()+" ORDER BY sort ,full_name ";
|
|
|
+ String contSql = " SELECT DISTINCT c.p_key_id as pKeyId,c.p_id as pId, CASE WHEN c.type =1 then c.full_name when c.type =2 then c.node_name END AS fullName,c.type,c.major_data_type as majorDataType from m_wbs_tree_contract c , "+
|
|
|
+ " (SELECT a.* from m_wbs_tree_contract a ,m_wbs_tree_contract b where b.p_key_id=a.p_id and a.table_owner in(1,2,3) and a.is_deleted=0 and b.is_deleted=0 and b.ancestors_p_id like '%"+wtcEva.getPId()+"%' and b.contract_id ="+wtcEva.getContractId()+" and b.major_data_type=8 and a.node_name NOT LIKE '%\\__%' ) d "+
|
|
|
+ " where (FIND_IN_SET(c.p_key_id,d.ancestors_p_id) or c.p_key_id=d.p_key_id) and c.ancestors_p_id like '%"+wtcEva.getPId()+"%' and c.contract_id ="+wtcEva.getContractId()+" and c.is_deleted=0 "+
|
|
|
+ " ORDER BY c.sort ,c.full_name ";
|
|
|
+
|
|
|
+ List<WbsTreeContractLazyVO> allNode = this.getSqlList(contSql, WbsTreeContractLazyVO.class);
|
|
|
+ List<WbsTreeContractLazyVO> conNode= getAllChildNodesWithStream(wtcEva.getPId()+"",allNode);
|
|
|
+ //将conNode 转成Map对象
|
|
|
+ Map<Long, WbsTreeContractLazyVO> DataMap = conNode.stream().collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, WbsTreeContractLazyVO -> WbsTreeContractLazyVO));
|
|
|
+ List<WbsTreeContractLazyVO> tableInfo = new ArrayList<>();
|
|
|
+ StringBuffer sb = new StringBuffer();
|
|
|
+ for (WbsTreeContractLazyVO info : conNode) {
|
|
|
+ System.out.println(info.getFullName()+""+info.getPKeyId());
|
|
|
+ if(info.getType()==2){
|
|
|
+ WbsTreeContractLazyVO wbsTreeContractLazyVO = DataMap.get(info.getPId());
|
|
|
+ if(wbsTreeContractLazyVO!=null && wbsTreeContractLazyVO.getMajorDataType()!=null && wbsTreeContractLazyVO.getMajorDataType()==8 && info.getFullName().indexOf("__")<0 ){
|
|
|
+ tableInfo.add(info);
|
|
|
+ sb.append(info.getPKeyId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ System.out.println("123");
|
|
|
+ String pkeyIds = tableInfo.stream().map(WbsTreeContractLazyVO::getPKeyId).map(Object::toString).collect(Collectors.joining(","));
|
|
|
+
|
|
|
+ String sqlInfo = "select " +keys +",p_key_id from "+ FB02.TABLE_NAME +" c where p_key_id in("+pkeyIds+") ORDER BY FIND_IN_SET(p_key_id,'"+pkeyIds+"')";
|
|
|
+ System.out.println("1231");
|
|
|
+
|
|
|
+ List<Map<String, Object>> mapList = jdbcTemplate.queryForList(sqlInfo);
|
|
|
if (mapList.size() > 0) {
|
|
|
List<Item02> abList = new ArrayList<>();
|
|
|
for (Map<String, Object> map : mapList) {
|
|
@@ -6047,17 +6038,17 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
item.setName(StringUtils.handleNull(map.get(fbName.getKey())).split("_\\^_")[0]);
|
|
|
item.setPassRate(BaseUtils.obj2DoubleZero(StringUtils.handleNull(map.get(passRate.getKey())).split("_\\^_")[0]));
|
|
|
item.setLevel(StringUtils.handleNull(map.get(fbLevel.getKey())).split("_\\^_")[0]);
|
|
|
- item.setTreeCode(StringUtils.handleNull(map.get("tree_code")));
|
|
|
+ item.setTreeCode(StringUtils.handleNull(map.get("p_key_id")));
|
|
|
abList.add(item);
|
|
|
}
|
|
|
/*合并相同分部评定*/
|
|
|
- BinaryOperator<Item02> biOp = (v1, v2) -> {
|
|
|
+ /* BinaryOperator<Item02> biOp = (v1, v2) -> {
|
|
|
if (v1.getScores() >= v2.getScores()) {
|
|
|
return v1;
|
|
|
}
|
|
|
return v2;
|
|
|
};
|
|
|
- abList = new ArrayList<>(abList.stream().collect(Collectors.toMap(Item02::getTreeCode, f -> f, biOp)).values());
|
|
|
+ abList = new ArrayList<>(abList.stream().collect(Collectors.toMap(Item02::getTreeCode, f -> f, biOp)).values());*/
|
|
|
dw02.source(abList);
|
|
|
if (dw02.getDatas().size() > 0) {
|
|
|
Map<String, String> tableKeysCoordsMap = FormulaUtils.getElementCell(wtcEva.getHtmlUrl());
|
|
@@ -6083,6 +6074,33 @@ public class FormulaServiceImpl extends BaseServiceImpl<FormulaMapper, Formula>
|
|
|
}
|
|
|
|
|
|
|
|
|
+ // 批量加载+内存计算
|
|
|
+/* public List<WbsTreeContractLazyVO> getAllChildNodesWithStream(Long parentId, List<WbsTreeContractLazyVO> allNodes) {
|
|
|
+
|
|
|
+ // 2. 构建内存索引
|
|
|
+ Map<Long, WbsTreeContractLazyVO> nodeMap = allNodes.stream()
|
|
|
+ .collect(Collectors.toMap(WbsTreeContractLazyVO::getPKeyId, Function.identity()));
|
|
|
+
|
|
|
+ Map<Long, List<WbsTreeContractLazyVO>> childrenMap = allNodes.stream()
|
|
|
+ .filter(node -> node.getPId() != null)
|
|
|
+ .collect(Collectors.groupingBy(WbsTreeContractLazyVO::getPId));
|
|
|
+
|
|
|
+ // 3. 递归查找子节点
|
|
|
+ List<WbsTreeContractLazyVO> result = new ArrayList<>();
|
|
|
+ Deque<Long> stack = new ArrayDeque<>();
|
|
|
+ stack.push(Func.toLong(parentId));
|
|
|
+
|
|
|
+ while (!stack.isEmpty()) {
|
|
|
+ Long currentId = stack.pop();
|
|
|
+ WbsTreeContractLazyVO node = nodeMap.get(currentId);
|
|
|
+ if (node != null) {
|
|
|
+ result.add(node);
|
|
|
+ childrenMap.getOrDefault(currentId, Collections.emptyList())
|
|
|
+ .forEach(child -> stack.push(child.getPKeyId()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }*/
|
|
|
// 获取所有子节点
|
|
|
public List<WbsTreeContractLazyVO> getAllChildNodesWithStream(String parentId, List<WbsTreeContractLazyVO> allNodes) {
|
|
|
List<WbsTreeContractLazyVO> children = new ArrayList<>();
|