<?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>
|