Commit bb97c224 authored by duanruiming's avatar duanruiming

[add] 数据库优化2

parent 70354f12
......@@ -12,10 +12,10 @@
strategy,
schedule_start,
schedule_end,
`time`,
"time",
frequency,
status,
user,
"user",
operation
) VALUES
<foreach collection="list" item="entity" separator=",">
......
......@@ -47,6 +47,8 @@ public class StrategyControlDataEntity extends PageVO {
private String wkt;
@TableField(exist = false)
private String optMethod;
@TableField("\"user\"")
private String user;
@TableField("operation")
private String operation;
}
......@@ -30,7 +30,7 @@
<sql id="Base_Column_List">
id
, cross_id, scheme_id, dir_type, turn_type, offset, ring_no, phase_no, phase_order_id, ori_green_time,
, cross_id, scheme_id, dir_type, turn_type, "offset", ring_no, phase_no, phase_order_id, ori_green_time,
opt_time, opt_type, opt_reason, start_time, end_time, is_relation, relation_cross_id, opt_result, opt_result_desc,
data_batch_time, restore_result, data_extend
</sql>
......@@ -72,7 +72,7 @@
</select>
<insert id="insertOne" parameterType="net.wanji.opt.po.base.CrossSchemeOptLogPO">
insert into t_base_cross_scheme_opt_log (cross_id, scheme_id, dir_type, turn_type, offset, ring_no, phase_no,
insert into t_base_cross_scheme_opt_log (cross_id, scheme_id, dir_type, turn_type, "offset", ring_no, phase_no,
phase_order_id, ori_green_time, opt_time, opt_type, opt_reason,
start_time,
end_time, is_relation, relation_cross_id, opt_result, opt_result_desc,
......@@ -84,7 +84,7 @@
<insert id="insertBatch" parameterType="net.wanji.opt.po.base.CrossSchemeOptLogPO">
insert into t_base_cross_scheme_opt_log
(cross_id, scheme_id, dir_type, turn_type, offset, ring_no, phase_no,
(cross_id, scheme_id, dir_type, turn_type, "offset", ring_no, phase_no,
phase_order_id, ori_green_time, opt_time, opt_type, opt_reason,
start_time, end_time, is_relation, relation_cross_id, opt_result, opt_result_desc,
data_batch_time, restore_result, data_extend)
......
......@@ -12,10 +12,10 @@
strategy,
schedule_start,
schedule_end,
`time`,
time,
frequency,
status,
user,
"user",
operation
) VALUES
<foreach collection="list" item="entity" separator=",">
......
......@@ -25,14 +25,14 @@
<!-- 统一接口:绿波路口车道级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findCrossObjectIndex"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT MIN(COALESCE(t.unit_time,#{startDate})) start_time,
SELECT MIN(COALESCE(CAST(T.unit_time AS TIMESTAMP),#{startDate})) as start_time,
(case
when #{groupType}=0 then TO_CHAR(DATE_ADD(t.unit_time,INTERVAL 5 MINUTE),'YYYY-MM-DD HH24:MI:00')
when #{groupType}=1 then TO_CHAR(DATE_ADD(t.unit_time,INTERVAL 15 MINUTE),'YYYY-MM-DD HH24:MI:00')
when #{groupType}=2 then TO_CHAR(DATE_ADD(t.unit_time,INTERVAL 30 MINUTE),'YYYY-MM-DD HH24:MI:00')
when #{groupType}=3 then TO_CHAR(DATE_ADD(t.unit_time,INTERVAL 60 MINUTE),'YYYY-MM-DD HH24:00:00')
when #{groupType}=0 then TO_CHAR(CAST(T.unit_time AS TIMESTAMP) + INTERVAL 5 MINUTE,'YYYY-MM-DD HH24:MI:00')
when #{groupType}=1 then TO_CHAR(CAST(T.unit_time AS TIMESTAMP) + INTERVAL 15 MINUTE,'YYYY-MM-DD HH24:MI:00')
when #{groupType}=2 then TO_CHAR(CAST(T.unit_time AS TIMESTAMP) + INTERVAL 30 MINUTE,'YYYY-MM-DD HH24:MI:00')
when #{groupType}=3 then TO_CHAR(CAST(T.unit_time AS TIMESTAMP) + INTERVAL 60 MINUTE,'YYYY-MM-DD HH24:00:00')
end
) end_time,
) AS end_time,
cross_id ,
lane_no ,
dir_type ,
......@@ -43,24 +43,24 @@
MIN(queue_length) AS min_queue_length,
round(CAST(AVG(queue_length) AS NUMERIC)) AS avg_queue_length,
round(CAST(AVG(stop_times) AS NUMERIC),2) AS stop_times,
roundCAST(AVG(delay_time) AS NUMERIC),2) AS delay_time,
round(CAST(AVG(delay_time) AS NUMERIC),2) AS delay_time,
round(CAST(AVG(traffic_index) AS NUMERIC),2) AS traffic_index,
round(CAST(AVG(sturation) AS NUMERIC),4) AS sturation,
round(CAST(AVG(green_light_efficiency) AS NUMERIC),4) AS green_light_efficiency,
round(CAST(AVG(vehicle_length_ratio_mean) AS NUMERIC),4) AS vehicle_length_ratio_mean,
round(CAST(AVG(CAST(vehicle_length_ratio_mean AS NUMERIC)) AS NUMERIC),4) AS vehicle_length_ratio_mean,
STRING_AGG(service_level||'',',') AS service_level
FROM
(
SELECT start_time,
(case
when #{groupType}=0 then TO_CHAR(concat( TO_CHAR( start_time,'YYYY-MM-DD' ), ' ', TO_CHAR( start_time,'HH24' ), ':', floor( EXTRACT(MINUTE FROM start_time ) / 5 ) * 5 ),'YYYY-MM-DD HH24:MI:00' )
when #{groupType}=1 then TO_CHAR(concat( TO_CHAR( start_time,'YYYY-MM-DD' ), ' ', TO_CHAR( start_time,'HH24' ), ':', floor( EXTRACT(MINUTE FROM start_time ) / 15 ) * 15 ),'YYYY-MM-DD HH24:MI:00' )
when #{groupType}=2 then TO_CHAR(concat( TO_CHAR( start_time,'YYYY-MM-DD' ), ' ', TO_CHAR( start_time,'HH24' ), ':', floor( EXTRACT(MINUTE FROM start_time ) / 30 ) * 30 ),'YYYY-MM-DD HH24:MI:00' )
when #{groupType}=0 then TO_TIMESTAMP(concat( TO_CHAR( start_time,'YYYY-MM-DD' ), ' ', TO_CHAR( start_time,'HH24' ), ':', floor( EXTRACT(MINUTE FROM start_time ) / 5 ) * 5 ),'YYYY-MM-DD HH24:MI:00' )
when #{groupType}=1 then TO_TIMESTAMP(concat( TO_CHAR( start_time,'YYYY-MM-DD' ), ' ', TO_CHAR( start_time,'HH24' ), ':', floor( EXTRACT(MINUTE FROM start_time ) / 15 ) * 15 ),'YYYY-MM-DD HH24:MI:00' )
when #{groupType}=2 then TO_TIMESTAMP(concat( TO_CHAR( start_time,'YYYY-MM-DD' ), ' ', TO_CHAR( start_time,'HH24' ), ':', floor( EXTRACT(MINUTE FROM start_time ) / 30 ) * 30 ),'YYYY-MM-DD HH24:MI:00' )
when #{groupType}=3 then TO_CHAR(start_time,'YYYY-MM-DD HH24:00:00' )
when #{groupType}=4 then TO_CHAR(start_time,'YYYY-MM-DD 00:00:00' )
else TO_CHAR(start_time,'YYYY-01-01 00:00:00') <!-- 按查询时间范围不分粒度进行聚合处理 -->
end
) unit_time,
) AS unit_time,
t.cross_id,
<choose>
<!-- 路口级 -->
......@@ -123,7 +123,7 @@
and t.cross_id = #{crossId}
</if>
<if test="startDate !=null and endDate !=null">
and dt >= CAST(TO_CHAR(#{startDate},'YYYYMMDD') AS INT4) and dt &lt;= CAST(TO_CHAR(#{endDate},'YYYYMMDD') AS INT4)
and dt >= CAST(TO_CHAR(#{startDate},'YYYYMMDD') AS INT4) and dt &lt;= CAST(TO_CHAR(#{startDate},'YYYYMMDD') AS INT4)
AND start_time >= TO_TIMESTAMP(#{startDate},'YYYY-MM-DD HH24:MI:SS') and start_time &lt; TO_TIMESTAMP(#{endDate},'YYYY-MM-DD HH24:MI:SS')
</if>
<choose>
......
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