Commit 80fd9b7a authored by duanruiming's avatar duanruiming

[update] 数据插入优化

parent f1e7eefc
......@@ -43,11 +43,11 @@ public class EventDataServiceImpl implements EventDataService {
eventInfoPO4DB.setEndTime(eventDataDTO.getEventEndTime());
eventInfoPO4DB.setAlarmStatus(eventDataDTO.getEventStatus());
eventInfoMapper.updateOne(eventInfoPO4DB);
}
} else {
EventInfoPO eventInfoPO = getEventInfoPO(eventDataDTO);
eventInfoMapper.insertOne(eventInfoPO);
}
}
} catch (Exception e) {
log.error("事件保存异常:", e);
throw new RuntimeException(e);
......@@ -74,6 +74,7 @@ public class EventDataServiceImpl implements EventDataService {
eventInfoPO.setPlaceDesc(eventDataDTO.getEventType());
eventInfoPO.setDir(eventDataDTO.getDirection());
eventInfoPO.setRuksj(new Date());
eventInfoPO.setAlarmStatus(eventDataDTO.getEventStatus());
return eventInfoPO;
}
......
......@@ -2,6 +2,7 @@ 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.BeanListUtils;
import net.wanji.common.utils.tool.JacksonUtils;
import net.wanji.databus.dao.entity.GreenwaveHistPO;
......@@ -28,6 +29,7 @@ import java.util.stream.Collectors;
* @date 2024/11/19 19:04
*/
@Service
@Slf4j
public class GreenBeltInfoServiceImpl implements GreenBeltInfoService {
@Resource
......@@ -353,6 +355,7 @@ public class GreenBeltInfoServiceImpl implements GreenBeltInfoService {
@Transactional(rollbackFor = Exception.class)
@Override
public void savePeriod(String message) throws Exception {
try {
ObjectMapper instance = JacksonUtils.getInstance();
GreenWavePeriodDTO greenWavePeriodDTO = instance.readValue(message, GreenWavePeriodDTO.class);
List<GreenwaveRealtimePO> greenwaveRealtimePOS = greenWavePeriodDTO.getEventList();
......@@ -372,6 +375,10 @@ public class GreenBeltInfoServiceImpl implements GreenBeltInfoService {
BeanListUtils.populateList(greenwaveRealtimePOS, list, GreenwaveRealtimePO.class);
greenwaveHistMapper.insertBatch(list);
}
} catch (Exception e) {
log.error("绿波周期数据存储异常:{}", e);
throw new RuntimeException(e);
}
}
public static String greenBeltInfoData = "{\n" +
......@@ -379,20 +386,20 @@ public class GreenBeltInfoServiceImpl implements GreenBeltInfoService {
" \"belt_start_backward\": {\n" +
" \"13MQV0B5KE0\": 13.0,\n" +
" \"13MRN0B5MV0\": 39.0,\n" +
" \"13MSS0B5NT0\": 0.0,\n" +
" \"13MVM0B5OV0\": 5.0,\n" +
" \"13MSS0B5NT0\": 3.0,\n" +
" \"13MVM0B5OV0\": 10.0,\n" +
" \"13N0C0B5P30\": 0.0\n" +
" },\n" +
" \"belt_start_forward\": {\n" +
" \"13MQV0B5KE0\": 0.0,\n" +
" \"13MRN0B5MV0\": 10.0,\n" +
" \"13MSS0B5NT0\": 46.0,\n" +
" \"13MVM0B5OV0\": 20.0,\n" +
" \"13N0C0B5P30\": 51.0\n" +
" \"13MSS0B5NT0\": 50.0,\n" +
" \"13MVM0B5OV0\": 29.0,\n" +
" \"13N0C0B5P30\": 55.0\n" +
" },\n" +
" \"control_duration\": 1800,\n" +
" \"control_method\": 1,\n" +
" \"control_time\": \"2024-12-12T11:00:00\",\n" +
" \"control_time\": \"2024-12-15T10:33:00\",\n" +
" \"cycle\": {\n" +
" \"13MQV0B5KE0\": 140.0,\n" +
" \"13MRN0B5MV0\": 140.0,\n" +
......@@ -403,52 +410,52 @@ public class GreenBeltInfoServiceImpl implements GreenBeltInfoService {
" \"distance_backward\": {\n" +
" \"13MQV0B5KE0\": -1.0,\n" +
" \"13MRN0B5MV0\": 947.2222222222222,\n" +
" \"13MSS0B5NT0\": 575.9686507936507,\n" +
" \"13MVM0B5OV0\": 807.5999999999999,\n" +
" \"13N0C0B5P30\": 200.71428571428572\n" +
" \"13MSS0B5NT0\": 574.85,\n" +
" \"13MVM0B5OV0\": 807.7222222222222,\n" +
" \"13N0C0B5P30\": 204.28571428571428\n" +
" },\n" +
" \"distance_forward\": {\n" +
" \"13MQV0B5KE0\": 947.2222222222222,\n" +
" \"13MRN0B5MV0\": 568.1777777777778,\n" +
" \"13MSS0B5NT0\": 806.7321428571428,\n" +
" \"13MVM0B5OV0\": 202.85714285714283,\n" +
" \"13MRN0B5MV0\": 575.745238095238,\n" +
" \"13MSS0B5NT0\": 797.542857142857,\n" +
" \"13MVM0B5OV0\": 203.57142857142858,\n" +
" \"13N0C0B5P30\": -1.0\n" +
" },\n" +
" \"dynamic\": 1,\n" +
" \"forward_direction\": \"w2e\",\n" +
" \"green_width_backward\": 62.0,\n" +
" \"green_width_forward\": 62.0,\n" +
" \"green_width_backward\": 56.99999999999998,\n" +
" \"green_width_forward\": 57.0,\n" +
" \"greenbelt_direction\": 2,\n" +
" \"greenbelt_id\": \"3\",\n" +
" \"greenbelt_length\": 2518.0,\n" +
" \"greenbelt_type\": 1,\n" +
" \"key_cross\": \"13MRN0B5MV0\",\n" +
" \"max_cycle\": 140,\n" +
" \"max_speed_backward\": 57.0,\n" +
" \"max_speed_forward\": 59.0,\n" +
" \"min_speed_backward\": 47.0,\n" +
" \"min_speed_forward\": 49.0,\n" +
" \"max_speed_backward\": 55.0,\n" +
" \"max_speed_forward\": 60.0,\n" +
" \"min_speed_backward\": 45.0,\n" +
" \"min_speed_forward\": 50.0,\n" +
" \"model_select\": 1,\n" +
" \"offset\": {\n" +
" \"13MQV0B5KE0\": 117.0,\n" +
" \"13MRN0B5MV0\": 29.0,\n" +
" \"13MSS0B5NT0\": 27.0,\n" +
" \"13MVM0B5OV0\": 108.0,\n" +
" \"13N0C0B5P30\": 95.0\n" +
" \"13MQV0B5KE0\": 113.0,\n" +
" \"13MRN0B5MV0\": 25.0,\n" +
" \"13MSS0B5NT0\": 18.0,\n" +
" \"13MVM0B5OV0\": 90.0,\n" +
" \"13N0C0B5P30\": 82.0\n" +
" },\n" +
" \"phase_end_backward\": {\n" +
" \"13MQV0B5KE0\": 114.0,\n" +
" \"13MRN0B5MV0\": 101.0,\n" +
" \"13MSS0B5NT0\": 114.0,\n" +
" \"13MVM0B5OV0\": 106.0,\n" +
" \"13N0C0B5P30\": 70.0\n" +
" \"13MQV0B5KE0\": 117.0,\n" +
" \"13MRN0B5MV0\": 96.0,\n" +
" \"13MSS0B5NT0\": 113.0,\n" +
" \"13MVM0B5OV0\": 105.0,\n" +
" \"13N0C0B5P30\": 68.0\n" +
" },\n" +
" \"phase_end_forward\": {\n" +
" \"13MQV0B5KE0\": 92.0,\n" +
" \"13MRN0B5MV0\": 101.0,\n" +
" \"13MSS0B5NT0\": 114.0,\n" +
" \"13MVM0B5OV0\": 106.0,\n" +
" \"13N0C0B5P30\": 113.0\n" +
" \"13MRN0B5MV0\": 96.0,\n" +
" \"13MSS0B5NT0\": 113.0,\n" +
" \"13MVM0B5OV0\": 105.0,\n" +
" \"13N0C0B5P30\": 112.0\n" +
" },\n" +
" \"phase_start_backward\": {\n" +
" \"13MQV0B5KE0\": 0.0,\n" +
......@@ -467,28 +474,28 @@ public class GreenBeltInfoServiceImpl implements GreenBeltInfoService {
" \"speed_backward\": {\n" +
" \"13MQV0B5KE0\": -1.0,\n" +
" \"13MRN0B5MV0\": 55.0,\n" +
" \"13MSS0B5NT0\": 50.57285714285714,\n" +
" \"13MVM0B5OV0\": 53.839999999999996,\n" +
" \"13N0C0B5P30\": 40.142857142857146\n" +
" \"13MSS0B5NT0\": 49.27285714285715,\n" +
" \"13MVM0B5OV0\": 46.9,\n" +
" \"13N0C0B5P30\": 40.857142857142854\n" +
" },\n" +
" \"speed_forward\": {\n" +
" \"13MQV0B5KE0\": 55.0,\n" +
" \"13MRN0B5MV0\": 60.160000000000004,\n" +
" \"13MSS0B5NT0\": 52.80428571428571,\n" +
" \"13MVM0B5OV0\": 40.57142857142857,\n" +
" \"13MRN0B5MV0\": 62.808571428571426,\n" +
" \"13MSS0B5NT0\": 56.29714285714285,\n" +
" \"13MVM0B5OV0\": 40.714285714285715,\n" +
" \"13N0C0B5P30\": -1.0\n" +
" },\n" +
" \"travel_time_backward\": {\n" +
" \"13MQV0B5KE0\": -1.0,\n" +
" \"13MRN0B5MV0\": 62.0,\n" +
" \"13MSS0B5NT0\": 41.0,\n" +
" \"13MVM0B5OV0\": 54.0,\n" +
" \"13MSS0B5NT0\": 42.0,\n" +
" \"13MVM0B5OV0\": 62.0,\n" +
" \"13N0C0B5P30\": 18.0\n" +
" },\n" +
" \"travel_time_forward\": {\n" +
" \"13MQV0B5KE0\": 62.0,\n" +
" \"13MRN0B5MV0\": 34.0,\n" +
" \"13MSS0B5NT0\": 55.0,\n" +
" \"13MRN0B5MV0\": 33.0,\n" +
" \"13MSS0B5NT0\": 51.0,\n" +
" \"13MVM0B5OV0\": 18.0,\n" +
" \"13N0C0B5P30\": -1.0\n" +
" }\n" +
......
......@@ -94,7 +94,8 @@
, dt
, event_serial_number
, green_id
, dir)
, dir
, alarm_status)
VALUES (
#{oid}
, #{plateNo}
......@@ -120,6 +121,7 @@
, #{eventSerialNumber}
, #{greenId}
, #{dir}
, #{alarmStatus}
)
ON DUPLICATE KEY UPDATE
end_time = values(end_time)
......
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