|
@@ -2,6 +2,7 @@ package com.xy.consumer.log;
|
|
|
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
|
+import com.xy.annotate.MqttConsumerAsyn;
|
|
import com.xy.config.SysThreadPoolConfig;
|
|
import com.xy.config.SysThreadPoolConfig;
|
|
import com.xy.consumer.MqttConsumer;
|
|
import com.xy.consumer.MqttConsumer;
|
|
import com.xy.entity.LogOperate;
|
|
import com.xy.entity.LogOperate;
|
|
@@ -11,7 +12,6 @@ import com.xy.mapper.LogOperateMapper;
|
|
import com.xy.mapper.LogSysEventsMapper;
|
|
import com.xy.mapper.LogSysEventsMapper;
|
|
import com.xy.mapper.LogTasksMapper;
|
|
import com.xy.mapper.LogTasksMapper;
|
|
import com.xy.utils.LambdaUtils;
|
|
import com.xy.utils.LambdaUtils;
|
|
-import com.xy.utils.ThreadPoolUtils;
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -20,6 +20,7 @@ import org.springframework.stereotype.Service;
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
|
|
+@MqttConsumerAsyn(value = SysThreadPoolConfig.LOG_POLL, isFailSaveEs = false)
|
|
public class LogConsumer implements MqttConsumer {
|
|
public class LogConsumer implements MqttConsumer {
|
|
|
|
|
|
private final LogOperateMapper logOperateMapper;
|
|
private final LogOperateMapper logOperateMapper;
|
|
@@ -30,20 +31,17 @@ public class LogConsumer implements MqttConsumer {
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public boolean message(String topic, String payload) {
|
|
public boolean message(String topic, String payload) {
|
|
- ThreadPoolUtils.excPoll(SysThreadPoolConfig.LOG_POLL, 1)
|
|
|
|
- .execute(() -> {
|
|
|
|
- JSONObject jsonObject = JSONUtil.parseObj(payload);
|
|
|
|
- String type = jsonObject.getStr(LambdaUtils.getProperty(LogOperate::getType));
|
|
|
|
- if ("operate".equals(type)) {
|
|
|
|
- logOperateMapper.insert(jsonObject.toBean(LogOperate.class));
|
|
|
|
- }
|
|
|
|
- if ("events".equals(type)) {
|
|
|
|
- logSysEventsMapper.insert(jsonObject.toBean(LogSysEvents.class));
|
|
|
|
- }
|
|
|
|
- if ("tasks".equals(type)) {
|
|
|
|
- logTasksMapper.insert(jsonObject.toBean(LogTasks.class));
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(payload);
|
|
|
|
+ String type = jsonObject.getStr(LambdaUtils.getProperty(LogOperate::getType));
|
|
|
|
+ if ("operate".equals(type)) {
|
|
|
|
+ logOperateMapper.insert(jsonObject.toBean(LogOperate.class));
|
|
|
|
+ }
|
|
|
|
+ if ("events".equals(type)) {
|
|
|
|
+ logSysEventsMapper.insert(jsonObject.toBean(LogSysEvents.class));
|
|
|
|
+ }
|
|
|
|
+ if ("tasks".equals(type)) {
|
|
|
|
+ logTasksMapper.insert(jsonObject.toBean(LogTasks.class));
|
|
|
|
+ }
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|