|
@@ -13,6 +13,8 @@ import com.zy.bms.service.ILogsService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
/**
|
|
|
* MQTT 收发日志 Service
|
|
|
*
|
|
@@ -23,6 +25,9 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
public class LogsService extends ServiceImpl<LogsMapper, Logs> implements ILogsService {
|
|
|
|
|
|
+ private static final Set<String> UBI_SET = new HashSet<>(Arrays.asList("21", "23", "26", "27", "28", "29", "30", "80"));
|
|
|
+ private static final Set<String> LP_SET = new HashSet<>(Arrays.asList("70", "71", "72"));
|
|
|
+
|
|
|
@Override
|
|
|
public void saveReceive(String topic, String payload) {
|
|
|
saveCommon(topic, payload, 0);
|
|
@@ -50,6 +55,13 @@ public class LogsService extends ServiceImpl<LogsMapper, Logs> implements ILogsS
|
|
|
MqttDTO tmp = MqttDTO.parse(content);
|
|
|
//创建日志对象
|
|
|
Logs entity = Logs.builder().topic(topic).type(type).m(tmp.getM()).content(content).build();
|
|
|
+ if (UBI_SET.contains(tmp.getM())) {
|
|
|
+ entity.setDeviceType(Constant.DEVICE_TYPE.UBI);
|
|
|
+ } else if (LP_SET.contains(tmp.getM())) {
|
|
|
+ entity.setDeviceType(Constant.DEVICE_TYPE.LP);
|
|
|
+ } else {
|
|
|
+ entity.setDeviceType(tmp.getString("type"));
|
|
|
+ }
|
|
|
String openNum = Constant.splitOpenNum(topic);
|
|
|
entity.setOpenNum(openNum == null ? tmp.getString("regnum") : openNum);
|
|
|
baseMapper.insert(entity);
|