job
潘志宝
2024-08-26 cd5f8564e84694d098a4eeddecc36aa8ce7cfdf3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 
<mapper namespace="com.iailab.module.mcs.dao.StModelResultDao">
 
    <resultMap id="StModelResultEntity" type="com.iailab.module.mcs.entity.StModelResultEntity">
        <result property="modelId" column="model_id"/>
        <result property="resultKey" column="result_key"/>
        <result property="resultValue" column="result_value"/>
        <result property="resultTime" column="result_time"/>
    </resultMap>
 
    <resultMap id="StoreDependableAnalysisDTO" type="com.iailab.module.any.dto.AnyStoreReliabilityDTO">
        <result property="dateTime" column="dateTime"/>
        <result property="grade" column="grade"/>
        <result property="state" column="state"/>
        <result property="analysis" column="analysis"/>
    </resultMap>
 
 
    <select id="getLastResultByCode" parameterType="map" resultType="com.iailab.module.mcs.dto.StModelResultDTO">
        select t2.result_key resultKey, t2.result_value resultValue, t2.result_time resultTime
        from t_st_model t1
                 inner join t_st_model_result t2 on t2.model_id = t1.id and t2.result_time = t1.run_time
        where t1.model_code = #{modelCode}
    </select>
    <select id="getResultByCodeDate" parameterType="map" resultType="com.iailab.module.mcs.dto.StModelResultDTO">
        select t2.result_key resultKey, t2.result_value resultValue, t2.result_time resultTime
        from t_st_model t1
                 inner join t_st_model_result t2 on t2.model_id = t1.id
        where t1.model_code = #{modelCode}
          and DATE_FORMAT(t2.result_time, '%Y-%m-%d') = #{resultTime}
    </select>
 
    <select id="getResultList" parameterType="map" resultMap="StModelResultEntity">
        SELECT
        b.model_id,
        b.result_key,
        b.result_value,
        b.result_time
        FROM
        t_st_model_result b
        left JOIN t_st_model a ON a.id = b.model_id
        WHERE
        b.result_key not in ('status', 'tips')
        <if test="modelId != null and modelId != ''">
            AND b.model_id = #{modelId}
        </if>
        <if test="modelCode != null and modelCode != ''">
            AND a.model_code = #{modelCode}
        </if>
        AND result_time BETWEEN #{startDate} AND #{endDate}
        ORDER BY
        b.result_time ${sortType}
    </select>
 
    <delete id="cleanModelResult" parameterType="map">
        delete
        from t_st_model_result
        where result_time between #{startdate} and #{enddate}
    </delete>
 
    <insert id="insertList" parameterType="list">
        INSERT INTO `t_st_model_result` (id, `model_id`, `line_index`, `result_key`, `result_value`, `result_time`)
        VALUES
        <foreach item="item" collection="list" separator=",">
            (#{item.id},#{item.modelId},#{item.lineIndex},#{item.resultKey},#{item.resultValue},#{item.resultTime})
        </foreach>
    </insert>
</mapper>