Commit 018866b7 authored by zhouleilei's avatar zhouleilei

Merge remote-tracking branch 'origin/master'

parents af2428c0 89c54ba6
...@@ -9,8 +9,9 @@ import lombok.Getter; ...@@ -9,8 +9,9 @@ import lombok.Getter;
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public enum CrossOptStrategyEnum { public enum CrossOptResultStrategyEnum {
ZERO(0, "无策略"), // 优化策略
ZERO(0, "均衡调控"),
ONE(1, "绿灯空放"), ONE(1, "绿灯空放"),
TWO(2, "失衡"), TWO(2, "失衡"),
THREE(3, "溢出"); THREE(3, "溢出");
...@@ -19,11 +20,11 @@ public enum CrossOptStrategyEnum { ...@@ -19,11 +20,11 @@ public enum CrossOptStrategyEnum {
private String desc; private String desc;
public static String getDesc(int code) { public static String getDesc(int code) {
for (CrossOptStrategyEnum value : CrossOptStrategyEnum.values()) { for (CrossOptResultStrategyEnum value : CrossOptResultStrategyEnum.values()) {
if (code == value.code) { if (code == value.code) {
return value.getDesc(); return value.getDesc();
} }
} }
return "无策略"; return CrossOptResultStrategyEnum.ZERO.getDesc();
} }
} }
...@@ -10,7 +10,7 @@ import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper; ...@@ -10,7 +10,7 @@ import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.dao.mapper.CrossDirDataHistMapper; import net.wanji.databus.dao.mapper.CrossDirDataHistMapper;
import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper; import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper;
import net.wanji.databus.po.*; import net.wanji.databus.po.*;
import net.wanji.opt.common.enums.CrossOptStrategyEnum; import net.wanji.opt.common.enums.CrossOptResultStrategyEnum;
import net.wanji.opt.common.enums.OptStatusEnum; import net.wanji.opt.common.enums.OptStatusEnum;
import net.wanji.opt.common.enums.StrategyControlEnum; import net.wanji.opt.common.enums.StrategyControlEnum;
import net.wanji.opt.dao.mapper.HoloEventMapper; import net.wanji.opt.dao.mapper.HoloEventMapper;
...@@ -95,7 +95,6 @@ public class CrossIndexServiceImpl implements CrossIndexService { ...@@ -95,7 +95,6 @@ public class CrossIndexServiceImpl implements CrossIndexService {
for (StrategyCrossResultEntity entity : list) { for (StrategyCrossResultEntity entity : list) {
CrossOptResult crossOptResult = new CrossOptResult(); CrossOptResult crossOptResult = new CrossOptResult();
Date date = entity.getIssueTime(); Date date = entity.getIssueTime();
//Date date = DateUtil.parse(entity.getIssueTime(), "yyyy-MM-dd HH:mm:ss");
crossOptResult.setTimeStamp(date); crossOptResult.setTimeStamp(date);
Integer countDown = entity.getCountDown(); Integer countDown = entity.getCountDown();
if (entity.getCurrentAlgo() == 2) { if (entity.getCurrentAlgo() == 2) {
...@@ -104,9 +103,17 @@ public class CrossIndexServiceImpl implements CrossIndexService { ...@@ -104,9 +103,17 @@ public class CrossIndexServiceImpl implements CrossIndexService {
crossOptResult.setCountDown(countDown); crossOptResult.setCountDown(countDown);
Integer currentAlgo = entity.getCurrentAlgo(); Integer currentAlgo = entity.getCurrentAlgo();
crossOptResult.setStrategy(currentAlgo); crossOptResult.setStrategy(currentAlgo);
crossOptResult.setStrategyName(CrossOptStrategyEnum.getDesc(currentAlgo)); crossOptResult.setStrategyName(CrossOptResultStrategyEnum.getDesc(currentAlgo));
crossOptResults.add(crossOptResult); crossOptResults.add(crossOptResult);
} }
} else {
// 如果当前时间没有数据
CrossOptResult crossOptResult = new CrossOptResult();
crossOptResult.setTimeStamp(new Date());
crossOptResult.setCountDown(0);
crossOptResult.setStrategy(0);
crossOptResult.setStrategyName(CrossOptResultStrategyEnum.getDesc(0));
crossOptResults.add(crossOptResult);
} }
return crossOptResults; return crossOptResults;
} }
...@@ -172,13 +179,13 @@ public class CrossIndexServiceImpl implements CrossIndexService { ...@@ -172,13 +179,13 @@ public class CrossIndexServiceImpl implements CrossIndexService {
for (Map.Entry<Integer, List<StrategyCrossResultEntity>> entry : listMap.entrySet()) { for (Map.Entry<Integer, List<StrategyCrossResultEntity>> entry : listMap.entrySet()) {
Integer currentAlgo = entry.getKey(); Integer currentAlgo = entry.getKey();
List<StrategyCrossResultEntity> value = entry.getValue(); List<StrategyCrossResultEntity> value = entry.getValue();
if (Objects.equals(currentAlgo, CrossOptStrategyEnum.ONE.getCode())) { if (Objects.equals(currentAlgo, CrossOptResultStrategyEnum.ONE.getCode())) {
crossStatusCountVO.setPhaseEmptyCount(value.size()); crossStatusCountVO.setPhaseEmptyCount(value.size());
} }
if (Objects.equals(currentAlgo, CrossOptStrategyEnum.TWO.getCode())) { if (Objects.equals(currentAlgo, CrossOptResultStrategyEnum.TWO.getCode())) {
crossStatusCountVO.setUnbalanceCount(value.size()); crossStatusCountVO.setUnbalanceCount(value.size());
} }
if (Objects.equals(currentAlgo, CrossOptStrategyEnum.THREE.getCode())) { if (Objects.equals(currentAlgo, CrossOptResultStrategyEnum.THREE.getCode())) {
crossStatusCountVO.setOverFlowCount(value.size()); crossStatusCountVO.setOverFlowCount(value.size());
} }
} }
......
...@@ -267,7 +267,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -267,7 +267,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
.average() .average()
.orElse(0.0); .orElse(0.0);
double round = (double) (Math.round(v)); double round = (double) (Math.round(v));
vo.setValue(round); vo.setValue(v);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDataHistPOExt::getGreenLightEfficiency) .mapToDouble(CrossDataHistPOExt::getGreenLightEfficiency)
...@@ -400,7 +400,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -400,7 +400,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
.average() .average()
.orElse(0.0); .orElse(0.0);
double round = (double) (Math.round(v)); double round = (double) (Math.round(v));
vo.setValue(round); vo.setValue(v);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossDirDataHistPO::getGreenLightEfficiency) .mapToDouble(CrossDirDataHistPO::getGreenLightEfficiency)
...@@ -515,7 +515,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -515,7 +515,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
.average() .average()
.orElse(0.0); .orElse(0.0);
double round = (double) (Math.round(v)); double round = (double) (Math.round(v));
vo.setValue(round); vo.setValue(v);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossTurnDataHistPO::getGreenLightEfficiency) .mapToDouble(CrossTurnDataHistPO::getGreenLightEfficiency)
...@@ -635,7 +635,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService { ...@@ -635,7 +635,7 @@ public class MainlineEvaluateServiceImpl implements MainlineEvaluateService {
.average() .average()
.orElse(0.0); .orElse(0.0);
double round = (double) (Math.round(v)); double round = (double) (Math.round(v));
vo.setValue(round); vo.setValue(v);
} else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) { } else if (Objects.equals(metricCode, StrategyAndMetricsEnum.Metrics.GREEN_LIGHT_EFFICIENCY.getCode())) {
double v = filteredList.stream() double v = filteredList.stream()
.mapToDouble(CrossLaneDataHistPOExt::getGreenLightEfficiency) .mapToDouble(CrossLaneDataHistPOExt::getGreenLightEfficiency)
......
...@@ -259,6 +259,9 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -259,6 +259,9 @@ public class StrategyControlServiceImpl implements StrategyControlService {
StrategyControlDataEntity strategyControlDataEntity = strategyList.get(0); StrategyControlDataEntity strategyControlDataEntity = strategyList.get(0);
histVO.setStrategy(strategyControlDataEntity.getStrategy()); histVO.setStrategy(strategyControlDataEntity.getStrategy());
histVO.setStrategyName("绿波带"); histVO.setStrategyName("绿波带");
} else {
histVO.setStrategy(0);
histVO.setStrategyName("绿波带");
} }
histVO.setOptTime(entity.getControlTime()); histVO.setOptTime(entity.getControlTime());
histVO.setResult(Objects.equals(1, entity.getControlMethod()) ? "失败" : "成功"); histVO.setResult(Objects.equals(1, entity.getControlMethod()) ? "失败" : "成功");
...@@ -313,6 +316,7 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -313,6 +316,7 @@ public class StrategyControlServiceImpl implements StrategyControlService {
} }
strategyControlDataEntity.setCrossName(greenwaveInfoPO.getName()); strategyControlDataEntity.setCrossName(greenwaveInfoPO.getName());
strategyControlDataEntity.setWkt(greenwaveInfoPO.getWkt()); strategyControlDataEntity.setWkt(greenwaveInfoPO.getWkt());
strategyControlDataEntity.setOptMethod("效率提升");
results.add(strategyControlDataEntity); results.add(strategyControlDataEntity);
} }
} }
...@@ -366,8 +370,6 @@ public class StrategyControlServiceImpl implements StrategyControlService { ...@@ -366,8 +370,6 @@ public class StrategyControlServiceImpl implements StrategyControlService {
queryWrapper.eq(StrategyControlDataEntity::getBizType, type); queryWrapper.eq(StrategyControlDataEntity::getBizType, type);
queryWrapper.le(StrategyControlDataEntity::getScheduleStart, current); queryWrapper.le(StrategyControlDataEntity::getScheduleStart, current);
queryWrapper.ge(StrategyControlDataEntity::getScheduleEnd, current); queryWrapper.ge(StrategyControlDataEntity::getScheduleEnd, current);
//queryWrapper.ge(StrategyControlDataEntity::getScheduleStart, current);
//queryWrapper.le(StrategyControlDataEntity::getScheduleEnd, current);
List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper); List<StrategyControlDataEntity> entities = strategyControlInfoMapper.selectList(queryWrapper);
List<StrategyControlDataEntity> results = new ArrayList<>(entities.size()); List<StrategyControlDataEntity> results = new ArrayList<>(entities.size());
for (StrategyControlDataEntity entity : entities) { for (StrategyControlDataEntity entity : entities) {
......
package net.wanji.opt.vo; package net.wanji.opt.vo;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import net.wanji.opt.config.Double2TwoDecimalPlacesSerializer;
/** /**
* @author Kent HAN * @author Kent HAN
...@@ -20,6 +22,7 @@ public class MainlineEvaluateBottomCurveVO { ...@@ -20,6 +22,7 @@ public class MainlineEvaluateBottomCurveVO {
private String scopeName; private String scopeName;
@ApiModelProperty(value = "数值") @ApiModelProperty(value = "数值")
@JsonSerialize(using = Double2TwoDecimalPlacesSerializer.class)
private Double value; private Double value;
@ApiModelProperty(value = "指标时间戳") @ApiModelProperty(value = "指标时间戳")
......
...@@ -333,7 +333,7 @@ ...@@ -333,7 +333,7 @@
<select id="findGreenWaveRunState" resultType="net.wanji.opt.vo.GreenWaveRunStateVO"> <select id="findGreenWaveRunState" resultType="net.wanji.opt.vo.GreenWaveRunStateVO">
select type as state,count(*) count, select type as state,count(*) count,
SUM(TIMESTAMPDIFF(SECOND,start_time, end_time)) duration, SUM(TIMESTAMPDIFF(SECOND,start_time, end_time)) duration,
TIMESTAMPDIFF(SECOND,#{startDate}, #{endDate}) totalTime TIMESTAMPDIFF(SECOND,#{startDate}, #{endDate}) total_time
from t_event_info t from t_event_info t
where start_time > #{startDate} and start_time &lt; #{endDate} where start_time > #{startDate} and start_time &lt; #{endDate}
<if test="eventTypeList!=null and eventTypeList.size>0"> <if test="eventTypeList!=null and eventTypeList.size>0">
...@@ -421,7 +421,7 @@ ...@@ -421,7 +421,7 @@
t1.lane_id, t1.lane_id,
t1.lane_no, t1.lane_no,
t1.turn as turn_type, t1.turn as turn_type,
MIN(ifnull(t2.start_time,#{startDate})) start_time, MIN(ifnull(t2.unit_time,#{startDate})) start_time,
SUM(t2.flow) flow, SUM(t2.flow) flow,
round(AVG(t2.speed),2) speed, round(AVG(t2.speed),2) speed,
MAX(t2.queue_length) max_queue_length, MAX(t2.queue_length) max_queue_length,
...@@ -446,11 +446,11 @@ ...@@ -446,11 +446,11 @@
left join ( left join (
SELECT id as lane_id,cross_id,start_time,flow,speed,queue_length,stop_times,delay_time,sturation , SELECT id as lane_id,cross_id,start_time,flow,speed,queue_length,stop_times,delay_time,sturation ,
(case (case
when #{groupType}=0 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE))) when #{groupType}=0 then start_time
when #{groupType}=1 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)) / 900) when #{groupType}=1 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 15 ) * 15 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=2 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)) / 1800) when #{groupType}=2 then DATE_FORMAT(concat( date( start_time ), ' ', HOUR ( start_time ), ':', floor( MINUTE ( start_time ) / 30 ) * 30 ),'%Y-%m-%d %H:%i:00' )
when #{groupType}=3 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)) / 3600) when #{groupType}=3 then DATE_FORMAT(start_time,'%Y-%m-%d %H:00:00' )
when #{groupType}=4 then CEIL(UNIX_TIMESTAMP(DATE_ADD(start_time,INTERVAL 5 MINUTE)) / (3600*24)) when #{groupType}=4 then DATE_FORMAT(start_time,'%Y-%m-%d 00:00:00' )
end end
) unit_time ) unit_time
from t_lane_data_hist from t_lane_data_hist
......
...@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -89,6 +90,24 @@ public class SignalCommandSyncTask { ...@@ -89,6 +90,24 @@ public class SignalCommandSyncTask {
log.error("路口在线状态控制模式更新失败,路口编号信息:{}", entry, e); log.error("路口在线状态控制模式更新失败,路口编号信息:{}", entry, e);
} }
} }
saveAndUpdate(insertList, updateList);
List<SignalCommandPO> sendList = new ArrayList<>();
sendList.addAll(insertList);
sendList.addAll(updateList);
if (!CollectionUtils.isEmpty(sendList)) {
sendAlarmKafka(sendList);
}
} else {
log.error("从路口灯态缓存获取控制模式在线离线状态为空:{}", crossLightsStatusMap);
}
} catch (Exception e) {
log.error("信号机状态同步异常:", e);
}
}
@Transactional(rollbackFor = Exception.class)
public void saveAndUpdate(List<SignalCommandPO> insertList, List<SignalCommandPO> updateList) {
try {
if (!CollectionUtils.isEmpty(insertList)) { if (!CollectionUtils.isEmpty(insertList)) {
signalCommandPOMapper.insertBatch(insertList); signalCommandPOMapper.insertBatch(insertList);
List<SignalCommandLogPO> signalCommandLogPOS = new ArrayList<>(insertList.size()); List<SignalCommandLogPO> signalCommandLogPOS = new ArrayList<>(insertList.size());
...@@ -102,17 +121,9 @@ public class SignalCommandSyncTask { ...@@ -102,17 +121,9 @@ public class SignalCommandSyncTask {
signalCommandLogPOMapper.insertBatch(signalCommandLogPOS); signalCommandLogPOMapper.insertBatch(signalCommandLogPOS);
log.info("路口状态控制模式变动,数据库更新成功:{}", updateList); log.info("路口状态控制模式变动,数据库更新成功:{}", updateList);
} }
List<SignalCommandPO> sendList = new ArrayList<>();
sendList.addAll(insertList);
sendList.addAll(updateList);
if (!CollectionUtils.isEmpty(sendList)) {
sendAlarmKafka(sendList);
}
} else {
log.error("从路口灯态缓存获取控制模式在线离线状态为空:{}", crossLightsStatusMap);
}
} catch (Exception e) { } catch (Exception e) {
log.error("信号机状态同步异常:", e); log.error("路口状态控制模式变动,数据库更新失败:", e);
throw new RuntimeException(e);
} }
} }
...@@ -121,8 +132,6 @@ public class SignalCommandSyncTask { ...@@ -121,8 +132,6 @@ public class SignalCommandSyncTask {
insertPO.setCrossId(crossId); insertPO.setCrossId(crossId);
insertPO.setStatus(statusCache); insertPO.setStatus(statusCache);
insertPO.setRunMode(runModeCache); insertPO.setRunMode(runModeCache);
insertPO.setCommandResult(1);
insertPO.setUpdateCount(0);
insertPO.setInsertTime(new Date()); insertPO.setInsertTime(new Date());
insertPO.setLampTime(lampTime); insertPO.setLampTime(lampTime);
return insertPO; return insertPO;
......
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