|
@@ -22,13 +22,12 @@ import org.springblade.common.constant.LauncherConstant;
|
|
|
import org.springblade.common.utils.SnowFlakeUtil;
|
|
|
import org.springblade.core.cache.utils.CacheUtil;
|
|
|
import org.springblade.core.mp.base.BaseServiceImpl;
|
|
|
+import org.springblade.core.mp.support.Condition;
|
|
|
import org.springblade.core.oss.model.BladeFile;
|
|
|
import org.springblade.core.secure.BladeUser;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
-import org.springblade.core.tool.utils.DateUtil;
|
|
|
-import org.springblade.core.tool.utils.Func;
|
|
|
-import org.springblade.core.tool.utils.ResourceUtil;
|
|
|
+import org.springblade.core.tool.utils.*;
|
|
|
import org.springblade.manager.entity.ContractInfo;
|
|
|
import org.springblade.manager.entity.WbsTreeContract;
|
|
|
import org.springblade.manager.feign.ContractClient;
|
|
@@ -49,6 +48,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import java.io.File;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -477,9 +477,7 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<InformationQueryVO> selectInformationQueryPage(IPage<InformationQueryVO> page, InformationQueryVO vo) {
|
|
|
- long current = (page.getCurrent() - 1L) * page.getSize();
|
|
|
-
|
|
|
+ public IPage<InformationQueryVO> selectInformationQueryPage(IPage<InformationQueryVO> page, InformationQueryVO vo, WbsTreeContract node) {
|
|
|
if (StringUtils.isNotEmpty(vo.getBetweenTime())) {
|
|
|
String[] betweenTime;
|
|
|
if (vo.getBetweenTime().contains("~")) {
|
|
@@ -501,10 +499,10 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
|
|
|
}
|
|
|
|
|
|
//获取总量
|
|
|
- Integer count = this.baseMapper.countInformationQueryTwo(vo);
|
|
|
+ //Integer count = this.baseMapper.countInformationQueryTwo(vo);
|
|
|
|
|
|
- //获取数据
|
|
|
- List<InformationQuery> result = this.baseMapper.selectInformationQueryPageTwo(current, page.getSize(), vo);
|
|
|
+ //获取全部数据(后面单独分页)
|
|
|
+ List<InformationQuery> result = this.baseMapper.selectInformationQueryPageTwo(vo);
|
|
|
|
|
|
//转换VO
|
|
|
if (result != null && result.size() != 0) {
|
|
@@ -564,15 +562,126 @@ public class InformationQueryServiceImpl extends BaseServiceImpl<InformationQuer
|
|
|
}
|
|
|
|
|
|
});
|
|
|
- page.setRecords(voResult);
|
|
|
- page.setTotal(count);
|
|
|
|
|
|
- return page;
|
|
|
- }
|
|
|
+ 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) {
|
|
|
+ /**
|
|
|
+ * @Author liuYC
|
|
|
+ * @Date 2023年5月5日11:53:57
|
|
|
+ * @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) {
|
|
|
+ //按节点顺序插入
|
|
|
+ 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 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," +
|
|
|
+ "IFNULL(if(length(trim(full_name)) > 0, full_name, node_name), node_name) AS fullName," +
|
|
|
+ "create_time from m_wbs_tree_contract where type = 1 and parent_id " +
|
|
|
+ "in(" + StringUtils.join(ids, ",") + ") and status = 1 and is_deleted = 0 " +
|
|
|
+ "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,将查询结果按照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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void getMergePdf(InformationQueryVO vor) throws FileNotFoundException {
|
|
|
String pdfUrl = vor.getPdfUrl();
|
|
|
if (StringUtils.isNotEmpty(vor.getEVisaPdfUrl())) {
|