Commit 19db6e88 authored by duanruiming's avatar duanruiming

[add] 事件修改交通指数逻辑优化

parent 190ec639
......@@ -17,6 +17,7 @@ public interface EventInfoMapper {
List<EventInfoPO> selectHistEvent();
void insertOne(EventInfoPO eventInfoPO);
void updateOne(EventInfoPO eventInfoPO);
void updateOneTraffic(EventInfoPO eventInfoPO);
/**
* 通过事件唯一ID查询
......
......@@ -43,6 +43,7 @@ public class EventDataServiceImpl implements EventDataService {
ObjectMapper mapper = JacksonUtils.getInstance();
EventDataDTO eventDataDTO = mapper.readValue(originData, EventDataDTO.class);
String eventId = eventDataDTO.getEventId();
log.error("事件唯一编号:{}", eventId);
// 如果同一时间id更新结束时间和告警状态
if (StringUtils.isNotBlank(eventId)) {
EventInfoPO eventInfoPO4DB = eventInfoMapper.selectByEventSerialNumber(eventId);
......@@ -60,15 +61,19 @@ public class EventDataServiceImpl implements EventDataService {
while (retryCount < 3) {
try {
eventInfoMapper.updateOne(eventInfoPO4DB);
log.warn("事件唯一编号,修改结束时间成功:{}, 修改参数:{}, 修改后入库参数:{}",
eventId, eventDataDTO, eventInfoPO4DB);
return;
} catch (TransactionRollbackException e) {
retryCount++;
log.warn("检测到死锁,进行第 {} 次重试", retryCount);
log.error("检测到死锁,进行第 {} 次重试", retryCount);
try {
// 等待一会,避免立刻冲突
Thread.sleep(100);
Thread.sleep(500);
} catch (InterruptedException ignored) {
log.warn("检测到死锁, Thread.sleep 100ms,异常:{}", ignored);
} catch (Exception e1) {
log.warn("检测到死锁, 重试修改逻辑异常异常:{}", e1);
}
}
}
......
......@@ -17,6 +17,7 @@ import net.wanji.datacenter.service.DataProcessService;
import org.apache.ignite.transactions.TransactionRollbackException;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
......@@ -155,6 +156,7 @@ public class DataProcessServiceImpl implements DataProcessService {
}
}
@Transactional(propagation = Propagation.NOT_SUPPORTED)
public void insertTrafficIndexForEventInfo(List<CrossDataRealtimePO> eventList) {
if (!CollectionUtils.isEmpty(eventList)) {
for (CrossDataRealtimePO crossDataRealtimePO : eventList) {
......@@ -167,7 +169,8 @@ public class DataProcessServiceImpl implements DataProcessService {
eventInfoPO.setTrafficIndex(trafficIndex);
while (retryCount <= 5) {
try {
eventInfoMapper.updateOne(eventInfoPO);
log.warn("事件唯一编号:{}, 修改交通指数后入库参数:{}", eventInfoPO.getTrafficIndex(), eventInfoPO);
eventInfoMapper.updateOneTraffic(eventInfoPO);
return;
} catch (TransactionRollbackException e) {
retryCount++;
......@@ -182,7 +185,7 @@ public class DataProcessServiceImpl implements DataProcessService {
}
}
} catch (Exception e) {
log.error("路口周期数据插入时间交通指数失败:{}", e);
log.warn("路口周期数据插入时间交通指数失败:{}", e);
}
}
}
......
......@@ -32,6 +32,7 @@
<file>${LOG_PATH}/dataCenter/info.log</file>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<level>ERROR</level>
<level>WARN</level>
<onMatch>DENY</onMatch>
<onMismatch>ACCEPT</onMismatch>
</filter>
......
......@@ -71,6 +71,14 @@
where event_serial_number = #{eventSerialNumber}
</update>
<update id="updateOneTraffic" parameterType="net.wanji.datacenter.pojo.po.EventInfoPO">
update t_event_info
set
modify_time = #{modifyTime},
traffic_index = #{trafficIndex}
where event_serial_number = #{eventSerialNumber}
</update>
<select id="selectByEventSerialNumber" parameterType="java.lang.String" resultType="net.wanji.datacenter.pojo.po.EventInfoPO">
SELECT <include refid="Base_Column_List"/>
FROM t_event_info
......
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