|
@@ -31,6 +31,7 @@ import org.springblade.core.mp.utils.PageUtil;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
import org.springblade.manager.entity.WbsTreePrivate;
|
|
|
+import org.springblade.manager.feign.WbsTreePrivateClient;
|
|
|
import org.springblade.resource.entity.Attach;
|
|
|
import org.springblade.system.cache.ParamCache;
|
|
|
import org.springframework.jdbc.core.BeanPropertyRowMapper;
|
|
@@ -50,6 +51,7 @@ import java.util.stream.Collectors;
|
|
|
public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectionDataMapper, TrialDetectionData> implements ITrialDetectionDataService {
|
|
|
|
|
|
private final TrialSelfInspectionRecordMapper inspectionRecordMapper;
|
|
|
+ private final WbsTreePrivateClient wbsTreePrivateClient;
|
|
|
private final JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
@Override
|
|
@@ -343,105 +345,144 @@ public class TrialDetectionDataServiceImpl extends BaseServiceImpl<TrialDetectio
|
|
|
}
|
|
|
String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
String sys_file_net_url = ParamCache.getValue(CommonConstant.SYS_FILE_NET_URL);
|
|
|
- //拼接工程部位names 单位、分部、分项
|
|
|
- List<WbsTreeContract> query = jdbcTemplate.query("select node_name,node_type,id,ancestors from m_wbs_tree_contract where node_type is not null and p_key_id in(" + projectPositionIds + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
- List<WbsTreeContract> dw = query.stream().filter(f -> f.getNodeType().equals(1)).collect(Collectors.toList());
|
|
|
- List<WbsTreeContract> fb = query.stream().filter(f -> f.getNodeType().equals(2)).collect(Collectors.toList());
|
|
|
- List<WbsTreeContract> fx = query.stream().filter(f -> f.getNodeType().equals(4)).collect(Collectors.toList());
|
|
|
- Set<String> set = new HashSet<>();
|
|
|
- if (dw.size() > 0 && fb.size() > 0 && fx.size() > 0) {
|
|
|
- for (WbsTreeContract fxNode : fx) {
|
|
|
- for (WbsTreeContract fbNode : fb) {
|
|
|
- if (fxNode.getAncestors().contains(fbNode.getId().toString())) {
|
|
|
- for (WbsTreeContract dwNode : dw) {
|
|
|
- if (fbNode.getAncestors().contains(dwNode.getId().toString())) {
|
|
|
- set.add(dwNode.getNodeName() + "/" + fbNode.getNodeName() + "/" + fxNode.getNodeName());
|
|
|
+ List<WbsTreeContract> query = jdbcTemplate.query("select full_name,node_type,id,ancestors,parent_id,wbs_id,wbs_type,project_id from m_wbs_tree_contract where node_type is not null and p_key_id in(" + projectPositionIds + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ List<WbsTreeContract> collect = query.stream().filter(f -> !f.getNodeType().equals(6)).collect(Collectors.toList());
|
|
|
+ if (collect.size() > 0) {
|
|
|
+ List<String> names = collect.stream().map(WbsTreeContract::getFullName).collect(Collectors.toList());
|
|
|
+ throw new ServiceException("选择的节点:【" + StringUtils.join(names, ",") + "】不是工序节点,操作失败");
|
|
|
+ }
|
|
|
+ WbsTreeContract node = query.stream().findAny().orElse(null);
|
|
|
+ Set<WbsTreeContract> resultNode = new HashSet<>();
|
|
|
+ if (node != null) {
|
|
|
+ this.fxSelectParentNode(query, resultNode, node.getProjectId(), node.getWbsId(), node.getWbsType().toString(), contractId);
|
|
|
+ }
|
|
|
+ if (resultNode.size() > 0) {
|
|
|
+ List<WbsTreeContract> dw = resultNode.stream()
|
|
|
+ .filter(f -> !f.getParentId().equals(0L) && f.getNodeType().equals(1))
|
|
|
+ .filter(f -> {
|
|
|
+ String[] split = f.getAncestors().split(",");
|
|
|
+ return split.length > 2;
|
|
|
+ })
|
|
|
+ .peek(obj -> {
|
|
|
+ String fullName = obj.getFullName();
|
|
|
+ obj.setFullName(fullName.trim());
|
|
|
+ })
|
|
|
+ .collect(Collectors.collectingAndThen(
|
|
|
+ Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(WbsTreeContract::getFullName))),
|
|
|
+ ArrayList::new)
|
|
|
+ );
|
|
|
+
|
|
|
+ List<WbsTreeContract> fb = resultNode.stream().filter(f -> f.getNodeType().equals(2)).collect(Collectors.toList());
|
|
|
+ List<WbsTreeContract> fx = resultNode.stream().filter(f -> f.getNodeType().equals(4)).collect(Collectors.toList());
|
|
|
+
|
|
|
+ //拼接工程部位names 单位、分部、分项
|
|
|
+ Set<String> set = new HashSet<>();
|
|
|
+ if (dw.size() > 0 && fb.size() > 0 && fx.size() > 0) {
|
|
|
+ for (WbsTreeContract fxNode : fx) {
|
|
|
+ for (WbsTreeContract fbNode : fb) {
|
|
|
+ if (fxNode.getAncestors().contains(fbNode.getId().toString())) {
|
|
|
+ for (WbsTreeContract dwNode : dw) {
|
|
|
+ if (fbNode.getAncestors().contains(dwNode.getId().toString())) {
|
|
|
+ set.add(dwNode.getFullName().trim() + "、" + fbNode.getFullName().trim() + "、" + fxNode.getFullName().trim());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- } else if (dw.size() > 0 && fb.size() > 0) {
|
|
|
- for (WbsTreeContract fbNode : fb) {
|
|
|
- for (WbsTreeContract dwNode : dw) {
|
|
|
- if (fbNode.getAncestors().contains(dwNode.getId().toString())) {
|
|
|
- set.add(dwNode.getNodeName() + "/" + fbNode.getNodeName() + "/");
|
|
|
+ } else if (dw.size() > 0 && fb.size() > 0) {
|
|
|
+ for (WbsTreeContract fbNode : fb) {
|
|
|
+ for (WbsTreeContract dwNode : dw) {
|
|
|
+ if (fbNode.getAncestors().contains(dwNode.getId().toString())) {
|
|
|
+ set.add(dwNode.getFullName().trim() + "、" + fbNode.getFullName().trim());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- } else if (dw.size() > 0 && fx.size() > 0) {
|
|
|
- for (WbsTreeContract fxNode : fx) {
|
|
|
- for (WbsTreeContract dwNode : dw) {
|
|
|
- if (fxNode.getAncestors().contains(dwNode.getId().toString())) {
|
|
|
- set.add(dwNode.getNodeName() + "/" + fxNode.getNodeName() + "/");
|
|
|
+ } else if (dw.size() > 0 && fx.size() > 0) {
|
|
|
+ for (WbsTreeContract fxNode : fx) {
|
|
|
+ for (WbsTreeContract dwNode : dw) {
|
|
|
+ if (fxNode.getAncestors().contains(dwNode.getId().toString())) {
|
|
|
+ set.add(dwNode.getFullName().trim() + "、" + fxNode.getFullName().trim());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- } else if (fb.size() > 0 && fx.size() > 0) {
|
|
|
- for (WbsTreeContract fxNode : fx) {
|
|
|
- for (WbsTreeContract fbNode : fb) {
|
|
|
- if (fxNode.getAncestors().contains(fbNode.getId().toString())) {
|
|
|
- set.add(fbNode.getNodeName() + "/" + fxNode.getNodeName());
|
|
|
+ } else if (fb.size() > 0 && fx.size() > 0) {
|
|
|
+ for (WbsTreeContract fxNode : fx) {
|
|
|
+ for (WbsTreeContract fbNode : fb) {
|
|
|
+ if (fxNode.getAncestors().contains(fbNode.getId().toString())) {
|
|
|
+ set.add(fbNode.getFullName().trim() + "、" + fxNode.getFullName().trim());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ } else if (dw.size() > 0) {
|
|
|
+ for (WbsTreeContract dwNode : dw) {
|
|
|
+ set.add(dwNode.getFullName().trim());
|
|
|
+ }
|
|
|
+ } else if (fb.size() > 0) {
|
|
|
+ for (WbsTreeContract dwNode : fb) {
|
|
|
+ set.add(dwNode.getFullName().trim());
|
|
|
+ }
|
|
|
+ } else if (fx.size() > 0) {
|
|
|
+ for (WbsTreeContract dwNode : fx) {
|
|
|
+ set.add(dwNode.getFullName().trim());
|
|
|
+ }
|
|
|
}
|
|
|
- } else if (dw.size() > 0) {
|
|
|
- for (WbsTreeContract dwNode : dw) {
|
|
|
- set.add(dwNode.getNodeName());
|
|
|
- }
|
|
|
- } else if (fb.size() > 0) {
|
|
|
- for (WbsTreeContract dwNode : fb) {
|
|
|
- set.add(dwNode.getNodeName());
|
|
|
- }
|
|
|
- } else if (fx.size() > 0) {
|
|
|
- for (WbsTreeContract dwNode : fx) {
|
|
|
- set.add(dwNode.getNodeName());
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- if (set.size() > 0) {
|
|
|
- List<Map<String, String>> resultMapList = new ArrayList<>();
|
|
|
- //获取当前合同段下的试验节点下的表
|
|
|
- WbsTreePrivate trialNode = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id =" + nodePKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
|
|
|
- if (trialNode != null) {
|
|
|
- List<WbsTreePrivate> trialNodeTabs = jdbcTemplate.query("select p_key_id,html_url from m_wbs_tree_private where html_url is not null and is_deleted = 0 and status = 1 and type = 2 and parent_id =" + trialNode.getId() + " and project_id =" + trialNode.getProjectId() + " and wbs_id = " + trialNode.getWbsId() + " and wbs_type = " + trialNode.getWbsType() + " and (trial_tab_contract_id is null OR (trial_tab_contract_id = " + contractId + "))", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
- for (WbsTreePrivate trialNodeTab : trialNodeTabs) {
|
|
|
- //匹配关联
|
|
|
- try {
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- File file1 = ResourceUtil.getFile(trialNodeTab.getHtmlUrl());
|
|
|
- InputStream fileInputStream;
|
|
|
- if (file1.exists()) {
|
|
|
- fileInputStream = new FileInputStream(file1);
|
|
|
- } else {
|
|
|
- String path = sys_file_net_url + trialNodeTab.getHtmlUrl().replaceAll("//", "/").replaceAll(file_path, "");
|
|
|
- fileInputStream = CommonUtil.getOSSInputStream(path);
|
|
|
- }
|
|
|
- String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
- htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
- htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
+ if (set.size() > 0) {
|
|
|
+ List<Map<String, String>> resultMapList = new ArrayList<>();
|
|
|
+ //获取当前合同段下的试验节点下的表
|
|
|
+ WbsTreePrivate trialNode = jdbcTemplate.query("select * from m_wbs_tree_private where p_key_id =" + nodePKeyId, new BeanPropertyRowMapper<>(WbsTreePrivate.class)).stream().findAny().orElse(null);
|
|
|
+ if (trialNode != null) {
|
|
|
+ List<WbsTreePrivate> trialNodeTabs = jdbcTemplate.query("select p_key_id,html_url from m_wbs_tree_private where html_url is not null and is_deleted = 0 and status = 1 and type = 2 and parent_id =" + trialNode.getId() + " and project_id =" + trialNode.getProjectId() + " and wbs_id = " + trialNode.getWbsId() + " and wbs_type = " + trialNode.getWbsType() + " and (trial_tab_contract_id is null OR (trial_tab_contract_id = " + contractId + "))", new BeanPropertyRowMapper<>(WbsTreePrivate.class));
|
|
|
+ for (WbsTreePrivate trialNodeTab : trialNodeTabs) {
|
|
|
+ //匹配关联
|
|
|
+ try {
|
|
|
+ Map<String, String> map = new LinkedHashMap<>();
|
|
|
+ File file1 = ResourceUtil.getFile(trialNodeTab.getHtmlUrl());
|
|
|
+ InputStream fileInputStream;
|
|
|
+ if (file1.exists()) {
|
|
|
+ fileInputStream = new FileInputStream(file1);
|
|
|
+ } else {
|
|
|
+ String path = sys_file_net_url + trialNodeTab.getHtmlUrl().replaceAll("//", "/").replaceAll(file_path, "");
|
|
|
+ fileInputStream = CommonUtil.getOSSInputStream(path);
|
|
|
+ }
|
|
|
+ String htmlString = IoUtil.readToString(fileInputStream);
|
|
|
+ htmlString = htmlString.replaceAll("placeholder", "placeholderxx");
|
|
|
+ htmlString = htmlString.replaceAll("title", "titlexx");
|
|
|
|
|
|
- Document doc = Jsoup.parse(htmlString);
|
|
|
- Elements ppName = doc.select("el-input[placeholderxx~=工程部位.*]");
|
|
|
- //工程部位
|
|
|
- if (ppName.size() >= 1) {
|
|
|
- for (Element element : ppName) {
|
|
|
- map.put("tabPKeyId", trialNodeTab.getPKeyId().toString());
|
|
|
- map.put(element.attr("keyname"), StringUtils.join(set, "、"));
|
|
|
- resultMapList.add(map);
|
|
|
- break;
|
|
|
+ Document doc = Jsoup.parse(htmlString);
|
|
|
+ Elements ppName = doc.select("el-input[placeholderxx~=工程部位.*]");
|
|
|
+ //工程部位
|
|
|
+ if (ppName.size() >= 1) {
|
|
|
+ for (Element element : ppName) {
|
|
|
+ map.put("tabPKeyId", trialNodeTab.getPKeyId().toString());
|
|
|
+ map.put(element.attr("keyname"), StringUtils.join(set, " / "));
|
|
|
+ resultMapList.add(map);
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+ return resultMapList;
|
|
|
}
|
|
|
- return resultMapList;
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ //反向递归查询父级节点
|
|
|
+ private void fxSelectParentNode(List<WbsTreeContract> wbsTreeContracts, Set<WbsTreeContract> resultNode, String projectId, String wbsId, String wbsType, String contractId) {
|
|
|
+ List<Long> fuIds = wbsTreeContracts.stream().map(WbsTreeContract::getParentId).distinct().collect(Collectors.toList());
|
|
|
+ if (fuIds.size() > 0 && fuIds.get(0) != 0L) {
|
|
|
+ List<WbsTreeContract> fuNodes = wbsTreePrivateClient.selectListNode(fuIds, projectId, wbsId, wbsType, contractId);
|
|
|
+ if (fuNodes.size() > 0) {
|
|
|
+ resultNode.addAll(fuNodes);
|
|
|
+ this.fxSelectParentNode(fuNodes, resultNode, projectId, wbsId, wbsType, contractId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|