暂态事件解析功能调整

This commit is contained in:
2023-09-13 16:09:02 +08:00
parent a937d5c68b
commit 9e62fc2b9e
5 changed files with 18 additions and 7 deletions

View File

@@ -413,6 +413,7 @@ public class MqttMessageHandler {
//todo 后期告警可能也是在这处理,通过是告警还是事件来区分暂态和稳态
case 0:
log.info("处理事件");
log.info("事件报文为:" + new String(message.getPayload(), StandardCharsets.UTF_8));
EventDto eventDto = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), EventDto.class);
JSONObject jsonObject0 = JSONObject.parseObject(JSON.toJSONString(eventDto));
AppEventMessage appEventMessage = JSONObject.toJavaObject(jsonObject0, AppEventMessage.class);
@@ -442,6 +443,7 @@ public class MqttMessageHandler {
response.setPri(AccessEnum.FIRST_CHANNEL.getCode());
response.setType(Integer.parseInt(TypeEnum.TYPE_15.getCode()));
response.setCode(200);
log.info("应答事件:" + new Gson().toJson(response));
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,new Gson().toJson(response),1,false);
}
break;

View File

@@ -122,7 +122,7 @@
<plugin>
<groupId>com.spotify</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>1.0.0</version>
<version>1.2.2</version>
<executions>
<!--执行mvn package,即执行 mvn clean package docker:build-->
<execution>

View File

@@ -111,6 +111,7 @@ public class CsWaveServiceImpl implements ICsWaveService {
* 时间处理
*/
public void channelTimeRange(String fileName, long time, long subtleTime, Double millisecond, String deviceId, String lineId) {
long endTime;
// 将startTime减去8小时8 * 3600秒
time -= 8 * 3600;
// 将millisecond转换为长整型并乘以1000以获取微秒
@@ -119,14 +120,17 @@ public class CsWaveServiceImpl implements ICsWaveService {
long finalTime = subtleTime + millisecondValue;
// 如果finalTime大于等于1000000将startTime增加1秒finalTime减去1000000
if (finalTime >= 1000000) {
time += 1;
endTime = time + 1;
finalTime -= 1000000;
} else {
endTime = time;
}
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String formatTime = format.format(time * 1000);
String formatTime1 = format.format(time * 1000);
String formatTime2 = format.format(endTime * 1000);
WaveTimeDto waveTimeDto = new WaveTimeDto();
waveTimeDto.setStartTime(formatTime + "." + subtleTime);
waveTimeDto.setEndTime(formatTime + "." + finalTime);
waveTimeDto.setStartTime(formatTime1 + "." + subtleTime);
waveTimeDto.setEndTime(formatTime2 + "." + finalTime);
waveTimeDto.setDeviceId(deviceId);
waveTimeDto.setLineId(lineId);
redisUtil.saveByKeyWithExpire(AppRedisKey.TIME+fileName,waveTimeDto,60L);

View File

@@ -196,11 +196,16 @@ public class EventServiceImpl implements IEventService {
* 时间转换
*/
public LocalDateTime timeFormat(Long time1, Long time2) {
String time;
//设置格式
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
//todo 这边暂时先这样处理,减去8小时。
String timeText = format.format((time1-8*3600) * 1000);
String time = timeText + "." + time2;
if (time2 == 0){
time = timeText + ".000000";
} else {
time = timeText + "." + time2;
}
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
return LocalDateTime.parse(time, fmt);
}

View File

@@ -54,7 +54,7 @@ public class AppEventConsumer extends EnhanceConsumerMessageHandler<AppEventMess
Integer dataType = appEventMessage.getMsg().getDataType();
switch (dataType) {
case 6:
log.info("分发至暂态事件处理");
log.info("分发至事件处理");
eventFeignClient.analysis(appEventMessage);
break;
case 7: