Commit 80cc4f8d authored by duanruiming's avatar duanruiming

[add] 优化绿波数据插入逻辑sql

parent 2ca7a1cc
...@@ -200,8 +200,9 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -200,8 +200,9 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<StrategyGreenOptHistEntity> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, greenId); queryWrapper.eq(StrategyGreenOptHistEntity::getGreenId, greenId);
queryWrapper.ge(StrategyGreenOptHistEntity::getControlTime, startOfDay); queryWrapper.ge(StrategyGreenOptHistEntity::getControlTime, startOfDay);
queryWrapper.ne(StrategyGreenOptHistEntity::getControlMethod, -1);
List<StrategyGreenOptHistEntity> entities = strategyGreenOptHistMapper.selectList(queryWrapper); List<StrategyGreenOptHistEntity> entities = strategyGreenOptHistMapper.selectList(queryWrapper);
if (!CollectionUtils.isEmpty(greenwaveHistPOS) && !CollectionUtils.isEmpty(entities)) { if (!CollectionUtils.isEmpty(greenwaveHistPOS)) {
for (GreenwaveHistPO histPO : greenwaveHistPOS) { for (GreenwaveHistPO histPO : greenwaveHistPOS) {
Integer curGreenId = histPO.getGreenId(); Integer curGreenId = histPO.getGreenId();
Date curStartTime = histPO.getStartTime(); Date curStartTime = histPO.getStartTime();
...@@ -209,6 +210,14 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -209,6 +210,14 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
Date startTimeminuteDate = get5MinuteDate(curStartTimeStr); Date startTimeminuteDate = get5MinuteDate(curStartTimeStr);
String roadDirection = histPO.getRoadDirection(); String roadDirection = histPO.getRoadDirection();
Double speed = histPO.getSpeed(); Double speed = histPO.getSpeed();
if (CollectionUtils.isEmpty(entities)) {
GreenBeltSpeedWidthVO vo = new GreenBeltSpeedWidthVO();
vo.setStartTime(curStartTime);
vo.setSpeed(speed);
vo.setWidth(0.0);
vo.setDirName(GreenBeltDirEnum.getDesc(roadDirection));
results.add(vo);
} else {
for (StrategyGreenOptHistEntity entity : entities) { for (StrategyGreenOptHistEntity entity : entities) {
Integer optGreenId = entity.getGreenId(); Integer optGreenId = entity.getGreenId();
String controlTime = entity.getControlTime(); String controlTime = entity.getControlTime();
...@@ -223,8 +232,15 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService { ...@@ -223,8 +232,15 @@ public class GreenBeltServiceImpl implements GreenBeltInfoService {
vo.setWidth(greenWidthTime); vo.setWidth(greenWidthTime);
vo.setDirName(GreenBeltDirEnum.getDesc(dir)); vo.setDirName(GreenBeltDirEnum.getDesc(dir));
results.add(vo); results.add(vo);
} else {
GreenBeltSpeedWidthVO vo = new GreenBeltSpeedWidthVO();
vo.setStartTime(curStartTime);
vo.setSpeed(speed);
vo.setWidth(0.0);
vo.setDirName(GreenBeltDirEnum.getDesc(roadDirection));
results.add(vo);
}
} }
} }
} }
} }
......
...@@ -88,10 +88,13 @@ ...@@ -88,10 +88,13 @@
<insert id="insertBatch" parameterType="net.wanji.databus.dao.entity.GreenwaveHistPO"> <insert id="insertBatch" parameterType="net.wanji.databus.dao.entity.GreenwaveHistPO">
insert into t_greenwave_hist insert into t_greenwave_hist
(<include refid="Base_Column_List"/>) (green_id, status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability,cord_queue_ratio,uncoordinate_phase_queue, start_time, gmt_create,gmt_modified,
strategy, strategy_duration, optimize_count, optimize_seconds,
green_wave_width, direction, plan_cycle, speed_high, speed_down, road_direction, sturation, batch_time)
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
(#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex},#{entity.speed}, (#{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex},#{entity.speed},
#{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate}, #{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate},
#{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio}, #{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio},
#{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified}, #{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified},
...@@ -100,6 +103,8 @@ ...@@ -100,6 +103,8 @@
#{entity.speedDown}, #{entity.roadDirection}, #{entity.sturation}, #{entity.batchTime} #{entity.speedDown}, #{entity.roadDirection}, #{entity.sturation}, #{entity.batchTime}
) )
</foreach> </foreach>
ON DUPLICATE KEY UPDATE
gmt_modified = values(gmt_modified)
</insert> </insert>
</mapper> </mapper>
...@@ -54,10 +54,13 @@ ...@@ -54,10 +54,13 @@
<insert id="insertBatch" parameterType="net.wanji.databus.dao.entity.GreenwaveRealtimePO"> <insert id="insertBatch" parameterType="net.wanji.databus.dao.entity.GreenwaveRealtimePO">
insert into t_greenwave_realtime insert into t_greenwave_realtime
(<include refid="Base_Column_List"></include>) (green_id, status,type,traffic_index,speed,trval_time,stop_times,queue_length,cong_rate,delay_time,nopark_pass_rate,
cord_reliability, cord_queue_ratio, uncoordinate_phase_queue, start_time, gmt_create,gmt_modified,
strategy, strategy_duration, optimize_count, optimize_seconds,
green_wave_width, direction, plan_cycle, speed_high, speed_down, road_direction, sturation, batch_time)
values values
<foreach collection="list" item="entity" separator=","> <foreach collection="list" item="entity" separator=",">
(#{entity.id}, #{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex}, #{entity.speed}, (#{entity.greenId}, #{entity.status}, #{entity.type}, #{entity.trafficIndex}, #{entity.speed},
#{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate}, #{entity.trvalTime}, #{entity.stopTimes}, #{entity.queueLength}, #{entity.congRate},
#{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio}, #{entity.delayTime}, #{entity.noparkPassRate}, #{entity.cordReliability}, #{entity.cordQueueRatio},
#{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified}, #{entity.uncoordinatePhaseQueue}, #{entity.startTime}, #{entity.gmtCreate}, #{entity.gmtModified},
......
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