Commit 08148ab4 authored by zhoushiguang's avatar zhoushiguang

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	wj-databus/src/main/java/net/wanji/databus/po/CrossDataRealtimePO.java
parents cbf4195a 7ccfb619
......@@ -18,6 +18,11 @@
</properties>
<dependencies>
<!--客户端负载均衡loadbalancer-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>knife4j-spring-boot-starter</artifactId>
......
......@@ -16,8 +16,9 @@ public enum EventStatusEnum {
ZERO(0, "未处理"),
ONE(1, "分析中"),
TWO(2, "优化中"),
THREE(3, "优化中"),
FOUR(4, "已结束");
THREE(3, "优化完"),
// 信控没有已结束,优化完
FOUR(4, "优化完");
private Integer code;
private String desc;
......
......@@ -92,9 +92,9 @@ public class CrossIndexServiceImpl implements CrossIndexService {
if (!CollectionUtils.isEmpty(list)) {
for (StrategyCrossResultEntity entity : list) {
CrossOptResult crossOptResult = new CrossOptResult();
Date date = DateUtil.parse(entity.getIssueTime(), "yyyy-MM-dd HH:mm:ss");
Date date = entity.getIssueTime();
//Date date = DateUtil.parse(entity.getIssueTime(), "yyyy-MM-dd HH:mm:ss");
crossOptResult.setTimeStamp(date);
String timingPlan = entity.getTimingPlan();
Integer countDown = entity.getCountDown();
if (entity.getCurrentAlgo() == 2) {
countDown = 5;
......@@ -127,9 +127,18 @@ public class CrossIndexServiceImpl implements CrossIndexService {
aiOptResultVO.setStrategy(currentAlgo);
// 失衡 均衡调控,其他效率提升
aiOptResultVO.setOptMethod(Objects.equals(1, currentAlgo) ? StrategyControlEnum.ONE.getMethod() : StrategyControlEnum.TWO.getMethod());
// 失衡 优化中,其他,优化完
Integer optStatus = Objects.equals(1, currentAlgo) ? OptStatusEnum.ONE.getCode() : OptStatusEnum.TWO.getCode();
aiOptResultVO.setOptStatus(optStatus);
// 失衡 优化中,15分钟内,优化中,其他,优化完
aiOptResultVO.setOptStatus(OptStatusEnum.TWO.getCode());
if (Objects.equals(1, currentAlgo)) {
Date issueTimeDate = resultEntity.getIssueTime();
//Date issueTimeDate = DateUtils.parseDate(issueTime);
long optTime = issueTimeDate.getTime();
long currentTimeMillis = System.currentTimeMillis();
long offset = currentTimeMillis - optTime;
if (offset <= 15 * 60 * 1000) {
aiOptResultVO.setOptStatus(OptStatusEnum.ONE.getCode());
}
}
aiOptResultVO.setOptStatusName(Objects.equals(1, currentAlgo) ? OptStatusEnum.ONE.getDesc() : OptStatusEnum.TWO.getDesc());
if (Objects.isNull(currentAlgo)) {
aiOptResultVO.setOptStatus(-1);
......
......@@ -6,6 +6,9 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import net.wanji.common.utils.tool.DateUtil;
import java.util.Date;
/**
* @author duanruiming
......@@ -24,10 +27,10 @@ public class StrategyCrossResultEntity {
private Integer currentAlgo;
@TableField("request_time")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private String requestTime;
private Date requestTime;
@TableField("issue_time")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private String issueTime;
private Date issueTime;
@TableField("response_code")
private Integer responseCode;
@TableField("timing_plan")
......
......@@ -2,6 +2,7 @@ package net.wanji.opt.synthesis.service.impl;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.alibaba.excel.util.DateUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.JsonProcessingException;
......@@ -189,9 +190,14 @@ public class StrategyControlServiceImpl implements StrategyControlService {
List<StrategyControlHistVO> results = new ArrayList<>();
LocalDate currentDate = LocalDate.now();
LocalDateTime midnight = currentDate.atStartOfDay();
// 查询当前绿波历史记录
setGreenOptHist(results, midnight, format);
setCrossOptHist(results, midnight);
try {
// 查询当前绿波历史记录
setGreenOptHist(results, midnight, format);
setCrossOptHist(results, midnight);
} catch (ParseException e) {
log.error("优化策略查询失败:", e);
JsonViewObject.newInstance().fail("优化策略查询失败");
}
List<StrategyControlHistVO> sorted = results.stream().sorted(Comparator.comparing(StrategyControlHistVO::getOptTime).reversed()).collect(Collectors.toList());
return JsonViewObject.newInstance().success(sorted);
}
......@@ -210,8 +216,14 @@ public class StrategyControlServiceImpl implements StrategyControlService {
histVO.setWkt(coordinateByCrossId.replace("POINT(", "").replace(" ", ",").replace(")", ""));
histVO.setStrategy(resultEntity.getCurrentAlgo());
histVO.setStrategyName(StrategyCrossAlgoEnum.getDescByCode(resultEntity.getCurrentAlgo()));
histVO.setOptTime(resultEntity.getIssueTime());
histVO.setResult(Objects.equals(200, resultEntity.getResponseCode()) ? "成功" : "失败");
Date issueTime = resultEntity.getIssueTime();
String format = DateUtils.format(issueTime, "yyyy-MM-dd HH:mm:ss");
histVO.setOptTime(format);
if (resultEntity.getCurrentAlgo() != 1) {
histVO.setResult(Objects.equals(200, resultEntity.getResponseCode()) ? "成功" : "失败");
} else {
histVO.setResult("成功");
}
results.add(histVO);
}
}
......
......@@ -105,7 +105,9 @@ public class SignalCommandSyncTask {
List<SignalCommandPO> sendList = new ArrayList<>();
sendList.addAll(insertList);
sendList.addAll(updateList);
sendAlarmKafka(sendList);
if (!CollectionUtils.isEmpty(sendList)) {
sendAlarmKafka(sendList);
}
} else {
log.error("从路口灯态缓存获取控制模式在线离线状态为空:{}", crossLightsStatusMap);
}
......
......@@ -4,13 +4,11 @@ import com.alibaba.fastjson.annotation.JSONField;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import net.wanji.databus.config.DoubleToTwoDecimalPlacesSerializer;
import org.omg.CORBA.UNKNOWN;
import java.util.Date;
......@@ -41,13 +39,14 @@ public class CrossDataRealtimePO {
* 交通指数(1~10)
*/
@ApiModelProperty(value = "交通指数(1~10)", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double trafficIndex;
/**
* 开始时间:yyyy-MM-dd HH;mm:ss
*/
@ApiModelProperty(value = "开始时间:yyyy-MM-dd HH:mm:ss", notes = "")
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date startTime;
@ApiModelProperty(value = "结束时间:yyyy-MM-dd HH:mm:ss", notes = "")
......@@ -73,16 +72,19 @@ public class CrossDataRealtimePO {
* 失衡指数
*/
@ApiModelProperty(value = "失衡指数", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double unbalanceIndex;
/**
* 溢出指数
*/
@ApiModelProperty(value = "溢出指数", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double spilloverIndex;
/**
* 拥堵指数
*/
@ApiModelProperty(value = "拥堵指数", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double congestionIndex;
/**
* 路口失衡方向:1,2,3...
......@@ -108,22 +110,24 @@ public class CrossDataRealtimePO {
* 交通流率/h
*/
@ApiModelProperty(value = "交通流率/h", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double flowRate;
/**
* 平均速度(km/h)
*/
@ApiModelProperty(value = "平均速度(km/h)", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double speed;
/**
* 最大排队(米)
*/
@ApiModelProperty(value = "最大排队(米)", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double queueLength;
/**
* 停车次数(次)
*/
@ApiModelProperty(value = "停车次数(次)", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double stopTimes;
/**
* 延误时间(秒)
......@@ -154,11 +158,13 @@ public class CrossDataRealtimePO {
* 红灯清空率
*/
@ApiModelProperty(value = "红灯清空率", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double clearRate;
/**
* 负载均衡度
*/
@ApiModelProperty(value = "负载均衡度", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double loadBalance;
/**
* 平均未清空车辆数量
......@@ -169,25 +175,32 @@ public class CrossDataRealtimePO {
* 绿灯有效利用率
*/
@ApiModelProperty(value = "绿灯有效利用率", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double greenLightEfficiency;
/**
* 溢流率
*/
@ApiModelProperty(value = "溢流率", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private Double effusionRate;
@ApiModelProperty(name = "不停车率",notes = "")
@ApiModelProperty(name = "不停车率", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
public Double noStopRate;
@ApiModelProperty(name = "一次停车率",notes = "")
@ApiModelProperty(name = "一次停车率", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
public Double oneStopRate;
@ApiModelProperty(name = "二次停车率",notes = "")
@ApiModelProperty(name = "二次停车率", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
public Double twoStopRate;
@ApiModelProperty(name = "三次停车率",notes = "")
@ApiModelProperty(name = "三次停车率", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
public Double threeStopRate;
@ApiModelProperty(value = "非机动车流量", notes = "")
private int nonMotorFlow;
@ApiModelProperty(value = "85位速度(km/h)", notes = "")
@TableField(value = "v_85")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private double v85;
@ApiModelProperty(value = "大车流量", notes = "")
private int trafficFlowA;
......@@ -196,10 +209,14 @@ public class CrossDataRealtimePO {
@ApiModelProperty(value = "小车流量", notes = "")
private int trafficFlowC;
@ApiModelProperty(value = "时间占有率", notes = "")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private double timeOccupancy;
@ApiModelProperty(value = "空间占有率", notes = "平均空间密度(长度占比)")
@JsonSerialize(using = DoubleToTwoDecimalPlacesSerializer.class)
private double vehicleLengthRatioMean;
/** add 20241123 适配神思数据 */
/**
* add 20241123 适配神思数据
*/
@ApiModelProperty(value = "执行策略 失衡 2拥堵 3溢出 4死锁 5 空放", notes = "")
private Integer strategy;
@ApiModelProperty(value = "策略执行持续时间;单位:s", notes = "")
......
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