Commit 44545b62 authored by duanruiming's avatar duanruiming

[update] 实时监控优化

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