|
@@ -1,22 +1,34 @@
|
|
|
package org.springblade.system.user.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.alibaba.nacos.common.utils.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.google.common.collect.Lists;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import org.apache.http.client.utils.DateUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
+import org.springblade.business.entity.InformationQuery;
|
|
|
+import org.springblade.business.entity.Task;
|
|
|
+import org.springblade.business.entity.TaskParallel;
|
|
|
+import org.springblade.business.entity.TreeContractFirst;
|
|
|
+import org.springblade.business.vo.InformationQueryVO;
|
|
|
+import org.springblade.business.vo.QueryProcessDataVO;
|
|
|
import org.springblade.common.constant.CommonConstant;
|
|
|
import org.springblade.common.constant.TenantConstant;
|
|
|
+import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.log.exception.ServiceException;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.mp.support.Query;
|
|
|
+import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
+import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tenant.BladeTenantProperties;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
import org.springblade.core.tool.constant.BladeConstant;
|
|
@@ -25,10 +37,14 @@ import org.springblade.core.tool.support.Kv;
|
|
|
import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.dto.SaveUserInfoByProjectDTO;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
+import org.springblade.manager.entity.WbsTreeContract;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
|
import org.springblade.manager.vo.WbsTreeContractLazyQueryInfoVO;
|
|
|
import org.springblade.manager.vo.WbsTreeContractLazyVO;
|
|
|
+import org.springblade.manager.vo.WbsTreeContractVO8;
|
|
|
+import org.springblade.resource.feign.NewIOSSClient;
|
|
|
import org.springblade.system.cache.DictCache;
|
|
|
+import org.springblade.system.cache.ParamCache;
|
|
|
import org.springblade.system.cache.SysCache;
|
|
|
import org.springblade.system.entity.Dept;
|
|
|
import org.springblade.system.entity.Tenant;
|
|
@@ -44,6 +60,7 @@ import org.springblade.system.user.mapper.UserMapper;
|
|
|
import org.springblade.system.user.service.IUserDeptService;
|
|
|
import org.springblade.system.user.service.IUserOauthService;
|
|
|
import org.springblade.system.user.service.IUserService;
|
|
|
+import org.springblade.system.user.util.FileUtils;
|
|
|
import org.springblade.system.user.vo.UserVO;
|
|
|
import org.springblade.system.user.wrapper.UserWrapper;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -54,6 +71,8 @@ import org.springframework.scheduling.annotation.Scheduled;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileNotFoundException;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
@@ -77,6 +96,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
/*存储当前合同段contractId_tableOwner对应的节点数量统计缓存信息*/
|
|
|
private final Map<String, List<WbsTreeContractLazyVO>> localCacheParentCountNodes = new ConcurrentHashMap<>();
|
|
|
|
|
|
+ private final NewIOSSClient newIOSSClient;
|
|
|
private static final String GUEST_NAME = "guest";
|
|
|
private final IUserDeptService userDeptService;
|
|
|
private final IUserOauthService userOauthService;
|
|
@@ -1212,4 +1232,413 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public IPage<InformationQueryVO> informationWriteQueryPage(InformationQueryVO vo) {
|
|
|
+ if (ObjectUtil.isEmpty(vo.getContractId())) {
|
|
|
+ throw new ServiceException("未获取到合同段id");
|
|
|
+ }
|
|
|
+ ContractInfo contract = jdbcTemplate.query("SELECT * FROM m_contract_info WHERE id = " + vo.getContractId(), new BeanPropertyRowMapper<>(ContractInfo.class)).stream().findAny().orElse(null);
|
|
|
+ if (ObjectUtil.isEmpty(contract)) {
|
|
|
+ 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);
|
|
|
+
|
|
|
+ Query query = new Query();
|
|
|
+ query.setSize(vo.getSize());
|
|
|
+ query.setCurrent(vo.getCurrent());
|
|
|
+
|
|
|
+ List<String> submitNodeKeyIds = new ArrayList<>();
|
|
|
+ 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);
|
|
|
+ if (node == null) {
|
|
|
+ if (org.apache.commons.lang.StringUtils.isEmpty(vo.getContractIdRelation())) {
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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() + "")) {
|
|
|
+ //TODO(暂不响应第一层根节点、第二层数据,数据量过多会导致响应超时)
|
|
|
+ if (node.getParentId() == 0) {
|
|
|
+ throw new ServiceException("请从第三层级节点开始进行检索");
|
|
|
+ } else {
|
|
|
+ WbsTreeContract wbsTreeContract = jdbcTemplate.query("select parent_id from m_wbs_tree_contract where is_deleted = 0 and status = 1 and type = 1 and id = " + node.getParentId() + " and contract_id = " + node.getContractId(), new BeanPropertyRowMapper<>(WbsTreeContract.class)).stream().findAny().orElse(null);
|
|
|
+ if (wbsTreeContract != null && wbsTreeContract.getParentId().equals(0L)) {
|
|
|
+ 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, ",") + ")";
|
|
|
+ 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 * 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());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ submitNodeKeyIds.addAll(queryDataResult.stream().map(QueryProcessDataVO::getPrimaryKeyId).distinct().collect(Collectors.toList()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ vo.setWbsIds(submitNodeKeyIds);
|
|
|
+
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getContractIdRelation())) {
|
|
|
+ vo.setContractId(Long.valueOf(vo.getContractIdRelation()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return this.selectInformationQueryPage(Condition.getPage(query), vo, node);
|
|
|
+ }
|
|
|
+
|
|
|
+ private IPage<InformationQueryVO> selectInformationQueryPage(IPage<InformationQueryVO> page, InformationQueryVO vo, WbsTreeContract node) {
|
|
|
+ if (StringUtils.isNotEmpty(vo.getBetweenTime())) {
|
|
|
+ String[] betweenTime;
|
|
|
+ if (vo.getBetweenTime().contains("~")) {
|
|
|
+ String[] between = vo.getBetweenTime().split("~");
|
|
|
+ betweenTime = new String[]{between[0], between[1]};
|
|
|
+ } else {
|
|
|
+ betweenTime = new String[]{vo.getBetweenTime(), DateUtils.formatDate(new Date(), "yyyy-MM-dd")};
|
|
|
+ }
|
|
|
+ vo.setStartTime(betweenTime[0]);
|
|
|
+ vo.setEndTime(betweenTime[1]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getFileUserIdAndName())) {
|
|
|
+ vo.setFileUserIdAndName(vo.getFileUserIdAndName().split("-")[0]);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (vo.getStatus() != null) {
|
|
|
+ vo.setTaskStatus(vo.getStatus().toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取全部数据
|
|
|
+ List<InformationQuery> result = baseMapper.selectInformationQueryPageTwo(vo);
|
|
|
+ if (result != null && result.size() != 0) {
|
|
|
+ //属于待审批、已审批状态任务Task信息,以及当前任务对应的副任务TaskParallel信息
|
|
|
+ Map<String, List<Task>> taskMaps = 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());
|
|
|
+ String informationIdsStr = informationIds.stream().map(String::valueOf).collect(Collectors.joining(","));
|
|
|
+ if (org.apache.commons.lang.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));
|
|
|
+ taskMaps = query.stream().collect(Collectors.groupingBy(Task::getFormDataId));
|
|
|
+ Set<String> processInstanceIds = query.stream().map(Task::getProcessInstanceId).map(id -> "'" + id + "'").collect(Collectors.toSet());
|
|
|
+ if (processInstanceIds.size() > 0) {
|
|
|
+ List<TaskParallel> taskParallels = jdbcTemplate.query("select task_user, task_user_name, e_visa_status, status, process_instance_id, initiative,e_visa_content from u_task_parallel where is_deleted = 0 and process_instance_id in(" + org.apache.commons.lang.StringUtils.join(processInstanceIds, ",") + ")", new BeanPropertyRowMapper<>(TaskParallel.class));
|
|
|
+ taskParallelMaps = taskParallels.stream().collect(Collectors.groupingBy(TaskParallel::getProcessInstanceId));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验关联的工序节点是否全都已审批
|
|
|
+ List<String> sjRecordIds = result.stream().map(InformationQuery::getSjRecordIds).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
+ Set<Long> ids = new HashSet<>();
|
|
|
+ for (String sjRecordId : sjRecordIds) {
|
|
|
+ List<Long> longs = Func.toLongList(sjRecordId);
|
|
|
+ ids.addAll(longs);
|
|
|
+ }
|
|
|
+ List<InformationQuery> informationQueries = new ArrayList<>();
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ informationQueries = jdbcTemplate.query("SELECT * FROM u_information_query WHERE id IN(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(InformationQuery.class));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<InformationQueryVO> voResult = JSONArray.parseArray(JSONObject.toJSONString(result), InformationQueryVO.class);
|
|
|
+ List<InformationQuery> finalInformationQueries = informationQueries;
|
|
|
+ Map<String, List<Task>> finalTaskMaps = taskMaps;
|
|
|
+ Map<String, List<TaskParallel>> finalTaskParallelMaps = taskParallelMaps;
|
|
|
+ voResult.forEach(vor -> {
|
|
|
+ if (ObjectUtil.isNotEmpty(vor.getCreateTime())) {
|
|
|
+ vor.setStartTime(DateUtil.format(vor.getCreateTime(), "yyyy-MM-dd"));
|
|
|
+ }
|
|
|
+ vor.setTaskStatusStr(new Integer("0").equals(vor.getStatus()) ? "未上报" : new Integer("1").equals(vor.getStatus()) ? "待审批" : new Integer("2").equals(vor.getStatus()) ? "已审批" : "已废除");
|
|
|
+ try {
|
|
|
+ String fileUserIdAndName = vor.getFileUserIdAndName();
|
|
|
+ String[] fileUserIdAndNames = fileUserIdAndName.split(",");
|
|
|
+ List<String> names = new ArrayList<>();
|
|
|
+ for (String str : fileUserIdAndNames) {
|
|
|
+ String[] strArr = str.split("-");
|
|
|
+ if (!names.contains(strArr[1])) {
|
|
|
+ names.add(strArr[1]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vor.setFileUserIdAndName(String.join(",", names));
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Arrays.asList("1,2".split(",")).contains(vor.getStatus().toString())) {
|
|
|
+ List<Task> tasks = finalTaskMaps.getOrDefault(vor.getId().toString(), null);
|
|
|
+ //获取创建时间最新的那条任务数据(存在多条任务指向同一个form_data_id,即一条资料多次上报,这里要获取最新的)
|
|
|
+ if (tasks != null && tasks.size() > 0) {
|
|
|
+ Optional<Task> maxTask = tasks.stream().max(Comparator.comparing(Task::getCreateTime));
|
|
|
+ Task maxTaskObject = maxTask.get();
|
|
|
+ List<TaskParallel> linkTasks = finalTaskParallelMaps.getOrDefault(maxTaskObject.getProcessInstanceId(), null);
|
|
|
+ if (linkTasks != null && linkTasks.size() > 0) {
|
|
|
+ this.integrationMethod(vor, linkTasks);
|
|
|
+ }
|
|
|
+ vor.setReportNumber(String.valueOf(tasks.get(0).getBatch()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //校验关联的工序节点是否全都已审批
|
|
|
+ if (StringUtils.isNotEmpty(vor.getSjRecordIds())) {
|
|
|
+ List<String> recordIdList = Func.toStrList(vor.getSjRecordIds());
|
|
|
+ List<InformationQuery> informationQueryList = finalInformationQueries.stream()
|
|
|
+ .filter(f -> recordIdList.contains(f.getId().toString()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ boolean isApprove = informationQueryList.stream()
|
|
|
+ .allMatch(f -> f.getStatus().equals(2));
|
|
|
+ vor.setIsApprove(isApprove);
|
|
|
+ }
|
|
|
+
|
|
|
+ //试验关联文件pdf
|
|
|
+ try {
|
|
|
+ this.getMergePdf(vor);
|
|
|
+ } catch (FileNotFoundException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(voResult)) {
|
|
|
+ return page.setRecords(null);
|
|
|
+
|
|
|
+ } else if (voResult.size() == 1) {
|
|
|
+ page.setRecords(voResult);
|
|
|
+ page.setTotal(voResult.size());
|
|
|
+ return page;
|
|
|
+
|
|
|
+ } else if (voResult.size() > 1) {
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getIsFirst())) {
|
|
|
+
|
|
|
+ long current = (page.getCurrent() - 1) * page.getSize();
|
|
|
+ if (current < 0) {
|
|
|
+ throw new IllegalArgumentException("当前页码不能小于0");
|
|
|
+ }
|
|
|
+ int currentNow = (int) (current / page.getSize() + 1);
|
|
|
+ int pageSize = (int) page.getSize();
|
|
|
+ int fromIndex = (currentNow - 1) * pageSize;
|
|
|
+ int toIndex = Math.min(currentNow * pageSize, voResult.size());
|
|
|
+ List<InformationQueryVO> subList = voResult.subList(fromIndex, toIndex);
|
|
|
+ page.setRecords(subList);
|
|
|
+ page.setTotal(voResult.size());
|
|
|
+ return page;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ /**
|
|
|
+ * 资料查询
|
|
|
+ * @author liuyc
|
|
|
+ * @date 2024年1月6日10:23:14
|
|
|
+ * @description
|
|
|
+ * 处理资料查询,page资料填报数据与节点顺序同步展示问题,查询出当前选择节点下所有资料填报信息,
|
|
|
+ * 然后匹配节点位置信息,不分页查询page数据,分页查询会导致数据匹配异常,处理完匹配后,再分页返回。
|
|
|
+ */
|
|
|
+ //获取选择的节点下的所有子节点信息
|
|
|
+ WbsTreeContract oldSelectedNode = BeanUtil.copyProperties(node, WbsTreeContract.class);
|
|
|
+ List<WbsTreeContract> treeAll = this.getChildNodesZL(oldSelectedNode);
|
|
|
+ if (treeAll == null) {
|
|
|
+ treeAll = new ArrayList<>();
|
|
|
+ }
|
|
|
+ treeAll.add(0, oldSelectedNode);
|
|
|
+
|
|
|
+ if (treeAll.size() > 1) {
|
|
|
+ LinkedList<InformationQueryVO> resultData = new LinkedList<>();
|
|
|
+ LinkedHashMap<Long, InformationQueryVO> dataMaps = voResult.stream()
|
|
|
+ .collect(Collectors.toMap(InformationQueryVO::getWbsId, Function.identity(),
|
|
|
+ (oldValue, newValue) -> oldValue, LinkedHashMap::new));
|
|
|
+ for (WbsTreeContract resultNode : treeAll) {
|
|
|
+ InformationQueryVO queryVO = dataMaps.get(resultNode.getPKeyId());
|
|
|
+ if (queryVO != null) {
|
|
|
+ //按节点顺序插入Page数据
|
|
|
+ resultData.add(queryVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (resultData.size() > 0) {
|
|
|
+ long current = (page.getCurrent() - 1) * page.getSize();
|
|
|
+ if (current < 0) {
|
|
|
+ throw new IllegalArgumentException("当前页码不能小于0");
|
|
|
+ }
|
|
|
+ int currentNow = (int) (current / page.getSize() + 1);
|
|
|
+ int pageSize = (int) page.getSize();
|
|
|
+ int fromIndex = (currentNow - 1) * pageSize;
|
|
|
+ int toIndex = Math.min(currentNow * pageSize, resultData.size());
|
|
|
+ List<InformationQueryVO> subList = resultData.subList(fromIndex, toIndex);
|
|
|
+ page.setRecords(subList);
|
|
|
+ page.setTotal(resultData.size());
|
|
|
+ return page;
|
|
|
+ } else {
|
|
|
+ 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 void integrationMethod(InformationQueryVO vo, List<TaskParallel> linkList) {
|
|
|
+ for (TaskParallel taskPa : linkList) {
|
|
|
+ if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 1) {
|
|
|
+ taskPa.setEVisaStatus(2);
|
|
|
+ } else if (taskPa.getStatus() == 3 && taskPa.getTaskUser().equals(SecureUtil.getUserId().toString())) {
|
|
|
+ taskPa.setEVisaStatus(3);
|
|
|
+ } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 99) {
|
|
|
+ taskPa.setEVisaStatus(999);
|
|
|
+ } else {
|
|
|
+ taskPa.setEVisaStatus(1);
|
|
|
+ }
|
|
|
+
|
|
|
+ String eVisaFailedInfo = "";
|
|
|
+ if (taskPa.getStatus() == 2 && ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 2) {
|
|
|
+ if (taskPa.getEVisaContent().contains("请等待") && ObjectUtil.isEmpty(eVisaFailedInfo)) {
|
|
|
+ eVisaFailedInfo = taskPa.getEVisaContent();
|
|
|
+ }
|
|
|
+ } else if (ObjectUtil.isNotEmpty(taskPa.getEVisaStatus()) && taskPa.getEVisaStatus() == 999) {
|
|
|
+ if (ObjectUtil.isEmpty(eVisaFailedInfo)) {
|
|
|
+ eVisaFailedInfo = taskPa.getEVisaContent();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ vo.setWaitingUserList(taskPa.getTaskUserName(), taskPa.getEVisaStatus());
|
|
|
+ vo.setEVisaFailedInfo(eVisaFailedInfo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getMergePdf(InformationQueryVO vor) throws FileNotFoundException {
|
|
|
+ String pdfUrl = vor.getPdfUrl();
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(vor.getEVisaPdfUrl())) {
|
|
|
+ //优先使用电签的pdf
|
|
|
+ pdfUrl = vor.getEVisaPdfUrl();
|
|
|
+ vor.setPdfUrl(pdfUrl);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (org.apache.commons.lang.StringUtils.isNotEmpty(vor.getPdfTrialUrl()) || org.apache.commons.lang.StringUtils.isNotEmpty(vor.getPdfTrialUrlPosition())) {
|
|
|
+ //合并试验关联文件、试验工程部位信息的pdf
|
|
|
+ List<String> pdfList = new ArrayList<>();
|
|
|
+ //施工填报的原始pdf
|
|
|
+ pdfList.add(pdfUrl);
|
|
|
+ //关联试验的pdf
|
|
|
+ String pdfTrialUrl = vor.getPdfTrialUrl();
|
|
|
+ String pdfTrialUrlPosition = vor.getPdfTrialUrlPosition();
|
|
|
+ if (pdfTrialUrl != null) {
|
|
|
+ pdfList.add(pdfTrialUrl);
|
|
|
+ }
|
|
|
+ if (pdfTrialUrlPosition != null) {
|
|
|
+ pdfList.add(pdfTrialUrlPosition);
|
|
|
+ }
|
|
|
+ //合并
|
|
|
+ if (pdfList.size() >= 2) {
|
|
|
+ String file_path = ParamCache.getValue(CommonConstant.SYS_LOCAL_URL);
|
|
|
+ Long id = SnowFlakeUtil.getId();
|
|
|
+ String trialPdf = file_path + "/pdf/" + id + ".pdf";
|
|
|
+ File trialPdf2 = ResourceUtil.getFile(trialPdf);
|
|
|
+ if (trialPdf2.exists()) {
|
|
|
+ trialPdf2.delete();
|
|
|
+ }
|
|
|
+ //合并当前所有选择的试验pdf
|
|
|
+ FileUtils.mergePdfPublicMethods(pdfList, trialPdf);
|
|
|
+ BladeFile bladeFile = this.newIOSSClient.uploadFile(id + ".pdf", trialPdf);
|
|
|
+ if (bladeFile != null && ObjectUtils.isNotEmpty(bladeFile.getLink())) {
|
|
|
+ vor.setPdfUrl(bladeFile.getLink());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<WbsTreeContract> getChildNodesZL(WbsTreeContract obj) {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void recursionGetChildNodesZL(List<WbsTreeContract> list, List<WbsTreeContract> result, String contractId) {
|
|
|
+ List<Long> ids = list.stream().map(WbsTreeContract::getId).collect(Collectors.toList());
|
|
|
+ if (ids.size() > 0) {
|
|
|
+ //构建以parent_id为key的Map
|
|
|
+ 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 parent_id IN (" + org.apache.commons.lang.StringUtils.join(ids, ",") + ") " +
|
|
|
+ "AND contract_id = " + contractId + " 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;
|
|
|
+ });
|
|
|
+ //按照ids的顺序加入result
|
|
|
+ for (Long id : ids) {
|
|
|
+ if (queryMap != null && queryMap.containsKey(id)) {
|
|
|
+ List<WbsTreeContract> nodes = queryMap.get(id);
|
|
|
+ result.addAll(nodes);
|
|
|
+ recursionGetChildNodesZL(nodes, result, contractId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|