Commit 4f3e75e9 authored by wangyecheng's avatar wangyecheng

方案评价优化sql

parent acb9dc95
......@@ -11,75 +11,74 @@
</select>
<select id="getOverflow" parameterType="net.wanji.opt.po.trend.EventInfoSimplePo" resultType="net.wanji.opt.po.trend.EventInfoSimplePo" >
SELECT count(*) as event_count,
sum(duration) duration,
count(t2.event_id) as optimizecount
sum(duration) duration,
count(event_id) as optimizecount
FROM
(
SELECT t1.cross_id,t1.event_serial_number,t1.type,TIMESTAMPDIFF(SECOND,t1.start_time,t1.end_time) duration from t_event_info t1
Where 1=1
(
SELECT t1.cross_id,t1.event_serial_number,t1.type,
TIMESTAMPDIFF(SECOND,t1.start_time,t1.end_time) duration,
t2.event_id
from t_event_info t1
left JOIN
t_strategy_cross_result t2
on t1.event_serial_number=t2.event_id
<if test="crossId!=null and crossId!=''">
AND t1.cross_id=#{crossId}
AND t2.cross_id=#{crossId}
</if>
<if test="startTime!=null and endTime!=null">
AND start_time>=#{startTime} and start_time &lt;=#{endTime}
<if test="startTime!=null and endTime!=null">
AND t2.issue_time>=#{startTime} and t2.issue_time &lt;=#{endTime}
</if>
<if test="evenType!=null">
AND t1.type=#{evenType}
<if test="currentAlgo!=null and currentAlgo!=''">
AND t2.current_algo=#{currentAlgo}
</if>
) t1
left JOIN
(
SELECT t1.cross_id,t1.event_id from t_strategy_cross_result t1
WHERE
1=1
Where 1=1
<if test="crossId!=null and crossId!=''">
AND t1.cross_id=#{crossId}
</if>
<if test="startTime!=null and endTime!=null">
AND issue_time>=#{startTime} and issue_time &lt;=#{endTime}
<if test="startTime!=null and endTime!=null">
AND t1.start_time>=#{startTime} and t1.start_time &lt;=#{endTime}
</if>
<if test="currentAlgo!=null">
AND t1.current_algo=#{currentAlgo}
<if test="evenType!=null and evenType!='' ">
AND t1.type=#{evenType}
</if>
) t2
on t1.event_serial_number=t2.event_id
GROUP BY t1.cross_id,t1.type
)t
GROUP BY cross_id,type
</select>
<select id="getContrastOverflow" parameterType="net.wanji.opt.po.trend.EventInfoSimplePo" resultType="net.wanji.opt.po.trend.EventInfoSimplePo">
SELECT count(*) as event_count,
sum(duration) duration,
count(t2.event_id) as optimizecount
count(event_id) as optimizecount
FROM
(
SELECT t1.cross_id,t1.event_serial_number,t1.type,TIMESTAMPDIFF(SECOND,t1.start_time,t1.end_time) duration from t_event_info t1
Where 1=1
SELECT t1.cross_id,t1.event_serial_number,
t1.type,TIMESTAMPDIFF(SECOND,t1.start_time,t1.end_time) duration,
t2.event_id
from t_event_info t1
left JOIN
t_strategy_cross_result t2
on t1.event_serial_number=t2.event_id
<if test="crossId!=null and crossId!=''">
AND t1.cross_id=#{crossId}
AND t2.cross_id=#{crossId}
</if>
<if test="contrastStartTime!=null and constrastEndTime!=null">
AND start_time>=#{contrastStartTime} and start_time &lt;=#{constrastEndTime}
<if test="contrastStartTime!=null and constrastEndTime!=null">
AND t2.issue_time>=#{contrastStartTime} and t2.issue_time &lt;=#{constrastEndTime}
</if>
<if test="evenType!=null">
AND t1.type=#{evenType}
<if test="currentAlgo!=null">
AND t2.current_algo=#{currentAlgo}
</if>
) t1
left JOIN
(
SELECT t1.cross_id,t1.event_id from t_strategy_cross_result t1
WHERE
1=1
1=1
<if test="crossId!=null and crossId!=''">
AND t1.cross_id=#{crossId}
</if>
<if test="contrastStartTime!=null and constrastEndTime!=null">
AND issue_time>=#{contrastStartTime} and issue_time &lt;=#{constrastEndTime}
AND t1.cross_id=#{crossId}
</if>
<if test="contrastStartTime!=null and constrastEndTime!=null">
AND t1.start_time>=#{contrastStartTime} and t1.start_time &lt;=#{constrastEndTime}
</if>
<if test="currentAlgo!=null">
AND t1.current_algo=#{currentAlgo}
<if test="evenType!=null">
AND t1.type=#{evenType}
</if>
) t2
on t1.event_serial_number=t2.event_id
GROUP BY t1.cross_id,t1.type
)t
GROUP BY cross_id,type
</select>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment