Просмотр исходного кода

bug

Signed-off-by: liuyc <56808083@qq.com>
liuyc 1 год назад
Родитель
Сommit
45318523fb

+ 1 - 1
blade-service/blade-meter/src/main/java/org/springblade/meter/service/impl/MeterTreeContractServiceImpl.java

@@ -578,7 +578,7 @@ public class MeterTreeContractServiceImpl extends BaseServiceImpl<MeterTreeContr
         } else {
             /*非根节点导入,获取当前节点*/
             if (ObjectUtil.isEmpty(meterTreeContract.getNodeCode())) {
-                throw new ServiceException("当前选择导入的节点编号为空,操作失败");
+                throw new ServiceException("当前选择导入的工程编号为空,操作失败");
             }
             rootNodesImport.add(meterTreeContract);
         }

+ 94 - 76
blade-service/blade-user/src/main/java/org/springblade/system/user/mapper/UserMapper.xml

@@ -129,82 +129,100 @@
     </select>
 
     <select id="selectInformationQueryPageTwo" resultType="org.springblade.business.entity.InformationQuery">
-        select
-        query.pdf_trial_url,
-        query.pdf_trial_url_position,
-        query.wbs_id,
-        query.id,
-        query.name,
-        query.number,
-        query.create_time,
-        query.status,
-        query.report_number,
-        query.file_user_id_and_name,
-        query.pdf_url,
-        query.e_visa_pdf_url,
-        query.task_id,
-        query.sj_record_ids
-        from
-        (
-        select
-        iq.pdf_trial_url_position,
-        iq.pdf_trial_url,
-        iq.sort,
-        iq.id,
-        iq.name,
-        iq.number,
-        iq.create_time,
-        iq.status,
-        (case iq.STATUS when 0 THEN null else t.batch end) as report_number,
-        iq.file_user_id_and_name,
-        date_format(iq.create_time,'%Y-%m-%d') as createTimes,
-        iq.pdf_url,
-        iq.e_visa_pdf_url,
-        iq.wbs_id,
-        t.id as task_id,
-        iq.sj_record_ids
-        from u_information_query iq left join (select * from u_task k where k.status!=3 and k.project_id =
-        #{query.projectId} group by
-        form_data_id) t on iq.id = t.form_data_id and t.is_deleted = 0
-        where
-        iq.is_deleted = 0
-        and iq.classify = #{query.classify}
-        and iq.contract_id = #{query.contractId}
-        <if test="query.taskStatus != null and query.taskStatus != ''">
-            <choose>
-                <when test="query.taskStatus == 0">
-                    and (iq.status = 0 or iq.status = 3)
-                </when>
-                <otherwise>
-                    and iq.status = #{query.taskStatus}
-                </otherwise>
-            </choose>
-        </if>
-        <if test="query.sourceType != null and query.sourceType != ''">and iq.source_type = #{query.sourceType}</if>
-        <if test="query.reportNumber != null and query.reportNumber != ''">and t.batch = #{query.reportNumber}</if>
-        <if test="query.fileUserIdAndName != null and query.fileUserIdAndName != ''">and iq.file_user_id_and_name like
-            concat('%',#{query.fileUserIdAndName},'%')
-        </if>
-        <if test="query.queryValue != null and query.queryValue != ''">and (iq.name like
-            concat('%',#{query.queryValue},'%') OR iq.number like concat('%',#{query.queryValue},'%'))
-        </if>
-        <if test="query.firstTitle != null and query.firstTitle != ''">and iq.type = 3</if>
-        <if test="query.firstTitle == null or query.firstTitle == ''">and iq.type != 3</if>
-        <if test="query.wbsIds != null">
-            and iq.wbs_id in
-            <foreach collection="query.wbsIds" item="wbsIdc" open="(" separator="," close=")">
-                #{wbsIdc}
-            </foreach>
-        </if>
-        ) AS query
-        where
-        1 = 1
-        <if test="query.reportNumber != null and query.reportNumber != ''">and report_number = #{query.reportNumber}
-        </if>
-        <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
-            and query.createTimes between #{query.startTime} and #{query.endTime}
-        </if>
-        order by create_time desc
+        SELECT
+            query.pdf_trial_url,
+            query.pdf_trial_url_position,
+            query.wbs_id,
+            query.id,
+            query.name,
+            query.number,
+            query.create_time,
+            query.status,
+            query.report_number,
+            query.file_user_id_and_name,
+            query.pdf_url,
+            query.e_visa_pdf_url,
+            query.task_id,
+            query.sj_record_ids
+        FROM
+            (
+            SELECT
+                iq.pdf_trial_url_position,
+                iq.pdf_trial_url,
+                iq.sort,
+                iq.id,
+                iq.name,
+                iq.number,
+                iq.create_time,
+                date_format(iq.create_time,'%Y-%m-%d') AS createTimes,
+                iq.status,
+                (CASE iq.STATUS WHEN 0 THEN NULL ELSE t.batch END) AS report_number,
+                iq.file_user_id_and_name,
+                iq.pdf_url,
+                iq.e_visa_pdf_url,
+                iq.wbs_id,
+                t.id AS task_id,
+                iq.sj_record_ids
+            FROM
+                 u_information_query iq
+                LEFT JOIN
+                ( SELECT form_data_id, batch, id, is_deleted FROM u_task k
+                WHERE k.STATUS != 3 AND k.contract_id = #{query.contractId}
+                ORDER BY k.create_time DESC LIMIT 1 ) t ON iq.id = t.form_data_id
+                AND t.is_deleted = 0
+
+            WHERE
+                iq.is_deleted = 0
+            AND iq.classify = #{query.classify}
+            AND iq.contract_id = #{query.contractId}
+
+                <if test="query.taskStatus != null and query.taskStatus != ''">
+                    <choose>
+                        <when test="query.taskStatus == 0">
+                            AND (iq.status = 0 OR iq.status = 3)
+                        </when>
+                        <otherwise>
+                            AND iq.status = #{query.taskStatus}
+                        </otherwise>
+                    </choose>
+                </if>
+                <if test="query.sourceType != null and query.sourceType != ''">
+                    AND iq.source_type = #{query.sourceType}
+                </if>
+                <if test="query.reportNumber != null and query.reportNumber != ''">
+                    AND t.batch = #{query.reportNumber}
+                </if>
+                <if test="query.fileUserIdAndName != null and query.fileUserIdAndName != ''">
+                    AND iq.file_user_id_and_name LIKE concat('%',#{query.fileUserIdAndName},'%')
+                </if>
+                <if test="query.queryValue != null and query.queryValue != ''">
+                    AND (iq.name LIKE concat('%',#{query.queryValue},'%') OR iq.number LIKE concat('%',#{query.queryValue},'%'))
+                </if>
+                <if test="query.firstTitle != null and query.firstTitle != ''">
+                    AND iq.type = 3
+                </if>
+                <if test="query.firstTitle == null or query.firstTitle == ''">
+                    AND iq.type != 3
+                </if>
+                <!--<if test="query.wbsIds != null">
+                    AND iq.wbs_id IN
+                    <foreach collection="query.wbsIds" item="wbsIdc" open="(" separator="," close=")">
+                        #{wbsIdc}
+                    </foreach>
+                </if>-->
+
+            ) AS query
+
+        WHERE 1 = 1
+
+            <if test="query.reportNumber != null and query.reportNumber != ''">
+                AND report_number = #{query.reportNumber}
+            </if>
+            <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''">
+                AND query.createTimes BETWEEN #{query.startTime} AND #{query.endTime}
+            </if>
+
+        ORDER BY create_time DESC
     </select>
 
 </mapper>

+ 50 - 21
blade-service/blade-user/src/main/java/org/springblade/system/user/service/impl/UserServiceImpl.java

@@ -96,6 +96,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
     /*存储当前合同段contractId_tableOwner对应的节点数量统计缓存信息*/
     private final Map<String, List<WbsTreeContractLazyVO>> localCacheParentCountNodes = new ConcurrentHashMap<>();
 
+    /*存储当前合同段对应的资料查询信息*/
+    private final Map<String, List<InformationQuery>> localCacheQueryInfoAll = new ConcurrentHashMap<>();
+
     private final NewIOSSClient newIOSSClient;
     private static final String GUEST_NAME = "guest";
     private final IUserDeptService userDeptService;
@@ -958,6 +961,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
             localCacheNodes.clear();
             localCacheQueryInfos.clear();
             localCacheParentCountNodes.clear();
+            localCacheQueryInfoAll.clear();
 
             //清除RedisWbs树节点缓存(此处的Redis为每层懒加载缓存)
             Set<String> keysByNodes = redisTemplate.keys("blade-manager::contract:wbstree:*");
@@ -1277,12 +1281,21 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                     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," +
+                        /*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, ",") + ")";
+                                " 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);
@@ -1297,7 +1310,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                             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<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());
                         }
@@ -1306,6 +1319,10 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                 }
             }
 
+            if (submitNodeKeyIds.size() <= 0) {
+                throw new ServiceException("未获取到节点信息");
+            }
+
             vo.setWbsIds(submitNodeKeyIds);
 
             if (org.apache.commons.lang.StringUtils.isNotEmpty(vo.getContractIdRelation())) {
@@ -1337,9 +1354,24 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
             vo.setTaskStatus(vo.getStatus().toString());
         }
 
-        //获取全部数据
-        List<InformationQuery> result = baseMapper.selectInformationQueryPageTwo(vo);
+        /*获取当前资料缓存*/
+        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);
+        }
+        long endTime = System.currentTimeMillis();
+        long executionTime = endTime - startTime;
+        _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信息
             Map<String, List<Task>> taskMaps = new HashMap<>();
             Map<String, List<TaskParallel>> taskParallelMaps = new HashMap<>();
@@ -1364,7 +1396,7 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
             }
             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));
+                informationQueries = jdbcTemplate.query("SELECT id FROM u_information_query WHERE id IN(" + StringUtils.join(ids, ",") + ")", new BeanPropertyRowMapper<>(InformationQuery.class));
             }
 
             List<InformationQueryVO> voResult = JSONArray.parseArray(JSONObject.toJSONString(result), InformationQueryVO.class);
@@ -1449,17 +1481,13 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                     return page;
 
                 } else {
-                    /**
-                     * 资料查询
-                     * @author liuyc
-                     * @date 2024年1月6日10:23:14
-                     * @description
-                     *   处理资料查询,page资料填报数据与节点顺序同步展示问题,查询出当前选择节点下所有资料填报信息,
-                     *   然后匹配节点位置信息,不分页查询page数据,分页查询会导致数据匹配异常,处理完匹配后,再分页返回。
-                     */
-                    //获取选择的节点下的所有子节点信息
+                    long startTime_1 = System.currentTimeMillis();
                     WbsTreeContract oldSelectedNode = BeanUtil.copyProperties(node, WbsTreeContract.class);
-                    List<WbsTreeContract> treeAll = this.getChildNodesZL(oldSelectedNode);
+                    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<>();
                     }
@@ -1604,13 +1632,16 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
     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 " +
+                            "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, ",") + ") " +
-                            "AND contract_id = " + contractId + " ORDER BY sort,fullName,create_time",
+                            "ORDER BY sort,fullName,create_time",
                     rs -> {
                         Map<Long, List<WbsTreeContract>> map = new LinkedHashMap<>();
                         while (rs.next()) {
@@ -1629,7 +1660,6 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
                         }
                         return map;
                     });
-            //按照ids的顺序加入result
             for (Long id : ids) {
                 if (queryMap != null && queryMap.containsKey(id)) {
                     List<WbsTreeContract> nodes = queryMap.get(id);
@@ -1640,5 +1670,4 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
         }
     }
 
-
 }