Commit a88921c6 authored by hanbing's avatar hanbing

[add] 新信号评价-运行评价-详细指标查询-范围下拉列表

parent d2afa625
package net.wanji.opt.bo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2023/6/9 13:52
*/
@Data
@ApiModel(value = "MetricsDetailBO", description = "详细指标查询输入参数")
public class MetricsDetailBO {
@ApiModelProperty(value = "路口ID", required = true)
private String crossId;
@ApiModelProperty(value = "进口方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
private Integer dir;
@ApiModelProperty(value = "转向:u掉头;l左转;s直行;r右转")
private String turn;
@ApiModelProperty(name = "车道序号,从左车道开始编号11、12、13...")
private Integer laneSort;
@ApiModelProperty(value = "日期,格式 M/d,如 7/17", required = true)
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "M/d", timezone = "GMT+8")
private Date date;
@ApiModelProperty(value = "对比时间间隔(分钟)", required = true)
private Integer minutes;
}
......@@ -6,12 +6,12 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.bo.CrossIdAndStartEndDateBO;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.vo.RunningEvaluateCrossListVO;
import net.wanji.opt.bo.CrossNameBO;
import net.wanji.opt.bo.MetricsDetailBO;
import net.wanji.opt.service.impl.RunningEvaluateServiceImpl;
import net.wanji.opt.vo.RunningEvaluateCrossEvaluateVO;
import net.wanji.opt.vo.RunningEvaluateIndexStatusVO;
import net.wanji.opt.vo.RunningEvaluateSchemeProblemsVO;
import net.wanji.opt.vo.*;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -108,4 +108,28 @@ public class RunningEvaluateController {
return JsonViewObject.newInstance().success(res);
}
@ApiOperation(value = "详细指标查询-范围下拉列表", notes = "详细指标查询-范围下拉列表", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/scopeTree",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = RunningEvaluateScopeTreeVO.class),
})
public JsonViewObject scopeTree(@RequestBody CrossIdBO bo) {
RunningEvaluateScopeTreeVO res = runningEvaluateService.scopeTree(bo);
return JsonViewObject.newInstance().success(res);
}
@ApiOperation(value = "详细指标查询", notes = "详细指标查询", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/metricsDetail",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = RunningEvaluateMetricsDetailVO.class),
})
public JsonViewObject schemeProblems(@RequestBody MetricsDetailBO bo) {
List<RunningEvaluateMetricsDetailVO> res = runningEvaluateService.metricsDetail(bo);
return JsonViewObject.newInstance().success(res);
}
}
\ No newline at end of file
package net.wanji.opt.service;
import net.wanji.databus.bo.CrossIdAndStartEndDateBO;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.vo.RunningEvaluateCrossListVO;
import net.wanji.opt.bo.CrossNameBO;
import net.wanji.opt.vo.RunningEvaluateIndexStatusVO;
import net.wanji.opt.vo.RunningEvaluateCrossEvaluateVO;
import net.wanji.opt.vo.RunningEvaluateSchemeProblemsVO;
import net.wanji.opt.bo.MetricsDetailBO;
import net.wanji.opt.vo.*;
import java.util.List;
......@@ -21,4 +21,8 @@ public interface RunningEvaluateService {
List<RunningEvaluateIndexStatusVO> spilloverStatus(CrossIdAndStartEndDateBO bo);
List<RunningEvaluateSchemeProblemsVO> schemeProblems(CrossIdAndStartEndDateBO bo);
List<RunningEvaluateMetricsDetailVO> metricsDetail(MetricsDetailBO bo);
RunningEvaluateScopeTreeVO scopeTree(CrossIdBO bo);
}
package net.wanji.opt.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.enums.CrossStatusEnum;
import net.wanji.common.enums.TurnConvertEnum;
import net.wanji.common.utils.tool.CrossUtil;
import net.wanji.common.utils.tool.TimeArrayUtil;
import net.wanji.databus.bo.CrossIdAndStartEndDateBO;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.databus.dao.entity.BaseCrossDirInfoPO;
import net.wanji.databus.dao.entity.BaseCrossSchemePO;
import net.wanji.databus.dao.entity.CrossSectionPO;
import net.wanji.databus.dao.mapper.BaseCrossSchemeMapper;
import net.wanji.databus.dao.mapper.BaseCrossSectionMapper;
import net.wanji.databus.dao.mapper.CrossDataHistMapper;
import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.po.CrossDataHistPO;
import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.databus.dao.mapper.*;
import net.wanji.databus.po.*;
import net.wanji.databus.vo.RunningEvaluateCrossListVO;
import net.wanji.opt.bo.CrossNameBO;
import net.wanji.opt.bo.MetricsDetailBO;
import net.wanji.opt.service.RunningEvaluateService;
import net.wanji.opt.vo.RunningEvaluateCrossEvaluateVO;
import net.wanji.opt.vo.RunningEvaluateIndexStatusVO;
import net.wanji.opt.vo.RunningEvaluateSchemeProblemsVO;
import net.wanji.opt.vo.*;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import java.time.Instant;
/**
* @author Kent HAN
......@@ -44,15 +43,27 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
private final CrossDataHistMapper crossDataHistMapper;
private final BaseCrossSectionMapper baseCrossSectionMapper;
private final BaseCrossSchemeMapper baseCrossSchemeMapper;
private final BaseCrossDirInfoMapper baseCrossDirInfoMapper;
private final BaseCrossTurnInfoMapper baseCrossTurnInfoMapper;
private final LaneInfoMapper laneInfoMapper;
private final BaseCrossInfoMapper baseCrossInfoMapper;
public RunningEvaluateServiceImpl(CrossDataRealtimeMapper crossDataRealtimeMapper,
CrossDataHistMapper crossDataHistMapper,
@Qualifier("baseCrossSectionMapper") BaseCrossSectionMapper baseCrossSectionMapper,
@Qualifier("baseCrossSchemeMapper") BaseCrossSchemeMapper baseCrossSchemeMapper) {
@Qualifier("baseCrossSchemeMapper") BaseCrossSchemeMapper baseCrossSchemeMapper,
@Qualifier("baseCrossDirInfoMapper") BaseCrossDirInfoMapper baseCrossDirInfoMapper,
@Qualifier("baseCrossTurnInfoMapper") BaseCrossTurnInfoMapper baseCrossTurnInfoMapper,
@Qualifier("laneInfoMapper") LaneInfoMapper laneInfoMapper,
@Qualifier("baseCrossInfoMapper") BaseCrossInfoMapper baseCrossInfoMapper) {
this.crossDataRealtimeMapper = crossDataRealtimeMapper;
this.crossDataHistMapper = crossDataHistMapper;
this.baseCrossSectionMapper = baseCrossSectionMapper;
this.baseCrossSchemeMapper = baseCrossSchemeMapper;
this.baseCrossDirInfoMapper = baseCrossDirInfoMapper;
this.baseCrossTurnInfoMapper = baseCrossTurnInfoMapper;
this.laneInfoMapper = laneInfoMapper;
this.baseCrossInfoMapper = baseCrossInfoMapper;
}
@Override
......@@ -62,6 +73,13 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
for (RunningEvaluateCrossListVO runningEvaluateCrossListVO : crossDataRealtimePOList) {
Double sturation = runningEvaluateCrossListVO.getSturation();
runningEvaluateCrossListVO.setServiceLevel(CrossUtil.getServiceLevel(sturation));
// 路口经纬度
String crossId = runningEvaluateCrossListVO.getCrossId();
BaseCrossInfoPO baseCrossInfoPO = baseCrossInfoMapper.selectById(crossId);
String location = baseCrossInfoPO.getLocation();
double[] lonLat = CrossUtil.getLonLat(location);
runningEvaluateCrossListVO.setLongitude(lonLat[0]);
runningEvaluateCrossListVO.setLatitude(lonLat[1]);
}
// 按服务水平降序排序
List<RunningEvaluateCrossListVO> res = crossDataRealtimePOList.stream()
......@@ -181,6 +199,71 @@ public class RunningEvaluateServiceImpl implements RunningEvaluateService {
return res;
}
@Override
public List<RunningEvaluateMetricsDetailVO> metricsDetail(MetricsDetailBO bo) {
return null;
}
@Override
public RunningEvaluateScopeTreeVO scopeTree(CrossIdBO bo) {
String crossId = bo.getCrossId();
RunningEvaluateScopeTreeVO runningEvaluateScopeTreeVO = new RunningEvaluateScopeTreeVO();
runningEvaluateScopeTreeVO.setCrossId(crossId);
List<RunningEvaluateScopeTreeVO.DirVO> dirVOList= buildDirVOList(crossId);
runningEvaluateScopeTreeVO.setChild(dirVOList);
return runningEvaluateScopeTreeVO;
}
private List<RunningEvaluateScopeTreeVO.DirVO> buildDirVOList(String crossId) {
List<RunningEvaluateScopeTreeVO.DirVO> res = new ArrayList<>();
Integer type = 1; // 进口
List<BaseCrossDirInfoPO> baseCrossDirInfoPOList =
baseCrossDirInfoMapper.selectByCrossIdAndInOutType(crossId, type);
for (BaseCrossDirInfoPO baseCrossDirInfoPO : baseCrossDirInfoPOList) {
RunningEvaluateScopeTreeVO.DirVO dirVO = new RunningEvaluateScopeTreeVO.DirVO();
Integer dir = baseCrossDirInfoPO.getDirType();
dirVO.setDir(dir);
List<RunningEvaluateScopeTreeVO.TurnVO> turnVOList = buildTurnVOList(crossId, dir);
dirVO.setChild(turnVOList);
res.add(dirVO);
}
return res;
}
private List<RunningEvaluateScopeTreeVO.TurnVO> buildTurnVOList(String crossId, Integer dir) {
List<RunningEvaluateScopeTreeVO.TurnVO> res = new ArrayList<>();
List<CrossTurnInfoPO> crossTurnInfoPOList = baseCrossTurnInfoMapper.selectByCrossIdAndDir(crossId, dir);
for (CrossTurnInfoPO crossTurnInfoPO : crossTurnInfoPOList) {
RunningEvaluateScopeTreeVO.TurnVO turnVO = new RunningEvaluateScopeTreeVO.TurnVO();
String turnType = crossTurnInfoPO.getTurnType();
turnVO.setTurn(turnType);
List<RunningEvaluateScopeTreeVO.LaneVO> laneVOList = buildLaneVOList(crossId, dir, turnType);
turnVO.setChild(laneVOList);
res.add(turnVO);
}
return res;
}
private List<RunningEvaluateScopeTreeVO.LaneVO> buildLaneVOList(String crossId, Integer dir, String turnType) {
List<RunningEvaluateScopeTreeVO.LaneVO> res = new ArrayList<>();
List<Integer> keyList = TurnConvertEnum.getKeyListBySingleCode(turnType);
Integer type = 2; // 进口
if (ObjectUtil.isNotEmpty(keyList)) {
List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectByTurnType(crossId, type, dir, keyList);
for (LaneInfoPO laneInfoPO : laneInfoPOList) {
RunningEvaluateScopeTreeVO.LaneVO laneVO = new RunningEvaluateScopeTreeVO.LaneVO();
Integer sort = laneInfoPO.getSort();
laneVO.setLaneSort(sort);
res.add(laneVO);
}
}
return res;
}
private List<RunningEvaluateSchemeProblemsVO.DateAndScheme> buildDateAndSchemeList(
List<CrossDataHistPO> uniqueList, String crossId) {
List<RunningEvaluateSchemeProblemsVO.DateAndScheme> res = new ArrayList<>();
......
package net.wanji.opt.vo;
import io.swagger.annotations.ApiModel;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Kent HAN
* @date 2023/2/9 8:38
*/
@Data
@NoArgsConstructor
@ApiModel(value = "RunningEvaluateMetricsDetailVO", description = "评价指标查询返回值")
public class RunningEvaluateMetricsDetailVO {
}
package net.wanji.opt.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* @author Kent HAN
* @date 2023/2/9 8:38
*/
@Data
@NoArgsConstructor
@ApiModel(value = "RunningEvaluateScopeTreeVO", description = "详细指标查询-范围下拉列表")
public class RunningEvaluateScopeTreeVO {
@ApiModelProperty(value = "路口ID")
private String crossId;
@ApiModelProperty(value = "方向列表")
private List<DirVO> child;
@NoArgsConstructor
@Data
public static class DirVO {
@ApiModelProperty(value = "方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
private Integer dir;
@ApiModelProperty(value = "转向列表")
private List<TurnVO> child;
}
@NoArgsConstructor
@Data
public static class TurnVO {
@ApiModelProperty(value = "转向:u掉头;l左转;s直行;r右转")
private String turn;
@ApiModelProperty(value = "车道列表")
private List<LaneVO> child;
}
@NoArgsConstructor
@Data
public static class LaneVO {
@ApiModelProperty(name = "车道序号,从左车道开始编号11、12、13...")
private Integer laneSort;
}
}
package net.wanji.common.enums;
import java.util.ArrayList;
import java.util.List;
/**
* @author hfx
* @date 2023/1/28 18:03
......@@ -71,11 +74,21 @@ public enum TurnConvertEnum {
public static String getDescByCode(String code){
for (TurnConvertEnum e : TurnConvertEnum.values()) {
if(e.code.equals(code)){
if(e.code.contains(code)){
return e.desc;
}
}
return null;
}
public static List<Integer> getKeyListBySingleCode(String singleCode){
List<Integer> res = new ArrayList<>();
for (TurnConvertEnum e : TurnConvertEnum.values()) {
if(e.code.contains(singleCode)){
res.add(e.key);
}
}
return res;
}
}
......@@ -18,4 +18,6 @@ public interface BaseCrossDirInfoMapper {
BaseCrossDirInfoPO selectByCrossIdAndDirType(String crossId, Integer key);
List<BaseCrossDirInfoPO> selectByCrossId(String crossId);
List<BaseCrossDirInfoPO> selectByCrossIdAndInOutType(String crossId, Integer type);
}
package net.wanji.databus.dao.mapper;
import net.wanji.databus.po.CrossTurnInfoPO;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface BaseCrossTurnInfoMapper {
List<CrossTurnInfoPO> selectByCrossIdAndDir(String crossId, Integer dir);
}
......@@ -35,4 +35,6 @@ public interface LaneInfoMapper {
String selectPreId(String crossId, Integer dir);
List<LaneInfoPO> listLaneInfo();
List<LaneInfoPO> selectByTurnType(String crossId, Integer type, Integer dir, List<Integer> keyList);
}
package net.wanji.opt.po.base;
package net.wanji.databus.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author hfx
* @date 2023/1/12 13:37
......@@ -11,19 +13,26 @@ import lombok.Data;
@Data
public class CrossTurnInfoPO {
@ApiModelProperty(name = "转向ID",notes = "")
private String turnId;
/** 转向ID(路口ID_驶入方向_转向类型) */
@ApiModelProperty(name = "转向ID(路口ID_驶入方向_转向类型)",notes = "")
private String id ;
/** 转向类型:u掉头;l左转;s直行;r右转; */
@ApiModelProperty(name = "转向类型:u掉头;l左转;s直行;r右转;",notes = "")
private Integer turnType;
private String turnType ;
/** 驶入方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北 */
@ApiModelProperty(name = "驶入方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北",notes = "")
private Integer inDir;
private Integer inDir ;
/** 驶出方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北 */
@ApiModelProperty(name = "驶出方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北",notes = "")
private Integer outDir;
private Integer outDir ;
/** 路口ID */
@ApiModelProperty(name = "路口ID",notes = "")
private String crossId;
private String crossId ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
}
......@@ -17,12 +17,21 @@ public class RunningEvaluateCrossListVO {
@ApiModelProperty(value = "路口ID")
private String crossId;
@ApiModelProperty(value = "路口名称")
private String crossName;
@ApiModelProperty(name = "饱和度")
@JsonIgnore
private Double sturation;
@ApiModelProperty(value = "服务水平")
String serviceLevel;
private String serviceLevel;
@ApiModelProperty(value = "路口经度")
private Double longitude ;
@ApiModelProperty(value = "路口纬度")
private Double latitude ;
}
......@@ -2,6 +2,10 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.databus.dao.mapper.BaseCrossDirInfoMapper">
<sql id="baseColumnList">
id,dir_type,in_out_type,cross_id,length,is_pedestrian,gmt_create,gmt_modified
</sql>
<select id="selectInDirsByCrossId" resultType="java.lang.Integer">
SELECT dir_type
FROM t_base_cross_dir_info
......@@ -22,4 +26,10 @@
where cross_id = #{crossId}
</select>
<select id="selectByCrossIdAndInOutType" resultType="net.wanji.databus.dao.entity.BaseCrossDirInfoPO">
select <include refid="baseColumnList"></include>
from t_base_cross_dir_info
where cross_id = #{crossId} and in_out_type = #{type}
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.databus.dao.mapper.BaseCrossTurnInfoMapper">
<sql id="baseColumnList">
id,turn_type,in_dir,out_dir,cross_id,gmt_create,gmt_modified
</sql>
<select id="selectByCrossIdAndDir" resultType="net.wanji.databus.po.CrossTurnInfoPO">
select <include refid="baseColumnList"></include>
from t_base_cross_turn_info
where cross_id = #{crossId} and in_dir = #{dir}
</select>
</mapper>
......@@ -20,6 +20,10 @@
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<sql id="baseColumnList">
id,code,sort,type,dir,turn,category,cross_id,rid,length,width,wkt,gmt_create,gmt_modified
</sql>
<insert id="insertBatch">
insert into t_base_lane_info(id,code,sort,type,dir,turn,category,cross_id,rid,length,width,wkt)
values
......@@ -104,4 +108,13 @@
</if>
</select>
<select id="selectByTurnType" resultType="net.wanji.databus.po.LaneInfoPO">
select <include refid="baseColumnList"></include>
from t_base_lane_info
where cross_id = #{crossId} and type = #{type} and dir = #{dir} and turn in
<foreach collection="keyList" item="key" separator="," open="(" close=")">
#{key}
</foreach>
</select>
</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