From 0fbd01c6fe5386e454d4053df161b01e8b42f423 Mon Sep 17 00:00:00 2001 From: 潘志宝 <979469083@qq.com> Date: 星期五, 23 八月 2024 14:22:13 +0800 Subject: [PATCH] DS --- iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml | 184 ++++++++++++++-------------------------------- 1 files changed, 56 insertions(+), 128 deletions(-) diff --git a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml index 692743b..b093fcc 100644 --- a/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml +++ b/iailab-module-model/iailab-module-model-biz/src/main/resources/mapper/mcs/StModelResultDao.xml @@ -3,140 +3,68 @@ <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="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> + <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="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> - <select id="getModelResultList" resultType="com.iailab.common.dto.IndexStatisticDTO"> - SELECT - b.result_time dateTime,b.result_value data - FROM - t_st_model a, - t_st_model_result b - WHERE a.id = b.model_id - AND b.line_index = '0' - AND b.result_key = #{key} - AND result_time BETWEEN #{startDate} AND #{endDate} - ORDER BY - b.result_time - </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 + <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> - <insert id="migrationModelResult" - parameterType="java.util.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> - - <select id="getStorePageList" resultType="com.iailab.module.any.dto.AnyStoreReliabilityDTO"> - select t.* from ( - SELECT result_time as 'dateTime', - MAX(CASE WHEN result_key = 'score' THEN result_value END) AS 'score', - MAX(CASE WHEN result_key = 'analysis' THEN result_value END) AS 'analysis', - MAX(CASE WHEN result_key = 'judgement' THEN result_value END) AS 'judgement' - FROM `t_st_model_result` - <where> - model_id = #{params.modelId} - <if test="params.startTime != null and params.startTime != ''"> - and result_time >= #{params.startTime} - </if> - <if test="params.endTime != null and params.endTime != ''"> - and result_time <= #{params.endTime} - </if> - </where> - GROUP BY result_time - ) as t - <where> - <if test="params.judgement != null and params.judgement != ''"> - t.judgement like concat('%',#{params.judgement},'%') - </if> - </where> - </select> - <select id="getEvaluationPageList" resultType="com.iailab.module.any.dto.AnyAllEvaluationDTO"> - select * from ( - SELECT result_time as 'dateTime', - MAX(CASE WHEN result_key = 'first_level' THEN result_value END) AS 'first_level', - MAX(CASE WHEN result_key = 'zong_level' THEN result_value END) AS 'zong_level', - MAX(CASE WHEN result_key = 'shu_liang_fen' THEN result_value END) AS 'shu_liang_fen', - MAX(CASE WHEN result_key = 'zhi_liang_fen' THEN result_value END) AS 'zhi_liang_fen', - MAX(CASE WHEN result_key = 'sheng_chan_fen' THEN result_value END) AS 'sheng_chan_fen', - MAX(CASE WHEN result_key = 'guo_cheng_fen' THEN result_value END) AS 'guo_cheng_fen', - MAX(CASE WHEN result_key = 'guan_li_fen' THEN result_value END) AS 'guan_li_fen' - FROM `t_st_model_result` - <where> - model_id = #{params.modelId} - <if test="params.startDate != null and params.startDate != ''"> - and result_time >= #{params.startDate} - </if> - <if test="params.endDate != null and params.endDate != ''"> - and result_time <= #{params.endDate} - </if> - </where> - GROUP BY result_time - ) as t - <where> - <if test="params.state != null and params.state != ''"> - state like concat('%',#{params.state},'%') - </if> - </where> - </select> + <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> \ No newline at end of file -- Gitblit v1.9.3