Commit 36f9f27d authored by zhoushiguang's avatar zhoushiguang

国产化修改

parent ea984a31
......@@ -71,7 +71,7 @@ public class BaseCrossInfoCache implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
init();
//init();
}
public void init() {
......
......@@ -53,7 +53,7 @@ public class BaseCrossPhaseInfoCache implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
init();
// init();
}
public void init() {
......
......@@ -53,7 +53,7 @@ public class CrossDirTurnPhaseCache implements CommandLineRunner {
@Override
public void run(String... args) {
init();
// init();
}
/**
......
......@@ -62,7 +62,7 @@ public class CrossRidInfoCache implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
init();
// init();
}
public void init() {
......
......@@ -26,7 +26,7 @@ public class GreenCrossDirInfoCache implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
try {
init();
// init();
} catch (Exception e) {
log.error("缓存加载失败:", e);
throw new RuntimeException(e);
......
......@@ -28,12 +28,12 @@ public class GreenWaveInfoCache implements CommandLineRunner {
@Override
public void run(String... args) throws Exception {
try {
List<GreenwaveInfoPO> greenWaveInfoPOS = greenwaveInfoMapper.selectAll();
if (!CollectionUtils.isEmpty(greenWaveInfoPOS)) {
for (GreenwaveInfoPO greenWaveInfoPO : greenWaveInfoPOS) {
greenWaveMap.put(greenWaveInfoPO.getId(), greenWaveInfoPO);
}
}
// List<GreenwaveInfoPO> greenWaveInfoPOS = greenwaveInfoMapper.selectAll();
// if (!CollectionUtils.isEmpty(greenWaveInfoPOS)) {
// for (GreenwaveInfoPO greenWaveInfoPO : greenWaveInfoPOS) {
// greenWaveMap.put(greenWaveInfoPO.getId(), greenWaveInfoPO);
// }
// }
} catch (Exception e) {
log.error("绿波信息初始化失败:", e);
throw new RuntimeException("绿波信息初始化失败!");
......
......@@ -8,7 +8,7 @@ import java.text.ParseException;
import java.util.List;
public interface AnalysisGreenCongestionPeriodService {
public void selectCountByCongestionPeriod() throws ParseException;
public void selectCountByCongestionPeriod() throws ParseException;
public void selectCountByLandData() throws ParseException;
public void selectCountByCrossData() throws ParseException;
public void selectCountByCrossDataOneDay() throws ParseException;
......
......@@ -13,6 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource;
import java.text.ParseException;
......@@ -20,7 +21,7 @@ import java.text.ParseException;
@Configurable
@EnableScheduling
@Slf4j
@Profile("docker")
@Profile("!dev")
public class AnalysisGreenCongestionPeriodWeekTask {
@Autowired
private AnalysisGreenCongestionPeriodService analysisGreenCongestionPeriodService;
......@@ -29,31 +30,44 @@ public class AnalysisGreenCongestionPeriodWeekTask {
EventInfoService eventInfoService;
@Scheduled(cron = "0 30 2 ? * 1")
public void task() throws ParseException {
//@PostConstruct
public void task() throws ParseException {
try {
long st = System.currentTimeMillis();
analysisGreenCongestionPeriodService.selectCountByCongestionPeriod();
long et = System.currentTimeMillis();
log.info("计算任务 selectCountByCongestionPeriod 耗时:{}ms", et - st);
} catch (Exception e) {
log.error("", e);
}
try {
long st = System.currentTimeMillis();
analysisGreenCongestionPeriodService.selectCountByLandData();
//analysisGreenCongestionPeriodService.selectCountByCrossData();
}catch (Exception e){
log.error("",e);
long et = System.currentTimeMillis();
log.info("计算任务 selectCountByLandData 耗时:{}ms", et - st);
} catch (Exception e) {
log.error("", e);
}
}
@Scheduled(cron = "0 0 2 ? * ? ")
public void taskDay() throws ParseException {
public void taskDay() throws ParseException {
try {
long st = System.currentTimeMillis();
analysisGreenCongestionPeriodService.selectCountByCrossDataOneDay();
}catch (Exception e){
log.error("",e);
long et = System.currentTimeMillis();
log.info("计算任务 taskDay 耗时:{}ms", et - st);
} catch (Exception e) {
log.error("", e);
}
}
@Scheduled(cron = "0 0 2 ? * ? ")
public void insertCrossSlowRunEventData() throws ParseException {
public void insertCrossSlowRunEventData() throws ParseException {
long st = System.currentTimeMillis();
try {
DateTime endTDateTime = DateUtil.date();
......@@ -63,13 +77,15 @@ public class AnalysisGreenCongestionPeriodWeekTask {
String sdt = startTDateTime.toString("yyyy-MM-dd HH:00:00");
//窗口截止时间
endTDateTime = DateUtil.parseDateTime(sdt).offset(DateField.HOUR,24).offset(DateField.SECOND,-1);
endTDateTime = DateUtil.parseDateTime(sdt).offset(DateField.HOUR, 24).offset(DateField.SECOND, -1);
String edt = endTDateTime.toString("yyyy-MM-dd HH:mm:ss");
eventInfoService.insertCrossSlowRunEventData(sdt,edt);
eventInfoService.insertCrossSlowRunEventData(sdt, edt);
}catch (Exception e){
log.error("",e);
} catch (Exception e) {
log.error("", e);
}
long et = System.currentTimeMillis();
log.info("计算任务 insertCrossSlowRunEventData 耗时:{}ms", et - st);
}
}
......@@ -22,14 +22,14 @@ public class AnalysisProblemCrossDayTask implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行时间:" + LocalDateTime.now());
// log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行时间:" + LocalDateTime.now());
// 干线协调方向频发拥堵/缓行路段
try {
// analysisProblemCrossDayService.insertAnalysisProblemCrossDay();
} catch (Exception e) {
log.error("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行错误" + e);
}
log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行结束时间:" + LocalDateTime.now());
// log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行结束时间:" + LocalDateTime.now());
}
/**
......
......@@ -23,14 +23,14 @@ public class AnalysisProblemCrossDirHourTask implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now());
// log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now());
// 周总体拥堵概况更新
try {
// executeCrossOverFlowTask();
}catch (Exception e){
log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e);
}
log.info("服务启动时--周总体拥堵概况更新--任务执行结束时间:" + LocalDateTime.now());
// log.info("服务启动时--周总体拥堵概况更新--任务执行结束时间:" + LocalDateTime.now());
}
/**
......
......@@ -18,14 +18,14 @@ public class GreenWaveWeekDataTask implements ApplicationRunner {
private GreenWaveWeekDataService greenWaveWeekDataService;
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now());
// log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now());
// 周总体拥堵概况更新
try {
// greenWaveWeekDataService.insertGreenWaveWeekData();
}catch (Exception e){
log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e);
}
log.info("服务启动时--周总体拥堵概况更新--任务执行结束时间:" + LocalDateTime.now());
// log.info("服务启动时--周总体拥堵概况更新--任务执行结束时间:" + LocalDateTime.now());
}
/**
......
......@@ -2,14 +2,18 @@ spring:
cloud:
nacos:
config:
server-addr: 37.12.182.29:8848
server-addr: 37.8.219.227:28848
file-extension: yaml
group: signal
namespace: signal
username: nacos
password: nacos
password: Nacos@2025
application:
# dubbo启动需要程序名称
name: signal-optimize-data-compute
main:
allow-circular-references: true
inforsuite:
license-path: d:/data/license
\ No newline at end of file
......@@ -459,7 +459,7 @@
cross_id,
concat( '[', STRING_AGG(dir_type||'',','), ']' ) as dir,
start_time,
DATE_ADD( start_time, INTERVAL 5 MINUTE ) AS end_time,
DATE_ADD( start_time, INTERVAL '5 MINUTE' ) AS end_time,
dt,
now()
FROM
......@@ -469,7 +469,8 @@
AND `status` = 2
GROUP BY
cross_id,
start_time
start_time,
dt
HAVING
count(*)>=2
ON CONFLICT (cross_id,dir,start_time)
......
......@@ -23,8 +23,9 @@
</resultMap>
<select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap">
SELECT a.green_id,a.road_direction,a.start_time,a.status FROM t_greenwave_hist a
where a.start_time between TO_TIMESTAMP(#{date},'YYYY-MM-DD 00:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 23:59:59')
SELECT a.green_id,a.road_direction,a.start_time,a.status
FROM t_greenwave_hist a
where a.start_time between (TO_TIMESTAMP(#{date},'YYYY-MM-DD 00:00:00'))::TIMESTAMP and (DATE_TRUNC('day',#{date}::date) + INTERVAL '1 DAY' - INTERVAL '1 SECOND' )::TIMESTAMP
and a.green_id is not null
order by a.green_id,a.road_direction,a.start_time
</select>
......@@ -36,7 +37,7 @@
<insert id="insertGreenCongestionPeriodData" parameterType="map">
insert into t_analysis_green_wave_congest_time_span (green_id,road_direction,week_day,congest_start_time,congest_end_time,congest_index,status,travel_time,speed,peak_type,year_week,week_start_time,week_end_time,insert_time)
SELECT a.green_id,a.road_direction,#{weekDay} as week_day, TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') as congest_start_time,TO_TIMESTAMP(DATE_ADD(#{endTime},INTERVAL 5 MINUTE),'YYYY-MM-DD HH24:MI:SS') as congest_end_time,AVG(traffic_index),#{status} as status,CEIL(AVG(trval_time)),AVG(speed),
SELECT a.green_id,a.road_direction,#{weekDay} as week_day, TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') as congest_start_time,TO_TIMESTAMP(DATE_ADD(#{endTime},INTERVAL '5 MINUTE'),'YYYY-MM-DD HH24:MI:SS') as congest_end_time,AVG(traffic_index),#{status} as status,CEIL(AVG(trval_time)),AVG(speed),
#{peakType} as peak_type,#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now()
FROM t_greenwave_hist a
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
......@@ -71,7 +72,7 @@
where t1.key_cross_id is not null and t.type = 2) t3 on t2.id = t3.id
where t3.key_cross_id is not null and dt = CAST(#{date} AS INT4) ) t4
where t4.cross_id = #{crossId}
and t4.start_time between TO_TIMESTAMP(DATE_SUB(#{startTime},INTERVAL '10 MINUTE'),'YYYY-MM-DD HH24:MI:00') and TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
and t4.start_time between DATE_SUB(#{startTime},INTERVAL '10 MINUTE') and TO_TIMESTAMP(#{endTime},'YYYY-MM-DD HH24:MI:SS')
group by t4.cross_id,t4.start_time
</select>
......@@ -84,7 +85,7 @@
#{avgFlow} as flow,#{maxFlow} as max_flow,#{peakType} as peak_type,#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{trafficThreshold} as traffic_threshold
from t_greenwave_hist a
where TO_TIMESTAMP(a.start_time,'YYYY-MM-DD HH24:MI:00') between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP(DATE_SUB(#{endTime},INTERVAL '5 MINUTE'),'YYYY-MM-DD HH24:MI:SS')
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:SS') and DATE_SUB(#{endTime},INTERVAL '5 MINUTE')
and CAST(a.green_id AS VARCHAR) = #{greenId}
and a.road_direction = #{roadDirection}
</insert>
......@@ -93,7 +94,7 @@
select t.green_id,t1.key_cross_id as cross_id, t.road_direction,t.peak_start_time as start_time,t.peak_end_time as endTime ,t.traffic_index,t.peak_type
from t_analysis_green_wave_peak_detail t
left join t_greenwave_key_cross_lane t1 on t1.green_id = t.green_id
where t.peak_start_time BETWEEN TO_TIMESTAMP(#{date},'YYYY-MM-DD 00:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 23:59:59')
where t.peak_start_time BETWEEN TO_TIMESTAMP(#{date}||' 00:00:00','YYYY-MM-DD HH24:MI:SS') and TO_TIMESTAMP(#{date}||' 23:59:59','YYYY-MM-DD HH24:MI:SS')
order by t.green_id,t1.key_cross_id ,t.road_direction,t.peak_type,t.traffic_index desc
</select>
......@@ -107,8 +108,8 @@
<select id="selectCrossTrafficThreshold" parameterType="String" resultMap="AnalysisLaneDataHistMap">
select t.cross_id,t.traffic_index
from t_cross_data_hist t
where t.start_time BETWEEN TO_TIMESTAMP(#{date},'YYYY-MM-DD 09:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 16:30:10')
and t.cross_id = #{crossId}
where t.start_time BETWEEN TO_TIMESTAMP(#{date}||'090000','YYYYMMDDHH24MISS') and TO_TIMESTAMP(#{date}||'163010','YYYYMMDDHH24MISS')
and t.cross_id = #{crossId}
order by t.traffic_index desc
</select>
......@@ -131,8 +132,22 @@
#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now()
from t_cross_data_hist a
where TO_TIMESTAMP(a.start_time,'YYYY-MM-DD HH24:MI:00') between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:00') and TO_TIMESTAMP(DATE_SUB(#{endTime},INTERVAL 5 MINUTE),'YYYY-MM-DD HH24:MI:SS')
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:00') and DATE_SUB(#{endTime},INTERVAL '5 MINUTE')
and a.cross_id = #{crossId}
ON CONFLICT ("year_week", "cross_id", "peak_start_time", "week_day", "day_type", "peak_type")
DO UPDATE SET
peak_end_time=excluded.peak_end_time ,
day_total_flow=excluded.day_total_flow ,
day_max_hour_flow=excluded.day_max_hour_flow ,
peak_max_hour_flow=excluded.peak_max_hour_flow ,
peak_traffic_index=excluded.peak_traffic_index ,
peak_capacity=excluded.peak_capacity ,
peak_avg_deay_time=excluded.peak_avg_deay_time ,
peak_max_queue_length=excluded.peak_max_queue_length ,
peak_avg_stop_times=excluded.peak_avg_stop_times ,
week_start_time=excluded.week_start_time ,
week_end_time=excluded.week_end_time ,
insert_time=excluded.insert_time
</insert>
<insert id="insertCrossDataHistByDay" parameterType="map">
......@@ -146,8 +161,22 @@
#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time,
TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{maxFlow},sum(flow),AVG(speed)
from t_cross_data_hist a
where TO_TIMESTAMP(a.start_time,'YYYY-MM-DD HH24:MI:00') between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:00') and TO_TIMESTAMP(DATE_SUB(#{endTime},INTERVAL 5 MINUTE),'YYYY-MM-DD HH24:MI:SS')
where a.start_time between TO_TIMESTAMP(#{startTime},'YYYY-MM-DD HH24:MI:00') and DATE_SUB(#{endTime},INTERVAL '5 MINUTE')
and a.cross_id = #{crossId}
ON CONFLICT ("year_week", "cross_id", "peak_start_time", "week_day", "day_type", "peak_type")
DO UPDATE SET
peak_end_time=excluded.peak_end_time ,
day_total_flow=excluded.day_total_flow ,
day_max_hour_flow=excluded.day_max_hour_flow ,
peak_max_hour_flow=excluded.peak_max_hour_flow ,
peak_traffic_index=excluded.peak_traffic_index ,
peak_capacity=excluded.peak_capacity ,
peak_avg_deay_time=excluded.peak_avg_deay_time ,
peak_max_queue_length=excluded.peak_max_queue_length ,
peak_avg_stop_times=excluded.peak_avg_stop_times ,
week_start_time=excluded.week_start_time ,
week_end_time=excluded.week_end_time ,
insert_time=excluded.insert_time
</insert>
<select id="selectCrossPeakDetail" parameterType="String" resultMap="AnalysisLaneDataHistMap">
......
......@@ -40,7 +40,7 @@
and a.dt >= CAST(#{dtStart} AS INT4) and a.dt &lt;= CAST(#{dtEnd} AS INT4)
</when>
<otherwise>
and a.dt = CAST(TO_CHAR(DATE_sub(now(), INTERVAL 24 HOUR ), 'YYYYMMDD') AS INT4)
and a.dt = CAST(TO_CHAR(DATE_sub(now(), INTERVAL '24 HOUR' ), 'YYYYMMDD') AS INT4)
</otherwise>
</choose>
and a.type in ('701', '702', '703', '707')
......@@ -57,7 +57,7 @@
and a.dt >= CAST(#{dtStart} AS INT4) and a.dt &lt;= CAST(#{dtEnd} AS INT4)
</when>
<otherwise>
and a.dt = CASE(TO_CHAR((DATE_sub(now(), INTERVAL 24 HOUR ), 'YYYYMMDD') AS INT4)
and a.dt = CAST(TO_CHAR(DATE_sub(now(), INTERVAL '24 HOUR' ), 'YYYYMMDD') AS INT4)
</otherwise>
</choose>
and a.type in ('705','706')
......@@ -70,11 +70,11 @@
from t_strategy_green_opt_hist a
where a.control_time = (select MAX(control_time)
from t_strategy_green_opt_hist
where green_id = #{greenID}
and control_time <![CDATA[ >= ]]> DATE_FORMAT(DATE_sub(#{time}, INTERVAL control_duration SECOND), 'YYYY-MM-DD HH24:MI:SS')
where green_id = CAST(#{greenID} AS VARCHAR)
and control_time <![CDATA[ >= ]]> DATE_sub(TO_TIMESTAMP(#{time}, 'YYYY-MM-DD HH24:MI:SS'), INTERVAL 1800 SECOND)
and control_time <![CDATA[ <= ]]> TO_TIMESTAMP(#{time}, 'YYYY-MM-DD HH24:MI:SS')
and response_code = 200)
and a.green_id = #{greenID}
and a.green_id = CAST(#{greenID} AS VARCHAR)
</select>
<select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
......@@ -84,7 +84,7 @@
from t_strategy_cross_result a
where a.event_id = #{eventSerialNumber}
and response_code = 200
and dt = CAST(TO_CHAR(#{time}, 'YYYYMMDD') AS INT4)
and dt = CAST(TO_CHAR(to_timestamp(#{time},'YYYY-MM-DD HH24:00:00'), 'YYYYMMDD') AS INT4)
and a.cross_id = #{crossID}
</select>
......
......@@ -230,22 +230,24 @@
TO_CHAR(a.start_time,'HH24:MI:SS'),
'~',
CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS'))
)
ORDER BY extract(epoch from (a.end_time - a.start_time)) desc
)::text
,',' ORDER BY extract(epoch from (a.end_time - a.start_time)) desc
)
,',',1) as serious_time_span,
max(extract(epoch from (a.end_time - a.start_time)) as serious_duration,
max(extract(epoch from (a.end_time - a.start_time))) as serious_duration,
STRING_AGG(CONCAT(
TO_CHAR(a.start_time,'HH24:MI:SS'),
'~',
CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS'))
)
)::text
) time_span_list,
(EXTRACT(ISODOW FROM start_time)+1) week_day,
concat(TO_CHAR(start_time,'YYYY'),'',(EXTRACT(WEEKS FROM start_time::date)+1)) year_week
concat(TO_CHAR(start_time,'YYYY'),'',(EXTRACT(WEEKS FROM start_time::date)+1))::INTEGER year_week
from t_event_info a
left join t_base_cross_info b on a.cross_id = b.id
where dt = CAST(TO_CHAR(DATE_SUB(now(),INTERVAL 1 DAY),'YYYYMMDD') AS INT4) and a.type in ('701','702','703','707')
where dt = CAST(TO_CHAR(DATE_SUB(now(),INTERVAL '1 DAY'),'YYYYMMDD') AS INT4) and a.type in ('701','702','703','707')
group by a.cross_id, b.area_id,a.category,a.type
ON CONFLICT (cross_id,event_type,dt)
......@@ -289,25 +291,28 @@
TO_CHAR(a.start_time,'HH24:MI:SS'),
'~',
CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS'))
),
',' ORDER BY extract(epoch from (a.end_time - a.start_time)) desc
)::text
,',' ORDER BY extract(epoch from (a.end_time - a.start_time)) desc
)
,',',1) as serious_time_span,
max( extract(epoch from (a.end_time - a.start_time))) as serious_duration,
STRING_AGG(CONCAT(
TO_CHAR(a.start_time,'HH24:MI:SS'),
'~',
CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS'))
),','
)::text
,','
) time_span_list,
(EXTRACT(ISODOW FROM start_time)+1) week_day,
concat(TO_CHAR(start_time,'YYYY'),'',(EXTRACT(WEEKS FROM start_time::date)+1)) year_week
concat(TO_CHAR(start_time,'YYYY'),'',(EXTRACT(WEEKS FROM start_time::date)+1))::INTEGER year_week
from (
<!-- 路口缓行计算 -->
SELECT
cross_id,
start_time,
DATE_ADD( start_time, INTERVAL 5 MINUTE ) AS end_time,
DATE_ADD( start_time, INTERVAL '5 MINUTE' ) AS end_time,
dt,
'4' AS category,
'708' AS type
......@@ -350,10 +355,10 @@
e.area_id,
d.category,
d.type,
d.dir,
cast(d.dir as int),
count(1) as event_number ,
sum( extract(epoch from (d.end_time - d.start_time) ) as duration ,
TO_TIMESTAMP(CAST(DATE_SUB(now(),INTERVAL 1 HOUR) AS VARCHAR),'YYYY-MM-DD HH24:00:00') as dh1,
sum( extract(epoch from (d.end_time - d.start_time)) ) as duration ,
TO_TIMESTAMP(CAST(DATE_SUB(now(),INTERVAL '1 HOUR') AS VARCHAR),'YYYY-MM-DD HH24:00:00') as dh1,
TO_TIMESTAMP(CAST(now() AS VARCHAR),'YYYY-MM-DD HH24:00:00') as dh2,
CAST(TO_CHAR(now(),'YYYYMMDD') AS INT4) as dt ,
now()
......@@ -363,7 +368,7 @@
from
(select a.cross_id,a.category,a.type,a.start_time,a.end_time,SUBSTR(a.dir,2,LENGTH(a.dir)-2) as dir
from t_event_info a
where a.start_time >= TO_TIMESTAMP(CAST(DATE_SUB(now(),INTERVAL 1 HOUR) AS VARCHAR),'YYYY-MM-DD HH24:00:00')
where a.start_time >= TO_TIMESTAMP(CAST(DATE_SUB(now(),INTERVAL '1 HOUR') AS VARCHAR),'YYYY-MM-DD HH24:00:00')
and a.start_time <![CDATA[ < ]]> TO_TIMESTAMP(CAST(now() AS VARCHAR),'YYYY-MM-DD HH24:00:00')
and a.type in ('701','702','703','707')
and a.dir is not null
......@@ -509,12 +514,12 @@
b.out_dir,
c.name,
b.green_id,
DATE_SUB(CURDATE_DATE, INTERVAL 1 DAY) as startTime,
DATE_SUB(CURDATE_DATE, INTERVAL 1 SECOND) as endTime
DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY) as startTime,
DATE_SUB(CURRENT_DATE, INTERVAL 1 SECOND) as endTime
FROM
( SELECT count(*) AS dir_count, cross_id, dir_type, status FROM t_cross_dir_data_hist
WHERE
start_time BETWEEN DATE_SUB(CURDATE_DATE, INTERVAL '1 DAY') AND DATE_SUB(CURDATE_DATE, INTERVAL '1 SECOND')
start_time BETWEEN DATE_SUB(CURRENT_DATE, INTERVAL '1 DAY') AND DATE_SUB(CURRENT_DATE, INTERVAL '1 SECOND')
GROUP BY cross_id, dir_type, status ) a
LEFT JOIN t_greenwave_cross b ON a.cross_id = b.cross_id
LEFT JOIN t_base_cross_info c ON a.cross_id = c.id
......
......@@ -167,12 +167,12 @@
<!-- 新增表t_analysis_problem_green_day信息 -->
<insert id="insertAnalysisProblemGreenDay">
insert into t_analysis_problem_green_day (id,green_id,area_id,event_category,event_type,event_number,event_total_time,dt,insert_time)
select uuid_generate_v4(), a.green_id, b.area_id,a.category,a.type,count(1) as event_number ,
select uuid_generate_v4(), cast(a.green_id as int), b.area_id,a.category,a.type,count(1) as event_number ,
sum( extract(epoch from (a.end_time - a.start_time)) ) as duration ,
dt , now()
from t_event_info a
left join t_greenwave_info b on a.green_id = b.id
where dt = CAST(TO_CHAR(DATE_SUB(now(),INTERVAL 1 DAY),'YYYYMMDD') AS INT4) and a.type in ('705','706') and a.green_id != ''
left join t_greenwave_info b on cast(a.green_id as int) = b.id
where dt = CAST(TO_CHAR(DATE_SUB(now(),INTERVAL '1 DAY'),'YYYYMMDD') AS INT4) and a.type in ('705','706') and a.green_id != ''
group by a.green_id, b.area_id,a.category,a.type
ON CONFLICT (green_id,event_type,dt)
DO UPDATE SET
......@@ -188,35 +188,66 @@
<!-- 新增表t_analysis_problem_green_hour信息 -->
<insert id="insertAnalysisProblemGreenHour">
insert into t_analysis_problem_green_hour (id,green_id,area_id,event_category,event_type,dir,event_number,event_total_time,window_start_time,window_end_time,dt,insert_time)
select uuid_generate_v4(), d.green_id, e.area_id,d.category,d.type,d.dir,count(1) as event_number , sum( TIMESTAMPDIFF(SECOND, d.start_time , d.end_time) ) as duration ,
TO_CHAR(DATE_SUB(now(),INTERVAL 1 HOUR),'YYYY-MM-DD HH24:00:00') as dh1, TO_CHAR(now(),'YYYY-MM-DD HH24:00:00') as dh2,
TO_CHAR(now(),'YYYYMMDD') as dt , now()
from
(select DISTINCT b.green_id,b.category,b.type,b.start_time,b.end_time, unnest(string_to_array(dir, ',')) AS dir
from
(select a.green_id,a.category,a.type,a.start_time,a.end_time,SUBSTR(a.dir,2,LENGTH(a.dir)-2) as dir
from t_event_info a
where a.start_time >= TO_TIMESTAMP(CAST(DATE_SUB(now(),INTERVAL 1 HOUR) AS VARCHAR),'YYYY-MM-DD HH24:00:00')
and a.start_time <![CDATA[ < ]]> TO_TIMESTAMP(CAST(now() AS VARCHAR),'YYYY-MM-DD HH24:00:00')
and a.type in ('705','706') and a.green_id != ''
and a.dir is not null
and length(a.dir)>2
) b
INSERT INTO t_analysis_problem_green_hour ( ID, green_id, area_id, event_category, event_type, dir, event_number, event_total_time, window_start_time, window_end_time, dt, insert_time )
SELECT
uuid_generate_v4 ( ),
d.green_id,
e.area_id,
d.category,
d.TYPE,
cast(d.dir as int),
COUNT ( 1 ) AS event_number,
SUM(EXTRACT(EPOCH FROM (d.end_time - d.start_time)))::INTEGER AS duration,
TO_CHAR( DATE_SUB ( now( ), INTERVAL '1 HOUR' ), 'YYYY-MM-DD HH24:00:00' )::TIMESTAMP AS dh1,
TO_CHAR( now( ), 'YYYY-MM-DD HH24:00:00' )::TIMESTAMP AS dh2,
TO_CHAR( now( ), 'YYYYMMDD' )::INTEGER AS dt,
now( )
FROM
(
SELECT DISTINCT
cast(b.green_id as int),
b.category,
b.TYPE,
b.start_time,
b.end_time,
UNNEST ( string_to_array( dir, ',' ) ) AS dir
FROM
(
SELECT
A.green_id,
A.category,
A.TYPE,
A.start_time,
A.end_time,
SUBSTR( A.dir, 2, LENGTH ( A.dir ) - 2 ) AS dir
FROM
t_event_info A
WHERE
A.start_time >= TO_TIMESTAMP( CAST ( DATE_SUB ( now( ), INTERVAL '1 HOUR' ) AS VARCHAR ), 'YYYY-MM-DD HH24:00:00' )
AND A.start_time &lt; TO_TIMESTAMP( CAST ( now( ) AS VARCHAR ), 'YYYY-MM-DD HH24:00:00' )
AND A.TYPE IN ( '705', '706' )
AND A.green_id != ''
AND A.dir IS NOT NULL
AND LENGTH ( A.dir ) > 2
) b
) d
left join t_greenwave_info e on d.green_id = e.id
group by d.green_id, e.area_id,d.category,d.type,d.dir
ON CONFLICT (dir,green_id,dt,event_type,window_start_time)
DO UPDATE SET
id=excluded.id,
area_id=excluded.area_id,
event_category=excluded.event_category,
dir=excluded.dir,
event_number=excluded.event_number,
event_total_time=excluded.event_total_time,
window_end_time=excluded.window_end_time,
insert_time=excluded.insert_time
;
LEFT JOIN t_greenwave_info e ON d.green_id = e.ID
GROUP BY
d.green_id,
e.area_id,
d.category,
d.TYPE,
d.dir
ON CONFLICT ( dir, green_id, dt, event_type, window_start_time ) DO
UPDATE
SET ID = excluded.ID,
area_id = excluded.area_id,
event_category = excluded.event_category,
dir = excluded.dir,
event_number = excluded.event_number,
event_total_time = excluded.event_total_time,
window_end_time = excluded.window_end_time,
insert_time = excluded.insert_time;
</insert>
<!-- 根据条件查询表t_analysis_problem_green_day信息 -->
......
......@@ -171,7 +171,7 @@
<include refid="AnalysisGreenWaveOptimizeWeekByCondition" />
</select>
<select id="getTotalityData"
resultType="net.wanji.opt.controllerv2.report.vo.GreenWaveOptimizeAnalysisDataDTO">
resultType="net.wanji.opt.vo2.report.GreenWaveOptimizeAnalysisDataDTO">
SELECT
COALESCE(sum( optimize_count ),0) AS optimize_count,
COALESCE(sum( optimize_duration ),0) AS optimize_duration,
......@@ -196,7 +196,7 @@
</foreach>
</if>
</select>
<select id="selectListByYearWeek" resultType="net.wanji.opt.controllerv2.report.vo.AnalysisGreenWaveOptimizeWeekVO">
<select id="selectListByYearWeek" resultType="net.wanji.opt.vo2.report.AnalysisGreenWaveOptimizeWeekVO">
SELECT
<include refid="Base_Column_List"/>
FROM t_analysis_green_wave_optimize_week where year_week = #{yearWeek}
......
......@@ -28,7 +28,7 @@
</foreach>
</if>
</select>
<select id="getTotalitySituation" resultType="net.wanji.opt.controllerv2.report.vo.CrossPeakAnalysis">
<select id="getTotalitySituation" resultType="net.wanji.opt.vo2.report.CrossPeakAnalysis">
SELECT
cross_id,
<if test="dayType = null">
......
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