liujie
2026-04-01 2f74a0e6c101edc69de6d5e19e7c071e09a9c3ea
ruoyi-system/src/main/resources/mapper/system/ProjectMapper.xml
@@ -25,26 +25,43 @@
        <result column="permission" property="permission" />
    </resultMap>
    <select id="getDeviceDetailCheckList" resultType="com.ruoyi.system.vo.DeviceDetailCheckListVo">
            select t1.id,t2.name planName,t2.type planType,t1.date checkTime,t1.system_fuzzy fuzzyScore,t1.system_score score,t3.risk_level riskLevel,
                   t3.contain_device_res ,t3.contain_system_res,t2.id planId
            from task t1
            left join plan t2 on t1.plan_id = t2.id
            left join eval_result t3 on t1.id = t3.check_task_id
            where t1.project_id = #{query.projectId}
            <if test="query.planName != null and query.planName != ''">
                and t2.name like concat('%',#{query.planName},'%')
            </if>
            <if test="query.planType != null">
                and t2.type = #{query.planType}
            </if>
            <if test="query.startTime != null and query.startTime != ''">
                and t1.date >= #{query.startTime}
            </if>
            <if test="query.endTime != null and query.endTime != ''">
                and  #{query.endTime} >=t1.date
            </if>
            GROUP BY t2.id
            order by t1.date desc
        SELECT
        t1.id AS id,
        t2.id AS planId,
        t2.name AS planName,
        t2.type AS planType,
        MAX(t1.date) AS checkTime,
        -- 从eval_result表获取风险等级(取fuzzy类型的)
        MAX(CASE WHEN t3.type = 'fuzzy' THEN t3.risk_level END) AS riskLevel,
        -- 从eval_result表获取设备资源(取fuzzy类型的)
        MAX(CASE WHEN t3.type = 'fuzzy' THEN t3.contain_device_res END) AS contain_device_res,
        -- 从eval_result表获取系统资源(取fuzzy类型的)
        MAX(CASE WHEN t3.type = 'fuzzy' THEN t3.contain_system_res END) AS contain_system_res,
        -- 将fuzzy类型的分数放到fuzzyScore字段,保留4位小数
        ROUND(MAX(CASE WHEN t3.type = 'fuzzy' THEN t3.score END), 4) AS fuzzyScore,
        -- 将score类型的分数放到score字段,保留4位小数
        ROUND(MAX(CASE WHEN t3.type = 'score' THEN t3.score END), 4) AS score,
        -- 也可以获取score类型的风险等级(如果需要)
        MAX(CASE WHEN t3.type = 'score' THEN t3.risk_level END) AS scoreRiskLevel
        FROM task t1
        LEFT JOIN plan t2 ON t1.plan_id = t2.id
        LEFT JOIN eval_result t3 ON t1.id = t3.check_task_id
        WHERE t1.project_id = #{query.projectId}
        <if test="query.planName != null and query.planName != ''">
            AND t2.name LIKE CONCAT('%', #{query.planName}, '%')
        </if>
        <if test="query.planType != null">
            AND t2.type = #{query.planType}
        </if>
        <if test="query.startTime != null and query.startTime != ''">
            AND t1.date >= #{query.startTime}
        </if>
        <if test="query.endTime != null and query.endTime != ''">
            AND t1.date &lt;= #{query.endTime}
        </if>
        GROUP BY t2.id, t2.name, t2.type
        HAVING t2.id IS NOT NULL
        ORDER BY MAX(t1.date) DESC
    </select>