|
@@ -30,6 +30,7 @@ import org.springblade.business.service.IImageClassificationFileService;
|
|
|
import org.springblade.business.vo.TreeVo;
|
|
|
import org.springblade.common.utils.CommonUtil;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.tool.utils.ObjectUtil;
|
|
|
import org.springblade.manager.entity.WbsParam;
|
|
|
import org.springblade.manager.entity.WbsTree;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
@@ -145,12 +146,25 @@ public class ImageClassificationFileServiceImpl extends BaseServiceImpl<ImageCla
|
|
|
|
|
|
@Override
|
|
|
public String getFileTitleName(String pKeyId) {
|
|
|
- WbsTreeContract wbsTreeContract = jdbcTemplate.query("select id,ancestors,contract_id,project_id,wbs_id from m_wbs_tree_contract where is_deleted = 0 and status = 1 and p_key_id = " + pKeyId, new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
|
+ WbsTreeContract wbsTreeContract = jdbcTemplate.query("select * from m_wbs_tree_contract where is_deleted = 0 and status = 1 and p_key_id = " + pKeyId, new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
|
if (wbsTreeContract != null) {
|
|
|
+ //获取当前节点所有父级节点
|
|
|
+ List<WbsTreeContract> result = new ArrayList<>();
|
|
|
+ this.recursiveGetParentNodes(result, wbsTreeContract);
|
|
|
+ result.add(wbsTreeContract);
|
|
|
+ result.sort(Comparator.comparing(WbsTreeContract::getNodeType).thenComparing(WbsTreeContract::getParentId));
|
|
|
+ List<String> allNodeIds = result.stream().map(WbsTreeContract::getId).map(String::valueOf).collect(Collectors.toList());
|
|
|
+
|
|
|
WbsParam wbsParam = jdbcTemplate.query("select v from m_wbs_param where is_deleted = 0 and status = 1 and v is not null and k = 'FILE_TITLE' and name = '文件题名' and node_id = " + wbsTreeContract.getId(), new BeanPropertyRowMapper<>(WbsParam.class)).stream().findAny().orElse(null);
|
|
|
- if (wbsParam != null) {
|
|
|
- String[] titles = wbsParam.getV().split("-");
|
|
|
+
|
|
|
+ if (ObjectUtil.isNotEmpty(wbsTreeContract.getOldId())) {
|
|
|
+ //表示复制、新增节点
|
|
|
+ wbsParam = jdbcTemplate.query("select v from m_wbs_param where is_deleted = 0 and status = 1 and v is not null and k = 'FILE_TITLE' and name = '文件题名' and node_id = " + wbsTreeContract.getOldId(), new BeanPropertyRowMapper<>(WbsParam.class)).stream().findAny().orElse(null);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (wbsParam != null && allNodeIds.size() > 0) {
|
|
|
List<String> nodeNumber = new ArrayList<>();
|
|
|
+ String[] titles = wbsParam.getV().split("-");
|
|
|
for (String title : titles) {
|
|
|
if (title.contains("c") || title.contains("C")) {
|
|
|
String lastStr = title.substring(title.length() - 1);
|
|
@@ -158,31 +172,29 @@ public class ImageClassificationFileServiceImpl extends BaseServiceImpl<ImageCla
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<String> ancestors = Arrays.asList(wbsTreeContract.getAncestors().split(","));
|
|
|
-
|
|
|
List<String> ids = new ArrayList<>();
|
|
|
for (String index : nodeNumber) {
|
|
|
- if ("0".equals(index)) {
|
|
|
- index = "1";
|
|
|
- }
|
|
|
- if (Integer.parseInt(index) <= ancestors.size()) {
|
|
|
- String id = ancestors.get(Integer.parseInt(index));
|
|
|
+ if (Integer.parseInt(index) <= result.size()) {
|
|
|
+ String id = allNodeIds.get(Integer.parseInt(index));
|
|
|
if (StringUtils.isNotEmpty(id)) {
|
|
|
ids.add(id);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- List<WbsTreeContract> wbsTreeContractList = jdbcTemplate.query("select node_name from m_wbs_tree_contract where is_deleted = 0 and status = 1 and project_id = " + wbsTreeContract.getProjectId() + " and contract_id = " + wbsTreeContract.getContractId() + " and wbs_id = " + wbsTreeContract.getWbsId() + " and id in(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
- if (wbsTreeContractList.size() > 0) {
|
|
|
- List<String> nameList = wbsTreeContractList.stream().map(WbsTreeContract::getNodeName).collect(Collectors.toList());
|
|
|
+ List<WbsTreeContract> filteredList = result.stream()
|
|
|
+ .filter(e -> ids.stream().anyMatch(id -> id.equals(String.valueOf(e.getId()))))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (filteredList.size() > 0) {
|
|
|
+ List<String> nameList = filteredList.stream().map(WbsTreeContract::getFullName).collect(Collectors.toList());
|
|
|
if (nameList.size() > 0) {
|
|
|
return StringUtils.join(nameList, "");
|
|
|
}
|
|
|
} else {
|
|
|
- //如果私有是空的,就去公有WBS找
|
|
|
- List<WbsTree> wbsTreeList = jdbcTemplate.query("select node_name from m_wbs_tree where is_deleted = 0 and status = 1 and id in(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(WbsTree.class));
|
|
|
- List<String> nameList = wbsTreeList.stream().map(WbsTree::getNodeName).collect(Collectors.toList());
|
|
|
+ //如果私有WBS为空,到公有WBS获取
|
|
|
+ List<WbsTree> wbsTreeList = jdbcTemplate.query("select full_name from m_wbs_tree where is_deleted = 0 and status = 1 and id in(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(WbsTree.class));
|
|
|
+ List<String> nameList = wbsTreeList.stream().map(WbsTree::getFullName).collect(Collectors.toList());
|
|
|
if (nameList.size() > 0) {
|
|
|
return StringUtils.join(nameList, "");
|
|
|
}
|
|
@@ -192,4 +204,13 @@ public class ImageClassificationFileServiceImpl extends BaseServiceImpl<ImageCla
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ //反向递归获取父级
|
|
|
+ private void recursiveGetParentNodes(List<WbsTreeContract> result, WbsTreeContract wbsTreeContract) {
|
|
|
+ WbsTreeContract parentNode = jdbcTemplate.query("select * from m_wbs_tree_contract where is_deleted = 0 and status = 1 and type = 1 and parent_id != 0 and id = " + wbsTreeContract.getParentId() + " and contract_id = " + wbsTreeContract.getContractId(), new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
|
+ if (parentNode != null) {
|
|
|
+ result.add(parentNode);
|
|
|
+ this.recursiveGetParentNodes(result, parentNode);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|