Commit e5adda23 authored by hanbing's avatar hanbing

[add] 态势监测-表格分时段查询

parent 77b1e0bc
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 = "CrossIdAndTimeSpanBO", description = "路口时段入参")
public class CrossIdAndTimeSpanBO {
@ApiModelProperty(value = "路口编号")
private String crossId;
@ApiModelProperty(value = "时段开始时间 格式 yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@ApiModelProperty(value = "时段结束时间 格式 yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date endTime;
}
......@@ -6,10 +6,7 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.bo.CrossIdBO;
import net.wanji.opt.bo.GreenwaveDetailBO;
import net.wanji.opt.bo.GreenwaveIdAndTimeStampBO;
import net.wanji.opt.bo.GreenwaveIdBO;
import net.wanji.opt.bo.SaveGreenwaveStrategyBO;
import net.wanji.opt.bo.*;
import net.wanji.opt.dto.strategy.AddOrUpdateSceneDTO;
import net.wanji.opt.dto.trend.AbnormalCrossListDTO;
import net.wanji.opt.dto.trend.EventAlarmDTO;
......@@ -188,4 +185,16 @@ public class TrendController {
CountRealTimeVO countRealTimeVO = trendService.countRealTime(crossId);
return JsonViewObject.newInstance().success(countRealTimeVO);
}
@ApiOperation(value = "表格分时段查询", notes = "表格分时段查询",response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/tableQuery",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = TableQueryVO.class),
})
public JsonViewObject tableQuery(@RequestBody CrossIdAndTimeSpanBO crossIdAndTimeSpanBO) {
TableQueryVO tableQueryVO = trendService.tableQuery(crossIdAndTimeSpanBO);
return JsonViewObject.newInstance().success(tableQueryVO);
}
}
\ No newline at end of file
......@@ -39,4 +39,6 @@ public interface TrendService {
GreenwaveDetailVO currentGreenwaveDetail(GreenwaveIdBO bo) throws ParseException;
CountRealTimeVO countRealTime(String crossId);
TableQueryVO tableQuery(CrossIdAndTimeSpanBO crossIdAndTimeSpanBO);
}
......@@ -1058,6 +1058,63 @@ public class TrendServiceImpl implements TrendService {
return countRealTimeVO;
}
@Override
public TableQueryVO tableQuery(CrossIdAndTimeSpanBO crossIdAndTimeSpanBO) {
String crossId = crossIdAndTimeSpanBO.getCrossId();
Date startTime = crossIdAndTimeSpanBO.getStartTime();
Date endTime = crossIdAndTimeSpanBO.getEndTime();
TableQueryVO tableQueryVO = new TableQueryVO();
// todo 实时数据
// tableQueryVO.setRealTimeData();
// 将Date对象转换为10位时间戳
int startTimeStamp = (int) (startTime.getTime() / 1000);
int endTimeStamp = (int) (endTime.getTime() / 1000);
List<CrossLaneDataHistPOExt> poExtList = crossLaneDataHistMapper
.selectByCrossIdAndTimeSpan(crossId, startTimeStamp, endTimeStamp);
tableQueryVO.setCycleData(buildCycleData(poExtList));
return tableQueryVO;
}
private List<TableQueryVO.CycleDataElement> buildCycleData(List<CrossLaneDataHistPOExt> poExtList) {
List<TableQueryVO.CycleDataElement> res = new ArrayList<>();
for (CrossLaneDataHistPOExt po : poExtList) {
TableQueryVO.CycleDataElement vo = new TableQueryVO.CycleDataElement();
Integer batchTime = po.getBatchTime();
// 将10位时间戳转换为毫秒
long millis = batchTime * 1000L;
// 使用毫秒值创建Date对象
Date dateFromTimestamp = new Date(millis);
vo.setTime(dateFromTimestamp);
vo.setDir(po.getDir());
vo.setLaneSort(po.getSort());
vo.setFlow(po.getFlow());
Double speed = po.getSpeed();
vo.setSpeed((int) Math.round(speed));
Double queueLength = po.getQueueLength();
vo.setQueueLength((int) Math.round(queueLength));
Integer delayTime = po.getDelayTime();
vo.setDelayTime(delayTime);
Double stopTimes = po.getStopTimes();
vo.setStopTimes((int) Math.round(stopTimes));
Double vehheadTime = po.getVehheadTime();
vo.setVehheadTime((int) Math.round(vehheadTime));
res.add(vo);
}
return res;
}
private MainlineSchemeAnalysisVO.GreenwaveData findMatchingData(
List<MainlineSchemeAnalysisVO.GreenwaveData> greenwaveData) {
......
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 = "TableQueryVO", description = "表格分时段查询")
public class TableQueryVO {
@ApiModelProperty(value = "实时数据")
private List<RealTimeDataElement> realTimeData;
@ApiModelProperty(value = "周期数据")
private List<CycleDataElement> cycleData;
@NoArgsConstructor
@Data
public static class RealTimeDataElement {
@ApiModelProperty(value = "时间 格式 yyyy-MM-dd HH:mm:ss")
private Date time;
@ApiModelProperty(value = "方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
private Integer dir;
@ApiModelProperty(value = "车道,从左车道开始编号11、12、13...")
private Integer laneSort;
@ApiModelProperty(value = "排队长度")
private Integer queueLength;
@ApiModelProperty(value = "头车位置")
private Integer firstCarPosition;
@ApiModelProperty(value = "末车位置")
private Integer endCarPosition;
}
@NoArgsConstructor
@Data
public static class CycleDataElement {
@ApiModelProperty(value = "时间 格式 yyyy-MM-dd HH:mm:ss")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date time;
@ApiModelProperty(value = "方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北")
private Integer dir;
@ApiModelProperty(value = "车道,从左车道开始编号11、12、13...")
private Integer laneSort;
@ApiModelProperty(value = "流量")
private Integer flow;
@ApiModelProperty(value = "速度")
private Integer speed;
@ApiModelProperty(value = "最大排队")
private Integer queueLength;
@ApiModelProperty(value = "平均延误")
private Integer delayTime ;
@ApiModelProperty(value = "平均停车次数")
private Integer stopTimes;
@ApiModelProperty(value = "平均车头时距")
private Integer vehheadTime;
}
}
......@@ -24,4 +24,6 @@ public interface CrossLaneDataHistMapper extends BaseMapper<CrossLaneDataHistPO>
List<CrossLaneDataHistPOExt> selectByCrossId(String crossId, int endTimeStamp, int startTimeStamp);
Integer selectCountByCrossIdAndTimeSpan(String crossId, int startTimeStamp, int endTimeStamp);
List<CrossLaneDataHistPOExt> selectByCrossIdAndTimeSpan(String crossId, int startTimeStamp, int endTimeStamp);
}
......@@ -92,4 +92,13 @@
and batch_time <![CDATA[ >= ]]> #{startTimeStamp}
and batch_time <![CDATA[ <= ]]> #{endTimeStamp};
</select>
<select id="selectByCrossIdAndTimeSpan" resultType="net.wanji.databus.po.CrossLaneDataHistPOExt">
SELECT t2.dir, t2.sort, t1.flow, t1.speed, t1.queue_length, t1.delay_time, t1.stop_times,
t1.vehhead_time, t1.batch_time
FROM t_lane_data_hist t1 JOIN t_base_lane_info t2 ON t1.id = t2.id
where t1.cross_id = #{crossId}
and batch_time <![CDATA[ >= ]]> #{startTimeStamp}
and batch_time <![CDATA[ <= ]]> #{endTimeStamp};
</select>
</mapper>
\ No newline at end of file
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