|
@@ -147,6 +147,8 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
|
|
|
private final ExcelTabClient excelTabClient;
|
|
|
|
|
|
+ private final IRecycleBinService recycleBinService;
|
|
|
+
|
|
|
@Autowired
|
|
|
StringRedisTemplate RedisTemplate;
|
|
|
|
|
@@ -609,14 +611,16 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
// @PushMessage(clientId = ClientIdConstant.BUSINESS_CLIENT_ID)
|
|
|
public R<Object> abolishOne(@RequestParam String primaryKeyId, @RequestParam String classify, @RequestParam String projectId, @RequestParam String contractId) {
|
|
|
//查询填报状态
|
|
|
- InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 1));
|
|
|
+ InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getContractId, contractId)
|
|
|
+ .eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 1).ne(InformationQuery::getStatus, 3));
|
|
|
primaryKeyId = primaryKeyId + "*";
|
|
|
if (businessData != null) {
|
|
|
//使用批量废除接口
|
|
|
return this.batchAbolish(businessData.getId().toString(), primaryKeyId, projectId, contractId, "撤回成功");
|
|
|
} else {
|
|
|
//试验
|
|
|
- InformationQuery businessDataTrial = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 2));
|
|
|
+ InformationQuery businessDataTrial = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getContractId, contractId)
|
|
|
+ .eq(InformationQuery::getType, 2).ne(InformationQuery::getStatus, 3));
|
|
|
if (businessDataTrial != null) {
|
|
|
//使用批量废除接口
|
|
|
return this.batchAbolish(businessDataTrial.getId().toString(), primaryKeyId, projectId, contractId, "撤回成功");
|
|
@@ -653,7 +657,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//记录状态
|
|
|
String status = "1";
|
|
|
//查询填报状态,type=1资料填报
|
|
|
- InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 1).last("limit 1"));
|
|
|
+ InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 1).last("order by id desc limit 1"));
|
|
|
if (businessData != null) {
|
|
|
switch (businessData.getStatus()) {
|
|
|
case 0:
|
|
@@ -715,7 +719,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//记录状态
|
|
|
String status = "1";
|
|
|
//查询填报状态,type=1资料填报
|
|
|
- InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 1));
|
|
|
+ InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, primaryKeyId).eq(InformationQuery::getClassify, classify).eq(InformationQuery::getType, 1).last("order by id desc limit 1"));
|
|
|
if (businessData != null) {
|
|
|
switch (businessData.getStatus()) {
|
|
|
case 0:
|
|
@@ -780,7 +784,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//查询填报状态,type=3首件
|
|
|
InformationQuery businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery()
|
|
|
.eq(InformationQuery::getId, id)
|
|
|
- .eq(InformationQuery::getType, 3)
|
|
|
+ .eq(InformationQuery::getType, 3).last("order by id desc limit 1")
|
|
|
);
|
|
|
if (businessData != null) {
|
|
|
switch (businessData.getStatus()) {
|
|
@@ -906,7 +910,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
//此时的ids是当前节点的primaryKeyId但并不是业务数据ID,需要根据ids和classify去查询具体的业务ID
|
|
|
if (ObjectUtil.isNotEmpty(startTaskVO.getTrialSelfInspectionRecordId())) {
|
|
|
//试验
|
|
|
- businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, startTaskVO.getIds().replaceAll(",", "")).eq(InformationQuery::getClassify, startTaskVO.getClassify().toString()).eq(InformationQuery::getType, 2).eq(InformationQuery::getContractId,startTaskVO.getContractId()));
|
|
|
+ businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, startTaskVO.getIds().replaceAll(",", "")).eq(InformationQuery::getClassify, startTaskVO.getClassify().toString()).eq(InformationQuery::getType, 2).eq(InformationQuery::getContractId,startTaskVO.getContractId()).last("order by id desc limit 1"));
|
|
|
if (businessData != null) {
|
|
|
//设置业务数据ID
|
|
|
startTaskVO.setIds(businessData.getWbsId().toString());
|
|
@@ -916,7 +920,7 @@ public class InformationWriteQueryController extends BladeController {
|
|
|
return R.data(300, false, "未查询到填报信息,上报失败");
|
|
|
}
|
|
|
} else { //质检
|
|
|
- businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, startTaskVO.getIds().replaceAll(",", "")).eq(InformationQuery::getClassify, startTaskVO.getClassify().toString()).eq(InformationQuery::getType, 1));
|
|
|
+ businessData = this.informationQueryService.getOne(Wrappers.<InformationQuery>lambdaQuery().eq(InformationQuery::getWbsId, startTaskVO.getIds().replaceAll(",", "")).eq(InformationQuery::getClassify, startTaskVO.getClassify().toString()).eq(InformationQuery::getType, 1).last("order by id desc limit 1"));
|
|
|
if (businessData != null) {
|
|
|
//设置业务数据ID
|
|
|
startTaskVO.setIds(businessData.getId().toString());
|
|
@@ -1170,7 +1174,7 @@ public R<String> batchDownloadFileToZip(String ids, HttpServletResponse response
|
|
|
//已审批、已撤销的任务,修改业务数据的审批状态为未上报并撤签即可
|
|
|
LambdaUpdateWrapper<InformationQuery> wrapper = Wrappers.lambdaUpdate();
|
|
|
//更改状态为未上报
|
|
|
- wrapper.set(InformationQuery::getStatus, 0);
|
|
|
+ wrapper.set(InformationQuery::getStatus, 3);
|
|
|
//将电签的pdf路径置空
|
|
|
wrapper.set(InformationQuery::getEVisaPdfUrl, null);
|
|
|
//将上报批次置空
|
|
@@ -1208,6 +1212,9 @@ public R<String> batchDownloadFileToZip(String ids, HttpServletResponse response
|
|
|
}
|
|
|
|
|
|
for (InformationQuery query : queries) {
|
|
|
+ if (query.getStatus() != null && query.getStatus() != 3) {
|
|
|
+ this.informationQueryService.update(Wrappers.<InformationQuery>lambdaUpdate().eq(InformationQuery::getId, query.getId()).set(InformationQuery::getStatus, 3));
|
|
|
+ }
|
|
|
if (StringUtils.isNotEmpty(query.getFileUserIdAndName())) {
|
|
|
String[] userArray = query.getFileUserIdAndName().split(",");
|
|
|
for (String str : userArray) {
|
|
@@ -1353,7 +1360,7 @@ public R<String> batchDownloadFileToZip(String ids, HttpServletResponse response
|
|
|
@ApiOperation(value = "批量上报")
|
|
|
// @PushMessage(clientId = ClientIdConstant.BUSINESS_CLIENT_ID)
|
|
|
public R<Object> batchTask(@RequestBody StartTaskVO startTaskVO) {
|
|
|
- // 1= 代表 试验 流程上报 2=试验 - 委托单上报 其他=质检或别的项目上报
|
|
|
+ // 1= 代表 试验 流程上报 2=试验 - 委托单上报 3=首件上报 其他=质检或别的项目上报
|
|
|
Long appType = startTaskVO.getTrialSelfInspectionRecordId();
|
|
|
if (ObjectUtil.isEmpty(SecureUtil.getUserId()) || SecureUtil.getUserId() == -1L) {
|
|
|
throw new ServiceException("未获取到当前用户信息");
|
|
@@ -1381,7 +1388,19 @@ public R<Object> batchTask(@RequestBody StartTaskVO startTaskVO) {
|
|
|
}
|
|
|
|
|
|
Map<String, InformationQuery> queryMap = new HashMap<>();
|
|
|
- queryList.forEach(query -> queryMap.put(query.getId().toString(), query));
|
|
|
+ List<InformationQuery> saveQueryList = new ArrayList<>();
|
|
|
+ queryList.forEach(query -> {
|
|
|
+ if (query.getStatus() != null && query.getStatus() == 3) {
|
|
|
+ query.setId(SnowFlakeUtil.getId());
|
|
|
+ query.setStatus(0);
|
|
|
+ saveQueryList.add(query);
|
|
|
+ }
|
|
|
+ queryMap.put(query.getId().toString(), query);
|
|
|
+ });
|
|
|
+ if (!saveQueryList.isEmpty()) {
|
|
|
+ this.informationQueryService.saveBatch(saveQueryList);
|
|
|
+ ids = queryList.stream().map(InformationQuery::getId).map(String::valueOf).toArray(String[]::new);
|
|
|
+ }
|
|
|
boolean var = false;
|
|
|
|
|
|
try {
|
|
@@ -1413,6 +1432,10 @@ public R<Object> batchTask(@RequestBody StartTaskVO startTaskVO) {
|
|
|
//设置上报类型
|
|
|
if (appType != null && appType == 2L) {
|
|
|
taskVO.setApprovalType(8);
|
|
|
+ } else if (appType != null && appType == 1L) {
|
|
|
+ taskVO.setApprovalType(9);
|
|
|
+ } else if (appType != null && appType == 3L) {
|
|
|
+ taskVO.setApprovalType(10);
|
|
|
} else {
|
|
|
taskVO.setApprovalType(1);
|
|
|
}
|
|
@@ -1454,7 +1477,7 @@ public R<Object> batchTask(@RequestBody StartTaskVO startTaskVO) {
|
|
|
jdbcTemplate.execute(sql);
|
|
|
}
|
|
|
var = true;
|
|
|
- getPdfs(queryMap.get(id));
|
|
|
+// getPdfs(queryMap.get(id));
|
|
|
} else {
|
|
|
return R.fail("创建主流程失败");
|
|
|
}
|
|
@@ -3087,8 +3110,8 @@ private void currentNodeAllParent(StringBuilder nodeName, WbsTreeContract curren
|
|
|
private void currentNodeAllChild(List<WbsTreeContract> resultChildNodes, List<WbsTreeContract> childNodes, String contractId) {
|
|
|
if (childNodes.size() > 0) {
|
|
|
//如果存在子级,那么递归获取子级的子级
|
|
|
- List<Long> ids = childNodes.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
|
- List<WbsTreeContract> childNodeList = jdbcTemplate.query("select p_key_id,id,parent_id,type from m_wbs_tree_contract where is_deleted = 0 and contract_id = " + contractId + " and parent_id in(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ List<Long> ids = childNodes.stream().map(WbsTreeContract::getId).distinct().collect(Collectors.toList());
|
|
|
+ List<WbsTreeContract> childNodeList = jdbcTemplate.query("select p_key_id,id,parent_id,type,contract_id,project_id,full_name,node_name from m_wbs_tree_contract where is_deleted = 0 and contract_id = " + contractId + " and parent_id in(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
if (childNodeList.size() > 0) {
|
|
|
resultChildNodes.addAll(childNodeList);
|
|
|
this.currentNodeAllChild(resultChildNodes, childNodeList, contractId);
|
|
@@ -3123,105 +3146,211 @@ public R removeContractTreeNodeJudge(@RequestParam String ids) {
|
|
|
return R.data(true);
|
|
|
}
|
|
|
|
|
|
-/**
|
|
|
- * 删除节点
|
|
|
- *
|
|
|
- * @param ids 节点的primaryKeyId(只有一个值)
|
|
|
- * @return 删除结果
|
|
|
- */
|
|
|
-@PostMapping("/removeContractTreeNode")
|
|
|
-@ApiOperationSupport(order = 11)
|
|
|
-@ApiOperation(value = "删除节点")
|
|
|
-@ApiImplicitParam(name = "ids", value = "节点的primaryKeyId")
|
|
|
-public R<Boolean> removeContractTreeNode(@RequestParam String ids) {
|
|
|
- //根据传入的节点,将其所有子节点删除
|
|
|
- WbsTreeContract removeNode = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.parseLong(ids));
|
|
|
+ /**
|
|
|
+ * 删除节点
|
|
|
+ * @param ids 节点的primaryKeyId
|
|
|
+ * @return 删除结果
|
|
|
+ */
|
|
|
+ @PostMapping("/removeContractTreeNode")
|
|
|
+ @ApiOperationSupport(order = 11)
|
|
|
+ @ApiOperation(value = "批量删除节点")
|
|
|
+ @ApiImplicitParam(name = "ids", value = "节点的primaryKeyId, 逗号拼接")
|
|
|
+ public R<Boolean> removeContractTreeNode(@RequestParam String ids) {
|
|
|
+ if (!ids.isEmpty()) {
|
|
|
+ List<WbsTreeContract> removeWbsTreeContracts = this.jdbcTemplate.query("select p_key_id,id,parent_id,type,contract_id,project_id,full_name,node_name from m_wbs_tree_contract where is_deleted = 0 and p_key_id in (" + ids + ")", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+ if (removeWbsTreeContracts.isEmpty()) {
|
|
|
+ return R.fail("删除失败:节点不存在");
|
|
|
+ }
|
|
|
|
|
|
- /*//判断是否存在原始节点
|
|
|
- if (ObjectUtil.isEmpty(removeNode.getOldId())) {
|
|
|
- return R.data(300, false, "节点【" + removeNode.getFullName() + "】为原始节点,不允许删除");
|
|
|
- }*/
|
|
|
+ String contractId = removeWbsTreeContracts.get(0).getContractId();
|
|
|
+ String projectId = removeWbsTreeContracts.get(0).getProjectId();
|
|
|
+ removeWbsTreeContracts.forEach(node -> {
|
|
|
+ if (contractId == null || !contractId.equals(node.getContractId())) {
|
|
|
+ throw new ServiceException("删除失败:节点不属于同一合同段");
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- //查询当前操作的节点的父级关系
|
|
|
- StringBuilder parentNodeName = new StringBuilder();
|
|
|
- this.currentNodeAllParent(parentNodeName, removeNode);
|
|
|
+ List<WbsTreeContract> removeNodeList = new ArrayList<>();
|
|
|
+ Map<Long , WbsTreeContract> unremoveNodeMap = new HashMap<>();
|
|
|
+ // 查询所有子节点
|
|
|
+ this.currentNodeAllChild(removeNodeList, removeWbsTreeContracts, contractId);
|
|
|
+ removeNodeList.addAll(removeWbsTreeContracts);
|
|
|
+ // 根据pKeyId去重
|
|
|
+ removeNodeList = distinct(removeNodeList);
|
|
|
+ //获取pKeyId
|
|
|
+ List<Long> removeList = removeNodeList.stream().map(WbsTreeContract::getPKeyId).distinct().collect(Collectors.toList());
|
|
|
+ if (!removeList.isEmpty()) {
|
|
|
+ String wbsIds = removeList.stream().map(Object::toString).collect(Collectors.joining(","));
|
|
|
+ /** 判断是否子节点有上报或审批过的资料,因为父id和祖级节点错误,直接使用上面的值去查询上报情况*/
|
|
|
+ List<String> unRemoveIds = jdbcTemplate.queryForList("SELECT wbs_id from u_information_query WHERE wbs_id in (" + wbsIds + ") and is_deleted = 0 and status in (1,2) GROUP BY wbs_id HAVING count(1) > 0", String.class);
|
|
|
+ if (!unRemoveIds.isEmpty()) {
|
|
|
+ // 剔除此节点
|
|
|
+ Map<String, String> map = unRemoveIds.stream().collect(Collectors.toMap(id -> id, Function.identity()));
|
|
|
+ removeNodeList.removeIf(node -> {
|
|
|
+ //删除掉表格 TODO(不清楚为什么要剔除表格,按理说删除节点后,节点下的表也应该一起删除的,猜测或许是为了方便恢复节点的时候表数据还存在)2023年9月19日
|
|
|
+ boolean removeIf = node.getType() != null && new Integer("2").equals(node.getType());
|
|
|
+ boolean equals = map.containsKey(node.getPKeyId().toString());
|
|
|
+ if (equals) {
|
|
|
+ unremoveNodeMap.put(node.getPKeyId(), node);
|
|
|
+ }
|
|
|
+ return removeIf || equals;
|
|
|
+ });
|
|
|
+ Map<Long, WbsTreeContract> contractMap = removeNodeList.stream().collect(Collectors.toMap(WbsTreeContract::getId, Function.identity()));
|
|
|
+ Map<Long, WbsTreeContract> tempMap = new HashMap<>();
|
|
|
+ unremoveNodeMap.forEach((key, value) -> collectNodeAndAncestors(value, contractMap, tempMap));
|
|
|
+ unremoveNodeMap.putAll(tempMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(removeNodeList.isEmpty()) {
|
|
|
+ return R.fail("删除失败,该节点下有已填报的资料");
|
|
|
+ }
|
|
|
|
|
|
- //判断是否子节点有上报或审批过的资料
|
|
|
-// List<InformationQuery> list = informationQueryService.selectChildrenNodeInfo(removeNode);
|
|
|
-// if (list != null && list.size() >= 1) {
|
|
|
-// return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
|
|
|
-// }
|
|
|
+ StringBuilder position = new StringBuilder();
|
|
|
+ List<String> idArray = removeNodeList.stream().filter(wbsTreeContract -> !unremoveNodeMap.containsKey(wbsTreeContract.getPKeyId())).map(wbsTreeContract -> {
|
|
|
+ position.append(",").append(StringUtils.isNotEmpty(wbsTreeContract.getFullName()) ? wbsTreeContract.getFullName() : wbsTreeContract.getNodeName());
|
|
|
+ return wbsTreeContract.getPKeyId() + "";
|
|
|
+ }).distinct().collect(Collectors.toList());
|
|
|
|
|
|
- //查询所有子节点 TODO(不能用ancestors字段获取,ancestors字段有问题,目前用递归获取)2023年9月19日
|
|
|
- //List<WbsTreeContract> removeNodeList = jdbcTemplate.query("select p_key_id,type from m_wbs_tree_contract where is_deleted = 0 and contract_id = " + removeNode.getContractId() + " and ancestors like '%" + removeNode.getId() + "%'", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
- List<WbsTreeContract> removeNodeList = new ArrayList<>();
|
|
|
- this.currentNodeAllChild(removeNodeList, Collections.singletonList(removeNode), removeNode.getContractId());
|
|
|
+ JSONObject json = new JSONObject();
|
|
|
+ json.put("operationObjIds", idArray);
|
|
|
+ String positionStr = position.substring(1);
|
|
|
+ json.put("operationObjName", positionStr);
|
|
|
+ json.put("projectId", projectId);
|
|
|
+ json.put("contractId", contractId);
|
|
|
+ this.operationLogClient.saveUserOperationLog(4, "资料管理", "工序资料", json);
|
|
|
+
|
|
|
+ //保存进回收站
|
|
|
+ this.recycleBinService.save(new RecycleBin(String.join(",", idArray), "工程划分批量删除", 2, positionStr, projectId, contractId));
|
|
|
+ //改为物理删除 (8.28改为逻辑删除,方便恢复)
|
|
|
+ this.wbsTreeContractClient.removeContractTreeNode(idArray);
|
|
|
+ //更新redis
|
|
|
+ this.informationQueryService.delAsyncWbsTree(removeWbsTreeContracts.get(0).getContractId());
|
|
|
+ }
|
|
|
+ return R.data(true);
|
|
|
+ }
|
|
|
|
|
|
- //获取pKeyId
|
|
|
- List<Long> removeList = removeNodeList.stream().map(WbsTreeContract::getPKeyId).distinct().collect(Collectors.toList());
|
|
|
- if (removeList.size() > 0) {
|
|
|
- /** 判断是否子节点有上报或审批过的资料,因为父id和祖级节点错误,直接使用上面的值去查询上报情况*/
|
|
|
- List<InformationQuery> list = informationQueryService.selectChildrenNodeInfo(removeList);
|
|
|
- if (list != null && list.size() >= 1) {
|
|
|
- return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
|
|
|
+ // 递归收集节点及其所有父节点
|
|
|
+ private void collectNodeAndAncestors(WbsTreeContract node, Map<Long, WbsTreeContract> contractMap, Map<Long , WbsTreeContract> unremoveNodeMap) {
|
|
|
+ if (node == null || node.getParentId() == null || contractMap == null || contractMap.isEmpty()) return;
|
|
|
+ WbsTreeContract item = contractMap.get(node.getParentId());
|
|
|
+ if (item != null && item.getId() != null && item.getId().equals(node.getParentId())) {
|
|
|
+ unremoveNodeMap.put(item.getPKeyId(), item);
|
|
|
+ collectNodeAndAncestors(item, contractMap, unremoveNodeMap);
|
|
|
}
|
|
|
- //拼接
|
|
|
- ids = ids + "," + String.join(",", JSONArray.parseArray(JSONObject.toJSONString(removeList), String.class));
|
|
|
- //删除掉表格 TODO(不清楚为什么要剔除表格,按理说删除节点后,节点下的表也应该一起删除的,猜测或许是为了方便恢复节点的时候表数据还存在)2023年9月19日
|
|
|
- removeNodeList.removeIf(tree -> tree.getType() != null && new Integer("2").equals(tree.getType()));
|
|
|
}
|
|
|
- //获取被删除节点名称
|
|
|
- //String nodeName = StringUtils.isNotEmpty(removeNode.getFullName()) ? removeNode.getFullName() : removeNode.getNodeName() + "," + removeNodeList.stream().map(wbs -> StringUtils.isNotEmpty(wbs.getFullName()) ? wbs.getFullName() : wbs.getNodeName()).collect(Collectors.joining());
|
|
|
-
|
|
|
- //获取当前节点下所有填报节点
|
|
|
- /*List<QueryProcessDataVO> queryProcess = new ArrayList<>();
|
|
|
- if (!Arrays.asList("1,2,3,4".split(",")).contains(removeNode.getMajorDataType().toString())) {
|
|
|
- queryProcess = this.informationQueryService.queryProcessDataByParentIdAndContractId2(removeNode.getId().toString(), 1, removeNode.getContractId());
|
|
|
- if (queryProcess == null || queryProcess.size() == 0) {
|
|
|
- //填报节点
|
|
|
- queryProcess = this.informationQueryService.queryProcessDataByPrimaryKeyIdAndClassify(removeNode.getPKeyId().toString(), 1);
|
|
|
- }
|
|
|
+ private List<WbsTreeContract> distinct(List<WbsTreeContract> list) {
|
|
|
+ if (list == null || list.isEmpty()) {
|
|
|
+ return list;
|
|
|
}
|
|
|
-
|
|
|
- if (queryProcess != null && queryProcess.size() > 0) {
|
|
|
- //检查这些填报节点是否存在已经审批或已经上报的节点,如果存在则不允许删除
|
|
|
- List<QueryProcessDataVO> approvalList = queryProcess.stream().filter(vo -> new Integer("2").equals(vo.getStatus()) && vo.getInformationQueryId() != null).collect(Collectors.toList());
|
|
|
- List<QueryProcessDataVO> runTaskList = queryProcess.stream().filter(vo -> new Integer("1").equals(vo.getStatus()) && vo.getInformationQueryId() != null).collect(Collectors.toList());
|
|
|
- if (approvalList.size() > 0 || runTaskList.size() > 0) {
|
|
|
- //说明存在已经审批或已经上报的节点,不允许删除
|
|
|
- return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
|
|
|
+ Map<Long, WbsTreeContract> tempMap = new HashMap<>();
|
|
|
+ return list.stream().filter(node -> {
|
|
|
+ if (tempMap.containsKey(node.getPKeyId())) {
|
|
|
+ return false;
|
|
|
}
|
|
|
- }*/
|
|
|
-
|
|
|
- //保存操作记录
|
|
|
- List<String> idArray = JSONArray.parseArray(JSONObject.toJSONString(ids.split(",")), String.class);
|
|
|
- //获取当前节点的所有父节点
|
|
|
- List<WbsTreeContract> result = new ArrayList<>();
|
|
|
- result.add(removeNode);
|
|
|
- this.queryParentNode(removeNode, result);
|
|
|
- StringBuilder pathName = new StringBuilder();
|
|
|
- for (int i = 1, l = result.size(); i <= l; i++) {
|
|
|
- WbsTreeContract node = result.get(result.size() - i);
|
|
|
- pathName.append("-").append(StringUtils.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
|
|
|
+ tempMap.put(node.getPKeyId(), node);
|
|
|
+ return true;
|
|
|
+ }).collect(Collectors.toList());
|
|
|
}
|
|
|
- JSONObject json = new JSONObject();
|
|
|
- json.put("operationObjIds", idArray);
|
|
|
- json.put("operationObjName", pathName.substring(1));
|
|
|
- json.put("projectId", removeNode.getProjectId());
|
|
|
- json.put("contractId", removeNode.getContractId());
|
|
|
- this.operationLogClient.saveUserOperationLog(4, "资料管理", "工序资料", json);
|
|
|
-
|
|
|
- //保存进回收站
|
|
|
- this.recycleBinClient.saveDelBusinessData(idArray, StringUtils.isNotEmpty(removeNode.getFullName()) ? removeNode.getFullName() : removeNode.getNodeName(), 2, parentNodeName.toString(), removeNode.getProjectId(), removeNode.getContractId());
|
|
|
-
|
|
|
- //改为物理删除 (8.28改为逻辑删除,方便恢复)
|
|
|
- this.wbsTreeContractClient.removeContractTreeNode(idArray);
|
|
|
-
|
|
|
- //更新redis
|
|
|
- this.informationQueryService.delAsyncWbsTree(removeNode.getContractId());
|
|
|
|
|
|
- return R.data(true);
|
|
|
-}
|
|
|
+///**
|
|
|
+// * 删除节点
|
|
|
+// *
|
|
|
+// * @param ids 节点的primaryKeyId(只有一个值)
|
|
|
+// * @return 删除结果
|
|
|
+// */
|
|
|
+//@PostMapping("/removeContractTreeNode")
|
|
|
+//@ApiOperationSupport(order = 11)
|
|
|
+//@ApiOperation(value = "删除节点")
|
|
|
+//@ApiImplicitParam(name = "ids", value = "节点的primaryKeyId")
|
|
|
+//public R<Boolean> removeContractTreeNode(@RequestParam String ids) {
|
|
|
+// //根据传入的节点,将其所有子节点删除
|
|
|
+// WbsTreeContract removeNode = this.wbsTreeContractClient.getContractWbsTreeByPrimaryKeyId(Long.parseLong(ids));
|
|
|
+//
|
|
|
+// /*//判断是否存在原始节点
|
|
|
+// if (ObjectUtil.isEmpty(removeNode.getOldId())) {
|
|
|
+// return R.data(300, false, "节点【" + removeNode.getFullName() + "】为原始节点,不允许删除");
|
|
|
+// }*/
|
|
|
+//
|
|
|
+// //查询当前操作的节点的父级关系
|
|
|
+// StringBuilder parentNodeName = new StringBuilder();
|
|
|
+// this.currentNodeAllParent(parentNodeName, removeNode);
|
|
|
+//
|
|
|
+// //判断是否子节点有上报或审批过的资料
|
|
|
+//// List<InformationQuery> list = informationQueryService.selectChildrenNodeInfo(removeNode);
|
|
|
+//// if (list != null && list.size() >= 1) {
|
|
|
+//// return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
|
|
|
+//// }
|
|
|
+//
|
|
|
+// //查询所有子节点 TODO(不能用ancestors字段获取,ancestors字段有问题,目前用递归获取)2023年9月19日
|
|
|
+// //List<WbsTreeContract> removeNodeList = jdbcTemplate.query("select p_key_id,type from m_wbs_tree_contract where is_deleted = 0 and contract_id = " + removeNode.getContractId() + " and ancestors like '%" + removeNode.getId() + "%'", new BeanPropertyRowMapper<>(WbsTreeContract.class));
|
|
|
+// List<WbsTreeContract> removeNodeList = new ArrayList<>();
|
|
|
+// this.currentNodeAllChild(removeNodeList, Collections.singletonList(removeNode), removeNode.getContractId());
|
|
|
+//
|
|
|
+// //获取pKeyId
|
|
|
+// List<Long> removeList = removeNodeList.stream().map(WbsTreeContract::getPKeyId).distinct().collect(Collectors.toList());
|
|
|
+// if (removeList.size() > 0) {
|
|
|
+// /** 判断是否子节点有上报或审批过的资料,因为父id和祖级节点错误,直接使用上面的值去查询上报情况*/
|
|
|
+// List<InformationQuery> list = informationQueryService.selectChildrenNodeInfo(removeList);
|
|
|
+// if (list != null && list.size() >= 1) {
|
|
|
+// return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
|
|
|
+// }
|
|
|
+// //拼接
|
|
|
+// ids = ids + "," + String.join(",", JSONArray.parseArray(JSONObject.toJSONString(removeList), String.class));
|
|
|
+// //删除掉表格 TODO(不清楚为什么要剔除表格,按理说删除节点后,节点下的表也应该一起删除的,猜测或许是为了方便恢复节点的时候表数据还存在)2023年9月19日
|
|
|
+// removeNodeList.removeIf(tree -> tree.getType() != null && new Integer("2").equals(tree.getType()));
|
|
|
+// }
|
|
|
+// //获取被删除节点名称
|
|
|
+// //String nodeName = StringUtils.isNotEmpty(removeNode.getFullName()) ? removeNode.getFullName() : removeNode.getNodeName() + "," + removeNodeList.stream().map(wbs -> StringUtils.isNotEmpty(wbs.getFullName()) ? wbs.getFullName() : wbs.getNodeName()).collect(Collectors.joining());
|
|
|
+//
|
|
|
+// //获取当前节点下所有填报节点
|
|
|
+// /*List<QueryProcessDataVO> queryProcess = new ArrayList<>();
|
|
|
+// if (!Arrays.asList("1,2,3,4".split(",")).contains(removeNode.getMajorDataType().toString())) {
|
|
|
+// queryProcess = this.informationQueryService.queryProcessDataByParentIdAndContractId2(removeNode.getId().toString(), 1, removeNode.getContractId());
|
|
|
+// if (queryProcess == null || queryProcess.size() == 0) {
|
|
|
+// //填报节点
|
|
|
+// queryProcess = this.informationQueryService.queryProcessDataByPrimaryKeyIdAndClassify(removeNode.getPKeyId().toString(), 1);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// if (queryProcess != null && queryProcess.size() > 0) {
|
|
|
+// //检查这些填报节点是否存在已经审批或已经上报的节点,如果存在则不允许删除
|
|
|
+// List<QueryProcessDataVO> approvalList = queryProcess.stream().filter(vo -> new Integer("2").equals(vo.getStatus()) && vo.getInformationQueryId() != null).collect(Collectors.toList());
|
|
|
+// List<QueryProcessDataVO> runTaskList = queryProcess.stream().filter(vo -> new Integer("1").equals(vo.getStatus()) && vo.getInformationQueryId() != null).collect(Collectors.toList());
|
|
|
+// if (approvalList.size() > 0 || runTaskList.size() > 0) {
|
|
|
+// //说明存在已经审批或已经上报的节点,不允许删除
|
|
|
+// return R.data(300, false, "存在已经上报或审批的节点,不允许删除");
|
|
|
+// }
|
|
|
+// }*/
|
|
|
+//
|
|
|
+// //保存操作记录
|
|
|
+// List<String> idArray = JSONArray.parseArray(JSONObject.toJSONString(ids.split(",")), String.class);
|
|
|
+// //获取当前节点的所有父节点
|
|
|
+// List<WbsTreeContract> result = new ArrayList<>();
|
|
|
+// result.add(removeNode);
|
|
|
+// this.queryParentNode(removeNode, result);
|
|
|
+// StringBuilder pathName = new StringBuilder();
|
|
|
+// for (int i = 1, l = result.size(); i <= l; i++) {
|
|
|
+// WbsTreeContract node = result.get(result.size() - i);
|
|
|
+// pathName.append("-").append(StringUtils.isNotEmpty(node.getFullName()) ? node.getFullName() : node.getNodeName());
|
|
|
+// }
|
|
|
+// JSONObject json = new JSONObject();
|
|
|
+// json.put("operationObjIds", idArray);
|
|
|
+// json.put("operationObjName", pathName.substring(1));
|
|
|
+// json.put("projectId", removeNode.getProjectId());
|
|
|
+// json.put("contractId", removeNode.getContractId());
|
|
|
+// this.operationLogClient.saveUserOperationLog(4, "资料管理", "工序资料", json);
|
|
|
+//
|
|
|
+// //保存进回收站
|
|
|
+// this.recycleBinClient.saveDelBusinessData(idArray, StringUtils.isNotEmpty(removeNode.getFullName()) ? removeNode.getFullName() : removeNode.getNodeName(), 2, parentNodeName.toString(), removeNode.getProjectId(), removeNode.getContractId());
|
|
|
+//
|
|
|
+// //改为物理删除 (8.28改为逻辑删除,方便恢复)
|
|
|
+// this.wbsTreeContractClient.removeContractTreeNode(idArray);
|
|
|
+//
|
|
|
+// //更新redis
|
|
|
+// this.informationQueryService.delAsyncWbsTree(removeNode.getContractId());
|
|
|
+//
|
|
|
+// return R.data(true);
|
|
|
+//}
|
|
|
|
|
|
/**
|
|
|
* 新增子节点
|