暂态事件解析功能调整
This commit is contained in:
@@ -413,6 +413,7 @@ public class MqttMessageHandler {
|
|||||||
//todo 后期告警可能也是在这处理,通过是告警还是事件来区分暂态和稳态
|
//todo 后期告警可能也是在这处理,通过是告警还是事件来区分暂态和稳态
|
||||||
case 0:
|
case 0:
|
||||||
log.info("处理事件");
|
log.info("处理事件");
|
||||||
|
log.info("事件报文为:" + new String(message.getPayload(), StandardCharsets.UTF_8));
|
||||||
EventDto eventDto = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), EventDto.class);
|
EventDto eventDto = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), EventDto.class);
|
||||||
JSONObject jsonObject0 = JSONObject.parseObject(JSON.toJSONString(eventDto));
|
JSONObject jsonObject0 = JSONObject.parseObject(JSON.toJSONString(eventDto));
|
||||||
AppEventMessage appEventMessage = JSONObject.toJavaObject(jsonObject0, AppEventMessage.class);
|
AppEventMessage appEventMessage = JSONObject.toJavaObject(jsonObject0, AppEventMessage.class);
|
||||||
@@ -442,6 +443,7 @@ public class MqttMessageHandler {
|
|||||||
response.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
response.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||||
response.setType(Integer.parseInt(TypeEnum.TYPE_15.getCode()));
|
response.setType(Integer.parseInt(TypeEnum.TYPE_15.getCode()));
|
||||||
response.setCode(200);
|
response.setCode(200);
|
||||||
|
log.info("应答事件:" + new Gson().toJson(response));
|
||||||
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,new Gson().toJson(response),1,false);
|
publisher.send("/Dev/DataRsp/"+version+"/"+nDid,new Gson().toJson(response),1,false);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -122,7 +122,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>com.spotify</groupId>
|
<groupId>com.spotify</groupId>
|
||||||
<artifactId>docker-maven-plugin</artifactId>
|
<artifactId>docker-maven-plugin</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.2.2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
<!--执行mvn package,即执行 mvn clean package docker:build-->
|
||||||
<execution>
|
<execution>
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ public class CsWaveServiceImpl implements ICsWaveService {
|
|||||||
* 时间处理
|
* 时间处理
|
||||||
*/
|
*/
|
||||||
public void channelTimeRange(String fileName, long time, long subtleTime, Double millisecond, String deviceId, String lineId) {
|
public void channelTimeRange(String fileName, long time, long subtleTime, Double millisecond, String deviceId, String lineId) {
|
||||||
|
long endTime;
|
||||||
// 将startTime减去8小时(8 * 3600秒)
|
// 将startTime减去8小时(8 * 3600秒)
|
||||||
time -= 8 * 3600;
|
time -= 8 * 3600;
|
||||||
// 将millisecond转换为长整型,并乘以1000以获取微秒
|
// 将millisecond转换为长整型,并乘以1000以获取微秒
|
||||||
@@ -119,14 +120,17 @@ public class CsWaveServiceImpl implements ICsWaveService {
|
|||||||
long finalTime = subtleTime + millisecondValue;
|
long finalTime = subtleTime + millisecondValue;
|
||||||
// 如果finalTime大于等于1000000,将startTime增加1秒,finalTime减去1000000
|
// 如果finalTime大于等于1000000,将startTime增加1秒,finalTime减去1000000
|
||||||
if (finalTime >= 1000000) {
|
if (finalTime >= 1000000) {
|
||||||
time += 1;
|
endTime = time + 1;
|
||||||
finalTime -= 1000000;
|
finalTime -= 1000000;
|
||||||
|
} else {
|
||||||
|
endTime = time;
|
||||||
}
|
}
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
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 waveTimeDto = new WaveTimeDto();
|
||||||
waveTimeDto.setStartTime(formatTime + "." + subtleTime);
|
waveTimeDto.setStartTime(formatTime1 + "." + subtleTime);
|
||||||
waveTimeDto.setEndTime(formatTime + "." + finalTime);
|
waveTimeDto.setEndTime(formatTime2 + "." + finalTime);
|
||||||
waveTimeDto.setDeviceId(deviceId);
|
waveTimeDto.setDeviceId(deviceId);
|
||||||
waveTimeDto.setLineId(lineId);
|
waveTimeDto.setLineId(lineId);
|
||||||
redisUtil.saveByKeyWithExpire(AppRedisKey.TIME+fileName,waveTimeDto,60L);
|
redisUtil.saveByKeyWithExpire(AppRedisKey.TIME+fileName,waveTimeDto,60L);
|
||||||
|
|||||||
@@ -196,11 +196,16 @@ public class EventServiceImpl implements IEventService {
|
|||||||
* 时间转换
|
* 时间转换
|
||||||
*/
|
*/
|
||||||
public LocalDateTime timeFormat(Long time1, Long time2) {
|
public LocalDateTime timeFormat(Long time1, Long time2) {
|
||||||
|
String time;
|
||||||
//设置格式
|
//设置格式
|
||||||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
//todo 这边暂时先这样处理,减去8小时。
|
//todo 这边暂时先这样处理,减去8小时。
|
||||||
String timeText = format.format((time1-8*3600) * 1000);
|
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");
|
DateTimeFormatter fmt = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
|
||||||
return LocalDateTime.parse(time, fmt);
|
return LocalDateTime.parse(time, fmt);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class AppEventConsumer extends EnhanceConsumerMessageHandler<AppEventMess
|
|||||||
Integer dataType = appEventMessage.getMsg().getDataType();
|
Integer dataType = appEventMessage.getMsg().getDataType();
|
||||||
switch (dataType) {
|
switch (dataType) {
|
||||||
case 6:
|
case 6:
|
||||||
log.info("分发至暂态事件处理");
|
log.info("分发至事件处理");
|
||||||
eventFeignClient.analysis(appEventMessage);
|
eventFeignClient.analysis(appEventMessage);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
|
|||||||
Reference in New Issue
Block a user