Commit b4bde89b authored by duanruiming's avatar duanruiming

[update] 路口优化结果添加字段

parent 969552c5
......@@ -32,6 +32,7 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle
/**
* 相位空放优化指标周期
*
* @param record
* @param acknowledgment
* @throws Exception
......@@ -76,10 +77,15 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle
if (StringUtils.isNotBlank(message)) {
ObjectMapper mapper = JacksonUtils.getInstance();
ImbalanceAlgorithmDTO imbalanceAlgorithmDTO = mapper.readValue(message, ImbalanceAlgorithmDTO.class);
crossStrategyOptService.save(imbalanceAlgorithmDTO);
// 未操作的不存
// 溢出 rtnType=0 不操作
if (0 != imbalanceAlgorithmDTO.getRtnType()) {
crossStrategyOptService.save(imbalanceAlgorithmDTO);
}
}
acknowledgment.acknowledge();
}
@Override
@NonNull
public Object handleError(Message<?> message, ListenerExecutionFailedException e) {
......@@ -94,265 +100,4 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle
log.error(errorMessage);
return KafkaListenerErrorHandler.super.handleError(message, exception, consumer);
}
public static void main(String[] args) throws Exception {
ObjectMapper mapper = JacksonUtils.getInstance();
ImbalanceAlgorithmDTO imbalanceAlgorithmDTO = mapper.readValue(str, ImbalanceAlgorithmDTO.class);
System.err.println(imbalanceAlgorithmDTO);
}
public static String str = "{\n" +
" \"code\": 200,\n" +
" \"msg\": \"success\",\n" +
" \"requestTime\": \"2024-11-23 10:15:44\",\n" +
" \"issueTime\": \"2024-11-23 10:15:44\",\n" +
" \"data\": {\n" +
" \"cycle\": 100,\n" +
" \"green_time\": [\n" +
" 0,\n" +
" 0,\n" +
" 72,\n" +
" 72,\n" +
" 20,\n" +
" 20,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0\n" +
" ],\n" +
" \"cross_id\": \"a5d6b25f8857448584e904690d4b4d2f\",\n" +
" \"control_id\": 677903,\n" +
" \"provider\": \"hisense\",\n" +
" \"plan_no\": \"31\",\n" +
" \"offset\": 58,\n" +
" \"ring_cnt\": 2,\n" +
" \"ring_set\": {\n" +
" \"0\": {\n" +
" \"0\": [\n" +
" 5\n" +
" ],\n" +
" \"1\": [\n" +
" 4\n" +
" ]\n" +
" },\n" +
" \"1\": {\n" +
" \"0\": [\n" +
" 6\n" +
" ],\n" +
" \"1\": [\n" +
" 3\n" +
" ]\n" +
" }\n" +
" },\n" +
" \"seq_id\": [\n" +
" 1,\n" +
" 2,\n" +
" 3,\n" +
" 4,\n" +
" 5,\n" +
" 6,\n" +
" 7,\n" +
" 8,\n" +
" 9,\n" +
" 10,\n" +
" 11,\n" +
" 12,\n" +
" 13,\n" +
" 14,\n" +
" 15,\n" +
" 16\n" +
" ],\n" +
" \"red_time\": [\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0\n" +
" ],\n" +
" \"yellow_time\": [\n" +
" 0,\n" +
" 0,\n" +
" 4,\n" +
" 4,\n" +
" 4,\n" +
" 4,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0\n" +
" ],\n" +
" \"green_flash\": [\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1\n" +
" ],\n" +
" \"person_flash\": [\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1,\n" +
" -1\n" +
" ],\n" +
" \"min_green\": [\n" +
" 15,\n" +
" 14,\n" +
" 30,\n" +
" 30,\n" +
" 14,\n" +
" 14,\n" +
" 14,\n" +
" 14,\n" +
" 15,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0\n" +
" ],\n" +
" \"max_green\": [\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000,\n" +
" 1000\n" +
" ],\n" +
" \"direction\": [\n" +
" [\n" +
" [\n" +
" 0,\n" +
" 1\n" +
" ]\n" +
" ],\n" +
" [],\n" +
" [\n" +
" [\n" +
" 3,\n" +
" 13\n" +
" ],\n" +
" [\n" +
" 0,\n" +
" 2\n" +
" ]\n" +
" ],\n" +
" [\n" +
" [\n" +
" 1,\n" +
" 13\n" +
" ],\n" +
" [\n" +
" 2,\n" +
" 2\n" +
" ]\n" +
" ],\n" +
" [\n" +
" [\n" +
" 2,\n" +
" 13\n" +
" ]\n" +
" ],\n" +
" [\n" +
" [\n" +
" 0,\n" +
" 13\n" +
" ],\n" +
" [\n" +
" 1,\n" +
" 1\n" +
" ]\n" +
" ],\n" +
" [],\n" +
" [],\n" +
" [],\n" +
" [],\n" +
" [],\n" +
" [],\n" +
" [],\n" +
" [],\n" +
" [],\n" +
" []\n" +
" ]\n" +
" },\n" +
" \"crossId\": \"a5d6b25f8857448584e904690d4b4d2f\",\n" +
" \"crossName\": \"龙鼎大道-龙翔路\",\n" +
" \"currentAlgo\": 2,\n" +
" \"timingPlan\": [\n" +
" 0,\n" +
" 0,\n" +
" 72,\n" +
" 72,\n" +
" 20,\n" +
" 20,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0,\n" +
" 0\n" +
" ]\n" +
"}";
}
......@@ -31,7 +31,9 @@ public class ImbalanceAlgorithmDTO {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date issueTime;
// 发是否成功(200成功,其他失败)
private int responseCode;
private Integer responseCode;
// 响应内容
private String responseContent;
// 配时信息
private List<Integer> timingPlan;
// 入库时间
......
package net.wanji.datacenter.pojo.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
......@@ -35,5 +36,9 @@ public class PhaseEmptyDataDTO {
private Integer controlMode;
private Integer crossRealStatus;
private String ctrId;
/** 是否成功(200成功,其他失败)*/
private Integer responseCode;
/** 响应内容 */
private String responseContent;
}
}
......@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import java.util.Date;
......@@ -14,6 +15,7 @@ import java.util.Date;
*/
@Data
@TableName("t_strategy_cross_result")
@JsonIgnoreProperties(ignoreUnknown = true)
public class CrossStrategyResultEntity {
@TableId(value = "id", type = IdType.AUTO)
private Integer id;
......@@ -29,6 +31,8 @@ public class CrossStrategyResultEntity {
private Date issueTime;
@TableField("response_code")
private Integer responseCode;
@TableField("response_content")
private String responseContent;
@TableField("timing_plan")
private String timingPlan;
@TableField("insert_time")
......
package net.wanji.datacenter.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.datacenter.cache.CrossInfoCache;
import net.wanji.datacenter.common.PhaseEmptyEnum;
......@@ -22,6 +22,7 @@ import java.util.Objects;
* @date 2024/11/23 16:14
*/
@Service
@Slf4j
public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
@Resource
......@@ -40,7 +41,7 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
Integer countDown = idx.getCountDown();
Integer rtnType = idx.getRtnType();
// rtnType大于0时,未执行
if (rtnType < 0) {
if (rtnType < 0) {
Long signalMachineStamp = idx.getSignalMachineStamp();
Long createStamp = idx.getCreateStamp();
Date date = new Date(curStamp);
......@@ -54,16 +55,18 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
entity.setInsertTime(new Date(createStamp));
entity.setCountDown(countDown);
entity.setExtendTime(countDown);
entity.setResponseCode(rtnType);
entity.setResponseCode(idx.getResponseCode());
entity.setRtnType(rtnType);
String name = CrossInfoCache.getName(crossId);
entity.setCrossName(name);
entity.setEmptyDir(PhaseEmptyEnum.getDir(rtnType));
entity.setEmptyTurn(PhaseEmptyEnum.getTurn(rtnType));
entity.setResponseContent(idx.getResponseContent());
crossStrategyResultMapper.insert(entity);
}
}
} catch (JsonProcessingException e) {
} catch (Exception e) {
log.error("相位空放优化结果入库异常:", e);
throw new Exception(e);
}
......@@ -73,30 +76,27 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
@Override
public void save(ImbalanceAlgorithmDTO dto) {
try {
// 未操作的不存
// 溢出 rtnType=0 不操作 失衡未推送,目前只考虑溢出
if (0 != dto.getRtnType()) {
ObjectMapper mapper = JacksonUtils.getInstance();
CrossStrategyResultEntity crossStrategyResultEntity = new CrossStrategyResultEntity();
crossStrategyResultEntity.setCrossId(dto.getPlatformId());
crossStrategyResultEntity.setCrossName(dto.getCrossName());
crossStrategyResultEntity.setCurrentAlgo(dto.getCurrentAlgo());
crossStrategyResultEntity.setRequestTime(dto.getRequestTime());
crossStrategyResultEntity.setIssueTime(dto.getIssueTime());
crossStrategyResultEntity.setResponseCode(dto.getResponseCode());
crossStrategyResultEntity.setTimingPlan(mapper.writeValueAsString(dto.getTimingPlan()));
crossStrategyResultEntity.setInsertTime(dto.getInsertTime());
crossStrategyResultEntity.setRtnType(dto.getRtnType());
crossStrategyResultEntity.setExtendTime(dto.getExtendTime());
crossStrategyResultEntity.setBlockRegion(dto.getBlockRegion() + 1);
crossStrategyResultEntity.setBlockType(dto.getBlockType());
crossStrategyResultEntity.setCountDown(dto.getCountDown());
crossStrategyResultEntity.setVideoStamp(dto.getVideoStamp());
crossStrategyResultEntity.setSignalMachineStamp(dto.getSignalMachineStamp());
crossStrategyResultEntity.setControlDir(dto.getControlDir());
crossStrategyResultEntity.setData(mapper.writeValueAsString(dto.getData()));
crossStrategyResultMapper.insert(crossStrategyResultEntity);
}
ObjectMapper mapper = JacksonUtils.getInstance();
CrossStrategyResultEntity crossStrategyResultEntity = new CrossStrategyResultEntity();
crossStrategyResultEntity.setCrossId(dto.getPlatformId());
crossStrategyResultEntity.setCrossName(dto.getCrossName());
crossStrategyResultEntity.setCurrentAlgo(dto.getCurrentAlgo());
crossStrategyResultEntity.setRequestTime(dto.getRequestTime());
crossStrategyResultEntity.setIssueTime(dto.getIssueTime());
crossStrategyResultEntity.setResponseCode(dto.getResponseCode());
crossStrategyResultEntity.setTimingPlan(mapper.writeValueAsString(dto.getTimingPlan()));
crossStrategyResultEntity.setInsertTime(dto.getInsertTime());
crossStrategyResultEntity.setRtnType(dto.getRtnType());
crossStrategyResultEntity.setExtendTime(dto.getExtendTime());
crossStrategyResultEntity.setBlockRegion(dto.getBlockRegion() + 1);
crossStrategyResultEntity.setBlockType(dto.getBlockType());
crossStrategyResultEntity.setCountDown(dto.getCountDown());
crossStrategyResultEntity.setVideoStamp(dto.getVideoStamp());
crossStrategyResultEntity.setSignalMachineStamp(dto.getSignalMachineStamp());
crossStrategyResultEntity.setControlDir(dto.getControlDir());
crossStrategyResultEntity.setData(mapper.writeValueAsString(dto.getData()));
crossStrategyResultEntity.setResponseContent(dto.getResponseContent());
crossStrategyResultMapper.insert(crossStrategyResultEntity);
} catch (Exception e) {
throw new RuntimeException(e);
}
......
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