Commit 36f9f27d authored by zhoushiguang's avatar zhoushiguang

国产化修改

parent ea984a31
...@@ -71,7 +71,7 @@ public class BaseCrossInfoCache implements CommandLineRunner { ...@@ -71,7 +71,7 @@ public class BaseCrossInfoCache implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
init(); //init();
} }
public void init() { public void init() {
......
...@@ -53,7 +53,7 @@ public class BaseCrossPhaseInfoCache implements CommandLineRunner { ...@@ -53,7 +53,7 @@ public class BaseCrossPhaseInfoCache implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
init(); // init();
} }
public void init() { public void init() {
......
...@@ -53,7 +53,7 @@ public class CrossDirTurnPhaseCache implements CommandLineRunner { ...@@ -53,7 +53,7 @@ public class CrossDirTurnPhaseCache implements CommandLineRunner {
@Override @Override
public void run(String... args) { public void run(String... args) {
init(); // init();
} }
/** /**
......
...@@ -62,7 +62,7 @@ public class CrossRidInfoCache implements CommandLineRunner { ...@@ -62,7 +62,7 @@ public class CrossRidInfoCache implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
init(); // init();
} }
public void init() { public void init() {
......
...@@ -26,7 +26,7 @@ public class GreenCrossDirInfoCache implements CommandLineRunner { ...@@ -26,7 +26,7 @@ public class GreenCrossDirInfoCache implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
try { try {
init(); // init();
} catch (Exception e) { } catch (Exception e) {
log.error("缓存加载失败:", e); log.error("缓存加载失败:", e);
throw new RuntimeException(e); throw new RuntimeException(e);
......
...@@ -28,12 +28,12 @@ public class GreenWaveInfoCache implements CommandLineRunner { ...@@ -28,12 +28,12 @@ public class GreenWaveInfoCache implements CommandLineRunner {
@Override @Override
public void run(String... args) throws Exception { public void run(String... args) throws Exception {
try { try {
List<GreenwaveInfoPO> greenWaveInfoPOS = greenwaveInfoMapper.selectAll(); // List<GreenwaveInfoPO> greenWaveInfoPOS = greenwaveInfoMapper.selectAll();
if (!CollectionUtils.isEmpty(greenWaveInfoPOS)) { // if (!CollectionUtils.isEmpty(greenWaveInfoPOS)) {
for (GreenwaveInfoPO greenWaveInfoPO : greenWaveInfoPOS) { // for (GreenwaveInfoPO greenWaveInfoPO : greenWaveInfoPOS) {
greenWaveMap.put(greenWaveInfoPO.getId(), greenWaveInfoPO); // greenWaveMap.put(greenWaveInfoPO.getId(), greenWaveInfoPO);
} // }
} // }
} catch (Exception e) { } catch (Exception e) {
log.error("绿波信息初始化失败:", e); log.error("绿波信息初始化失败:", e);
throw new RuntimeException("绿波信息初始化失败!"); throw new RuntimeException("绿波信息初始化失败!");
......
package net.wanji.opt.servicev2.judgeanalysis.impl; package net.wanji.opt.servicev2.judgeanalysis.impl;
import com.github.pagehelper.util.StringUtil; import com.github.pagehelper.util.StringUtil;
import lombok.extern.slf4j.Slf4j;
import net.wanji.databus.dao.entity.GreenwaveInfoPO; import net.wanji.databus.dao.entity.GreenwaveInfoPO;
import net.wanji.databus.dao.mapper.GreenwaveInfoMapper; import net.wanji.databus.dao.mapper.GreenwaveInfoMapper;
import net.wanji.opt.common.TimeIntervalMerger; import net.wanji.opt.common.TimeIntervalMerger;
...@@ -55,6 +56,7 @@ import java.util.stream.Collectors; ...@@ -55,6 +56,7 @@ import java.util.stream.Collectors;
* @since 2025-03-20 * @since 2025-03-20
*/ */
@Service @Service
@Slf4j
public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCongestionPeriodService { public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCongestionPeriodService {
@Resource @Resource
private AnalysisGreenCongestionPeriodMapper analysisGreenCongestionPeriodMapper; private AnalysisGreenCongestionPeriodMapper analysisGreenCongestionPeriodMapper;
...@@ -80,7 +82,10 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -80,7 +82,10 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
for (int i = 0; i < 7; i++) { for (int i = 0; i < 7; i++) {
LocalDate date = todayOfWeek.plusDays(i); LocalDate date = todayOfWeek.plusDays(i);
//获取干线数据 //获取干线数据
long st = System.currentTimeMillis();
List<AnalysisGreenCongestionPeriod> greenList = analysisGreenCongestionPeriodMapper.selectGreenDataHist(date.toString()); List<AnalysisGreenCongestionPeriod> greenList = analysisGreenCongestionPeriodMapper.selectGreenDataHist(date.toString());
long et = System.currentTimeMillis();
log.info("获取干线数据耗时:{}ms,date:{},size:{}",et-st,date.toString(),greenList.size());
LinkedList<AnalysisGreenCongestionPeriod> queue = new LinkedList<>(); LinkedList<AnalysisGreenCongestionPeriod> queue = new LinkedList<>();
String greenId = ""; String greenId = "";
String roadDirection = ""; String roadDirection = "";
...@@ -105,8 +110,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -105,8 +110,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay", i + 1); map.put("weekDay", i + 1);
map.put("roadDirection", roadDirection); map.put("roadDirection", roadDirection);
map.put("peakType", isMoning(startTime)); map.put("peakType", isMoning(startTime));
map.put("weekStartTime", todayOfWeek); map.put("weekStartTime", todayOfWeek.toString());
map.put("weekEndTime", endOfWeek); map.put("weekEndTime", endOfWeek.toString());
map.put("greenId", greenId); map.put("greenId", greenId);
map.put("status", queue.getFirst().getStatus()); map.put("status", queue.getFirst().getStatus());
//写入缓行数据 //写入缓行数据
...@@ -132,8 +137,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -132,8 +137,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay", i + 1); map.put("weekDay", i + 1);
map.put("roadDirection", roadDirection); map.put("roadDirection", roadDirection);
map.put("peakType", isMoning(startTime)); map.put("peakType", isMoning(startTime));
map.put("weekStartTime", todayOfWeek); map.put("weekStartTime", todayOfWeek.toString());
map.put("weekEndTime", endOfWeek); map.put("weekEndTime", endOfWeek.toString());
map.put("greenId", greenId); map.put("greenId", greenId);
map.put("status", queue.getFirst().getStatus()); map.put("status", queue.getFirst().getStatus());
//写入缓行数据 //写入缓行数据
...@@ -153,8 +158,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -153,8 +158,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay", i + 1); map.put("weekDay", i + 1);
map.put("roadDirection", roadDirection); map.put("roadDirection", roadDirection);
map.put("peakType", isMoning(startTime)); map.put("peakType", isMoning(startTime));
map.put("weekStartTime", todayOfWeek); map.put("weekStartTime", todayOfWeek.toString());
map.put("weekEndTime", endOfWeek); map.put("weekEndTime", endOfWeek.toString());
map.put("greenId", greenId); map.put("greenId", greenId);
map.put("status", queue.getFirst().getStatus()); map.put("status", queue.getFirst().getStatus());
//写入缓行数据 //写入缓行数据
...@@ -174,8 +179,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -174,8 +179,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay", i + 1); map.put("weekDay", i + 1);
map.put("roadDirection", roadDirection); map.put("roadDirection", roadDirection);
map.put("peakType", isMoning(startTime)); map.put("peakType", isMoning(startTime));
map.put("weekStartTime", todayOfWeek); map.put("weekStartTime", todayOfWeek.toString());
map.put("weekEndTime", endOfWeek); map.put("weekEndTime", endOfWeek.toString());
map.put("greenId", greenId); map.put("greenId", greenId);
map.put("status", queue.getLast().getStatus()); map.put("status", queue.getLast().getStatus());
//写入缓行数据 //写入缓行数据
...@@ -205,6 +210,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -205,6 +210,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
enqueue(queue, temp); enqueue(queue, temp);
} }
} }
long et1 = System.currentTimeMillis();
log.info("干线数据计算总耗时:{}ms,date:{}",et1-et,date.toString());
} }
} }
...@@ -610,8 +617,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -610,8 +617,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",i + 1); map.put("weekDay",i + 1);
map.put("roadDirection",roadDirection); map.put("roadDirection",roadDirection);
map.put("peakType",isMoning(startTime)); map.put("peakType",isMoning(startTime));
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("avgFlow",avgFlow); map.put("avgFlow",avgFlow);
map.put("greenId",temp.getGreenId()); map.put("greenId",temp.getGreenId());
...@@ -708,8 +715,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -708,8 +715,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",i + 1); map.put("weekDay",i + 1);
map.put("roadDirection",roadDirection); map.put("roadDirection",roadDirection);
map.put("peakType",3); map.put("peakType",3);
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("avgFlow",avgFlow); map.put("avgFlow",avgFlow);
map.put("greenId",queue.getFirst().getGreenId()); map.put("greenId",queue.getFirst().getGreenId());
...@@ -775,8 +782,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -775,8 +782,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",i + 1); map.put("weekDay",i + 1);
map.put("roadDirection",roadDirection); map.put("roadDirection",roadDirection);
map.put("peakType",3); map.put("peakType",3);
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("avgFlow",avgFlow); map.put("avgFlow",avgFlow);
map.put("greenId",peakDetailList.get(b).getGreenId()); map.put("greenId",peakDetailList.get(b).getGreenId());
...@@ -833,8 +840,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -833,8 +840,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay", i + 1); map.put("weekDay", i + 1);
map.put("roadDirection", roadDirection); map.put("roadDirection", roadDirection);
map.put("peakType", 3); map.put("peakType", 3);
map.put("weekStartTime", todayOfWeek); map.put("weekStartTime", todayOfWeek.toString());
map.put("weekEndTime", endOfWeek); map.put("weekEndTime", endOfWeek.toString());
map.put("maxFlow", maxFlow); map.put("maxFlow", maxFlow);
map.put("avgFlow", avgFlow); map.put("avgFlow", avgFlow);
map.put("greenId", peakDetailList.get(b).getGreenId()); map.put("greenId", peakDetailList.get(b).getGreenId());
...@@ -895,8 +902,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -895,8 +902,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",i + 1); map.put("weekDay",i + 1);
map.put("roadDirection",roadDirection); map.put("roadDirection",roadDirection);
map.put("peakType",3); map.put("peakType",3);
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("avgFlow",avgFlow); map.put("avgFlow",avgFlow);
map.put("greenId",queue.getFirst().getGreenId()); map.put("greenId",queue.getFirst().getGreenId());
...@@ -1481,8 +1488,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -1481,8 +1488,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",day); map.put("weekDay",day);
map.put("peakType",isMoning(startTime)); map.put("peakType",isMoning(startTime));
map.put("dayType",isWorkDate(day)); map.put("dayType",isWorkDate(day));
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("maxFlowDate",maxFlowDate); map.put("maxFlowDate",maxFlowDate);
map.put("sumFlowDate",sumFlowDate); map.put("sumFlowDate",sumFlowDate);
...@@ -1506,15 +1513,19 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -1506,15 +1513,19 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
list.clear(); list.clear();
crossId = temp.getCrossId(); crossId = temp.getCrossId();
//计算该路口交通指数阈值,取一天的9点至16点30之间交通指数倒序的90%的数值为动态阈值 //计算该路口交通指数阈值,取一天的9点至16点30之间交通指数倒序的90%的数值为动态阈值
List<laneDataHist> crossTrafficList = analysisGreenCongestionPeriodMapper.selectCrossTrafficThreshold(date.toString().replaceAll("-",""),crossId); try {
if(crossTrafficList.get(9).getTrafficIndex() <= 1.5) { List<laneDataHist> crossTrafficList = analysisGreenCongestionPeriodMapper.selectCrossTrafficThreshold(date.toString().replaceAll("-", ""), crossId);
if (crossTrafficList.get(9).getTrafficIndex() <= 1.5) {
trafficThreshold = 1.5; trafficThreshold = 1.5;
}else { } else {
trafficThreshold = crossTrafficList.get(9).getTrafficIndex(); trafficThreshold = crossTrafficList.get(9).getTrafficIndex();
} }
startTime = ""; startTime = "";
endTime = ""; endTime = "";
enqueue(queue,temp); enqueue(queue, temp);
}catch (Exception e) {
log.error("",e);
}
} }
} }
queue.clear(); queue.clear();
...@@ -1590,8 +1601,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -1590,8 +1601,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",day); map.put("weekDay",day);
map.put("peakType",3); map.put("peakType",3);
map.put("dayType",isWorkDate(day)); map.put("dayType",isWorkDate(day));
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("maxFlowDate",maxFlowDate); map.put("maxFlowDate",maxFlowDate);
map.put("sumFlowDate",sumFlowDate); map.put("sumFlowDate",sumFlowDate);
...@@ -1668,8 +1679,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -1668,8 +1679,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",day); map.put("weekDay",day);
map.put("peakType",3); map.put("peakType",3);
map.put("dayType",isWorkDate(day)); map.put("dayType",isWorkDate(day));
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("maxFlowDate",maxFlowDate); map.put("maxFlowDate",maxFlowDate);
map.put("sumFlowDate",sumFlowDate); map.put("sumFlowDate",sumFlowDate);
...@@ -1738,8 +1749,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -1738,8 +1749,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",day); map.put("weekDay",day);
map.put("peakType",3); map.put("peakType",3);
map.put("dayType",isWorkDate(day)); map.put("dayType",isWorkDate(day));
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("maxFlowDate",maxFlowDate); map.put("maxFlowDate",maxFlowDate);
map.put("sumFlowDate",sumFlowDate); map.put("sumFlowDate",sumFlowDate);
...@@ -1811,8 +1822,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo ...@@ -1811,8 +1822,8 @@ public class AnalysisGreenCongestionPeriodServiceImpl implements AnalysisGreenCo
map.put("weekDay",day); map.put("weekDay",day);
map.put("peakType",3); map.put("peakType",3);
map.put("dayType",isWorkDate(day)); map.put("dayType",isWorkDate(day));
map.put("weekStartTime",todayOfWeek); map.put("weekStartTime",todayOfWeek.toString());
map.put("weekEndTime",endOfWeek); map.put("weekEndTime",endOfWeek.toString());
map.put("maxFlow",maxFlow); map.put("maxFlow",maxFlow);
map.put("maxFlowDate",maxFlowDate); map.put("maxFlowDate",maxFlowDate);
map.put("sumFlowDate",sumFlowDate); map.put("sumFlowDate",sumFlowDate);
......
...@@ -13,6 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; ...@@ -13,6 +13,7 @@ import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import javax.annotation.PostConstruct;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.text.ParseException; import java.text.ParseException;
...@@ -20,7 +21,7 @@ import java.text.ParseException; ...@@ -20,7 +21,7 @@ import java.text.ParseException;
@Configurable @Configurable
@EnableScheduling @EnableScheduling
@Slf4j @Slf4j
@Profile("docker") @Profile("!dev")
public class AnalysisGreenCongestionPeriodWeekTask { public class AnalysisGreenCongestionPeriodWeekTask {
@Autowired @Autowired
private AnalysisGreenCongestionPeriodService analysisGreenCongestionPeriodService; private AnalysisGreenCongestionPeriodService analysisGreenCongestionPeriodService;
...@@ -29,16 +30,25 @@ public class AnalysisGreenCongestionPeriodWeekTask { ...@@ -29,16 +30,25 @@ public class AnalysisGreenCongestionPeriodWeekTask {
EventInfoService eventInfoService; EventInfoService eventInfoService;
@Scheduled(cron = "0 30 2 ? * 1") @Scheduled(cron = "0 30 2 ? * 1")
//@PostConstruct
public void task() throws ParseException { public void task() throws ParseException {
try { try {
long st = System.currentTimeMillis();
analysisGreenCongestionPeriodService.selectCountByCongestionPeriod(); 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.selectCountByLandData();
long et = System.currentTimeMillis();
//analysisGreenCongestionPeriodService.selectCountByCrossData(); log.info("计算任务 selectCountByLandData 耗时:{}ms", et - st);
}catch (Exception e){ } catch (Exception e) {
log.error("",e); log.error("", e);
} }
} }
...@@ -46,14 +56,18 @@ public class AnalysisGreenCongestionPeriodWeekTask { ...@@ -46,14 +56,18 @@ public class AnalysisGreenCongestionPeriodWeekTask {
public void taskDay() throws ParseException { public void taskDay() throws ParseException {
try { try {
long st = System.currentTimeMillis();
analysisGreenCongestionPeriodService.selectCountByCrossDataOneDay(); analysisGreenCongestionPeriodService.selectCountByCrossDataOneDay();
}catch (Exception e){ long et = System.currentTimeMillis();
log.error("",e); log.info("计算任务 taskDay 耗时:{}ms", et - st);
} catch (Exception e) {
log.error("", e);
} }
} }
@Scheduled(cron = "0 0 2 ? * ? ") @Scheduled(cron = "0 0 2 ? * ? ")
public void insertCrossSlowRunEventData() throws ParseException { public void insertCrossSlowRunEventData() throws ParseException {
long st = System.currentTimeMillis();
try { try {
DateTime endTDateTime = DateUtil.date(); DateTime endTDateTime = DateUtil.date();
...@@ -63,13 +77,15 @@ public class AnalysisGreenCongestionPeriodWeekTask { ...@@ -63,13 +77,15 @@ public class AnalysisGreenCongestionPeriodWeekTask {
String sdt = startTDateTime.toString("yyyy-MM-dd HH:00:00"); 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"); String edt = endTDateTime.toString("yyyy-MM-dd HH:mm:ss");
eventInfoService.insertCrossSlowRunEventData(sdt,edt); eventInfoService.insertCrossSlowRunEventData(sdt, edt);
}catch (Exception e){ } catch (Exception e) {
log.error("",e); log.error("", e);
} }
long et = System.currentTimeMillis();
log.info("计算任务 insertCrossSlowRunEventData 耗时:{}ms", et - st);
} }
} }
...@@ -22,14 +22,14 @@ public class AnalysisProblemCrossDayTask implements ApplicationRunner { ...@@ -22,14 +22,14 @@ public class AnalysisProblemCrossDayTask implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行时间:" + LocalDateTime.now()); // log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行时间:" + LocalDateTime.now());
// 干线协调方向频发拥堵/缓行路段 // 干线协调方向频发拥堵/缓行路段
try { try {
// analysisProblemCrossDayService.insertAnalysisProblemCrossDay(); // analysisProblemCrossDayService.insertAnalysisProblemCrossDay();
} catch (Exception e) { } catch (Exception e) {
log.error("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行错误" + e); log.error("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行错误" + e);
} }
log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行结束时间:" + LocalDateTime.now()); // log.info("服务启动时--干线协调方向频发拥堵/缓行路段--任务执行结束时间:" + LocalDateTime.now());
} }
/** /**
......
...@@ -23,14 +23,14 @@ public class AnalysisProblemCrossDirHourTask implements ApplicationRunner { ...@@ -23,14 +23,14 @@ public class AnalysisProblemCrossDirHourTask implements ApplicationRunner {
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now()); // log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now());
// 周总体拥堵概况更新 // 周总体拥堵概况更新
try { try {
// executeCrossOverFlowTask(); // executeCrossOverFlowTask();
}catch (Exception e){ }catch (Exception e){
log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e); log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e);
} }
log.info("服务启动时--周总体拥堵概况更新--任务执行结束时间:" + LocalDateTime.now()); // log.info("服务启动时--周总体拥堵概况更新--任务执行结束时间:" + LocalDateTime.now());
} }
/** /**
......
...@@ -18,14 +18,14 @@ public class GreenWaveWeekDataTask implements ApplicationRunner { ...@@ -18,14 +18,14 @@ public class GreenWaveWeekDataTask implements ApplicationRunner {
private GreenWaveWeekDataService greenWaveWeekDataService; private GreenWaveWeekDataService greenWaveWeekDataService;
@Override @Override
public void run(ApplicationArguments args) throws Exception { public void run(ApplicationArguments args) throws Exception {
log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now()); // log.info("服务启动时--周总体拥堵概况更新--任务执行时间:" + LocalDateTime.now());
// 周总体拥堵概况更新 // 周总体拥堵概况更新
try { try {
// greenWaveWeekDataService.insertGreenWaveWeekData(); // greenWaveWeekDataService.insertGreenWaveWeekData();
}catch (Exception e){ }catch (Exception e){
log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e); log.error("服务启动时--周总体拥堵概况更新--任务执行错误" + e);
} }
log.info("服务启动时--周总体拥堵概况更新--任务执行结束时间:" + LocalDateTime.now()); // log.info("服务启动时--周总体拥堵概况更新--任务执行结束时间:" + LocalDateTime.now());
} }
/** /**
......
...@@ -243,6 +243,25 @@ public class ReportGreenAndCrossOptimizeStatisticTask { ...@@ -243,6 +243,25 @@ public class ReportGreenAndCrossOptimizeStatisticTask {
//==========================================================================================================// //==========================================================================================================//
List<AnalysisReportCrossOptimizeDetail> optimizeList = new ArrayList<>(); List<AnalysisReportCrossOptimizeDetail> optimizeList = new ArrayList<>();
this.saveOptimizeInfo(optimizeList, list, startDate);
//==========================================================================================================//
if (!optimizeList.isEmpty()) {
analysisReportCrossOptimizeDetailMapper.insertBatch(optimizeList);
}
long et = System.currentTimeMillis();
log.info("计算路口周报-路口优化计算总耗时:{}ms,size:{}, starDate:{}", et - st, optimizeList.size(), startDate);
}
} catch (Exception e) {
log.error("计算路口周报-路口优化计算出现异常", e);
}
}
private void saveOptimizeInfo(List<AnalysisReportCrossOptimizeDetail> optimizeList, List<StrategyCrossResultEntity> list, String startDate) {
long et1 = System.currentTimeMillis();
Map<String, List<StrategyCrossResultEntity>> groupByCross = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getCurrentAlgo())); Map<String, List<StrategyCrossResultEntity>> groupByCross = list.stream().collect(Collectors.groupingBy(o -> o.getCrossId() + "_" + o.getCurrentAlgo()));
for (Map.Entry<String, List<StrategyCrossResultEntity>> entry : groupByCross.entrySet()) { for (Map.Entry<String, List<StrategyCrossResultEntity>> entry : groupByCross.entrySet()) {
String[] sps = entry.getKey().split("_"); String[] sps = entry.getKey().split("_");
...@@ -350,7 +369,7 @@ public class ReportGreenAndCrossOptimizeStatisticTask { ...@@ -350,7 +369,7 @@ public class ReportGreenAndCrossOptimizeStatisticTask {
//===========================================================================// //===========================================================================//
AiOptimizeStatistic param = new AiOptimizeStatistic(); AiOptimizeStatistic param = new AiOptimizeStatistic();
param.setCrossId(crossId); param.setCrossId(crossId);
param.setStatisticTime(Integer.valueOf( DateUtil.formatDate(lastWeekDateStartTime.toDate(), "yyyyMMdd"))); param.setStatisticTime(Integer.valueOf(DateUtil.formatDate(lastWeekDateStartTime.toDate(), "yyyyMMdd")));
param.setStrategy(Integer.valueOf(strategy)); param.setStrategy(Integer.valueOf(strategy));
List<AiOptimizeStatistic> lastOptList = aiOptimizeStatisticMapper.findAiOptimizeStatisticByCondition(param); List<AiOptimizeStatistic> lastOptList = aiOptimizeStatisticMapper.findAiOptimizeStatisticByCondition(param);
if (!lastOptList.isEmpty()) { if (!lastOptList.isEmpty()) {
...@@ -367,20 +386,6 @@ public class ReportGreenAndCrossOptimizeStatisticTask { ...@@ -367,20 +386,6 @@ public class ReportGreenAndCrossOptimizeStatisticTask {
log.info("计算路口周报-路口优分批入库耗时:{}ms,size:{} ,starDate:{}", System.currentTimeMillis() - et1, optimizeList.size(), startDate); log.info("计算路口周报-路口优分批入库耗时:{}ms,size:{} ,starDate:{}", System.currentTimeMillis() - et1, optimizeList.size(), startDate);
} }
} }
//==========================================================================================================//
if (!optimizeList.isEmpty()) {
analysisReportCrossOptimizeDetailMapper.insertBatch(optimizeList);
}
long et = System.currentTimeMillis();
log.info("计算路口周报-路口优化计算总耗时:{}ms,size:{}, starDate:{}", et - st, optimizeList.size(), startDate);
}
} catch (Exception e) {
log.error("计算路口周报-路口优化计算出现异常", e);
}
} }
......
...@@ -2,14 +2,18 @@ spring: ...@@ -2,14 +2,18 @@ spring:
cloud: cloud:
nacos: nacos:
config: config:
server-addr: 37.12.182.29:8848 server-addr: 37.8.219.227:28848
file-extension: yaml file-extension: yaml
group: signal group: signal
namespace: signal namespace: signal
username: nacos username: nacos
password: nacos password: Nacos@2025
application: application:
# dubbo启动需要程序名称 # dubbo启动需要程序名称
name: signal-optimize-data-compute name: signal-optimize-data-compute
main: main:
allow-circular-references: true allow-circular-references: true
inforsuite:
license-path: d:/data/license
\ No newline at end of file
...@@ -48,7 +48,7 @@ ...@@ -48,7 +48,7 @@
where green_id = #{greenId} where green_id = #{greenId}
</select> </select>
<!-- 统计指标查询 -->
<select id="findStatisticIndex" resultMap="BaseResultMap"> <select id="findStatisticIndex" resultMap="BaseResultMap">
SELECT SELECT
green_id, green_id,
...@@ -58,12 +58,12 @@ ...@@ -58,12 +58,12 @@
when road_direction='e2w' then '东向西' when road_direction='e2w' then '东向西'
when road_direction='w2e' then '西向东' when road_direction='w2e' then '西向东'
end ) road_direction, end ) road_direction,
DATE_FORMAT( start_time, '%Y-%m-%d %H:%i:00' ) start_time, to_char(start_time, 'YYYY-MM-DD HH24:MI:00') start_time,
round(AVG(speed),2) speed, round(AVG(speed),2) speed,
round(AVG(delay_time)) delay_time, round(AVG(delay_time)) delay_time,
round(AVG(stop_times),2) stop_times, round(AVG(stop_times),2) stop_times,
round(AVG(trval_time)) trval_time, round(AVG(trval_time)) trval_time,
round(AVG(if(queue_length=-1,null,queue_length))) queue_length, round(AVG(NULLIF(queue_length, -1))) queue_length,
speed_factor speed_factor
FROM FROM
t_greenwave_hist t_greenwave_hist
...@@ -71,12 +71,12 @@ ...@@ -71,12 +71,12 @@
<include refid="sql_query"/> <include refid="sql_query"/>
<include refid="fuzzySearch"/> <include refid="fuzzySearch"/>
<if test="startDate !=null and endDate !=null"> <if test="startDate !=null and endDate !=null">
AND start_time BETWEEN #{startDate} AND start_time BETWEEN #{startDate} AND #{endDate}
AND #{endDate}
</if> </if>
GROUP BY green_id,road_direction,DATE_FORMAT( start_time, '%Y-%m-%d %H:%i:00' ); GROUP BY green_id,road_direction, to_char(start_time, 'YYYY-MM-DD HH24:MI:00');
</select> </select>
<select id="selectRunMonitorV2" resultType="net.wanji.databus.dao.entity.GreenwaveHistPOExt"> <select id="selectRunMonitorV2" resultType="net.wanji.databus.dao.entity.GreenwaveHistPOExt">
SELECT green_id, SELECT green_id,
(case (case
...@@ -85,25 +85,25 @@ ...@@ -85,25 +85,25 @@
when road_direction='e2w' then '东向西' when road_direction='e2w' then '东向西'
when road_direction='w2e' then '西向东' when road_direction='w2e' then '西向东'
end ) roadDirection, end ) roadDirection,
DATE_FORMAT(start_time, '%H:%i') AS hour, TO_CHAR( start_time, 'HH24:MI' ) AS hour,
speed AS avg_speed, speed AS avg_speed,
traffic_index AS congestion_index, traffic_index AS congestion_index,
trval_time AS trval_time trval_time AS trval_time
FROM t_greenwave_hist FROM t_greenwave_hist
WHERE gmt_modified &gt; DATE_FORMAT(#{date}, '%Y-%m-%d 00:00:00') WHERE gmt_modified &gt; date_trunc('DAY', #{date} :: TIMESTAMP)
AND gmt_modified &lt; DATE_FORMAT(DATE_ADD(#{date}, INTERVAL 1 HOUR), '%Y-%m-%d %H:00:00') AND gmt_modified &lt; date_trunc('HOUR', #{date} :: TIMESTAMP) + interval '1 HOUR'
and green_id = #{greenId} and green_id = #{greenId}
</select> </select>
<!-- 查看路口协调/非协调方向5分钟粒度平均指标 -->
<select id="findUnCoordinateCrossIndex" resultType="map"> <select id="findUnCoordinateCrossIndex" resultType="map">
SELECT t.cross_id, SELECT t.cross_id,
t.start_time, t.start_time,
group_concat(concat(t.type,',',t.queue_length,',',T.stop_times,',',T.flow) SEPARATOR '@') index_list group_concat(concat(t.type,',',t.queue_length,',',t.stop_times,',',t.flow) SEPARATOR '@') index_list
FROM ( FROM (
SELECT cross_id, SELECT cross_id,
avg(queue_length) queue_length, avg(queue_length) queue_length,
round(avg(stop_times), 2) stop_times, round(AVG(stop_times) :: numeric, 2 ) stop_times,
DATE_FORMAT(start_time, '%Y-%m-%d %H:%i:00') start_time, DATE_FORMAT(start_time, '%Y-%m-%d %H:%i:00') start_time,
round(avg(flow)) flow, round(avg(flow)) flow,
1 as type 1 as type
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
UNION UNION
SELECT cross_id, SELECT cross_id,
avg(queue_length) queue_length, avg(queue_length) queue_length,
round(avg(stop_times), 2) stop_times, round( AVG ( stop_times ) :: numeric , 2 ) stop_times,
DATE_FORMAT(start_time, '%Y-%m-%d %H:%i:00') start_time, DATE_FORMAT(start_time, '%Y-%m-%d %H:%i:00') start_time,
round(avg(flow)) flow, round(avg(flow)) flow,
2 as type 2 as type
...@@ -129,30 +129,31 @@ ...@@ -129,30 +129,31 @@
AND start_time BETWEEN #{startDate} AND #{endDate} AND start_time BETWEEN #{startDate} AND #{endDate}
GROUP BY cross_id, start_time GROUP BY cross_id, start_time
) t ) t
GROUP BY t.cross_id,t.start_time GROUP BY t.cross_id,t.start_time;
;
</select> </select>
<!-- 绿波路口级指标趋势,支持按5分钟、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossIndex" resultMap="net.wanji.databus.dao.mapper.CrossDataHistMapper.BaseResultMap"> <select id="findGreenWaveCrossIndex" resultMap="net.wanji.databus.dao.mapper.CrossDataHistMapper.BaseResultMap">
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time, SELECT MIN(COALESCE(t.unit_time,#{startDate})) start_time,
cross_id, cross_id,
AVG(traffic_index) traffic_index, AVG(traffic_index) traffic_index,
SUM(flow) flow, SUM(flow) flow,
round(AVG(speed),2) speed, round(AVG(speed) :: NUMERIC,2) speed,
MAX(queue_length) queue_length, MAX(queue_length) queue_length,
round(AVG(stop_times),2) stop_times, round(AVG(stop_times) :: NUMERIC,2) stop_times,
round(AVG(delay_time),0) delay_time, round(AVG(delay_time),0) delay_time,
round(AVG(sturation),4) sturation round(AVG(sturation) :: NUMERIC,4) sturation
FROM FROM
( (
SELECT start_time, SELECT start_time,
(case (case
when #{groupType}=0 then start_time when #{groupType}=0 then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}=1 then to_char(date_trunc( 'HOUR', start_time ) + ( FLOOR ( EXTRACT ( MINUTE FROM start_time ) / 15 ) * 15 ) * INTERVAL '1 MINUTE',
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' ) 'YYYY-MM-DD HH24:MI:00')
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' ) when #{groupType}=2 then TO_CHAR(DATE_TRUNC( 'day', start_time ) + ( EXTRACT ( HOUR FROM start_time ) * INTERVAL '1 hour' ) + ( FLOOR ( EXTRACT ( MINUTE FROM start_time ) / 30 ) * 30 ) * INTERVAL '1 minute',
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' ) 'YYYY-MM-DD HH24:MI:00')
when #{groupType}=3 then TO_CHAR( DATE_TRUNC( 'hour', start_time ), 'YYYY-MM-DD HH24:00:00' )
when #{groupType}=4 then TO_CHAR( DATE_TRUNC( 'day', start_time ), 'YYYY-MM-DD 00:00:00' )
end end
) unit_time, ) unit_time,
cross_id, cross_id,
...@@ -175,30 +176,30 @@ ...@@ -175,30 +176,30 @@
GROUP BY t.cross_id,unit_time GROUP BY t.cross_id,unit_time
</select> </select>
<!-- 绿波路口方向级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossDirIndex" <select id="findGreenWaveCrossDirIndex"
resultMap="net.wanji.databus.dao.mapper.CrossDirDataHistMapper.BaseResultMap"> resultMap="net.wanji.databus.dao.mapper.CrossDirDataHistMapper.BaseResultMap">
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time, SELECT MIN(COALESCE(t.unit_time,#{startDate})) start_time,
cross_id, cross_id,
dir_type, dir_type,
round(AVG(traffic_index),2) traffic_index, round(AVG(traffic_index) :: NUMERIC,2) traffic_index,
SUM(flow) flow, SUM(flow) flow,
round(AVG(speed),2) speed, round(AVG(speed) :: NUMERIC,2) speed,
MAX(queue_length) queue_length, MAX(queue_length) queue_length,
round(AVG(stop_times),2) stop_times, round(AVG(stop_times) :: NUMERIC,2) stop_times,
round(AVG(delay_time),2) delay_time, round(AVG(delay_time) :: NUMERIC,2) delay_time,
round(AVG(sturation),4) sturation round(AVG(sturation) :: NUMERIC,4) sturation
FROM FROM
( (
SELECT start_time, SELECT start_time,
(case (case
when #{groupType}=0 then start_time when #{groupType}=0 then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}=1 then dt_15min
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}=2 then dt_30min
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' ) when #{groupType}=3 then dt_60min
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' ) when #{groupType}=4 then TO_CHAR( start_time, 'YYYY-MM-DD 00:00:00' )
end ELSE TO_CHAR( start_time, 'YYYY-01-01 00:00:00' )
) unit_time, END
) AS unit_time,
cross_id, cross_id,
dir_type, dir_type,
(traffic_index) traffic_index, (traffic_index) traffic_index,
...@@ -220,29 +221,30 @@ ...@@ -220,29 +221,30 @@
GROUP BY t.cross_id,t.dir_type,unit_time GROUP BY t.cross_id,t.dir_type,unit_time
</select> </select>
<!-- 绿波路口转向级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findGreenWaveCrossTurnIndex" <select id="findGreenWaveCrossTurnIndex"
resultMap="net.wanji.databus.dao.mapper.CrossTurnDataHistMapper.BaseResultMap"> resultMap="net.wanji.databus.dao.mapper.CrossTurnDataHistMapper.BaseResultMap">
SELECT MIN(ifnull(t.unit_time,#{startDate})) start_time, SELECT MIN(COALESCE(t.unit_time,#{startDate})) start_time,
cross_id crossId, cross_id crossId,
in_dir, in_dir,
turn_type, turn_type,
round(AVG(traffic_index),2) traffic_index, round(AVG(traffic_index) ::numeric,2) traffic_index,
SUM(flow) flow, SUM(flow) flow,
round(AVG(speed),2) speed, round(AVG(speed) ::numeric,2) speed,
MAX(queue_length) queue_length, MAX(queue_length) queue_length,
round(AVG(stop_times),2) stop_times, round(AVG(stop_times) ::numeric,2) stop_times,
round(AVG(delay_time),2) delay_time, round(AVG(delay_time) ::numeric,2) delay_time,
round(AVG(sturation),4) sturation round(AVG(sturation) ::numeric,4) sturation
FROM FROM
( (
SELECT start_time, SELECT start_time,
(case (case
when #{groupType}=0 then start_time when #{groupType}=0 then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}=1 then TO_CHAR(DATE_TRUNC('day', start_time) +(EXTRACT(HOUR FROM start_time) * INTERVAL '1 hour') +
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' ) (FLOOR(EXTRACT(MINUTE FROM start_time)/15)*15) * INTERVAL '1 minute','YYYY-MM-DD HH24:MI:00')
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' ) when #{groupType}=2 then TO_CHAR(DATE_TRUNC('day', start_time) +(EXTRACT(HOUR FROM start_time) * INTERVAL '1 hour') +
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' ) (FLOOR(EXTRACT(MINUTE FROM start_time)/30)*30) * INTERVAL '1 minute','YYYY-MM-DD HH24:MI:00')
when #{groupType}=3 then TO_CHAR(DATE_TRUNC('hour', start_time), 'YYYY-MM-DD HH24:00:00')
when #{groupType}=4 then TO_CHAR(DATE_TRUNC('day', start_time), 'YYYY-MM-DD 00:00:00')
end end
) unit_time, ) unit_time,
cross_id, cross_id,
...@@ -267,13 +269,13 @@ ...@@ -267,13 +269,13 @@
GROUP BY t.cross_id,t.in_dir,t.turn_type,unit_time GROUP BY t.cross_id,t.in_dir,t.turn_type,unit_time
</select> </select>
<!-- 统一接口:绿波路口车道级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findCrossObjectIndex" <select id="findCrossObjectIndex"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend"> resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT (case SELECT (case
when #{groupType}=4 then date_format(dt,'%Y-%m-%d 00:00:00') when #{groupType}='4' then TO_CHAR( to_date( dt :: TEXT, 'YYYYMMDD' ), 'YYYY-MM-DD 00:00:00' )
else else
MIN(ifnull(t.unit_time,#{startDate})) MIN (COALESCE (t.unit_time,
to_char(to_date(#{startDate},'YYYYMMDD'),'YYYY-MM-DD 00:00:00')) )
end end
) start_time, ) start_time,
cross_id , cross_id ,
...@@ -281,27 +283,27 @@ ...@@ -281,27 +283,27 @@
dir_type , dir_type ,
turn_type , turn_type ,
SUM(flow) flow, SUM(flow) flow,
round(AVG(speed),2) speed, ROUND( AVG ( speed ) :: NUMERIC, 2 ) speed,
MAX(queue_length) max_queue_length, MAX(queue_length) max_queue_length,
MIN(queue_length) min_queue_length, MIN(queue_length) min_queue_length,
round(AVG(queue_length)) avg_queue_length, ROUND( AVG ( queue_length ) :: NUMERIC ) avg_queue_length,
round(AVG(stop_times),2) stop_times, ROUND( AVG ( stop_times ) :: NUMERIC, 2 ) stop_times,
round(AVG(delay_time),2) delay_time, ROUND( AVG ( delay_time ) :: NUMERIC, 2 ) delay_time,
round(AVG(traffic_index),2) traffic_index, ROUND( AVG ( COALESCE(traffic_index, 1) ) :: NUMERIC, 2 ) traffic_index,
round(AVG(sturation),4) sturation, ROUND( AVG ( sturation ) :: NUMERIC, 4 ) sturation,
round(AVG(green_light_efficiency),4) green_light_efficiency, ROUND( AVG ( green_light_efficiency ) :: NUMERIC, 4 ) green_light_efficiency,
round(AVG(vehicle_length_ratio_mean),4) vehicle_length_ratio_mean, ROUND( AVG ( cast(vehicle_length_ratio_mean as NUMERIC) ), 4 ) vehicle_length_ratio_mean,
group_concat(service_level) service_level STRING_AGG(service_level :: text , ',') service_level
FROM FROM
( (
SELECT start_time,dt, SELECT start_time,dt,
(case (case
when #{groupType}=0 then start_time when #{groupType}='0' then start_time
when #{groupType}=1 then dt_15min when #{groupType}='1' then dt_15min
when #{groupType}=2 then dt_30min when #{groupType}='2' then dt_30min
when #{groupType}=3 then dt when #{groupType}='3' then dt_60min
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' ) when #{groupType}='4' then TO_CHAR(start_time, 'YYYY-MM-DD 00:00:00' )
else DATE_FORMAT(start_time,'%Y-01-01 00:00:00') <!-- 按查询时间范围不分粒度进行聚合处理 --> ELSE TO_CHAR( start_time, 'YYYY-01-01 00:00:00' ) <!-- 按查询时间范围不分粒度进行聚合处理 -->
end end
) unit_time, ) unit_time,
t.cross_id, t.cross_id,
...@@ -331,8 +333,8 @@ ...@@ -331,8 +333,8 @@
t2.sort as lane_no, t2.sort as lane_no,
t2.dir as dir_type, t2.dir as dir_type,
t2.turn as turn_type, t2.turn as turn_type,
null as service_level, null service_level,
null as traffic_index, 1 as traffic_index,
green_light_efficiency, green_light_efficiency,
vehicle_length_ratio_mean, vehicle_length_ratio_mean,
</when> </when>
...@@ -341,7 +343,7 @@ ...@@ -341,7 +343,7 @@
null as lane_no, null as lane_no,
null as dir_type, null as dir_type,
null as turn_type, null as turn_type,
ifnull(service_level,'A') service_level, coalesce(service_level,'A') service_level,
traffic_index, traffic_index,
green_light_efficiency, green_light_efficiency,
null as vehicle_length_ratio_mean, null as vehicle_length_ratio_mean,
...@@ -381,8 +383,10 @@ ...@@ -381,8 +383,10 @@
and t.cross_id = #{crossId} and t.cross_id = #{crossId}
</if> </if>
<if test="startDate !=null and endDate !=null"> <if test="startDate !=null and endDate !=null">
and dt >= date_format(#{startDate},'%Y%m%d') and dt &lt;= date_format(#{endDate},'%Y%m%d') AND dt >= TO_CHAR( to_date( #{startDate}, 'YYYYMMDD' ), 'YYYYMMDD' ) :: INTEGER
AND start_time >= #{startDate} and start_time &lt; #{endDate} AND dt &lt;= TO_CHAR( to_date( #{endDate}, 'YYYY-MM-DD' ), 'YYYYMMDD' ) :: INTEGER
AND start_time >= #{startDate} :: TIMESTAMP
AND start_time &lt; #{endDate} :: TIMESTAMP
</if> </if>
<choose> <choose>
<!-- 方向级 --> <!-- 方向级 -->
...@@ -430,24 +434,26 @@ ...@@ -430,24 +434,26 @@
</select> </select>
<!-- 查看干线拥堵运行状态 -->
<select id="findGreenWaveRunState" resultType="net.wanji.opt.vo.GreenWaveRunStateVO"> <select id="findGreenWaveRunState" resultType="net.wanji.opt.vo.GreenWaveRunStateVO">
select type as state,count(*) count, SELECT
SUM(TIMESTAMPDIFF(SECOND,start_time, end_time)) duration, type AS state,
TIMESTAMPDIFF(SECOND,#{startDate}, #{endDate}) total_time count(*) AS count,
from t_event_info t SUM(EXTRACT(EPOCH FROM (end_time - start_time)))::INTEGER AS duration,
where start_time >= #{startDate} and start_time &lt; #{endDate} EXTRACT(EPOCH FROM (#{endDate}::timestamp - #{startDate}::timestamp))::INTEGER AS total_time
FROM t_event_info t
WHERE start_time >= #{startDate}::timestamp
AND start_time &lt; #{endDate}::timestamp
<if test="eventTypeList!=null and eventTypeList.size>0"> <if test="eventTypeList!=null and eventTypeList.size>0">
and t.type in AND t.type IN
<foreach collection="eventTypeList" item="item" index="index" open="(" close=")" separator=","> <foreach collection="eventTypeList" item="item" index="index" open="(" close=")" separator=",">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="crossId !=null and crossId !=''"> <if test="crossId !=null and crossId !=''">
and cross_id = #{crossId} AND cross_id = #{crossId}
</if> </if>
<if test="greenId !=null and greenId !=''"> <if test="greenId !=null and greenId !=''">
and green_id = #{greenId} AND green_id = cast(#{greenId} as varchar)
</if> </if>
GROUP BY type GROUP BY type
</select> </select>
...@@ -476,21 +482,20 @@ ...@@ -476,21 +482,20 @@
</if> </if>
</select> </select>
<!-- 路口各出口方向路段指标 -->
<select id="findCrossExitRoadIndex" <select id="findCrossExitRoadIndex"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend"> resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
select t1.start_cross_id as cross_id, select t1.start_cross_id as cross_id,
t1.dir as dir_type, t1.dir as dir_type,
MIN(ifnull(t2.unit_time,#{startDate})) start_time, MIN(COALESCE(t2.unit_time :: TIMESTAMP,#{startDate}::timestamp)) start_time,
round(AVG(t2.traffic_index),2) traffic_index, round(AVG(t2.traffic_index)::numeric,2) traffic_index,
SUM(t2.flow) flow, SUM(t2.flow) flow,
round(AVG(t2.speed),2) speed, round(AVG(t2.speed)::numeric,2) speed,
MAX(t2.queue_length) max_queue_length, MAX(t2.queue_length) max_queue_length,
MIN(t2.queue_length) min_queue_length, MIN(t2.queue_length) min_queue_length,
round(AVG(t2.queue_length)) avg_queue_length, round(AVG(t2.queue_length)::numeric) avg_queue_length,
round(AVG(t2.stop_times),2) stop_times, round(AVG(t2.stop_times)::numeric,2) stop_times,
round(AVG(t2.delay_time),2) delay_time, round(AVG(t2.delay_time)::numeric,2) delay_time,
round(AVG(t2.sturation),4) sturation round(AVG(t2.sturation)::numeric,4) sturation
from from
( (
select id,start_cross_id,end_cross_id,in_dir as dir, 2 as type select id,start_cross_id,end_cross_id,in_dir as dir, 2 as type
...@@ -500,24 +505,23 @@ ...@@ -500,24 +505,23 @@
</if> </if>
) t1 ) t1
left join ( left join (
SELECT cross_id,dir_type,start_time,flow,speed,queue_length,stop_times,delay_time,sturation ,traffic_index, SELECT cross_id,dir_type,start_time,flow,speed,queue_length,stop_times,delay_time,sturation,traffic_index,
(case (case
when #{groupType}=0 then start_time when #{groupType}='0' then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}='1' then dt_15min
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}='2' then dt_30min
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' ) when #{groupType}='3' then dt_60min
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00: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 end
) unit_time ) unit_time
from t_cross_dir_data_hist from t_cross_dir_data_hist
WHERE start_time >= #{startDate} and start_time &lt; #{endDate} WHERE start_time >= #{startDate}::timestamp and start_time &lt; #{endDate}::timestamp
) t2 ) t2
on t2.cross_id=t1.end_cross_id and t2.dir_type=t1.dir on t2.cross_id=t1.end_cross_id and t2.dir_type=t1.dir
GROUP BY t1.start_cross_id,t1.dir,t2.unit_time GROUP BY t1.start_cross_id,t1.dir,t2.unit_time
</select> </select>
<!-- 路口各出口方向路段车道指标 -->
<select id="findCrossExitRoadLaneIndex" <select id="findCrossExitRoadLaneIndex"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend"> resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
select t1.end_cross_id as cross_id, select t1.end_cross_id as cross_id,
...@@ -525,15 +529,15 @@ ...@@ -525,15 +529,15 @@
t1.lane_id, t1.lane_id,
t1.lane_no, t1.lane_no,
t1.turn as turn_type, t1.turn as turn_type,
MIN(ifnull(t2.unit_time,#{startDate})) start_time, MIN(COALESCE(t2.unit_time :: TIMESTAMP,#{startDate}::timestamp)) start_time,
SUM(t2.flow) flow, SUM(t2.flow) flow,
round(AVG(t2.speed),2) speed, round(AVG(t2.speed)::numeric,2) speed,
MAX(t2.queue_length) max_queue_length, MAX(t2.queue_length) max_queue_length,
MIN(t2.queue_length) min_queue_length, MIN(t2.queue_length) min_queue_length,
round(AVG(t2.queue_length)) avg_queue_length, round(AVG(t2.queue_length)::numeric) avg_queue_length,
round(AVG(t2.stop_times),2) stop_times, round(AVG(t2.stop_times)::numeric,2) stop_times,
round(AVG(t2.delay_time),2) delay_time, round(AVG(t2.delay_time)::numeric,2) delay_time,
round(AVG(t2.sturation),4) sturation round(AVG(t2.sturation)::numeric,4) sturation
from from
( (
select t2.start_cross_id,t2.end_cross_id,t1.rid,t1.id lane_id,sort as lane_no,t1.type,t1.dir,t1.turn select t2.start_cross_id,t2.end_cross_id,t1.rid,t1.id lane_id,sort as lane_no,t1.type,t1.dir,t1.turn
...@@ -545,26 +549,28 @@ ...@@ -545,26 +549,28 @@
and start_cross_id = #{crossId} and start_cross_id = #{crossId}
</if> </if>
) t2 on t1.cross_id=t2.end_cross_id and t1.type=t2.type and t1.dir=t2.dir ) t2 on t1.cross_id=t2.end_cross_id and t1.type=t2.type and t1.dir=t2.dir
) t1 ) t1
left join ( left join (
SELECT id as lane_id,cross_id,start_time,flow,speed,queue_length,stop_times,delay_time,sturation , SELECT id as lane_id,cross_id,start_time,flow,speed,queue_length,stop_times,delay_time,sturation,
(case (case
when #{groupType}=0 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 5 ) * 5 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}='0' then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}='1' then dt_15min
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}='2' then dt_30min
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' ) when #{groupType}='3' then dt_60min
when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00: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 end
) unit_time ) unit_time
from t_lane_data_hist from t_lane_data_hist
WHERE start_time >= #{startDate} and start_time &lt; #{endDate} WHERE start_time >= #{startDate}::timestamp and start_time &lt; #{endDate}::timestamp
) t2 ) t2
on t2.lane_id=t1.lane_id on t2.lane_id=t1.lane_id
GROUP BY t1.end_cross_id,t1.dir,t1.lane_id,t1.turn,t2.unit_time GROUP BY t1.end_cross_id,t1.dir,t1.lane_id,t1.turn,t2.unit_time
ORDER BY t1.end_cross_id,t1.dir,t1.lane_no ORDER BY t1.end_cross_id,t1.dir,t1.lane_no
</select> </select>
<!--新增操作 --> <!--新增操作 -->
<insert id="save" parameterType="net.wanji.opt.entity.GreenwaveHist"> <insert id="save" parameterType="net.wanji.opt.entity.GreenwaveHist">
insert into insert into
...@@ -676,7 +682,7 @@ ...@@ -676,7 +682,7 @@
<![CDATA[ and id = #{id}]]> <![CDATA[ and id = #{id}]]>
</if> </if>
<if test="greenId != null and greenId != '' "> <if test="greenId != null and greenId != '' ">
<![CDATA[ and green_id = #{greenId}]]> <![CDATA[ and green_id = cast(#{greenId} as INTEGER)]]>
</if> </if>
<if test="status != null and status != '' "> <if test="status != null and status != '' ">
<![CDATA[ and status = #{status}]]> <![CDATA[ and status = #{status}]]>
...@@ -735,7 +741,7 @@ ...@@ -735,7 +741,7 @@
<![CDATA[ id = #{id}, ]]> <![CDATA[ id = #{id}, ]]>
</if> </if>
<if test="greenId != null and greenId != '' "> <if test="greenId != null and greenId != '' ">
<![CDATA[ green_id = #{greenId}, ]]> <![CDATA[ green_id = cast(#{greenId} as varchar)]]>
</if> </if>
<if test="status != null and status != '' "> <if test="status != null and status != '' ">
<![CDATA[ status = #{status}, ]]> <![CDATA[ status = #{status}, ]]>
...@@ -788,36 +794,36 @@ ...@@ -788,36 +794,36 @@
</set> </set>
</sql> </sql>
<!-- 统一接口:绿波路口车道级指标趋势,支持按5分钟粒度、15分钟粒度、30分钟粒度、1小时粒度汇聚 -->
<select id="findCrossObjectIndexByDay" <select id="findCrossObjectIndexByDay"
resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend"> resultType="net.wanji.opt.po.base.CrossLaneDataHistPoExtend">
SELECT SELECT
MIN(ifnull(t.unit_time,#{startDate})) start_time, MIN(COALESCE(t.unit_time :: TIMESTAMP,#{startDate}::timestamp)) start_time,
cross_id , cross_id,
lane_no , lane_no,
dir_type , dir_type,
turn_type , turn_type,
SUM(flow) flow, SUM(flow) flow,
round(AVG(speed),2) speed, ROUND(AVG(speed)::numeric,2) speed,
MAX(queue_length) max_queue_length, MAX(queue_length) max_queue_length,
MIN(queue_length) min_queue_length, MIN(queue_length) min_queue_length,
round(AVG(queue_length)) avg_queue_length, ROUND(AVG(queue_length)::numeric) avg_queue_length,
round(AVG(stop_times),2) stop_times, ROUND(AVG(stop_times)::numeric,2) stop_times,
round(AVG(delay_time),2) delay_time, ROUND(AVG(delay_time)::numeric,2) delay_time,
round(AVG(traffic_index),2) traffic_index, ROUND(AVG(traffic_index)::numeric,2) traffic_index,
round(AVG(sturation),4) sturation, ROUND(AVG(sturation)::numeric,4) sturation,
round(AVG(green_light_efficiency),4) green_light_efficiency, ROUND(AVG(green_light_efficiency)::numeric,4) green_light_efficiency,
round(AVG(vehicle_length_ratio_mean),4) vehicle_length_ratio_mean, ROUND(AVG(vehicle_length_ratio_mean ::numeric),4) vehicle_length_ratio_mean,
group_concat(service_level) service_level STRING_AGG(service_level,',') service_level
FROM FROM
( (
SELECT start_time, SELECT start_time,
(case (case
when #{groupType}=0 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 5 ) * 5 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}='0' then start_time
when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}='1' then dt_15min
when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' ) when #{groupType}='2' then dt_30min
when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' ) when #{groupType}='3' then dt_60min
else DATE_FORMAT(now(),'%Y-01-01 00: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 end
) unit_time, ) unit_time,
t.cross_id, t.cross_id,
...@@ -857,7 +863,7 @@ ...@@ -857,7 +863,7 @@
null as lane_no, null as lane_no,
null as dir_type, null as dir_type,
null as turn_type, null as turn_type,
ifnull(service_level,'A') service_level, COALESCE(service_level,'A') service_level,
traffic_index, traffic_index,
green_light_efficiency, green_light_efficiency,
null as vehicle_length_ratio_mean, null as vehicle_length_ratio_mean,
...@@ -888,7 +894,6 @@ ...@@ -888,7 +894,6 @@
<when test="objectType==4"> <when test="objectType==4">
FROM t_cross_data_hist t FROM t_cross_data_hist t
</when> </when>
<otherwise> <otherwise>
</otherwise> </otherwise>
</choose> </choose>
...@@ -897,7 +902,7 @@ ...@@ -897,7 +902,7 @@
and t.cross_id = #{crossId} and t.cross_id = #{crossId}
</if> </if>
<if test="startDate !=null and endDate !=null"> <if test="startDate !=null and endDate !=null">
and dt = date_format(#{startDate},'%Y%m%d') and dt = TO_CHAR(#{startDate}::date,'YYYYMMDD') :: integer
</if> </if>
<choose> <choose>
<!-- 方向级 --> <!-- 方向级 -->
...@@ -942,65 +947,61 @@ ...@@ -942,65 +947,61 @@
<otherwise> <otherwise>
</otherwise> </otherwise>
</choose> </choose>
</select> </select>
<!-- 按时间范围统计干线指标 -->
<select id="findGreenIndexByDateScope" resultType="net.wanji.opt.dto.report.GreenHistIndexDTO"> <select id="findGreenIndexByDateScope" resultType="net.wanji.opt.dto.report.GreenHistIndexDTO">
SELECT SELECT
a.green_id greenId, a.green_id greenId,
a.road_direction roadDirection, a.road_direction roadDirection,
b.flow, b.flow,
b.flow_all flowAll, b.flow_all flowAll,
round(AVG(a.traffic_index),2) trafficIndex, ROUND(AVG(a.traffic_index)::numeric,2) trafficIndex,
round(AVG(a.speed),2) speed, ROUND(AVG(a.speed)::numeric,2) speed,
round(AVG(a.delay_time)) delayTime, ROUND(AVG(a.delay_time)::numeric) delayTime,
round(AVG(a.stop_times),2) stopTimes, ROUND(AVG(a.stop_times)::numeric,2) stopTimes,
round(AVG(a.trval_time)) travelTime ROUND(AVG(a.trval_time)::numeric) travelTime
FROM FROM
t_greenwave_hist a t_greenwave_hist a
LEFT JOIN LEFT JOIN
( (
<!-- 取干线双向协调方向流量最大的 --> SELECT t3.green_id,t3.cross_id,SUM(t3.flow) flow,STRING_AGG(t3.flow::text,',') flow_all from (
SELECT t3.green_id,t3.cross_id,sum(t3.flow) flow,GROUP_CONCAT(t3.flow) flow_all from (
SELECT t1.green_id,t2.cross_id,t2.dir_type,t2.flow SELECT t1.green_id,t2.cross_id,t2.dir_type,t2.flow
from t_greenwave_cross t1 FROM t_greenwave_cross t1
join t_cross_dir_data_hist t2 JOIN t_cross_dir_data_hist t2
on t1.cross_id=t2.cross_id and t1.in_dir=t2.dir_type ON t1.cross_id=t2.cross_id AND t1.in_dir=t2.dir_type
where 1=1 WHERE 1=1
<if test="greenId!=null and greenId !=''"> <if test="greenId!=null and greenId !=''">
and t1.green_id = #{greenId} AND t1.green_id = #{greenId}
</if> </if>
<if test="startDate !=null and endDate !=null"> <if test="startDate !=null and endDate !=null">
AND t2.start_time BETWEEN #{startDate} AND t2.start_time BETWEEN #{startDate}::timestamp
AND #{endDate} AND #{endDate}::timestamp
</if> </if>
union UNION
SELECT t1.green_id,t2.cross_id,t2.dir_type,t2.flow SELECT t1.green_id,t2.cross_id,t2.dir_type,t2.flow
from t_greenwave_cross t1 FROM t_greenwave_cross t1
join t_cross_dir_data_hist t2 JOIN t_cross_dir_data_hist t2
on t1.cross_id=t2.cross_id and t1.out_dir=t2.dir_type ON t1.cross_id=t2.cross_id AND t1.out_dir=t2.dir_type
WHERE 1=1 WHERE 1=1
<if test="greenId!=null and greenId !=''"> <if test="greenId!=null and greenId !=''">
and t1.green_id = #{greenId} AND t1.green_id = #{greenId}
</if> </if>
<if test="startDate !=null and endDate !=null"> <if test="startDate !=null and endDate !=null">
AND t2.start_time BETWEEN #{startDate} AND t2.start_time BETWEEN #{startDate}::timestamp
AND #{endDate} AND #{endDate}::timestamp
</if> </if>
) t3 ) t3
GROUP BY t3.green_id,t3.cross_id GROUP BY t3.green_id,t3.cross_id
ORDER BY flow desc limit 1 ORDER BY flow DESC LIMIT 1
) b ) b
on a.green_id=b.green_id ON a.green_id=b.green_id
WHERE 1=1 WHERE 1=1
<if test="greenId!=null and greenId !=''"> <if test="greenId!=null and greenId !=''">
and a.green_id = #{greenId} AND a.green_id = #{greenId}
</if> </if>
<if test="startDate !=null and endDate !=null"> <if test="startDate !=null and endDate !=null">
AND a.start_time BETWEEN #{startDate} AND a.start_time BETWEEN #{startDate}::timestamp
AND #{endDate} AND #{endDate}::timestamp
</if> </if>
GROUP BY a.green_id,a.road_direction GROUP BY a.green_id,a.road_direction
</select> </select>
......
...@@ -459,7 +459,7 @@ ...@@ -459,7 +459,7 @@
cross_id, cross_id,
concat( '[', STRING_AGG(dir_type||'',','), ']' ) as dir, concat( '[', STRING_AGG(dir_type||'',','), ']' ) as dir,
start_time, start_time,
DATE_ADD( start_time, INTERVAL 5 MINUTE ) AS end_time, DATE_ADD( start_time, INTERVAL '5 MINUTE' ) AS end_time,
dt, dt,
now() now()
FROM FROM
...@@ -469,7 +469,8 @@ ...@@ -469,7 +469,8 @@
AND `status` = 2 AND `status` = 2
GROUP BY GROUP BY
cross_id, cross_id,
start_time start_time,
dt
HAVING HAVING
count(*)>=2 count(*)>=2
ON CONFLICT (cross_id,dir,start_time) ON CONFLICT (cross_id,dir,start_time)
......
...@@ -23,8 +23,9 @@ ...@@ -23,8 +23,9 @@
</resultMap> </resultMap>
<select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap"> <select id="selectGreenDataHist" parameterType="String" resultMap="AnalysisGreenCongestionPeriodMap">
SELECT a.green_id,a.road_direction,a.start_time,a.status FROM t_greenwave_hist a SELECT a.green_id,a.road_direction,a.start_time,a.status
where a.start_time between TO_TIMESTAMP(#{date},'YYYY-MM-DD 00:00:00') and TO_TIMESTAMP(#{date},'YYYY-MM-DD 23:59:59') 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 and a.green_id is not null
order by a.green_id,a.road_direction,a.start_time order by a.green_id,a.road_direction,a.start_time
</select> </select>
...@@ -36,7 +37,7 @@ ...@@ -36,7 +37,7 @@
<insert id="insertGreenCongestionPeriodData" parameterType="map"> <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) 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() #{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 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') 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 @@ ...@@ -71,7 +72,7 @@
where t1.key_cross_id is not null and t.type = 2) t3 on t2.id = t3.id 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 t3.key_cross_id is not null and dt = CAST(#{date} AS INT4) ) t4
where t4.cross_id = #{crossId} 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 group by t4.cross_id,t4.start_time
</select> </select>
...@@ -84,7 +85,7 @@ ...@@ -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, #{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 TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{trafficThreshold} as traffic_threshold
from t_greenwave_hist a 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 CAST(a.green_id AS VARCHAR) = #{greenId}
and a.road_direction = #{roadDirection} and a.road_direction = #{roadDirection}
</insert> </insert>
...@@ -93,7 +94,7 @@ ...@@ -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 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 from t_analysis_green_wave_peak_detail t
left join t_greenwave_key_cross_lane t1 on t1.green_id = t.green_id 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 order by t.green_id,t1.key_cross_id ,t.road_direction,t.peak_type,t.traffic_index desc
</select> </select>
...@@ -107,7 +108,7 @@ ...@@ -107,7 +108,7 @@
<select id="selectCrossTrafficThreshold" parameterType="String" resultMap="AnalysisLaneDataHistMap"> <select id="selectCrossTrafficThreshold" parameterType="String" resultMap="AnalysisLaneDataHistMap">
select t.cross_id,t.traffic_index select t.cross_id,t.traffic_index
from t_cross_data_hist t 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') where t.start_time BETWEEN TO_TIMESTAMP(#{date}||'090000','YYYYMMDDHH24MISS') and TO_TIMESTAMP(#{date}||'163010','YYYYMMDDHH24MISS')
and t.cross_id = #{crossId} and t.cross_id = #{crossId}
order by t.traffic_index desc order by t.traffic_index desc
</select> </select>
...@@ -131,8 +132,22 @@ ...@@ -131,8 +132,22 @@
#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time, #{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() TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now()
from t_cross_data_hist a 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} 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>
<insert id="insertCrossDataHistByDay" parameterType="map"> <insert id="insertCrossDataHistByDay" parameterType="map">
...@@ -146,8 +161,22 @@ ...@@ -146,8 +161,22 @@
#{weekNumber} as year_week,TO_TIMESTAMP(#{weekStartTime},'YYYY-MM-DD') as week_start_time, #{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) TO_TIMESTAMP(#{weekEndTime},'YYYY-MM-DD') as week_end_time,now(),#{maxFlow},sum(flow),AVG(speed)
from t_cross_data_hist a 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} 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>
<select id="selectCrossPeakDetail" parameterType="String" resultMap="AnalysisLaneDataHistMap"> <select id="selectCrossPeakDetail" parameterType="String" resultMap="AnalysisLaneDataHistMap">
......
...@@ -40,7 +40,7 @@ ...@@ -40,7 +40,7 @@
and a.dt >= CAST(#{dtStart} AS INT4) and a.dt &lt;= CAST(#{dtEnd} AS INT4) and a.dt >= CAST(#{dtStart} AS INT4) and a.dt &lt;= CAST(#{dtEnd} AS INT4)
</when> </when>
<otherwise> <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> </otherwise>
</choose> </choose>
and a.type in ('701', '702', '703', '707') and a.type in ('701', '702', '703', '707')
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
and a.dt >= CAST(#{dtStart} AS INT4) and a.dt &lt;= CAST(#{dtEnd} AS INT4) and a.dt >= CAST(#{dtStart} AS INT4) and a.dt &lt;= CAST(#{dtEnd} AS INT4)
</when> </when>
<otherwise> <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> </otherwise>
</choose> </choose>
and a.type in ('705','706') and a.type in ('705','706')
...@@ -70,11 +70,11 @@ ...@@ -70,11 +70,11 @@
from t_strategy_green_opt_hist a from t_strategy_green_opt_hist a
where a.control_time = (select MAX(control_time) where a.control_time = (select MAX(control_time)
from t_strategy_green_opt_hist from t_strategy_green_opt_hist
where green_id = #{greenID} where green_id = CAST(#{greenID} AS VARCHAR)
and control_time <![CDATA[ >= ]]> DATE_FORMAT(DATE_sub(#{time}, INTERVAL control_duration SECOND), 'YYYY-MM-DD HH24:MI:SS') 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 control_time <![CDATA[ <= ]]> TO_TIMESTAMP(#{time}, 'YYYY-MM-DD HH24:MI:SS')
and response_code = 200) and response_code = 200)
and a.green_id = #{greenID} and a.green_id = CAST(#{greenID} AS VARCHAR)
</select> </select>
<select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap"> <select id="getCrossStrategy" parameterType="String" resultMap="AnalysisProblemAndStrategyDayMap">
...@@ -84,7 +84,7 @@ ...@@ -84,7 +84,7 @@
from t_strategy_cross_result a from t_strategy_cross_result a
where a.event_id = #{eventSerialNumber} where a.event_id = #{eventSerialNumber}
and response_code = 200 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} and a.cross_id = #{crossID}
</select> </select>
......
...@@ -230,22 +230,24 @@ ...@@ -230,22 +230,24 @@
TO_CHAR(a.start_time,'HH24:MI:SS'), TO_CHAR(a.start_time,'HH24:MI:SS'),
'~', '~',
CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS')) CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS'))
) )::text
ORDER BY extract(epoch from (a.end_time - a.start_time)) desc ,',' ORDER BY extract(epoch from (a.end_time - a.start_time)) desc
) )
,',',1) as serious_time_span, ,',',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( STRING_AGG(CONCAT(
TO_CHAR(a.start_time,'HH24:MI:SS'), TO_CHAR(a.start_time,'HH24:MI:SS'),
'~', '~',
CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS')) CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS'))
) )::text
) time_span_list, ) time_span_list,
(EXTRACT(ISODOW FROM start_time)+1) week_day, (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 from t_event_info a
left join t_base_cross_info b on a.cross_id = b.id 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 group by a.cross_id, b.area_id,a.category,a.type
ON CONFLICT (cross_id,event_type,dt) ON CONFLICT (cross_id,event_type,dt)
...@@ -289,25 +291,28 @@ ...@@ -289,25 +291,28 @@
TO_CHAR(a.start_time,'HH24:MI:SS'), TO_CHAR(a.start_time,'HH24:MI:SS'),
'~', '~',
CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS')) CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS'))
), )::text
',' ORDER BY extract(epoch from (a.end_time - a.start_time)) desc ,',' ORDER BY extract(epoch from (a.end_time - a.start_time)) desc
) )
,',',1) as serious_time_span, ,',',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( STRING_AGG(CONCAT(
TO_CHAR(a.start_time,'HH24:MI:SS'), TO_CHAR(a.start_time,'HH24:MI:SS'),
'~', '~',
CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS')) CONCAT(TO_CHAR(a.end_time,'HH24:MI:SS'))
),',' )::text
,','
) time_span_list, ) time_span_list,
(EXTRACT(ISODOW FROM start_time)+1) week_day, (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 ( from (
<!-- 路口缓行计算 --> <!-- 路口缓行计算 -->
SELECT SELECT
cross_id, cross_id,
start_time, start_time,
DATE_ADD( start_time, INTERVAL 5 MINUTE ) AS end_time, DATE_ADD( start_time, INTERVAL '5 MINUTE' ) AS end_time,
dt, dt,
'4' AS category, '4' AS category,
'708' AS type '708' AS type
...@@ -350,10 +355,10 @@ ...@@ -350,10 +355,10 @@
e.area_id, e.area_id,
d.category, d.category,
d.type, d.type,
d.dir, cast(d.dir as int),
count(1) as event_number , count(1) as event_number ,
sum( extract(epoch from (d.end_time - d.start_time) ) as duration , 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(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, TO_TIMESTAMP(CAST(now() AS VARCHAR),'YYYY-MM-DD HH24:00:00') as dh2,
CAST(TO_CHAR(now(),'YYYYMMDD') AS INT4) as dt , CAST(TO_CHAR(now(),'YYYYMMDD') AS INT4) as dt ,
now() now()
...@@ -363,7 +368,7 @@ ...@@ -363,7 +368,7 @@
from 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 (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 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.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.type in ('701','702','703','707')
and a.dir is not null and a.dir is not null
...@@ -509,12 +514,12 @@ ...@@ -509,12 +514,12 @@
b.out_dir, b.out_dir,
c.name, c.name,
b.green_id, b.green_id,
DATE_SUB(CURDATE_DATE, INTERVAL 1 DAY) as startTime, DATE_SUB(CURRENT_DATE, INTERVAL 1 DAY) as startTime,
DATE_SUB(CURDATE_DATE, INTERVAL 1 SECOND) as endTime DATE_SUB(CURRENT_DATE, INTERVAL 1 SECOND) as endTime
FROM FROM
( SELECT count(*) AS dir_count, cross_id, dir_type, status FROM t_cross_dir_data_hist ( SELECT count(*) AS dir_count, cross_id, dir_type, status FROM t_cross_dir_data_hist
WHERE 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 GROUP BY cross_id, dir_type, status ) a
LEFT JOIN t_greenwave_cross b ON a.cross_id = b.cross_id 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 LEFT JOIN t_base_cross_info c ON a.cross_id = c.id
......
...@@ -167,12 +167,12 @@ ...@@ -167,12 +167,12 @@
<!-- 新增表t_analysis_problem_green_day信息 --> <!-- 新增表t_analysis_problem_green_day信息 -->
<insert id="insertAnalysisProblemGreenDay"> <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) 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 , sum( extract(epoch from (a.end_time - a.start_time)) ) as duration ,
dt , now() dt , now()
from t_event_info a from t_event_info a
left join t_greenwave_info b on a.green_id = b.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 != '' 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 group by a.green_id, b.area_id,a.category,a.type
ON CONFLICT (green_id,event_type,dt) ON CONFLICT (green_id,event_type,dt)
DO UPDATE SET DO UPDATE SET
...@@ -188,35 +188,66 @@ ...@@ -188,35 +188,66 @@
<!-- 新增表t_analysis_problem_green_hour信息 --> <!-- 新增表t_analysis_problem_green_hour信息 -->
<insert id="insertAnalysisProblemGreenHour"> <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) 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 , SELECT
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, uuid_generate_v4 ( ),
TO_CHAR(now(),'YYYYMMDD') as dt , now() d.green_id,
from e.area_id,
(select DISTINCT b.green_id,b.category,b.type,b.start_time,b.end_time, unnest(string_to_array(dir, ',')) AS dir d.category,
from d.TYPE,
(select a.green_id,a.category,a.type,a.start_time,a.end_time,SUBSTR(a.dir,2,LENGTH(a.dir)-2) as dir cast(d.dir as int),
from t_event_info a COUNT ( 1 ) AS event_number,
where a.start_time >= TO_TIMESTAMP(CAST(DATE_SUB(now(),INTERVAL 1 HOUR) AS VARCHAR),'YYYY-MM-DD HH24:00:00') SUM(EXTRACT(EPOCH FROM (d.end_time - d.start_time)))::INTEGER AS duration,
and a.start_time <![CDATA[ < ]]> TO_TIMESTAMP(CAST(now() AS VARCHAR),'YYYY-MM-DD HH24:00:00') TO_CHAR( DATE_SUB ( now( ), INTERVAL '1 HOUR' ), 'YYYY-MM-DD HH24:00:00' )::TIMESTAMP AS dh1,
and a.type in ('705','706') and a.green_id != '' TO_CHAR( now( ), 'YYYY-MM-DD HH24:00:00' )::TIMESTAMP AS dh2,
and a.dir is not null TO_CHAR( now( ), 'YYYYMMDD' )::INTEGER AS dt,
and length(a.dir)>2 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 ) b
) d ) d
left join t_greenwave_info e on d.green_id = e.id 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 GROUP BY
ON CONFLICT (dir,green_id,dt,event_type,window_start_time) d.green_id,
DO UPDATE SET e.area_id,
id=excluded.id, d.category,
area_id=excluded.area_id, d.TYPE,
event_category=excluded.event_category, d.dir
dir=excluded.dir, ON CONFLICT ( dir, green_id, dt, event_type, window_start_time ) DO
event_number=excluded.event_number, UPDATE
event_total_time=excluded.event_total_time, SET ID = excluded.ID,
window_end_time=excluded.window_end_time, area_id = excluded.area_id,
insert_time=excluded.insert_time 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> </insert>
<!-- 根据条件查询表t_analysis_problem_green_day信息 --> <!-- 根据条件查询表t_analysis_problem_green_day信息 -->
......
...@@ -171,7 +171,7 @@ ...@@ -171,7 +171,7 @@
<include refid="AnalysisGreenWaveOptimizeWeekByCondition" /> <include refid="AnalysisGreenWaveOptimizeWeekByCondition" />
</select> </select>
<select id="getTotalityData" <select id="getTotalityData"
resultType="net.wanji.opt.controllerv2.report.vo.GreenWaveOptimizeAnalysisDataDTO"> resultType="net.wanji.opt.vo2.report.GreenWaveOptimizeAnalysisDataDTO">
SELECT SELECT
COALESCE(sum( optimize_count ),0) AS optimize_count, COALESCE(sum( optimize_count ),0) AS optimize_count,
COALESCE(sum( optimize_duration ),0) AS optimize_duration, COALESCE(sum( optimize_duration ),0) AS optimize_duration,
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="selectListByYearWeek" resultType="net.wanji.opt.controllerv2.report.vo.AnalysisGreenWaveOptimizeWeekVO"> <select id="selectListByYearWeek" resultType="net.wanji.opt.vo2.report.AnalysisGreenWaveOptimizeWeekVO">
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM t_analysis_green_wave_optimize_week where year_week = #{yearWeek} FROM t_analysis_green_wave_optimize_week where year_week = #{yearWeek}
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
</foreach> </foreach>
</if> </if>
</select> </select>
<select id="getTotalitySituation" resultType="net.wanji.opt.controllerv2.report.vo.CrossPeakAnalysis"> <select id="getTotalitySituation" resultType="net.wanji.opt.vo2.report.CrossPeakAnalysis">
SELECT SELECT
cross_id, cross_id,
<if test="dayType = null"> <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