Commit 44545b62 authored by duanruiming's avatar duanruiming

[update] 实时监控优化

parent 00af15a2
......@@ -19,6 +19,6 @@ public interface CrossSchemeMapper {
* @param crossId
* @return
*/
List<CrossSchemePO> listCrossSchemeInfo(@Param("crossId") String crossId, @Param("schemeNo")String schemeNo);
List<CrossSchemePO> listCrossSchemeInfo(@Param("crossId") String crossId, @Param("schemeNo")String schemeNo, @Param("id")Integer id);
}
package net.wanji.opt.dao.mapper;
import net.wanji.opt.po.base.CrossPlanOptLogPO;
import net.wanji.opt.po.base.CrossSchemeOptLogPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -10,9 +11,11 @@ import java.util.List;
* @date 2023/01/31 18:32
*/
@Repository
public interface CrossPlanOptLogMapper {
public interface CrossSchemeOptLogMapper {
List<CrossPlanOptLogPO> selectByCrossId();
List<CrossSchemeOptLogPO> selectByCrossId();
int insertOne(CrossPlanOptLogPO entity);
int insertOne(CrossSchemeOptLogPO entity);
int insertBatch(@Param("list") List<CrossSchemeOptLogPO> list);
}
......@@ -17,7 +17,7 @@ public class CrossTurnDataRealtimeDTO {
private String turnId;
@ApiModelProperty(name = "转向类型:u掉头;l左转;s直行;r右转;", notes = "")
private Integer turnType;
private String turnType;
@ApiModelProperty(name = "驶入方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北", notes = "")
private Integer inDir;
......
......@@ -15,7 +15,7 @@ public class CrossTurnInfoDTO {
private String turnId;
@ApiModelProperty(name = "转向类型:u掉头;l左转;s直行;r右转;",notes = "")
private Integer turnType;
private String turnType;
@ApiModelProperty(name = "驶入方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北",notes = "")
private Integer inDir;
......
......@@ -9,13 +9,13 @@ import java.util.Date;
* @date 2023/01/31 18:20
*/
@Data
public class CrossPlanOptLogPO {
public class CrossSchemeOptLogPO {
private int id;
private String crossId;
private String planNo;
private String schemeNo;
private int dirType;
private int turnType;
private String turnType;
private int offset;
private int ringNo;
private String phaseNo;
......
......@@ -34,7 +34,7 @@ public class CrossSchemeServiceImpl implements CrossSchemeService {
@Override
public List<CrossSchemeDTO> listCrossSchemeInfo(String crossId) {
List<CrossSchemePO> schemePOList = crossSchemeMapper.listCrossSchemeInfo(crossId, "");
List<CrossSchemePO> schemePOList = crossSchemeMapper.listCrossSchemeInfo(crossId, "", null);
return BeanListUtils.populateList(schemePOList, new ArrayList<>(), CrossSchemeDTO.class);
}
......
......@@ -3,9 +3,11 @@ package net.wanji.opt.task;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.enums.CrossStatusEnum;
import net.wanji.common.framework.Constants;
import net.wanji.opt.dao.mapper.trend.CrossDataRealtimeMapper;
import net.wanji.opt.dto.CrossDataRealtimeDTO;
import net.wanji.opt.po.CrossDataRealtimePO;
import net.wanji.opt.po.trend.CrossDataRealtimePO;
import net.wanji.opt.service.CrossOptimizeService;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
......@@ -25,6 +27,8 @@ public class CrossMonitorTask {
@Resource
CrossOptimizeService crossOptimizeService;
@Resource
CrossDataRealtimeMapper crossDataRealtimeMapper;
/**
* 路口实时监测
......@@ -55,6 +59,7 @@ public class CrossMonitorTask {
/**
* 获取异常路口数据
*
* @return
*/
public List<CrossDataRealtimeDTO> listAbnormalCross(List<CrossDataRealtimePO> crossDataRealtimePOList) {
......@@ -62,21 +67,22 @@ public class CrossMonitorTask {
List<CrossDataRealtimeDTO> dtoList = new ArrayList<>();
CrossDataRealtimeDTO dto = null;
int status = 0;
for (CrossDataRealtimePO po: crossDataRealtimePOList) {
for (CrossDataRealtimePO po : crossDataRealtimePOList) {
// 获取失衡、拥堵、溢出路口数据
if(Constants.SystemParam.NO.equals(po.getIsSpillover()) || Constants.SystemParam.NO.equals(po.getIsCongestion()) || Constants.SystemParam.NO.equals(po.getIsUnbalance())) {
if (Constants.SystemParam.NO.equals(po.getIsSpillover()) || Constants.SystemParam.NO.equals(po.getIsCongestion()) || Constants.SystemParam.NO.equals(po.getIsUnbalance())) {
continue;
}
if(Constants.SystemParam.YES.equals(po.getIsSpillover())) { // 溢出
if (Constants.SystemParam.YES.equals(po.getIsSpillover())) { // 溢出
status = CrossStatusEnum.SPILLOVER.getCode();
} else if(Constants.SystemParam.YES.equals(po.getIsCongestion())) { // 拥堵
} else if (Constants.SystemParam.YES.equals(po.getIsCongestion())) { // 拥堵
status = CrossStatusEnum.CONGESTION.getCode();
} else if(Constants.SystemParam.YES.equals(po.getIsUnbalance())) { // 失衡
} else if (Constants.SystemParam.YES.equals(po.getIsUnbalance())) { // 失衡
status = CrossStatusEnum.UNBALANCE.getCode();
}
dto = new CrossDataRealtimeDTO();
BeanUtils.copyProperties(po, dto);
dto.setCrossId(po.getCrossId());
dto.setStatus(status);
dto.setDirList(null);
......@@ -89,13 +95,16 @@ public class CrossMonitorTask {
/**
* 获取路口实时监测数据
* (暂定从数据中心kafka获取)
*
* @return
*/
public List<CrossDataRealtimePO> listCrossDataRealtime() {
return new ArrayList<>();
// todo test数据
List<CrossDataRealtimePO> crossDataRealtimePOList = new ArrayList<>(1);
CrossDataRealtimePO crossDataRealtimePO = crossDataRealtimeMapper.selectById("14Q1409IRF0");
crossDataRealtimePOList.add(crossDataRealtimePO);
return crossDataRealtimePOList;
}
}
\ No newline at end of file
......@@ -13,11 +13,11 @@
<result property="schedulesId" column="schedulesId"/>
<result property="schedulesName" column="schedulesName"/>
<result property="status" column="status"/>
<result property="planId" column="planId"/>
<result property="planNo" column="planNo"/>
<result property="planId" column="plan_id"/>
<result property="planNo" column="plan_no"/>
<result property="crossId" column="cross_id"/>
<result property="week" column="week"/>
<result property="specialDate" column="specialDate"/>
<result property="specialDate" column="special_date"/>
</resultMap>
......@@ -39,8 +39,8 @@
<!-- 查询调度计划信息列表 -->
<select id="listSchedulesPlan" parameterType="String" resultMap="CrossSchedulesPlanPO">
SELECT
s.id schedules_id
,s.`name` schedules_name
s.id schedulesId
,s.`name` schedulesName
,s.`status`
,s.cross_id
,p.id plan_id
......
<?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.CrossPlanOptLogMapper">
<mapper namespace="net.wanji.opt.dao.mapper.CrossSchemeOptLogMapper">
<!-- 通用查询映射结果 -->
<resultMap type="net.wanji.opt.po.base.CrossPlanOptLogPO" id="BaseResultMap">
<resultMap type="net.wanji.opt.po.base.CrossSchemeOptLogPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="crossId" column="cross_id"/>
<result property="planNo" column="plan_no"/>
<result property="schemeNo" column="scheme_no"/>
<result property="dirType" column="dir_type"/>
<result property="turnType" column="turn_type"/>
<result property="offset" column="offset"/>
......@@ -28,7 +28,7 @@
</resultMap>
<sql id="Base_Column_List">
id, cross_id, plan_no, dir_type, turn_type, offset, ring_no, phase_no, phase_order_id, ori_green_time,
id, 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, start_time, end_time, is_relation, relation_cross_id, opt_result, opt_result_desc,
data_batch_time, restore_result
</sql>
......@@ -36,7 +36,7 @@
<select id="selectByCrossId" parameterType="String" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from t_base_cross_plan_opt_log
from t_base_cross_scheme_opt_log
<where>
<if test="crossId != null and crossId != ''">
and cross_id = #{crossId}
......@@ -44,15 +44,29 @@
</where>
</select>
<insert id="insertOne" parameterType="net.wanji.opt.po.base.CrossPlanOptLogPO">
insert into t_base_cross_plan_opt_log (cross_id, plan_no, dir_type, turn_type, offset, ring_no, phase_no,
<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,
start_time,
end_time, is_relation, relation_cross_id, opt_result, opt_result_desc,
data_batch_time, restore_result)
values (#{crossId}, #{planNo}, #{dirType}, #{turnType}, #{offset}, #{ringNo}, #{phaseNo}, #{phaseOrderId},
values (#{crossId}, #{schemeNo}, #{dirType}, #{turnType}, #{offset}, #{ringNo}, #{phaseNo}, #{phaseOrderId},
#{oriGreenTime}, #{optTime}, #{optType}, #{optReason}, #{startTime}, #{endTime}, #{isRelation},
#{relationCrossId}, #{optResult}, #{optResultDesc}, #{dataBatchTime}, #{restoreResult})
</insert>
<insert id="insertBatch" 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,
start_time, end_time, is_relation, relation_cross_id, opt_result, opt_result_desc,
data_batch_time, restore_result)
values
<foreach collection="list" item="entity" separator=",">
(#{entity.crossId}, #{entity.schemeNo}, #{entity.dirType}, #{entity.turnType}, #{entity.offset}, #{entity.ringNo}, #{entity.phaseNo}, #{entity.phaseOrderId},
#{entity.oriGreenTime}, #{entity.optTime}, #{entity.optType}, #{entity.optReason}, #{entity.startTime}, #{entity.endTime}, #{entity.isRelation},
#{entity.relationCrossId}, #{entity.optResult}, #{entity.optResultDesc}, #{entity.dataBatchTime}, #{entity.restoreResult})
</foreach>
</insert>
</mapper>
\ No newline at end of file
......@@ -31,6 +31,9 @@
<if test="schemeNo != null and schemeNo != ''">
and scheme_no = #{schemeNo}
</if>
<if test="id != null and id != ''">
and id = #{id}
</if>
</select>
......
......@@ -12,17 +12,17 @@ import java.util.List;
*/
@Repository
public interface RidInfoMapper {
Double selectRoadLength(@Param("startCrossid") String startCrossid,
@Param("endCrossid") String endCrossid);
Double selectRoadLength(@Param("startCrossId") String startCrossId,
@Param("endCrossId") String endCrossId);
String selectStartCrossOutDir(@Param("startCrossid") String startCrossid,
@Param("endCrossid") String endCrossid);
String selectStartCrossOutDir(@Param("startCrossId") String startCrossId,
@Param("endCrossId") String endCrossId);
String selectWkt(@Param("startCrossid") String startCrossid,
@Param("endCrossid") String endCrossid);
String selectWkt(@Param("startCrossId") String startCrossId,
@Param("endCrossId") String endCrossId);
List<RidInfoEntity> selectOne(@Param("startCrossid") String startCrossid,
@Param("endCrossid") String endCrossid);
List<RidInfoEntity> selectOne(@Param("startCrossId") String startCrossId,
@Param("endCrossId") String endCrossId);
RidInfoEntity selectByEndInDir(String endCrossId, int spilloverDirInt);
}
......@@ -40,19 +40,19 @@
<select id="selectRoadLength" resultType="java.lang.Double">
select length
from t_base_rid_info
where start_crossid = #{startCrossid} and end_crossid = #{endCrossid}
where start_crossid = #{startCrossId} and end_crossid = #{endCrossId}
</select>
<select id="selectStartCrossOutDir" resultType="java.lang.String">
select start_crossdirid
from t_base_rid_info
where start_crossid = #{startCrossid} and end_crossid = #{endCrossid}
where start_crossid = #{startCrossId} and end_crossid = #{endCrossId}
</select>
<select id="selectWkt" resultType="java.lang.String">
select wkt
from t_base_rid_info
where start_crossid = #{startCrossid} and end_crossid = #{endCrossid}
where start_crossid = #{startCrossId} and end_crossid = #{endCrossId}
</select>
<select id="selectOne" resultMap="BaseResultMap">
......@@ -61,10 +61,10 @@
from t_base_rid_info
<where>
<if test="startCrossId != null and startCrossId != ''">
and start_cross_id = #{startCrossid}
and start_cross_id = #{startCrossId}
</if>
<if test="endCrossId != null and endCrossId != ''">
and end_cross_id = #{endCrossid}
and end_cross_id = #{endCrossId}
</if>
</where>
</select>
......
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