Commit 4780005e authored by wangyecheng's avatar wangyecheng

研判路口原因分析

parent 3628c3d9
package net.wanji.opt.entity.judgeanalysis; package net.wanji.opt.entity.judgeanalysis;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import java.io.Serializable;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
...@@ -79,12 +78,16 @@ public class AnalysisProblemCrossDirHour implements Serializable { ...@@ -79,12 +78,16 @@ public class AnalysisProblemCrossDirHour implements Serializable {
/***非数据库字段****/ /***非数据库字段****/
//类型名称 //类型名称
@TableField(exist = false)
private String typeName; private String typeName;
//数量统计 //数量统计
@TableField(exist = false)
private String countNumber; private String countNumber;
//按小时开始时间 //按小时开始时间
@TableField(exist = false)
private String hours_window_start_time; private String hours_window_start_time;
//开始时间 年月日时分秒 //开始时间 年月日时分秒
@TableField(exist = false)
private String winStartTime; private String winStartTime;
} }
package net.wanji.opt.dao.mapper.judgeanalysis; package net.wanji.opt.dao.mapper.judgeanalysis;
import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.databus.po.CrossLaneDataHistPO;
import net.wanji.databus.po.CrossTurnDataHistPO;
import net.wanji.opt.entity.judgeanalysis.AnalysisCrossHourOverFlowTask;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDirHour; import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDirHour;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.wanji.opt.entity.judgeanalysis.CrossCongestionLaneReasonInfo;
import net.wanji.opt.entity.report.ConfigPeakHours;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
...@@ -50,5 +56,19 @@ public interface AnalysisProblemCrossDirHourMapper extends BaseMapper<AnalysisPr ...@@ -50,5 +56,19 @@ public interface AnalysisProblemCrossDirHourMapper extends BaseMapper<AnalysisPr
List<AnalysisProblemCrossDirHour> selectDirectByProblemTrend(Map<String, Object> Map); List<AnalysisProblemCrossDirHour> selectDirectByProblemTrend(Map<String, Object> Map);
List<AnalysisCrossHourOverFlowTask> getOverFolowInfo(@Param("crossId") String crossId, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
List<CrossTurnDataHistPO> getEmptyCrossTurnInfo(@Param("dir") Integer dir,@Param("turn") Integer turn, @Param("startTimeAll") String startTimeAll,@Param("endTimeALL") String endTimeALL);
List<ConfigPeakHours> getpeakHours();
List<AnalysisProblemCrossDirHour> getunBalanceProblem(Map<String, Object> happyParamMap);
List<CrossDirDataHistPO> getunBalancePeakFlow(@Param("dir1") Integer dir1, @Param("crossId") String crossId, @Param("moningPeakStartAll") String moningPeakStartAll, @Param("moningPeakEndAll") String moningPeakEndAll);
List<AnalysisProblemCrossDirHour> getCongestionProblem(Map<String, Object> happyParamMap);
List<CrossCongestionLaneReasonInfo> getCongestionReasoninfo(@Param("crossId") String crossId, @Param("dir") Integer dir, @Param("startTimeAll") String startTimeAll, @Param("endTimeALL") String endTimeALL);
} }
package net.wanji.opt.entity.judgeanalysis;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Date;
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("t_analysis_cross_overflow_reason")
public class AnalysisCrossHourOverFlowTask {
private static final long serialVersionUID = 1L;
// 路口ID
private String crossId;
// 主要溢出方向
private int overflowDir;
// 出口道总流量
private Integer outFlowSum;
// 平均流量/5min
private Integer outFlowAvg;
// 出口道方向下一个路口进口车道数量
private Integer nextCrossLaneNum;
// 下个路口通行能力
private Integer nextCrossCapacity;
// 到下一个路口之间间距,单位米
private Integer lengthToNextCross;
// 主要溢出时段开始时间
private String overflowStartTime;
// 主要溢出时段截止时间
private String overflowEndTime;
// 主要溢出时段内溢出事件数量
private Integer overflowNum;
// 日期,格式yyyyMMdd
private int dt;
// 数据插入时间
private Date insertTime;
/*
非数据库字段
* */
//溢出开始时间小时
private String overflowStartTimeHours;
//溢出结束时间小时
private String overflowEndTimeHours;
}
package net.wanji.opt.entity.judgeanalysis; package net.wanji.opt.entity.judgeanalysis;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.*;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable; import java.io.Serializable;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
...@@ -77,11 +76,22 @@ public class AnalysisProblemCrossDirHour implements Serializable { ...@@ -77,11 +76,22 @@ public class AnalysisProblemCrossDirHour implements Serializable {
*/ */
private LocalDateTime insertTime; private LocalDateTime insertTime;
/*
* 问题发生的转向
* */
private Integer turn;
/***非数据库字段****/ /***非数据库字段****/
//类型名称 //类型名称
@TableField(exist = false)
private String typeName; private String typeName;
//数量统计 //数量统计
@TableField(exist = false)
private String countNumber; private String countNumber;
//按小时开始时间 //按小时开始时间
@TableField(exist = false)
private String hours_window_start_time; private String hours_window_start_time;
//开始时间 年月日时分秒
@TableField(exist = false)
private String winStartTime;
} }
package net.wanji.opt.entity.judgeanalysis;
import lombok.Data;
/*
路口拥堵原因返回
* */
@Data
public class CrossCongestionLaneReasonInfo {
private String crossId; // 对应 cross_id
private Integer dir; // 对应 dir
private String id; // 对应 id
private Double sturation; // 对应 avg(sturation)
}
package net.wanji.opt.servicev2.judgeanalysis.impl; package net.wanji.opt.servicev2.judgeanalysis.impl;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import net.wanji.common.utils.tool.DateUtil; import net.wanji.common.utils.tool.DateUtil;
import net.wanji.databus.po.CrossDirDataHistPO;
import net.wanji.databus.po.CrossLaneDataHistPO;
import net.wanji.databus.po.CrossTurnDataHistPO;
import net.wanji.opt.common.EsDateIndexUtil; import net.wanji.opt.common.EsDateIndexUtil;
import net.wanji.opt.common.enums.CrossDirEnum; import net.wanji.opt.common.enums.CrossDirEnum;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDay; import net.wanji.opt.common.enums.LaneTurnEnum;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDirHour;
import net.wanji.opt.dao.mapper.judgeanalysis.AnalysisProblemCrossDirHourMapper; import net.wanji.opt.dao.mapper.judgeanalysis.AnalysisProblemCrossDirHourMapper;
import net.wanji.opt.entity.judgeanalysis.AnalysisCrossHourOverFlowTask;
import net.wanji.opt.entity.judgeanalysis.AnalysisProblemCrossDirHour;
import net.wanji.opt.entity.judgeanalysis.CrossCongestionLaneReasonInfo;
import net.wanji.opt.entity.report.ConfigPeakHours;
import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemCrossDirHourService; import net.wanji.opt.servicev2.judgeanalysis.AnalysisProblemCrossDirHourService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.collections.CollectionUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
* <p> * <p>
* 路口方向按小时粒度问题分析 服务实现类 * 路口方向按小时粒度问题分析 服务实现类
* </p> * </p>
* *
* @author fengyi * @author fengyi
* @since 2025-03-20 * @since 2025-03-20
*/ */
@Service @Service
public class AnalysisProblemCrossDirHourServiceImpl extends ServiceImpl<AnalysisProblemCrossDirHourMapper, AnalysisProblemCrossDirHour> implements AnalysisProblemCrossDirHourService { public class AnalysisProblemCrossDirHourServiceImpl extends ServiceImpl<AnalysisProblemCrossDirHourMapper, AnalysisProblemCrossDirHour> implements AnalysisProblemCrossDirHourService {
@Resource @Resource
private AnalysisProblemCrossDirHourMapper analysisProblemCrossDirHourMapper; private AnalysisProblemCrossDirHourMapper analysisProblemCrossDirHourMapper;
/** /**
* 路口方向按小时粒度问题分析详情 * 路口方向按小时粒度问题分析详情
* @param id *
* @return * @param id
*/ * @return
@Override */
public AnalysisProblemCrossDirHour info(Long id) { @Override
public AnalysisProblemCrossDirHour info(Long id) {
return getById(id);
} return getById(id);
}
/**
* 路口方向按小时粒度问题分析新增 /**
* @param param 根据需要进行传值 * 路口方向按小时粒度问题分析新增
* @return *
*/ * @param param 根据需要进行传值
@Override * @return
public void add(AnalysisProblemCrossDirHour param) { */
@Override
save(param); public void add(AnalysisProblemCrossDirHour param) {
}
save(param);
/** }
* 路口方向按小时粒度问题分析修改
* @param param 根据需要进行传值 /**
* @return * 路口方向按小时粒度问题分析修改
*/ *
@Override * @param param 根据需要进行传值
public void modify(AnalysisProblemCrossDirHour param) { * @return
*/
updateById(param); @Override
} public void modify(AnalysisProblemCrossDirHour param) {
/** updateById(param);
* 路口方向按小时粒度问题分析删除(单个条目) }
* @param id
* @return /**
*/ * 路口方向按小时粒度问题分析删除(单个条目)
@Override *
public void remove(Long id) { * @param id
removeById(id); * @return
} */
@Override
/** public void remove(Long id) {
* 路口方向按小时粒度问题分析删除(多个条目) removeById(id);
* @param ids }
* @return
*/ /**
@Override * 路口方向按小时粒度问题分析删除(多个条目)
public void removes(List<Long> ids) { *
* @param ids
removeByIds(ids); * @return
} */
Map<String,Object>getParamMap(String crossId,String eventType,Integer startTime, Integer endTime){ @Override
Map<String,Object> map=new HashMap(); public void removes(List<Long> ids) {
map.put("crossId",crossId);
map.put("eventType",eventType); removeByIds(ids);
map.put("startTime",startTime); }
map.put("endTime",endTime);
return map; Map<String, Object> getParamMap(String crossId, String eventType, Integer startTime, Integer endTime) {
} Map<String, Object> map = new HashMap();
@Override map.put("crossId", crossId);
public Map<String, Object> directionByProblemTrend(String crossId, String eventType, Integer startTime, Integer endTime) throws ParseException { map.put("eventType", eventType);
List<AnalysisProblemCrossDirHour>list=analysisProblemCrossDirHourMapper.selectSingerByProblemTrend(getParamMap(crossId,eventType,startTime,endTime)); map.put("startTime", startTime);
Date sd= DateUtil.parse(startTime.toString(), EsDateIndexUtil.YMD_FORMATTER); map.put("endTime", endTime);
Date ed =DateUtil.parse(endTime.toString(),EsDateIndexUtil.YMD_FORMATTER); return map;
//存放期间全部时段 }
Set<String> sortedSet = EsDateIndexUtil.getTimeGranularityAxis("4", DateUtil.formatDate(sd,EsDateIndexUtil.YMD_HM_FORMATTER), DateUtil.formatDate(ed,EsDateIndexUtil.YMD_HM_FORMATTER));
List<Map<String ,Object>>allList=new ArrayList<>(); @Override
public Map<String, Object> directionByProblemTrend(String crossId, String eventType, Integer startTime, Integer endTime) throws ParseException {
Map<Integer, List<AnalysisProblemCrossDirHour>> groupByType = list.stream().collect(Collectors.groupingBy(o ->o.getDir(), TreeMap::new, Collectors.toList())); List<AnalysisProblemCrossDirHour> list = analysisProblemCrossDirHourMapper.selectSingerByProblemTrend(getParamMap(crossId, eventType, startTime, endTime));
Date sd = DateUtil.parse(startTime.toString(), EsDateIndexUtil.YMD_FORMATTER);
for(Map.Entry<Integer,List<AnalysisProblemCrossDirHour>>entry:groupByType.entrySet()){ Date ed = DateUtil.parse(endTime.toString(), EsDateIndexUtil.YMD_FORMATTER);
Integer key = entry.getKey(); //存放期间全部时段
//同一方向每个日期问题数量 Set<String> sortedSet = EsDateIndexUtil.getTimeGranularityAxis("4", DateUtil.formatDate(sd, EsDateIndexUtil.YMD_HM_FORMATTER), DateUtil.formatDate(ed, EsDateIndexUtil.YMD_HM_FORMATTER));
List<AnalysisProblemCrossDirHour> value = entry.getValue(); List<Map<String, Object>> allList = new ArrayList<>();
String typeName = value.get(0).getTypeName(); Map<Integer, List<AnalysisProblemCrossDirHour>> groupByType = list.stream().collect(Collectors.groupingBy(o -> o.getDir(), TreeMap::new, Collectors.toList()));
Integer dir = value.get(0).getDir();
//有实际数据的时刻点 for (Map.Entry<Integer, List<AnalysisProblemCrossDirHour>> entry : groupByType.entrySet()) {
Set<String> timeList = value.stream().map(po -> po.getDt().toString()).collect(Collectors.toSet()); Integer key = entry.getKey();
//补充缺少时段数据,保留时段字段默认值 //同一方向每个日期问题数量
for (String timesing: sortedSet){ List<AnalysisProblemCrossDirHour> value = entry.getValue();
if(!timeList.contains(timesing)){
AnalysisProblemCrossDirHour analysisProblemCrossDirHour = new AnalysisProblemCrossDirHour(); String typeName = value.get(0).getTypeName();
analysisProblemCrossDirHour.setDt(Integer.valueOf(timesing)); Integer dir = value.get(0).getDir();
analysisProblemCrossDirHour.setEventNumber(0); //有实际数据的时刻点
value.add(analysisProblemCrossDirHour); Set<String> timeList = value.stream().map(po -> po.getDt().toString()).collect(Collectors.toSet());
} //补充缺少时段数据,保留时段字段默认值
} for (String timesing : sortedSet) {
value.stream().sorted(Comparator.comparing(AnalysisProblemCrossDirHour::getDt)).collect(Collectors.toList()); if (!timeList.contains(timesing)) {
List<Integer> numberlist = value.stream().map(AnalysisProblemCrossDirHour::getEventNumber).collect(Collectors.toList()); AnalysisProblemCrossDirHour analysisProblemCrossDirHour = new AnalysisProblemCrossDirHour();
Map<String,Object>maplist=new HashMap<>(); analysisProblemCrossDirHour.setDt(Integer.valueOf(timesing));
maplist.put("eventType",key); analysisProblemCrossDirHour.setEventNumber(0);
maplist.put("eventLabel",typeName); value.add(analysisProblemCrossDirHour);
maplist.put("dir",dir); }
maplist.put("dirName", CrossDirEnum.getDesc(dir)); }
maplist.put("list",numberlist); value.stream().sorted(Comparator.comparing(AnalysisProblemCrossDirHour::getDt)).collect(Collectors.toList());
allList.add(maplist); List<Integer> numberlist = value.stream().map(AnalysisProblemCrossDirHour::getEventNumber).collect(Collectors.toList());
} Map<String, Object> maplist = new HashMap<>();
maplist.put("eventType", key);
JSONObject jsonObject = new JSONObject(); maplist.put("eventLabel", typeName);
jsonObject.put("dataList", allList); maplist.put("dir", dir);
jsonObject.put("timeList",sortedSet); maplist.put("dirName", CrossDirEnum.getDesc(dir));
return jsonObject; maplist.put("list", numberlist);
} allList.add(maplist);
Map<String,Object>getHappyParamMap(String crossId,String eventType,Integer startTime, Integer endTime){ }
Map<String,Object> map=new HashMap();
map.put("crossId",crossId); JSONObject jsonObject = new JSONObject();
map.put("eventType",eventType); jsonObject.put("dataList", allList);
map.put("startTime",startTime); jsonObject.put("timeList", sortedSet);
map.put("endTime",endTime); return jsonObject;
return map; }
}
@Override Map<String, Object> getHappyParamMap(String crossId, String eventType, Integer startTime, Integer endTime) {
public Map<String, Object> crossingHappyByProblemTrend(String crossId, String eventType,Integer startTime, Integer endTime) throws Exception { Map<String, Object> map = new HashMap();
//按照小时 map.put("crossId", crossId);
List<AnalysisProblemCrossDirHour> listHourSql =analysisProblemCrossDirHourMapper.selectHappyByProblemTrend(getHappyParamMap(crossId,eventType,startTime,endTime)); map.put("eventType", eventType);
map.put("startTime", startTime);
//按照方向 map.put("endTime", endTime);
List<AnalysisProblemCrossDirHour> happyDriectList=analysisProblemCrossDirHourMapper.selectDirectByProblemTrend(getHappyParamMap(crossId,eventType,startTime,endTime)); return map;
}
//所有时间段
Set<String> allHourset=new LinkedHashSet(); @Override
//所有方向 public Map<String, Object> crossingHappyByProblemTrend(String crossId, String eventType, Integer startTime, Integer endTime) throws Exception {
List<Map<String ,Object>> allHappyList=new ArrayList<>(); // //按照小时
// 定义时间格式 //List<AnalysisProblemCrossDirHour> listHourSql =analysisProblemCrossDirHourMapper.selectHappyByProblemTrend(getHappyParamMap(crossId,eventType,startTime,endTime));
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm"); //
//取出时间 // //按照方向
for (AnalysisProblemCrossDirHour list: listHourSql) { // List<AnalysisProblemCrossDirHour> happyDriectList=analysisProblemCrossDirHourMapper.selectDirectByProblemTrend(getHappyParamMap(crossId,eventType,startTime,endTime));
String stringHour = list.getHours_window_start_time(); //所有时间段
if(stringHour!=null ) { // Set<String> allHourset=new LinkedHashSet();
// 解析时间字符串为LocalTime对象 // //所有方向
LocalTime startTimeHour = LocalTime.parse(stringHour, formatter); // List<Map<String ,Object>> allHappyList=new ArrayList<>();
// //计算原因reasonList
// 对时间加一个小时得到结束时间 // Map<String,Object> reasonmap=new HashMap();
LocalTime endTimeHour = startTimeHour.plusHours(1); // // 定义时间格式
// DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
// 格式化开始时间和结束时间为所需的字符串格式 // //取出时间
String formattedTimeRange = startTimeHour.format(formatter) + " - " + endTimeHour.format(formatter); // for (AnalysisProblemCrossDirHour list: listHourSql) {
allHourset.add(formattedTimeRange); //
} // String stringHour = list.getHours_window_start_time();
} // if(stringHour!=null ) {
// // 解析时间字符串为LocalTime对象
//取出方向 // LocalTime startTimeHour = LocalTime.parse(stringHour, formatter);
for (AnalysisProblemCrossDirHour dirlist: happyDriectList) { //
// // 对时间加一个小时得到结束时间
Integer dirCode = dirlist.getDir(); // LocalTime endTimeHour = startTimeHour.plusHours(1);
Map<String,Object>maplist=new HashMap<>(); //
maplist.put("dir",dirCode); // // 格式化开始时间和结束时间为所需的字符串格式
maplist.put("dirName", CrossDirEnum.getDesc(dirCode)); // String formattedTimeRange = startTimeHour.format(formatter) + " - " + endTimeHour.format(formatter);
allHappyList.add(maplist); // allHourset.add(formattedTimeRange);
} // }
// }
//
JSONObject jsonObject = new JSONObject(); // //取出方向
jsonObject.put("dirList", allHappyList); // for (AnalysisProblemCrossDirHour dirlist: happyDriectList) {
jsonObject.put("timeList",allHourset); //
return jsonObject; // Integer dirCode = dirlist.getDir();
} // Map<String,Object>maplist=new HashMap<>();
// maplist.put("dir",dirCode);
// maplist.put("dirName", CrossDirEnum.getDesc(dirCode));
// allHappyList.add(maplist);
// }
// 定义时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm");
DateTimeFormatter formatterAll = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
//所有时间段
Set<String> allHourset = new LinkedHashSet();
//所有方向
List<Map<String, Object>> allHappyList = new ArrayList<>();
//计算原因reasonList
Map<String, Object> reasonmap = new HashMap();
JSONObject jsonObject = new JSONObject();
//从溢出的中间表获取t_analysis_cross_overflow_reason
if ("703".equals(eventType)) {
List<AnalysisCrossHourOverFlowTask> OverFlowList = analysisProblemCrossDirHourMapper.getOverFolowInfo(crossId, startTime, endTime);
for (AnalysisCrossHourOverFlowTask item : OverFlowList) {
Integer dirCode = item.getOverflowDir();
//溢出方向
Map<String, Object> maplist = new HashMap<>();
maplist.put("dir", dirCode);
maplist.put("dirName", CrossDirEnum.getDesc(dirCode));
allHappyList.add(maplist);
//溢出时间
String overflowStartTimeHours = item.getOverflowStartTimeHours();
String overflowEndTimeHours = item.getOverflowEndTimeHours();
String finaOverFlowTime = overflowStartTimeHours + " - " + overflowEndTimeHours;
allHourset.add(finaOverFlowTime);
//计算原因reasonList
//平均流量
Integer outFlowAvg = item.getOutFlowAvg();
//进入出口各方向总流量
Integer outFlowSum = item.getOutFlowSum();
//下个路口通行能力
Integer nextCrossCapacity = item.getNextCrossCapacity();
//下个路口的进口车道数
Integer nextCrossLaneNum = item.getNextCrossLaneNum();
//路口间距
Integer lengthToNextCross = item.getLengthToNextCross();
reasonmap.put("dirCode", dirCode);
reasonmap.put("dirName", CrossDirEnum.getDesc(dirCode));
reasonmap.put("outFlowAvg", outFlowAvg);
reasonmap.put("nextCrossCapacity", nextCrossCapacity);
//仓位 = 下游路口进口车道数 * 路口间距/7
if (nextCrossLaneNum != null && lengthToNextCross != null) {
// 公式:仓位 = 下游路口进口车道数 * 路口间距 / 7
double position = (double) nextCrossLaneNum * lengthToNextCross / 7;
// 使用 BigDecimal 四舍五入保留两位小数
BigDecimal roundedPosition = new BigDecimal(position).setScale(2, RoundingMode.HALF_UP);
// 将仓位结果乘以 3 倍
BigDecimal tripledPosition = roundedPosition.multiply(new BigDecimal(3));
// 将仓位结果乘以 3 倍 再次四舍五入保留两位小数
BigDecimal finalPositionResult = tripledPosition.setScale(2, RoundingMode.HALF_UP);
// 比较 3倍仓位数finalPositionResult 和 outFlowSum总流量
BigDecimal outFlowSumBD = new BigDecimal(outFlowSum); // 将 Integer 转换为 BigDecimal
int comparisonCangwResult = outFlowSumBD.compareTo(finalPositionResult);
if (comparisonCangwResult > 0) {
//显示 出口道总流量大于仓位乘以 3 倍的结果
reasonmap.put("flag", "true");
// System.out.println("出口道总流量大于仓位乘以 3 倍的结果");
} else {
//不显示
reasonmap.put("flag", "false");
}
}
}
//方向
jsonObject.put("dirList", allHappyList);
//时段
jsonObject.put("timeList", allHourset);
//原因
jsonObject.put("reasonList", reasonmap);
}
//空放
if ("701".equals(eventType)) {
//获取早晚高峰t_config_peak_hours
List<ConfigPeakHours> peakHoursList = analysisProblemCrossDirHourMapper.getpeakHours();
String moningPeakStart = "";
String moningPeakEnd = "";
for (ConfigPeakHours peak : peakHoursList) {
if (peak.getPeakType() == 1) {
moningPeakStart = peak.getStartTime();
moningPeakEnd = peak.getEndTime();
}
}
//所有时间段
Set<String> emptyHourset = new HashSet();
//所有方向
List<Map<String, Object>> EmptyList = new ArrayList<>();
//计算原因reasonList
Map<String, Object> reasonEmptymap = new HashMap();
//空放主要时段的时分秒
String startTimeAll = "";
String endTimeALL = "";
//早高峰时间
String startTimeTall = "";
String endTimeTall = "";
//空放按照时间取事件数量最多的
List<AnalysisProblemCrossDirHour> emptyCrossList = analysisProblemCrossDirHourMapper.selectHappyByProblemTrend(getHappyParamMap(crossId, eventType, startTime, endTime));
for (AnalysisProblemCrossDirHour list : emptyCrossList) {
if (list != null) {
//方向
Integer dir = list.getDir();
//转向
Integer turn = list.getTurn();
//空放方向
Map<String, Object> maplist = new HashMap<>();
maplist.put("dir", dir);
maplist.put("dirName", CrossDirEnum.getDesc(dir));
EmptyList.add(maplist);
reasonEmptymap.put("dir", dir);
reasonEmptymap.put("dirName", CrossDirEnum.getDesc(dir));
//转向 LaneTurnEnum.getDesc()
reasonEmptymap.put("turn", turn);
if (turn != null) {
reasonEmptymap.put("turnName", LaneTurnEnum.getDesc(turn));
}
///空放时间时分秒
String windowStartTime1 = list.getWinStartTime();
if (windowStartTime1 != null) {
// 解析时间字符串为LocalTime对象
LocalDateTime windowStartTime = LocalDateTime.parse(windowStartTime1, formatterAll);
// 对年月日时分秒的 时间加一个小时得到结束时间
LocalDateTime windowEndTime = windowStartTime.plusHours(1);
if (windowStartTime != null && windowEndTime != null) {
///空放时间时分秒
startTimeAll = windowStartTime.format(formatterAll);
endTimeALL = windowEndTime.format(formatterAll);
}
}
if (startTimeAll != null) {
//早高峰是时间段
LocalDateTime givenTime = LocalDateTime.parse(startTimeAll, formatterAll);
// t_config_peak_hours 早高峰时间段
LocalTime morningPeakStart = LocalTime.parse(moningPeakStart);
LocalTime morningPeakEnd = LocalTime.parse(moningPeakEnd);
// 拼接日期和时间
LocalDateTime morningPeakStartTime = givenTime.with(morningPeakStart);
LocalDateTime morningPeakEndTime = givenTime.with(morningPeakEnd);
//主要空放当日早高峰开始结束时间
startTimeTall = morningPeakStartTime.format(formatterAll);
endTimeTall = morningPeakEndTime.format(formatterAll);
}
//空放时间小时级别
String stringHour = list.getHours_window_start_time();
if (stringHour != null) {
// 解析时间字符串为LocalTime对象
LocalTime startTimeHour = LocalTime.parse(stringHour, formatter);
// 对时间加一个小时得到结束时间
LocalTime endTimeHour = startTimeHour.plusHours(1);
// 格式化开始时间和结束时间为所需的字符串格式
String formattedTimeRange = startTimeHour.format(formatter) + " - " + endTimeHour.format(formatter);
emptyHourset.add(formattedTimeRange);
}
//查询主要空放时间的转向的流量
List<CrossTurnDataHistPO> CrossTurnDataHistList = analysisProblemCrossDirHourMapper.getEmptyCrossTurnInfo(dir, turn, startTimeAll, endTimeALL);
Integer emptyFlow = 0;
for (CrossTurnDataHistPO item : CrossTurnDataHistList) {
emptyFlow = item.getFlow();
}
//查询高峰空放时间的转向的流量
List<CrossTurnDataHistPO> CrossTurnTallList = analysisProblemCrossDirHourMapper.getEmptyCrossTurnInfo(dir, turn, startTimeTall, endTimeTall);
Integer emptyTallFlow = 0;
for (CrossTurnDataHistPO turnitem : CrossTurnTallList) {
emptyTallFlow = turnitem.flow;
}
//高峰流量的50%
BigDecimal tallFolwValue = new BigDecimal(emptyTallFlow);
BigDecimal resultHalf = tallFolwValue.multiply(new BigDecimal("0.5"));
BigDecimal tallFlowHalf = resultHalf.setScale(2, RoundingMode.HALF_UP);
// 将Integer转换为BigDecimal
BigDecimal avgemptyFlow = new BigDecimal(emptyFlow);
int comparisonCangwResult = avgemptyFlow.compareTo(tallFlowHalf);
//空放平均流量小于高峰计算的平均流量50%
if (comparisonCangwResult < 0) {
reasonEmptymap.put("flag", true);
// System.out.println("空放平均流量小于高峰计算的平均流量50%");
} else {
//不显示
reasonEmptymap.put("flag", false);
}
}
}
//方向
jsonObject.put("dirList", EmptyList);
//时段
jsonObject.put("timeList", emptyHourset);
//原因
jsonObject.put("reasonList", reasonEmptymap);
}
//失衡
if ("702".equals(eventType)) {
//所有时间段
Set<String> hourSet = new LinkedHashSet();
//所有方向
List<Map<String, Object>> dirList = new ArrayList<>();
//计算原因reasonList
Map<String, Object> reasonUnblancemap = new HashMap();
//失衡主要时段的时分秒
String startTimeAll = "";
String endTimeALL = "";
//早高峰开始结束时间全部
String moningPeakStartAll = "";
String moningPeakEndAll = "";
//晚高峰开始结束时间全部
String eveningPeakStartAll = "";
String eveningPeakEndAll = "";
//获取早晚高峰t_config_peak_hours
List<ConfigPeakHours> peakHoursList = analysisProblemCrossDirHourMapper.getpeakHours();
String moningPeakStart = "";
String moningPeakEnd = "";
String eveningPeakStart = "";
String eveningPeakEnd = "";
for (ConfigPeakHours peak : peakHoursList) {
if (peak.getPeakType() == 1) {
moningPeakStart = peak.getStartTime();
moningPeakEnd = peak.getEndTime();
}
if (peak.getPeakType() == 2) {
eveningPeakStart = peak.getStartTime();
eveningPeakEnd = peak.getEndTime();
}
}
//失衡直接取事件数量最多的前两条
List<AnalysisProblemCrossDirHour> unblanceCrossList = analysisProblemCrossDirHourMapper.getunBalanceProblem(getHappyParamMap(crossId, eventType, startTime, endTime));
//失衡时间小时级别
LocalTime startTimeHour = null;
LocalTime endTimeHour = null;
for (AnalysisProblemCrossDirHour unblanceitem : unblanceCrossList) {
//方向
Integer dir = unblanceitem.getDir();
//空放方向
Map<String, Object> maplist = new HashMap<>();
maplist.put("dir", dir);
maplist.put("dirName", CrossDirEnum.getDesc(dir));
dirList.add(maplist);
String stringHour = unblanceitem.getHours_window_start_time();
if (stringHour != null) {
// 解析时间字符串为LocalTime对象 开始时间
startTimeHour = LocalTime.parse(stringHour, formatter);
// 对开始时间加一个小时得到结束时间
endTimeHour = startTimeHour.plusHours(1);
// 失衡格式化开始时间和结束时间为所需的字符串格式
String formattedTimeRange = startTimeHour.format(formatter) + " - " + endTimeHour.format(formatter);
hourSet.add(formattedTimeRange);
}
///失衡时间年月日时分秒
String windowStartTime1 = unblanceitem.getWinStartTime();
if (windowStartTime1 != null) {
// 解析时间字符串为LocalTime对象
LocalDateTime windowStartTime = LocalDateTime.parse(windowStartTime1, formatterAll);
// 对年月日时分秒的 时间加一个小时得到结束时间
LocalDateTime windowEndTime = windowStartTime.plusHours(1);
if (windowStartTime != null && windowEndTime != null) {
///失衡时间时分秒
startTimeAll = windowStartTime.format(formatterAll);
endTimeALL = windowEndTime.format(formatterAll);
}
}
}
//拼接主要失衡早晚高峰
if (startTimeAll != null) {
//早高峰是时间段
LocalDateTime givenTime = LocalDateTime.parse(startTimeAll, formatterAll);
// t_config_peak_hours 早高峰时间段
LocalTime morningPeakStart = LocalTime.parse(moningPeakStart);
LocalTime morningPeakEnd = LocalTime.parse(moningPeakEnd);
// 拼接日期和时间
LocalDateTime morningPeakStartTime = givenTime.with(morningPeakStart);
LocalDateTime morningPeakEndTime = givenTime.with(morningPeakEnd);
//主要失衡当日早高峰开始结束时间
moningPeakStartAll = morningPeakStartTime.format(formatterAll);
moningPeakEndAll = morningPeakEndTime.format(formatterAll);
//晚高峰时间段
LocalDateTime givenTime1 = LocalDateTime.parse(startTimeAll, formatterAll);
// t_config_peak_hours 晚高峰时间段
LocalTime eveningPeakStart1 = LocalTime.parse(eveningPeakStart);
LocalTime eveningPeakEnd1 = LocalTime.parse(eveningPeakEnd);
// 拼接日期和时间
LocalDateTime eveningPeakStartTime = givenTime1.with(eveningPeakStart1);
LocalDateTime eveningPeakEndTime = givenTime1.with(eveningPeakEnd1);
//主要失衡当日晚高峰开始结束时间
eveningPeakStartAll = eveningPeakStartTime.format(formatterAll);
eveningPeakEndAll = eveningPeakEndTime.format(formatterAll);
}
//失衡的有两个方向
Integer dir1 = 0;
Integer dir2 = 0;
if (CollectionUtils.isNotEmpty(dirList)) {
dir1 = (Integer) dirList.get(0).get("dir");
dir2 = (Integer) dirList.get(1).get("dir");
reasonUnblancemap.put("dir1", dir1);
reasonUnblancemap.put("dir2", dir2);
reasonUnblancemap.put("dirName1", CrossDirEnum.getDesc(dir1));
reasonUnblancemap.put("dirName2", CrossDirEnum.getDesc(dir2));
}
//判断失衡时段是否在早晚高峰
//早高峰开始时间
LocalTime refStart1 = LocalTime.parse(moningPeakStart);
//早高峰结束时间
LocalTime refEnd1 = LocalTime.parse(moningPeakEnd);
//晚高峰开始时间
LocalTime refStart2 = LocalTime.parse(eveningPeakStart);
//晚高峰结束时间
LocalTime refEnd2 = LocalTime.parse(eveningPeakEnd);
//判断失衡时段是否在早晚高峰
boolean isWithinUnionRange = isWithinUnion(startTimeHour, endTimeHour, refStart1, refEnd1, refStart2, refEnd2);
//失衡时段在早晚高峰
if (isWithinUnionRange == true) {
//查询dir1早高峰的平均流量
List<CrossDirDataHistPO> morningPeakdir1List = analysisProblemCrossDirHourMapper.getunBalancePeakFlow(dir1, crossId, moningPeakStartAll, moningPeakEndAll);
Integer morningflow1 = 1;
for (CrossDirDataHistPO dir1Item : morningPeakdir1List) {
if (dir1Item != null) {
morningflow1 = dir1Item.getFlow();
}
}
//查询dir2早高峰的平均流量
List<CrossDirDataHistPO> morningPeakdir2List = analysisProblemCrossDirHourMapper.getunBalancePeakFlow(dir2, crossId, moningPeakStartAll, moningPeakEndAll);
Integer morningflow2 = 1;
for (CrossDirDataHistPO dir2Item : morningPeakdir2List) {
if (dir2Item != null) {
morningflow2 = dir2Item.getFlow();
}
}
//查询dir1的晚高峰的平均流量
List<CrossDirDataHistPO> eveningPeakdir1List = analysisProblemCrossDirHourMapper.getunBalancePeakFlow(dir1, crossId, eveningPeakStartAll, eveningPeakEndAll);
Integer eveningflow1 = 1;
for (CrossDirDataHistPO dir3Item : eveningPeakdir1List) {
if (dir3Item != null) {
eveningflow1 = dir3Item.getFlow();
}
}
//查询dir2的晚高峰的平均流量
List<CrossDirDataHistPO> eveningPeakdir2List = analysisProblemCrossDirHourMapper.getunBalancePeakFlow(dir2, crossId, eveningPeakStartAll, eveningPeakEndAll);
Integer eveningflow2 = 1;
for (CrossDirDataHistPO dir4item : eveningPeakdir2List) {
if (dir4item != null) {
eveningflow2 = dir4item.getFlow();
}
}
//计算早晚高峰流量比值
Double result = calculateAbsoluteDifference(morningflow1, morningflow2, eveningflow1, eveningflow2);
// 判断结果是否大于 0.5
double unblance = 0.5;
if (result > unblance) {
reasonUnblancemap.put("greaterthan", true);
// System.out.println("结果大于 0.5");
} else {
reasonUnblancemap.put("greaterthan", false);
//System.out.println("结果小于或等于 0.5");
}
reasonUnblancemap.put("morthingOrnigth", true);
} else {
reasonUnblancemap.put("morthingOrnigth", false);
}
//方向
jsonObject.put("dirList", dirList);
//时段
jsonObject.put("timeList", hourSet);
//原因
jsonObject.put("reasonList", reasonUnblancemap);
}
//拥堵
if ("707".equals(eventType)) {
//所有时间段
Set<String> hourSet = new HashSet();
//所有方向
List<Map<String, Object>> dirList = new ArrayList<>();
//计算原因reasonList
Map<String, Object> congestionReasonMap = new HashMap();
//拥堵的主要时段的时分秒
String startTimeAll = "";
String endTimeALL = "";
//拥堵直接取事件数量最多的前两条
List<AnalysisProblemCrossDirHour> congestionCrossList = analysisProblemCrossDirHourMapper.getCongestionProblem(getHappyParamMap(crossId, eventType, startTime, endTime));
Integer dir = 0;
//拥堵
for (AnalysisProblemCrossDirHour congestionitem : congestionCrossList) {
//拥堵方向
dir = congestionitem.getDir();
//拥堵方向
Map<String, Object> maplist = new HashMap<>();
maplist.put("dir", dir);
maplist.put("dirName", CrossDirEnum.getDesc(dir));
dirList.add(maplist);
congestionReasonMap.put("dir", dir);
congestionReasonMap.put("dirName", CrossDirEnum.getDesc(dir));
//拥堵时间段
String stringHour = congestionitem.getHours_window_start_time();
if (stringHour != null) {
// 解析时间字符串为LocalTime对象
LocalTime startTimeHour = LocalTime.parse(stringHour, formatter);
// 对时间加一个小时得到结束时间
LocalTime endTimeHour = startTimeHour.plusHours(1);
// 格式化开始时间和结束时间为所需的字符串格式
String formattedTimeRange = startTimeHour.format(formatter) + " - " + endTimeHour.format(formatter);
hourSet.add(formattedTimeRange);
}
///空放时间时分秒
String windowStartTime1 = congestionitem.getWinStartTime();
if (windowStartTime1 != null) {
// 解析时间字符串为LocalTime对象
LocalDateTime windowStartTime = LocalDateTime.parse(windowStartTime1, formatterAll);
// 对年月日时分秒的 时间加一个小时得到结束时间
LocalDateTime windowEndTime = windowStartTime.plusHours(1);
if (windowStartTime != null && windowEndTime != null) {
///空放时间时分秒
startTimeAll = windowStartTime.format(formatterAll);
endTimeALL = windowEndTime.format(formatterAll);
}
}
}
List<CrossCongestionLaneReasonInfo> congestionList = analysisProblemCrossDirHourMapper.getCongestionReasoninfo(crossId, dir, startTimeAll, endTimeALL);
//总的数量
int total = congestionList.size();
//统计车道饱和度大于0.8 车道数量
long count = congestionList.stream().filter(info -> info.getSturation() != null && info.getSturation() > 0.8).count();
//若单方向(如北进口)车道饱和度大于0.8的车道数量大于该方向车道数的50%,
Boolean result = count * 2 > total;
if (result == true) {
congestionReasonMap.put("flag", true);
} else {
congestionReasonMap.put("flag", false);
}
//方向
jsonObject.put("dirList", dirList);
//时段
jsonObject.put("timeList", hourSet);
//原因
jsonObject.put("reasonList", congestionReasonMap);
}
return jsonObject;
}
/**
* 计算两个除法结果差值的绝对值
*
* @param a
* @param b
* @param c
* @param d
* @return
*/
public static double calculateAbsoluteDifference(Integer a, Integer b, Integer c, Integer d) {
// 将整数转换为 double 进行除法运算
double division1 = (double) a / b;
double division2 = (double) c / d;
// 计算差值并取绝对值
return Math.abs(division1 - division2);
}
/**
* 判断目标时间段是否在两个参考时间段的并集范围内
*
* @param targetStart 目标时间段起点
* @param targetEnd 目标时间段终点
* @param refStart1 参考时间段 1 起点
* @param refEnd1 参考时间段 1 终点
* @param refStart2 参考时间段 2 起点
* @param refEnd2 参考时间段 2 终点
* @return true 表示目标时间段在并集范围内,false 表示不在
*/
public static boolean isWithinUnion(LocalTime targetStart, LocalTime targetEnd,
LocalTime refStart1, LocalTime refEnd1,
LocalTime refStart2, LocalTime refEnd2) {
// 检查目标时间段是否与第一个参考时间段有交集
boolean overlapsWithRef1 = !targetEnd.isBefore(refStart1) && !targetStart.isAfter(refEnd1);
// 检查目标时间段是否与第二个参考时间段有交集
boolean overlapsWithRef2 = !targetEnd.isBefore(refStart2) && !targetStart.isAfter(refEnd2);
// 如果目标时间段与任意一个参考时间段有交集,则返回 true
return overlapsWithRef1 || overlapsWithRef2;
}
} }
...@@ -99,6 +99,7 @@ ...@@ -99,6 +99,7 @@
<result column="dir" property="dir"/> <result column="dir" property="dir"/>
<result column="dt" property="dt"/> <result column="dt" property="dt"/>
<result column="insert_time" property="insertTime"/> <result column="insert_time" property="insertTime"/>
<result column="turn" property="turn"/>
<result column="hours_window_start_time" property="hours_window_start_time"/> <!-- 添加此行 --> <result column="hours_window_start_time" property="hours_window_start_time"/> <!-- 添加此行 -->
</resultMap> </resultMap>
...@@ -200,9 +201,11 @@ ...@@ -200,9 +201,11 @@
SELECT SELECT
dt, dt,
dir, dir,
turn,
t1.cross_id, t1.cross_id,
sum(event_number)AS event_number , sum(event_number)AS event_number ,
DATE_FORMAT(t1.window_start_time,'%H:%i') AS hours_window_start_time , DATE_FORMAT(t1.window_start_time,'%H:%i') AS hours_window_start_time ,
DATE_FORMAT(t1.window_start_time, '%Y-%m-%d %H:%i:%s') AS winStartTime,
t1.event_type, t1.event_type,
t2.label AS typeName t2.label AS typeName
FROM t_analysis_problem_cross_dir_hour t1 FROM t_analysis_problem_cross_dir_hour t1
...@@ -221,7 +224,7 @@ ...@@ -221,7 +224,7 @@
GROUP BY GROUP BY
DATE_FORMAT(t1.window_start_time,'%H:%i') DATE_FORMAT(t1.window_start_time,'%H:%i')
ORDER BY event_number desc ORDER BY event_number desc
limit 2 limit 1
</select> </select>
<select id="selectDirectByProblemTrend" parameterType="map" resultMap="AnalysisProblemCrossDirHourMap"> <select id="selectDirectByProblemTrend" parameterType="map" resultMap="AnalysisProblemCrossDirHourMap">
...@@ -249,7 +252,154 @@ ...@@ -249,7 +252,154 @@
GROUP BY GROUP BY
dir dir
ORDER BY event_number desc ORDER BY event_number desc
limit 1
</select>
<select id="getOverFolowInfo" parameterType="map" resultType="net.wanji.opt.entity.judgeanalysis.AnalysisCrossHourOverFlowTask">
select
cross_id,overflow_dir,out_flow_sum,out_flow_avg,next_cross_lane_num,
next_cross_capacity,length_to_next_cross,overflow_num,
dt,
DATE_FORMAT(t1.overflow_start_time,'%H:%i') as overflowStartTimeHours,
DATE_FORMAT(t1.overflow_end_time,'%H:%i') as overflowEndTimeHours
FROM t_analysis_cross_overflow_reason t1
WHERE
1=1
<if test="startTime != null and endTime != ''">
and t1.dt >= #{startTime} AND t1.dt &lt;= #{endTime}
</if>
<if test="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
</if>
ORDER BY overflow_num desc
limit 1
</select>
<select id="getEmptyCrossTurnInfo" parameterType="map" resultType="net.wanji.databus.po.CrossTurnDataHistPO">
SELECT
id,turn_type,in_dir,cross_id,
avg(flow) as flow
FROM
t_cross_turn_data_hist t1
WHERE
1=1
<if test="dir != null and dir != ''">
and t1.in_dir = #{dir}
</if>
<if test="turn != null and turn != ''">
and t1.turn_type = #{turn}
</if>
<if test="startTimeAll != null and endTimeALL != ''">
and t1.start_time >= #{startTimeAll} AND t1.start_time &lt;= #{endTimeALL}
</if>
</select>
<select id="getpeakHours" resultType="net.wanji.opt.entity.report.ConfigPeakHours">
select
id,city_code,peak_type,day_type,start_time,end_time
from t_config_peak_hours
</select>
<select id="getunBalanceProblem" parameterType="map" resultMap="AnalysisProblemCrossDirHourMap">
SELECT
dt,
dir,
turn,
t1.cross_id,
event_number,
DATE_FORMAT(t1.window_start_time,'%H:%i') AS hours_window_start_time ,
DATE_FORMAT(t1.window_start_time, '%Y-%m-%d %H:%i:%s') AS winStartTime,
t1.event_type,
t2.label AS typeName
FROM t_analysis_problem_cross_dir_hour t1
JOIN t_config_event_category t2 ON t1.event_type = t2.event_type
WHERE
1=1
<if test="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt &lt;= #{endTime}
</if>
<if test="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
</if>
<if test="eventType != null and eventType != ''">
and t1.event_type = #{eventType}
</if>
ORDER BY event_number desc
limit 2 limit 2
</select> </select>
<select id="getunBalancePeakFlow" parameterType="map" resultType="net.wanji.databus.po.CrossDirDataHistPO">
SELECT
avg(flow) as flow,
cross_id,
dir_type
FROM
t_cross_dir_data_hist t1
WHERE
1=1
<if test="dir1 != null and dir1 != ''">
and t1.dir_type = #{dir1}
</if>
<if test="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
</if>
<if test="moningPeakStartAll != null and moningPeakEndAll != null ">
and t1.start_time >= #{moningPeakStartAll} AND t1.start_time &lt;= #{moningPeakEndAll}
</if>
</select>
<select id="getCongestionProblem" parameterType="map" resultMap="AnalysisProblemCrossDirHourMap">
SELECT
dt,
dir,
turn,
t1.cross_id,
event_number,
DATE_FORMAT(t1.window_start_time,'%H:%i') AS hours_window_start_time ,
DATE_FORMAT(t1.window_start_time, '%Y-%m-%d %H:%i:%s') AS winStartTime,
t1.event_type,
t2.label AS typeName
FROM t_analysis_problem_cross_dir_hour t1
JOIN t_config_event_category t2 ON t1.event_type = t2.event_type
WHERE
1=1
<if test="startTime != null and endTime != ''">
and dt >= #{startTime} AND dt &lt;= #{endTime}
</if>
<if test="crossId != null and crossId != ''">
and t1.cross_id = #{crossId}
</if>
<if test="eventType != null and eventType != ''">
and t1.event_type = #{eventType}
</if>
ORDER BY event_number desc
limit 1
</select>
<select id="getCongestionReasoninfo" parameterType="map" resultType="CrossCongestionLaneReasonInfo">
SELECT a.cross_id,a.dir,a.id,avg(b.sturation) sturation
from t_base_lane_info a
LEFT JOIN
(
SELECT id,sturation
from t_lane_data_hist
where
1=1
<if test="crossId != null and crossId != ''">
and cross_id = #{crossId}
</if>
<if test="startTimeAll != null and endTimeALL != ''">
and start_time BETWEEN #{startTimeAll} AND #{endTimeALL}
</if>
) b
on a.id=b.id
where
1=1
and a.type=2
<if test="crossId != null and crossId != ''">
and a.cross_id = #{crossId}
</if>
<if test="dir != null and dir != ''">
and t1.dir = #{dir}
</if>
GROUP BY a.cross_id,a.dir,a.id
</select>
</mapper> </mapper>
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