Commit 6c87b648 authored by hanbing's avatar hanbing

[add] 诊断优化,查询优化效果

parent f4bafc14
......@@ -6,11 +6,13 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.dto.CrossIdDTO;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.dto.CrossIdAndDirDTO;
import net.wanji.opt.dto.CrossIdAndSchemeIdDTO;
import net.wanji.opt.dto.SendManualDTO;
import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.service.DiagnoService;
import net.wanji.opt.vo.CrossIdAndLocationVO;
import net.wanji.opt.vo.OptEffectVO;
import net.wanji.opt.vo.SchemeOptVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
......@@ -108,4 +110,16 @@ public class DiagnoController {
diagnoService.restoreSend(crossIdDTO);
return JsonViewObject.newInstance().success();
}
@ApiOperation(value = "优化效果", notes = "优化效果", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/optEffect",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = OptEffectVO.class),
})
public JsonViewObject optEffect(@RequestBody CrossIdAndDirDTO crossIdAndDirDTO) {
OptEffectVO optEffectVO = diagnoService.optEffect(crossIdAndDirDTO);
return JsonViewObject.newInstance().success(optEffectVO);
}
}
\ No newline at end of file
package net.wanji.opt.dao.mapper;
import net.wanji.opt.po.CrossDataHistPO;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author hanbing
* @date 2023/1/12 13:24
* @desc CrossInfoMapper
*/
@Repository
public interface CrossDataHistMapper {
List<CrossDataHistPO> selectByCrossIdAndTimestamp(String crossId, long preSeconds);
}
......@@ -18,4 +18,6 @@ public interface CrossSchemeOptLogMapper {
int insertOne(CrossSchemeOptLogPO entity);
int insertBatch(@Param("list") List<CrossSchemeOptLogPO> list);
List<CrossSchemeOptLogPO> selectMaxByCrossId(String crossId);
}
......@@ -15,4 +15,6 @@ import java.util.List;
public interface CrossDirDataHistMapper {
List<CrossDirDataHistPO> selectByCrossIdAndTimestamp(String crossId, long preSeconds);
List<CrossDirDataHistPO> selectByCrossIdDirAndTimestamp(String crossId, Integer dir, long preSeconds);
}
package net.wanji.opt.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
*
* @author Kent HAN
* @date 2022/12/20 10:17
*/
@Data
public class CrossIdAndDirDTO {
@ApiModelProperty(value = "路口ID,如:14Q1409IRF0", required = true)
private String crossId;
@ApiModelProperty(value = "进口方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北", required = false)
private Integer dir;
}
package net.wanji.opt.dto;
import lombok.Data;
/**
*
* @author Kent HAN
* @date 2022/12/20 10:17
*/
@Data
public class OptDataExtend {
private String sceneName;
private String strategyName;
private String ideaName;
}
package net.wanji.opt.po;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author hanbing
* @date 2023/1/10 16:36
* @desc CrossDataRealtimePO
*/
@Data
public class CrossDataHistPO {
/** 路口编号 */
@ApiModelProperty(name = "路口编号",notes = "")
private String crossId ;
/** 路口状态:0正常;1失衡;2拥堵;3溢出;4死锁 */
@ApiModelProperty(name = "路口状态:0正常;1失衡;2拥堵;3溢出;4死锁",notes = "")
private Integer status ;
/** 拥堵类型:1常规;2异常 */
@ApiModelProperty(name = "拥堵类型:1常规;2异常",notes = "")
private Integer type ;
/** 交通指数(1~10) */
@ApiModelProperty(name = "交通指数(1~10)",notes = "")
private Double trafficIndex ;
/** 开始时间:yyyy-MM-dd HH;mm:ss */
@ApiModelProperty(name = "开始时间:yyyy-MM-dd HH",notes = "mm:ss")
private Date startTime ;
/** 持续时间(单位:分钟) */
@ApiModelProperty(name = "持续时间(单位:分钟)",notes = "")
private Integer duration ;
/** 是否失衡:0否;1是 */
@ApiModelProperty(name = "是否失衡:0否;1是",notes = "")
private Integer isUnbalance ;
/** 是否溢出:0否;1是 */
@ApiModelProperty(name = "是否溢出:0否;1是",notes = "")
private Integer isSpillover ;
/** 是否拥堵:0否;1是 */
@ApiModelProperty(name = "是否拥堵:0否;1是",notes = "")
private Integer isCongestion ;
/** 失衡指数 */
@ApiModelProperty(name = "失衡指数",notes = "")
private Double unbalanceIndex ;
/** 溢出指数 */
@ApiModelProperty(name = "溢出指数",notes = "")
private Double spilloverIndex ;
/** 拥堵指数 */
@ApiModelProperty(name = "拥堵指数",notes = "")
private Double congestionIndex ;
/** 路口失衡方向:1,2,3... */
@ApiModelProperty(name = "路口失衡方向:1,2,3...",notes = "")
private String unbalanceDirs ;
/** 路口溢出方向:1,2,3... */
@ApiModelProperty(name = "路口溢出方向:1,2,3...",notes = "")
private String spilloverDirs ;
/** 路口拥堵方向:1,2,3... */
@ApiModelProperty(name = "路口拥堵方向:1,2,3...",notes = "")
private String congestionDirs ;
/** 交通流量(辆) */
@ApiModelProperty(name = "交通流量(辆)",notes = "")
private Integer flow ;
/** 交通流率/h */
@ApiModelProperty(name = "交通流率/h",notes = "")
private Double flowRate ;
/** 平均速度(km/h) */
@ApiModelProperty(name = "平均速度(km/h)",notes = "")
private Double speed ;
/** 最大排队(米) */
@ApiModelProperty(name = "最大排队(米)",notes = "")
private Double queueLength ;
/** 停车次数(次) */
@ApiModelProperty(name = "停车次数(次)",notes = "")
private Double stopTimes ;
/** 延误时间(秒) */
@ApiModelProperty(name = "延误时间(秒)",notes = "")
private Integer delayTime ;
/** 饱和度 */
@ApiModelProperty(name = "饱和度",notes = "")
private Double sturation ;
/** 采集时间(10位时间戳) */
@ApiModelProperty(name = "采集时间(10位时间戳)",notes = "")
private Integer batchTime ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
}
......@@ -53,7 +53,7 @@ public class CrossDirDataHistPO {
private Double sturation ;
/** 采集时间(10位时间戳) */
@ApiModelProperty(name = "采集时间(10位时间戳)",notes = "")
private Long batchTime ;
private Integer batchTime ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
......
package net.wanji.opt.service;
import net.wanji.common.dto.CrossIdDTO;
import net.wanji.opt.dto.CrossIdAndDirDTO;
import net.wanji.opt.dto.CrossIdAndSchemeIdDTO;
import net.wanji.opt.dto.SendManualDTO;
import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.vo.CrossIdAndLocationVO;
import net.wanji.opt.vo.OptEffectVO;
import net.wanji.opt.vo.SchemeOptVO;
import java.util.List;
......@@ -25,4 +27,6 @@ public interface DiagnoService {
void sendManual(SendManualDTO sendManualDTO) throws Exception;
void restoreSend(CrossIdDTO crossIdDTO) throws Exception;
OptEffectVO optEffect(CrossIdAndDirDTO crossIdAndDirDTO);
}
......@@ -276,7 +276,7 @@ public class TrendServiceImpl implements TrendService {
AbnormalCrossDetailVO.DirDataElement dirDataElement = new AbnormalCrossDetailVO.DirDataElement();
dirDataElement.setDir(crossDirDataHistPO.getDirType());
// 获取采集时间
Long batchTime = crossDirDataHistPO.getBatchTime();
Integer batchTime = crossDirDataHistPO.getBatchTime();
Date date = DateUtil.date(batchTime * 1000);
dirDataElement.setTime(date);
// 转换状态,3、4都算拥堵
......
package net.wanji.opt.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
import java.util.List;
/**
* @author Kent HAN
* @date 2023/2/9 8:38
*/
@Data
@NoArgsConstructor
@ApiModel(value = "OptEffectVO", description = "查询优化效果返回值")
public class OptEffectVO {
@ApiModelProperty(value = "路口名称")
String crossName;
@ApiModelProperty(value = "场景")
String sceneName;
@ApiModelProperty(value = "应用策略")
String strategyName;
@ApiModelProperty(value = "优化方法")
String ideaName;
@ApiModelProperty(value = "优化开始时间 格式2023-03-02 10:10")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
Date optStartTime;
@ApiModelProperty(value = "状态 1已完成 2优化中")
Integer status;
@ApiModelProperty(value = "拥堵指数延误折线图")
List<IndexDelay> indexDelayList;
@ApiModelProperty(value = "最大排队长度平均停车次数折线图")
List<QueueStop> queueStopList;
@Data
@NoArgsConstructor
@ApiModel(value = "IndexDelay", description = "拥堵指数延误折线图元素")
public static class IndexDelay {
@ApiModelProperty(value = "时间 格式14:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "GMT+8")
Date time;
@ApiModelProperty(value = "拥堵指数")
Double index;
@ApiModelProperty(value = "延误")
Integer delay;
}
@Data
@NoArgsConstructor
@ApiModel(value = "QueueStop", description = "最大排队长度平均停车次数折线图元素")
public static class QueueStop {
@ApiModelProperty(value = "时间 格式14:00")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "GMT+8")
Date time;
@ApiModelProperty(value = "最大排队长度")
Double queue;
@ApiModelProperty(value = "平均停车次数")
Double stop;
}
}
<?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.opt.dao.mapper.CrossDataHistMapper">
<select id="selectByCrossIdAndTimestamp" resultType="net.wanji.opt.po.CrossDataHistPO">
select
cross_id,status,type,traffic_index,start_time,duration,is_unbalance,is_spillover,is_congestion,unbalance_index,spillover_index,congestion_index,unbalance_dirs,spillover_dirs,congestion_dirs,flow,flow_rate,speed,queue_length,stop_times,delay_time,sturation,batch_time,gmt_create,gmt_modified
from t_cross_data_hist
where cross_id = #{crossId}
and batch_time <![CDATA[ >= ]]> #{preSeconds}
order by batch_time
</select>
</mapper>
......@@ -45,6 +45,14 @@
</where>
</select>
<select id="selectMaxByCrossId" resultType="net.wanji.opt.po.base.CrossSchemeOptLogPO">
select
<include refid="Base_Column_List"/>
from t_base_cross_scheme_opt_log
where cross_id = #{crossId}
and data_batch_time=(SELECT MAX(ABS(data_batch_time)) FROM t_base_cross_scheme_opt_log);
</select>
<insert id="insertOne" parameterType="net.wanji.opt.po.base.CrossSchemeOptLogPO">
insert into t_base_cross_scheme_opt_log (cross_id, scheme_no, dir_type, turn_type, offset, ring_no, phase_no,
phase_order_id, ori_green_time, opt_time, opt_type, opt_reason,
......
......@@ -11,4 +11,13 @@
and batch_time <![CDATA[ >= ]]> #{preSeconds}
order by batch_time
</select>
<select id="selectByCrossIdDirAndTimestamp" resultType="net.wanji.opt.po.trend.CrossDirDataHistPO">
select
id,dir_type,in_out_type,cross_id,length,status,traffic_index,flow,speed,queue_length,stop_times,delay_time,sturation,batch_time,gmt_create,gmt_modified
from t_cross_dir_data_hist
where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir}
and batch_time <![CDATA[ >= ]]> #{preSeconds}
order by batch_time
</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