Commit b4bde89b authored by duanruiming's avatar duanruiming

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

parent 969552c5
...@@ -32,6 +32,7 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle ...@@ -32,6 +32,7 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle
/** /**
* 相位空放优化指标周期 * 相位空放优化指标周期
*
* @param record * @param record
* @param acknowledgment * @param acknowledgment
* @throws Exception * @throws Exception
...@@ -76,10 +77,15 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle ...@@ -76,10 +77,15 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle
if (StringUtils.isNotBlank(message)) { if (StringUtils.isNotBlank(message)) {
ObjectMapper mapper = JacksonUtils.getInstance(); ObjectMapper mapper = JacksonUtils.getInstance();
ImbalanceAlgorithmDTO imbalanceAlgorithmDTO = mapper.readValue(message, ImbalanceAlgorithmDTO.class); ImbalanceAlgorithmDTO imbalanceAlgorithmDTO = mapper.readValue(message, ImbalanceAlgorithmDTO.class);
// 未操作的不存
// 溢出 rtnType=0 不操作
if (0 != imbalanceAlgorithmDTO.getRtnType()) {
crossStrategyOptService.save(imbalanceAlgorithmDTO); crossStrategyOptService.save(imbalanceAlgorithmDTO);
} }
}
acknowledgment.acknowledge(); acknowledgment.acknowledge();
} }
@Override @Override
@NonNull @NonNull
public Object handleError(Message<?> message, ListenerExecutionFailedException e) { public Object handleError(Message<?> message, ListenerExecutionFailedException e) {
...@@ -94,265 +100,4 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle ...@@ -94,265 +100,4 @@ public class CrossStrategyOptConsumerHandler implements KafkaListenerErrorHandle
log.error(errorMessage); log.error(errorMessage);
return KafkaListenerErrorHandler.super.handleError(message, exception, consumer); 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 { ...@@ -31,7 +31,9 @@ public class ImbalanceAlgorithmDTO {
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date issueTime; private Date issueTime;
// 发是否成功(200成功,其他失败) // 发是否成功(200成功,其他失败)
private int responseCode; private Integer responseCode;
// 响应内容
private String responseContent;
// 配时信息 // 配时信息
private List<Integer> timingPlan; private List<Integer> timingPlan;
// 入库时间 // 入库时间
......
package net.wanji.datacenter.pojo.dto; package net.wanji.datacenter.pojo.dto;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
...@@ -35,5 +36,9 @@ public class PhaseEmptyDataDTO { ...@@ -35,5 +36,9 @@ public class PhaseEmptyDataDTO {
private Integer controlMode; private Integer controlMode;
private Integer crossRealStatus; private Integer crossRealStatus;
private String ctrId; private String ctrId;
/** 是否成功(200成功,其他失败)*/
private Integer responseCode;
/** 响应内容 */
private String responseContent;
} }
} }
...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType; ...@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data; import lombok.Data;
import java.util.Date; import java.util.Date;
...@@ -14,6 +15,7 @@ import java.util.Date; ...@@ -14,6 +15,7 @@ import java.util.Date;
*/ */
@Data @Data
@TableName("t_strategy_cross_result") @TableName("t_strategy_cross_result")
@JsonIgnoreProperties(ignoreUnknown = true)
public class CrossStrategyResultEntity { public class CrossStrategyResultEntity {
@TableId(value = "id", type = IdType.AUTO) @TableId(value = "id", type = IdType.AUTO)
private Integer id; private Integer id;
...@@ -29,6 +31,8 @@ public class CrossStrategyResultEntity { ...@@ -29,6 +31,8 @@ public class CrossStrategyResultEntity {
private Date issueTime; private Date issueTime;
@TableField("response_code") @TableField("response_code")
private Integer responseCode; private Integer responseCode;
@TableField("response_content")
private String responseContent;
@TableField("timing_plan") @TableField("timing_plan")
private String timingPlan; private String timingPlan;
@TableField("insert_time") @TableField("insert_time")
......
package net.wanji.datacenter.service.impl; package net.wanji.datacenter.service.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.utils.tool.JacksonUtils; import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.datacenter.cache.CrossInfoCache; import net.wanji.datacenter.cache.CrossInfoCache;
import net.wanji.datacenter.common.PhaseEmptyEnum; import net.wanji.datacenter.common.PhaseEmptyEnum;
...@@ -22,6 +22,7 @@ import java.util.Objects; ...@@ -22,6 +22,7 @@ import java.util.Objects;
* @date 2024/11/23 16:14 * @date 2024/11/23 16:14
*/ */
@Service @Service
@Slf4j
public class CrossStrategyOptServiceImpl implements CrossStrategyOptService { public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
@Resource @Resource
...@@ -54,16 +55,18 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService { ...@@ -54,16 +55,18 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
entity.setInsertTime(new Date(createStamp)); entity.setInsertTime(new Date(createStamp));
entity.setCountDown(countDown); entity.setCountDown(countDown);
entity.setExtendTime(countDown); entity.setExtendTime(countDown);
entity.setResponseCode(rtnType); entity.setResponseCode(idx.getResponseCode());
entity.setRtnType(rtnType); entity.setRtnType(rtnType);
String name = CrossInfoCache.getName(crossId); String name = CrossInfoCache.getName(crossId);
entity.setCrossName(name); entity.setCrossName(name);
entity.setEmptyDir(PhaseEmptyEnum.getDir(rtnType)); entity.setEmptyDir(PhaseEmptyEnum.getDir(rtnType));
entity.setEmptyTurn(PhaseEmptyEnum.getTurn(rtnType)); entity.setEmptyTurn(PhaseEmptyEnum.getTurn(rtnType));
entity.setResponseContent(idx.getResponseContent());
crossStrategyResultMapper.insert(entity); crossStrategyResultMapper.insert(entity);
} }
} }
} catch (JsonProcessingException e) { } catch (Exception e) {
log.error("相位空放优化结果入库异常:", e);
throw new Exception(e); throw new Exception(e);
} }
...@@ -73,9 +76,6 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService { ...@@ -73,9 +76,6 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
@Override @Override
public void save(ImbalanceAlgorithmDTO dto) { public void save(ImbalanceAlgorithmDTO dto) {
try { try {
// 未操作的不存
// 溢出 rtnType=0 不操作 失衡未推送,目前只考虑溢出
if (0 != dto.getRtnType()) {
ObjectMapper mapper = JacksonUtils.getInstance(); ObjectMapper mapper = JacksonUtils.getInstance();
CrossStrategyResultEntity crossStrategyResultEntity = new CrossStrategyResultEntity(); CrossStrategyResultEntity crossStrategyResultEntity = new CrossStrategyResultEntity();
crossStrategyResultEntity.setCrossId(dto.getPlatformId()); crossStrategyResultEntity.setCrossId(dto.getPlatformId());
...@@ -95,8 +95,8 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService { ...@@ -95,8 +95,8 @@ public class CrossStrategyOptServiceImpl implements CrossStrategyOptService {
crossStrategyResultEntity.setSignalMachineStamp(dto.getSignalMachineStamp()); crossStrategyResultEntity.setSignalMachineStamp(dto.getSignalMachineStamp());
crossStrategyResultEntity.setControlDir(dto.getControlDir()); crossStrategyResultEntity.setControlDir(dto.getControlDir());
crossStrategyResultEntity.setData(mapper.writeValueAsString(dto.getData())); crossStrategyResultEntity.setData(mapper.writeValueAsString(dto.getData()));
crossStrategyResultEntity.setResponseContent(dto.getResponseContent());
crossStrategyResultMapper.insert(crossStrategyResultEntity); crossStrategyResultMapper.insert(crossStrategyResultEntity);
}
} catch (Exception e) { } catch (Exception e) {
throw new RuntimeException(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