|
@@ -1,5 +1,7 @@
|
|
package org.springblade.system.user.service.impl;
|
|
package org.springblade.system.user.service.impl;
|
|
|
|
|
|
|
|
+import cn.hutool.core.date.StopWatch;
|
|
|
|
+import cn.hutool.log.StaticLog;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.nacos.common.utils.StringUtils;
|
|
import com.alibaba.nacos.common.utils.StringUtils;
|
|
@@ -96,9 +98,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
/*存储当前合同段contractId_tableOwner对应的节点数量统计缓存信息*/
|
|
/*存储当前合同段contractId_tableOwner对应的节点数量统计缓存信息*/
|
|
private final Map<String, List<WbsTreeContractLazyVO>> localCacheParentCountNodes = new ConcurrentHashMap<>();
|
|
private final Map<String, List<WbsTreeContractLazyVO>> localCacheParentCountNodes = new ConcurrentHashMap<>();
|
|
|
|
|
|
- /*存储当前合同段对应的资料查询信息*/
|
|
|
|
- private final Map<String, List<InformationQuery>> localCacheQueryInfoAll = new ConcurrentHashMap<>();
|
|
|
|
-
|
|
|
|
private final NewIOSSClient newIOSSClient;
|
|
private final NewIOSSClient newIOSSClient;
|
|
private static final String GUEST_NAME = "guest";
|
|
private static final String GUEST_NAME = "guest";
|
|
private final IUserDeptService userDeptService;
|
|
private final IUserDeptService userDeptService;
|
|
@@ -951,7 +950,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
/**
|
|
/**
|
|
* 定时清理本地缓存信息,不在批量电签时删除,批量电签是多线程,会一直删除,导致缓存基本不生效(已废除Redis缓存,走本地缓存不需要Redis)
|
|
* 定时清理本地缓存信息,不在批量电签时删除,批量电签是多线程,会一直删除,导致缓存基本不生效(已废除Redis缓存,走本地缓存不需要Redis)
|
|
*/
|
|
*/
|
|
- @Scheduled(fixedRate = 120000) //每2分钟执行一次
|
|
|
|
|
|
+ @Scheduled(fixedRate = 180000) //每3分钟执行一次
|
|
public void clearContractLocalCacheAndRedisCache() {
|
|
public void clearContractLocalCacheAndRedisCache() {
|
|
//获取锁
|
|
//获取锁
|
|
ReentrantLock lock = new ReentrantLock();
|
|
ReentrantLock lock = new ReentrantLock();
|
|
@@ -961,7 +960,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
localCacheNodes.clear();
|
|
localCacheNodes.clear();
|
|
localCacheQueryInfos.clear();
|
|
localCacheQueryInfos.clear();
|
|
localCacheParentCountNodes.clear();
|
|
localCacheParentCountNodes.clear();
|
|
- localCacheQueryInfoAll.clear();
|
|
|
|
|
|
|
|
//清除RedisWbs树节点缓存(此处的Redis为每层懒加载缓存)
|
|
//清除RedisWbs树节点缓存(此处的Redis为每层懒加载缓存)
|
|
Set<String> keysByNodes = redisTemplate.keys("blade-manager::contract:wbstree:*");
|
|
Set<String> keysByNodes = redisTemplate.keys("blade-manager::contract:wbstree:*");
|
|
@@ -972,7 +970,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
} finally {
|
|
} finally {
|
|
//释放锁
|
|
//释放锁
|
|
lock.unlock();
|
|
lock.unlock();
|
|
- _logger.info("定时执行任务:{clearContractLocalCacheAndRedisCache} 完成 ... ");
|
|
|
|
|
|
+ _logger.info("定时执行任务:{clearContractLocalCacheAndRedisCache} 完成 ");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1000,7 +998,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
do {
|
|
do {
|
|
offset = (pageNumber - 1) * pageSize;
|
|
offset = (pageNumber - 1) * pageSize;
|
|
nodesAllPage = jdbcTemplate.query(
|
|
nodesAllPage = jdbcTemplate.query(
|
|
- "SELECT p_key_id, id, parent_id FROM m_wbs_tree_contract " +
|
|
|
|
|
|
+ "SELECT p_key_id,id,parent_id " +
|
|
|
|
+ ",sort,create_time,IFNULL(if(LENGTH (trim(full_name)) > 0, full_name, node_name), node_name) AS fullName " +
|
|
|
|
+ "FROM m_wbs_tree_contract " +
|
|
"WHERE type = 1 " +
|
|
"WHERE type = 1 " +
|
|
"AND status = 1 " +
|
|
"AND status = 1 " +
|
|
"AND is_deleted = 0 " +
|
|
"AND is_deleted = 0 " +
|
|
@@ -1245,7 +1245,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
if (ObjectUtil.isEmpty(contract)) {
|
|
if (ObjectUtil.isEmpty(contract)) {
|
|
throw new ServiceException("获取合同段信息失败");
|
|
throw new ServiceException("获取合同段信息失败");
|
|
}
|
|
}
|
|
- vo.setClassify(org.apache.commons.lang.StringUtils.isNotEmpty(vo.getClassifyType()) ? new Integer(vo.getClassifyType()) : contract.getContractType() == null ? 1 : new Integer("1").equals(contract.getContractType()) ? 1 : 2);
|
|
|
|
|
|
+ vo.setClassify(StringUtils.isNotEmpty(vo.getClassifyType()) ? new Integer(vo.getClassifyType()) : contract.getContractType() == null ? 1 : new Integer("1").equals(contract.getContractType()) ? 1 : 2);
|
|
|
|
|
|
Query query = new Query();
|
|
Query query = new Query();
|
|
query.setSize(vo.getSize());
|
|
query.setSize(vo.getSize());
|
|
@@ -1255,18 +1255,18 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
submitNodeKeyIds.add(vo.getWbsId().toString());
|
|
submitNodeKeyIds.add(vo.getWbsId().toString());
|
|
WbsTreeContract node = jdbcTemplate.query("SELECT * FROM m_wbs_tree_contract WHERE p_key_id = " + vo.getWbsId(), new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
WbsTreeContract node = jdbcTemplate.query("SELECT * FROM m_wbs_tree_contract WHERE p_key_id = " + vo.getWbsId(), new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
if (node == null) {
|
|
if (node == null) {
|
|
- if (org.apache.commons.lang.StringUtils.isEmpty(vo.getContractIdRelation())) {
|
|
|
|
|
|
+ if (StringUtils.isEmpty(vo.getContractIdRelation())) {
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
//监理
|
|
//监理
|
|
node = jdbcTemplate.query("SELECT * FROM m_wbs_tree_contract WHERE id = " + vo.getWbsId() + " AND contract_id = " + vo.getContractIdRelation(), new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
node = jdbcTemplate.query("SELECT * FROM m_wbs_tree_contract WHERE id = " + vo.getWbsId() + " AND contract_id = " + vo.getContractIdRelation(), new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ List<Long> childNodesPkeyIds = new ArrayList<>();
|
|
|
|
+ List<Long> lowestNodesPkeyIds = new ArrayList<>();
|
|
|
|
+
|
|
if (node != null) {
|
|
if (node != null) {
|
|
- List<WbsTreeContractVO8> lowestNodes = new ArrayList<>();
|
|
|
|
- List<QueryProcessDataVO> queryDataResult = new ArrayList<>();
|
|
|
|
if (!new Integer("6").equals(node.getNodeType()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType() + "")) {
|
|
if (!new Integer("6").equals(node.getNodeType()) && !Arrays.asList("1,2,3,4".split(",")).contains(node.getMajorDataType() + "")) {
|
|
- //TODO(暂不响应第一层根节点、第二层数据,数据量过多会导致响应超时)
|
|
|
|
if (node.getParentId() == 0) {
|
|
if (node.getParentId() == 0) {
|
|
throw new ServiceException("请从第三层级节点开始进行检索");
|
|
throw new ServiceException("请从第三层级节点开始进行检索");
|
|
} else {
|
|
} else {
|
|
@@ -1274,66 +1274,24 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
if (wbsTreeContract != null && wbsTreeContract.getParentId().equals(0L)) {
|
|
if (wbsTreeContract != null && wbsTreeContract.getParentId().equals(0L)) {
|
|
throw new ServiceException("请从第三层级节点开始进行检索");
|
|
throw new ServiceException("请从第三层级节点开始进行检索");
|
|
}
|
|
}
|
|
-
|
|
|
|
- WbsTreeContractVO8 vo8 = BeanUtil.copyProperties(node, WbsTreeContractVO8.class);
|
|
|
|
- this.lowestNodesRecursively(lowestNodes, Collections.singleton(vo8), node.getContractId());
|
|
|
|
-
|
|
|
|
- List<String> pKeyIds = lowestNodes.stream().map(WbsTreeContractVO8::getPKeyId).map(String::valueOf).collect(Collectors.toList());
|
|
|
|
- List<List<String>> partition = Lists.partition(pKeyIds, 1000);
|
|
|
|
- for (List<String> items : partition) {
|
|
|
|
- /*String sql = "SELECT wtc.id AS treeId,wtc.p_key_id AS primaryKeyId,wtc.ancestors AS ancestors,wtc.major_data_type AS majorDataType," +
|
|
|
|
- " wtc.node_type AS nodeType,IFNULL(if(length(trim(wtc.full_name)) > 0, wtc.full_name, wtc.node_name), wtc.node_name) AS title," +
|
|
|
|
- " wtc.parent_id AS parentId,uiq.id AS informationQueryId,IFNULL(uiq.status, 0) AS status,uiq.type AS queryType," +
|
|
|
|
- " CASE WHEN uiq.pdf_trial_url IS NULL THEN FALSE ELSE TRUE end AS isExperiment FROM m_wbs_tree_contract AS wtc" +
|
|
|
|
- " LEFT JOIN u_information_query AS uiq ON wtc.p_key_id = uiq.wbs_id AND uiq.classify = " + contract.getContractType() +
|
|
|
|
- " AND uiq.is_deleted = 0 AND wtc.is_deleted = 0 AND wtc.status = 1 WHERE wtc.p_key_id IN (" + org.apache.commons.lang.StringUtils.join(items, ",") + ")";*/
|
|
|
|
-
|
|
|
|
- String sql = "SELECT wtc.p_key_id AS primaryKeyId,uiq.type AS queryType " +
|
|
|
|
- " FROM m_wbs_tree_contract AS wtc" +
|
|
|
|
- " LEFT JOIN u_information_query AS uiq ON wtc.p_key_id = uiq.wbs_id" +
|
|
|
|
- " AND uiq.classify = " + contract.getContractType() +
|
|
|
|
- " AND uiq.is_deleted = 0 " +
|
|
|
|
- " WHERE wtc.p_key_id IN (" + org.apache.commons.lang.StringUtils.join(items, ",") + ") " +
|
|
|
|
- " AND wtc.is_deleted = 0 AND wtc.status = 1 ";
|
|
|
|
-
|
|
|
|
- List<QueryProcessDataVO> result = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(QueryProcessDataVO.class));
|
|
|
|
- if (result.size() > 0) {
|
|
|
|
- queryDataResult.addAll(result);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- //首件
|
|
|
|
- if (queryDataResult.size() > 0) {
|
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getIsFirst())) {
|
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getFirstTitle())) {
|
|
|
|
- queryDataResult = queryDataResult.stream().filter(qdr -> "3".equals(qdr.getQueryType())).collect(Collectors.toList());
|
|
|
|
- } else {
|
|
|
|
- List<String> treeIds = queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList());
|
|
|
|
- List<TreeContractFirst> firstList = jdbcTemplate.query("SELECT wbs_node_id FROM u_tree_contract_first WHERE is_deleted = 0 AND wbs_node_id IN (" + org.apache.commons.lang.StringUtils.join(treeIds, ",") + ")", new BeanPropertyRowMapper<>(TreeContractFirst.class));
|
|
|
|
- List<String> list = firstList.stream().map(fl -> (fl.getWbsNodeId() + "")).collect(Collectors.toList());
|
|
|
|
- queryDataResult = queryDataResult.stream().filter(qdr -> list.contains(qdr.getPrimaryKeyId())).collect(Collectors.toList());
|
|
|
|
- }
|
|
|
|
|
|
+ WbsTreeContract oldSelectedNode = BeanUtil.copyProperties(node, WbsTreeContract.class);
|
|
|
|
+ childNodesPkeyIds = this.getChildNodesPkeyIds(oldSelectedNode, lowestNodesPkeyIds);
|
|
|
|
+ List<String> sj = this.getSJ(contract, vo, lowestNodesPkeyIds);
|
|
|
|
+ if (sj != null && sj.size() > 0) {
|
|
|
|
+ submitNodeKeyIds.addAll(sj);
|
|
}
|
|
}
|
|
- submitNodeKeyIds.addAll(queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList()));
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
- if (submitNodeKeyIds.size() <= 0) {
|
|
|
|
- throw new ServiceException("未获取到节点信息");
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
vo.setWbsIds(submitNodeKeyIds);
|
|
vo.setWbsIds(submitNodeKeyIds);
|
|
-
|
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getContractIdRelation())) {
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(vo.getContractIdRelation())) {
|
|
vo.setContractId(Long.valueOf(vo.getContractIdRelation()));
|
|
vo.setContractId(Long.valueOf(vo.getContractIdRelation()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- return this.selectInformationQueryPage(Condition.getPage(query), vo, node);
|
|
|
|
|
|
+ return this.selectInformationQueryPage(Condition.getPage(query), vo, node, childNodesPkeyIds);
|
|
}
|
|
}
|
|
|
|
|
|
- private IPage<InformationQueryVO> selectInformationQueryPage(IPage<InformationQueryVO> page, InformationQueryVO vo, WbsTreeContract node) {
|
|
|
|
|
|
+ private IPage<InformationQueryVO> selectInformationQueryPage(IPage<InformationQueryVO> page, InformationQueryVO vo, WbsTreeContract node, List<Long> childNodesPkeyIds) {
|
|
if (StringUtils.isNotEmpty(vo.getBetweenTime())) {
|
|
if (StringUtils.isNotEmpty(vo.getBetweenTime())) {
|
|
String[] betweenTime;
|
|
String[] betweenTime;
|
|
if (vo.getBetweenTime().contains("~")) {
|
|
if (vo.getBetweenTime().contains("~")) {
|
|
@@ -1346,7 +1304,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
vo.setEndTime(betweenTime[1]);
|
|
vo.setEndTime(betweenTime[1]);
|
|
}
|
|
}
|
|
|
|
|
|
- if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getFileUserIdAndName())) {
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(vo.getFileUserIdAndName())) {
|
|
vo.setFileUserIdAndName(vo.getFileUserIdAndName().split("-")[0]);
|
|
vo.setFileUserIdAndName(vo.getFileUserIdAndName().split("-")[0]);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1354,30 +1312,24 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
vo.setTaskStatus(vo.getStatus().toString());
|
|
vo.setTaskStatus(vo.getStatus().toString());
|
|
}
|
|
}
|
|
|
|
|
|
- /*获取当前资料缓存*/
|
|
|
|
long startTime = System.currentTimeMillis();
|
|
long startTime = System.currentTimeMillis();
|
|
- List<InformationQuery> result = localCacheQueryInfoAll.get(vo.getContractId().toString() + "_" + vo.getClassifyType());
|
|
|
|
- if (result == null || result.size() <= 0) {
|
|
|
|
- result = baseMapper.selectInformationQueryPageTwo(vo);
|
|
|
|
- localCacheQueryInfoAll.put(vo.getContractId().toString() + "_" + vo.getClassifyType(), result);
|
|
|
|
|
|
+ List<InformationQuery> result = new ArrayList<>();
|
|
|
|
+ List<List<String>> partition = Lists.partition(vo.getWbsIds(), 500);
|
|
|
|
+ for (List<String> wbsIds : partition) {
|
|
|
|
+ vo.setWbsIds(wbsIds);
|
|
|
|
+ List<InformationQuery> queries = baseMapper.selectInformationQueryPageTwo(vo);
|
|
|
|
+ result.addAll(queries);
|
|
}
|
|
}
|
|
long endTime = System.currentTimeMillis();
|
|
long endTime = System.currentTimeMillis();
|
|
long executionTime = endTime - startTime;
|
|
long executionTime = endTime - startTime;
|
|
_logger.info("合同段 " + node.getContractId() + " 获取当前资料缓存 执行时间:" + executionTime + " ms");
|
|
_logger.info("合同段 " + node.getContractId() + " 获取当前资料缓存 执行时间:" + executionTime + " ms");
|
|
|
|
|
|
- if (result != null && result.size() != 0) {
|
|
|
|
-
|
|
|
|
- /*所查节点对应资料信息*/
|
|
|
|
- result = result.stream()
|
|
|
|
- .filter(informationQuery -> vo.getWbsIds().contains(informationQuery.getWbsId().toString()))
|
|
|
|
- .collect(Collectors.toList());
|
|
|
|
-
|
|
|
|
- //属于待审批、已审批状态任务Task信息,以及当前任务对应的副任务TaskParallel信息
|
|
|
|
|
|
+ if (result.size() != 0) {
|
|
Map<String, List<Task>> taskMaps = new HashMap<>();
|
|
Map<String, List<Task>> taskMaps = new HashMap<>();
|
|
Map<String, List<TaskParallel>> taskParallelMaps = new HashMap<>();
|
|
Map<String, List<TaskParallel>> taskParallelMaps = new HashMap<>();
|
|
List<Long> informationIds = result.stream().filter(f -> f.getStatus().equals(1) || f.getStatus().equals(2)).map(InformationQuery::getId).collect(Collectors.toList());
|
|
List<Long> informationIds = result.stream().filter(f -> f.getStatus().equals(1) || f.getStatus().equals(2)).map(InformationQuery::getId).collect(Collectors.toList());
|
|
String informationIdsStr = informationIds.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
String informationIdsStr = informationIds.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
- if (org.apache.commons.lang.StringUtils.isNotEmpty(informationIdsStr)) {
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(informationIdsStr)) {
|
|
List<Task> query = jdbcTemplate.query("SELECT id,form_data_id,process_instance_id,approval_type,status,batch,project_id,contract_id,create_time FROM u_task WHERE form_data_id IN(" + informationIdsStr + ") AND status IN (1, 2) AND is_deleted = 0", new BeanPropertyRowMapper<>(Task.class));
|
|
List<Task> query = jdbcTemplate.query("SELECT id,form_data_id,process_instance_id,approval_type,status,batch,project_id,contract_id,create_time FROM u_task WHERE form_data_id IN(" + informationIdsStr + ") AND status IN (1, 2) AND is_deleted = 0", new BeanPropertyRowMapper<>(Task.class));
|
|
taskMaps = query.stream().collect(Collectors.groupingBy(Task::getFormDataId));
|
|
taskMaps = query.stream().collect(Collectors.groupingBy(Task::getFormDataId));
|
|
Set<String> processInstanceIds = query.stream().map(Task::getProcessInstanceId).map(id -> "'" + id + "'").collect(Collectors.toSet());
|
|
Set<String> processInstanceIds = query.stream().map(Task::getProcessInstanceId).map(id -> "'" + id + "'").collect(Collectors.toSet());
|
|
@@ -1387,7 +1339,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //校验关联的工序节点是否全都已审批
|
|
|
|
List<String> sjRecordIds = result.stream().map(InformationQuery::getSjRecordIds).filter(Objects::nonNull).collect(Collectors.toList());
|
|
List<String> sjRecordIds = result.stream().map(InformationQuery::getSjRecordIds).filter(Objects::nonNull).collect(Collectors.toList());
|
|
Set<Long> ids = new HashSet<>();
|
|
Set<Long> ids = new HashSet<>();
|
|
for (String sjRecordId : sjRecordIds) {
|
|
for (String sjRecordId : sjRecordIds) {
|
|
@@ -1423,9 +1374,10 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /*任务状态*/
|
|
if (Arrays.asList("1,2".split(",")).contains(vor.getStatus().toString())) {
|
|
if (Arrays.asList("1,2".split(",")).contains(vor.getStatus().toString())) {
|
|
List<Task> tasks = finalTaskMaps.getOrDefault(vor.getId().toString(), null);
|
|
List<Task> tasks = finalTaskMaps.getOrDefault(vor.getId().toString(), null);
|
|
- //获取创建时间最新的那条任务数据(存在多条任务指向同一个form_data_id,即一条资料多次上报,这里要获取最新的)
|
|
|
|
|
|
+ /*获取创建时间最新的那条任务数据(存在多条任务指向同一个form_data_id,即一条资料多次上报,这里要获取最新的)*/
|
|
if (tasks != null && tasks.size() > 0) {
|
|
if (tasks != null && tasks.size() > 0) {
|
|
Optional<Task> maxTask = tasks.stream().max(Comparator.comparing(Task::getCreateTime));
|
|
Optional<Task> maxTask = tasks.stream().max(Comparator.comparing(Task::getCreateTime));
|
|
Task maxTaskObject = maxTask.get();
|
|
Task maxTaskObject = maxTask.get();
|
|
@@ -1437,7 +1389,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //校验关联的工序节点是否全都已审批
|
|
|
|
|
|
+ /*首件判断*/
|
|
if (StringUtils.isNotEmpty(vor.getSjRecordIds())) {
|
|
if (StringUtils.isNotEmpty(vor.getSjRecordIds())) {
|
|
List<String> recordIdList = Func.toStrList(vor.getSjRecordIds());
|
|
List<String> recordIdList = Func.toStrList(vor.getSjRecordIds());
|
|
List<InformationQuery> informationQueryList = finalInformationQueries.stream()
|
|
List<InformationQuery> informationQueryList = finalInformationQueries.stream()
|
|
@@ -1448,7 +1400,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
vor.setIsApprove(isApprove);
|
|
vor.setIsApprove(isApprove);
|
|
}
|
|
}
|
|
|
|
|
|
- //试验关联文件pdf
|
|
|
|
|
|
+ /*试验文件关联*/
|
|
try {
|
|
try {
|
|
this.getMergePdf(vor);
|
|
this.getMergePdf(vor);
|
|
} catch (FileNotFoundException e) {
|
|
} catch (FileNotFoundException e) {
|
|
@@ -1466,7 +1418,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
|
|
|
} else if (voResult.size() > 1) {
|
|
} else if (voResult.size() > 1) {
|
|
if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getIsFirst())) {
|
|
if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getIsFirst())) {
|
|
-
|
|
|
|
long current = (page.getCurrent() - 1) * page.getSize();
|
|
long current = (page.getCurrent() - 1) * page.getSize();
|
|
if (current < 0) {
|
|
if (current < 0) {
|
|
throw new IllegalArgumentException("当前页码不能小于0");
|
|
throw new IllegalArgumentException("当前页码不能小于0");
|
|
@@ -1479,29 +1430,16 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
page.setRecords(subList);
|
|
page.setRecords(subList);
|
|
page.setTotal(voResult.size());
|
|
page.setTotal(voResult.size());
|
|
return page;
|
|
return page;
|
|
-
|
|
|
|
} else {
|
|
} else {
|
|
- long startTime_1 = System.currentTimeMillis();
|
|
|
|
- WbsTreeContract oldSelectedNode = BeanUtil.copyProperties(node, WbsTreeContract.class);
|
|
|
|
- List<WbsTreeContract> treeAll = this.getChildNodesZL(oldSelectedNode); //按照顺序获取选择的节点下的所有子节点信息
|
|
|
|
- long endTime_1 = System.currentTimeMillis();
|
|
|
|
- long executionTime_1 = endTime_1 - startTime_1;
|
|
|
|
- _logger.info("合同段 " + node.getContractId() + " 获取选择的节点下的所有子节点信息 执行时间:" + executionTime_1 + " ms");
|
|
|
|
-
|
|
|
|
- if (treeAll == null) {
|
|
|
|
- treeAll = new ArrayList<>();
|
|
|
|
- }
|
|
|
|
- treeAll.add(0, oldSelectedNode);
|
|
|
|
-
|
|
|
|
- if (treeAll.size() > 1) {
|
|
|
|
|
|
+ childNodesPkeyIds.add(0, node.getPKeyId());
|
|
|
|
+ if (childNodesPkeyIds.size() > 1) {
|
|
LinkedList<InformationQueryVO> resultData = new LinkedList<>();
|
|
LinkedList<InformationQueryVO> resultData = new LinkedList<>();
|
|
LinkedHashMap<Long, InformationQueryVO> dataMaps = voResult.stream()
|
|
LinkedHashMap<Long, InformationQueryVO> dataMaps = voResult.stream()
|
|
.collect(Collectors.toMap(InformationQueryVO::getWbsId, Function.identity(),
|
|
.collect(Collectors.toMap(InformationQueryVO::getWbsId, Function.identity(),
|
|
(oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
(oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
- for (WbsTreeContract resultNode : treeAll) {
|
|
|
|
- InformationQueryVO queryVO = dataMaps.get(resultNode.getPKeyId());
|
|
|
|
|
|
+ for (Long pKeyId : childNodesPkeyIds) {
|
|
|
|
+ InformationQueryVO queryVO = dataMaps.get(pKeyId);
|
|
if (queryVO != null) {
|
|
if (queryVO != null) {
|
|
- //按节点顺序插入Page数据
|
|
|
|
resultData.add(queryVO);
|
|
resultData.add(queryVO);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1528,25 +1466,38 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
return page.setRecords(null);
|
|
return page.setRecords(null);
|
|
}
|
|
}
|
|
|
|
|
|
- private void lowestNodesRecursively(List<WbsTreeContractVO8> lowestNodes, Set<WbsTreeContractVO8> nodes, String contractId) {
|
|
|
|
- if (nodes.size() > 0) {
|
|
|
|
- Set<Long> ids = nodes.stream().map(WbsTreeContractVO8::getId).collect(Collectors.toSet());
|
|
|
|
- if (ids.size() > 0) {
|
|
|
|
- List<WbsTreeContractVO8> childNodes = jdbcTemplate.query("select a.p_key_id,a.id,(SELECT CASE WHEN COUNT(1) > 0 THEN 1 ELSE 0 END FROM m_wbs_tree_contract b WHERE b.parent_id = a.id AND b.contract_id = " + contractId + " AND b.status = 1 AND b.type = 1 AND b.is_deleted = 0) AS hasChildren from m_wbs_tree_contract a where a.type = 1 and a.status = 1 and a.is_deleted = 0 and a.contract_id = " + contractId + " and a.parent_id in(" + org.apache.commons.lang.StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(WbsTreeContractVO8.class));
|
|
|
|
- if (childNodes.size() > 0) {
|
|
|
|
- Set<WbsTreeContractVO8> lowestNode = childNodes.stream().filter(f -> f.getHasChildren().equals(0)).collect(Collectors.toSet());
|
|
|
|
- Set<WbsTreeContractVO8> noLowestNode = childNodes.stream().filter(f -> f.getHasChildren().equals(1)).collect(Collectors.toSet());
|
|
|
|
- //最底层节点
|
|
|
|
- if (lowestNode.size() > 0) {
|
|
|
|
- lowestNodes.addAll(lowestNode);
|
|
|
|
- }
|
|
|
|
- //非最底层节点
|
|
|
|
- if (noLowestNode.size() > 0) {
|
|
|
|
- this.lowestNodesRecursively(lowestNodes, noLowestNode, contractId);
|
|
|
|
- }
|
|
|
|
|
|
+ private List<String> getSJ(ContractInfo contract, InformationQueryVO vo, List<Long> lowestNodesPkeyIds) {
|
|
|
|
+ /*首件相关*/
|
|
|
|
+ List<QueryProcessDataVO> queryDataResult = new ArrayList<>();
|
|
|
|
+ List<List<Long>> partition = Lists.partition(lowestNodesPkeyIds, 500);
|
|
|
|
+ for (List<Long> items : partition) {
|
|
|
|
+ String sql = "SELECT wtc.p_key_id AS primaryKeyId,uiq.type AS queryType " +
|
|
|
|
+ " FROM m_wbs_tree_contract AS wtc" +
|
|
|
|
+ " LEFT JOIN u_information_query AS uiq ON wtc.p_key_id = uiq.wbs_id" +
|
|
|
|
+ " AND uiq.classify = " + contract.getContractType() +
|
|
|
|
+ " AND uiq.is_deleted = 0 " +
|
|
|
|
+ " WHERE wtc.p_key_id IN (" + org.apache.commons.lang.StringUtils.join(items, ",") + ") " +
|
|
|
|
+ " AND wtc.is_deleted = 0 AND wtc.status = 1 ";
|
|
|
|
+
|
|
|
|
+ List<QueryProcessDataVO> result = jdbcTemplate.query(sql, new BeanPropertyRowMapper<>(QueryProcessDataVO.class));
|
|
|
|
+ if (result.size() > 0) {
|
|
|
|
+ queryDataResult.addAll(result);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (queryDataResult.size() > 0) {
|
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getIsFirst())) {
|
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getFirstTitle())) {
|
|
|
|
+ queryDataResult = queryDataResult.stream().filter(qdr -> "3".equals(qdr.getQueryType())).collect(Collectors.toList());
|
|
|
|
+ } else {
|
|
|
|
+ List<String> treeIds = queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList());
|
|
|
|
+ List<TreeContractFirst> firstList = jdbcTemplate.query("SELECT wbs_node_id FROM u_tree_contract_first WHERE is_deleted = 0 AND wbs_node_id IN (" + org.apache.commons.lang.StringUtils.join(treeIds, ",") + ")", new BeanPropertyRowMapper<>(TreeContractFirst.class));
|
|
|
|
+ List<String> list = firstList.stream().map(fl -> (fl.getWbsNodeId() + "")).collect(Collectors.toList());
|
|
|
|
+ queryDataResult = queryDataResult.stream().filter(qdr -> list.contains(qdr.getPrimaryKeyId())).collect(Collectors.toList());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList());
|
|
}
|
|
}
|
|
|
|
+ return null;
|
|
}
|
|
}
|
|
|
|
|
|
private void integrationMethod(InformationQueryVO vo, List<TaskParallel> linkList) {
|
|
private void integrationMethod(InformationQueryVO vo, List<TaskParallel> linkList) {
|
|
@@ -1617,57 +1568,47 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private List<WbsTreeContract> getChildNodesZL(WbsTreeContract obj) {
|
|
|
|
|
|
+ private List<Long> getChildNodesPkeyIds(WbsTreeContract obj, List<Long> lowestNodesPkeyIds) {
|
|
if (obj != null) {
|
|
if (obj != null) {
|
|
- List<WbsTreeContract> wbsTreeContracts = Collections.singletonList(obj);
|
|
|
|
- List<WbsTreeContract> result = new ArrayList<>();
|
|
|
|
- this.recursionGetChildNodesZL(wbsTreeContracts, result, obj.getContractId());
|
|
|
|
- if (result.size() > 0) {
|
|
|
|
- return result;
|
|
|
|
|
|
+ List<Long> resultPKeyId = new ArrayList<>();
|
|
|
|
+ List<WbsTreeContractLazyVO> nodeAll = this.getNodeAll(obj.getContractId());
|
|
|
|
+ this.recursionGetChildNodesPkeyIds(nodeAll, Collections.singletonList(obj.getId()), resultPKeyId, lowestNodesPkeyIds);
|
|
|
|
+ if (resultPKeyId.size() > 0) {
|
|
|
|
+ return resultPKeyId;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- return null;
|
|
|
|
|
|
+ return new ArrayList<>();
|
|
}
|
|
}
|
|
|
|
|
|
- private void recursionGetChildNodesZL(List<WbsTreeContract> list, List<WbsTreeContract> result, String contractId) {
|
|
|
|
- List<Long> ids = list.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
|
|
|
|
+ private void recursionGetChildNodesPkeyIds(List<WbsTreeContractLazyVO> nodeAll, List<Long> ids, List<Long> resultPKeyId, List<Long> lowestNodesPkeyIds) {
|
|
if (ids.size() > 0) {
|
|
if (ids.size() > 0) {
|
|
- Map<Long, List<WbsTreeContract>> queryMap = jdbcTemplate.query(
|
|
|
|
- "SELECT id,p_key_id,parent_id,sort,create_time," +
|
|
|
|
- "IFNULL(if(LENGTH (trim(full_name)) > 0, full_name, node_name), node_name) AS fullName " +
|
|
|
|
- "FROM m_wbs_tree_contract " +
|
|
|
|
- "WHERE type = 1 " +
|
|
|
|
- "AND status = 1 " +
|
|
|
|
- "AND is_deleted = 0 " +
|
|
|
|
- "AND contract_id = " + contractId + " " +
|
|
|
|
- "AND parent_id IN (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ") " +
|
|
|
|
- "ORDER BY sort,fullName,create_time",
|
|
|
|
- rs -> {
|
|
|
|
- Map<Long, List<WbsTreeContract>> map = new LinkedHashMap<>();
|
|
|
|
- while (rs.next()) {
|
|
|
|
- WbsTreeContract item = new WbsTreeContract();
|
|
|
|
- item.setId(rs.getLong("id"));
|
|
|
|
- item.setPKeyId(rs.getLong("p_key_id"));
|
|
|
|
- item.setParentId(rs.getLong("parent_id"));
|
|
|
|
- item.setSort(rs.getInt("sort"));
|
|
|
|
- item.setFullName(rs.getString("fullName"));
|
|
|
|
- item.setCreateTime(rs.getTime("create_time"));
|
|
|
|
- Long parentId = item.getParentId();
|
|
|
|
- if (!map.containsKey(parentId)) {
|
|
|
|
- map.put(parentId, new ArrayList<>());
|
|
|
|
- }
|
|
|
|
- map.get(parentId).add(item);
|
|
|
|
- }
|
|
|
|
- return map;
|
|
|
|
- });
|
|
|
|
|
|
+ List<WbsTreeContractLazyVO> sortedFilteredNodes = nodeAll.stream()
|
|
|
|
+ .filter(f -> ids.contains(f.getParentId()))
|
|
|
|
+ .sorted(Comparator.comparing(WbsTreeContractLazyVO::getSort, Comparator.nullsLast(Integer::compareTo))
|
|
|
|
+ .thenComparing(WbsTreeContractLazyVO::getFullName, Comparator.nullsLast(String::compareTo))
|
|
|
|
+ .thenComparing(WbsTreeContractLazyVO::getCreateTime, Comparator.nullsLast(Comparator.naturalOrder())))
|
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+ Map<Long, List<WbsTreeContractLazyVO>> filteredNodesMap = new LinkedHashMap<>();
|
|
|
|
+ sortedFilteredNodes.forEach(node -> {
|
|
|
|
+ Long parentId = node.getParentId();
|
|
|
|
+ filteredNodesMap.computeIfAbsent(parentId, k -> new ArrayList<>()).add(node);
|
|
|
|
+ });
|
|
|
|
+
|
|
for (Long id : ids) {
|
|
for (Long id : ids) {
|
|
- if (queryMap != null && queryMap.containsKey(id)) {
|
|
|
|
- List<WbsTreeContract> nodes = queryMap.get(id);
|
|
|
|
- result.addAll(nodes);
|
|
|
|
- recursionGetChildNodesZL(nodes, result, contractId);
|
|
|
|
|
|
+ if (filteredNodesMap.containsKey(id)) {
|
|
|
|
+ List<WbsTreeContractLazyVO> nodes = filteredNodesMap.get(id);
|
|
|
|
+ for (WbsTreeContractLazyVO node : nodes) {
|
|
|
|
+ if (node.getHasChildren().equals(0)) {
|
|
|
|
+ lowestNodesPkeyIds.add(node.getPKeyId());
|
|
|
|
+ }
|
|
|
|
+ resultPKeyId.add(node.getPKeyId());
|
|
|
|
+ }
|
|
|
|
+ this.recursionGetChildNodesPkeyIds(nodeAll, nodes.stream().map(WbsTreeContractLazyVO::getId).collect(Collectors.toList()), resultPKeyId, lowestNodesPkeyIds);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|