|
@@ -4,19 +4,28 @@ import cn.hutool.core.date.StopWatch;
|
|
|
import cn.hutool.json.JSONObject;
|
|
import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.google.gson.JsonObject;
|
|
import com.google.gson.JsonObject;
|
|
|
|
|
+import com.zswl.dataservice.dao.iot.IotMainDao;
|
|
|
import com.zswl.dataservice.dao.mqtt.DeviceInfoDao;
|
|
import com.zswl.dataservice.dao.mqtt.DeviceInfoDao;
|
|
|
import com.zswl.dataservice.dao.mqtt.OperationMessageDao;
|
|
import com.zswl.dataservice.dao.mqtt.OperationMessageDao;
|
|
|
|
|
+import com.zswl.dataservice.dao.mqtt.OperationMessageResultDao;
|
|
|
import com.zswl.dataservice.dao.other.ExecuteMethodInfoDao;
|
|
import com.zswl.dataservice.dao.other.ExecuteMethodInfoDao;
|
|
|
|
|
+import com.zswl.dataservice.domain.iot.IotMain;
|
|
|
import com.zswl.dataservice.domain.mqtt.DeviceInfo;
|
|
import com.zswl.dataservice.domain.mqtt.DeviceInfo;
|
|
|
import com.zswl.dataservice.domain.mqtt.OperationMessage;
|
|
import com.zswl.dataservice.domain.mqtt.OperationMessage;
|
|
|
|
|
+import com.zswl.dataservice.domain.mqtt.OperationMessageResult;
|
|
|
import com.zswl.dataservice.domain.other.ExecuteMethodInfo;
|
|
import com.zswl.dataservice.domain.other.ExecuteMethodInfo;
|
|
|
|
|
+import com.zswl.dataservice.httpRequest.ApiRequestService;
|
|
|
|
|
+import com.zswl.dataservice.httpRequest.apiConf.APIResponseModel;
|
|
|
import com.zswl.dataservice.model.artemis.OperationMessageModel;
|
|
import com.zswl.dataservice.model.artemis.OperationMessageModel;
|
|
|
|
|
+import com.zswl.dataservice.model.artemis.OperationMessageResultModel;
|
|
|
|
|
+import com.zswl.dataservice.model.artemis.OperationMessageResultSearch;
|
|
|
import com.zswl.dataservice.model.artemis.OperationMessageSearchParam;
|
|
import com.zswl.dataservice.model.artemis.OperationMessageSearchParam;
|
|
|
import com.zswl.dataservice.model.mqtt.SendMessageModel;
|
|
import com.zswl.dataservice.model.mqtt.SendMessageModel;
|
|
|
import com.zswl.dataservice.service.base.SuperService;
|
|
import com.zswl.dataservice.service.base.SuperService;
|
|
|
import com.zswl.dataservice.service.mqtt.DeviceInfoService;
|
|
import com.zswl.dataservice.service.mqtt.DeviceInfoService;
|
|
|
import com.zswl.dataservice.service.mqtt.GateWayInfoService;
|
|
import com.zswl.dataservice.service.mqtt.GateWayInfoService;
|
|
|
import com.zswl.dataservice.service.payment.HxzService;
|
|
import com.zswl.dataservice.service.payment.HxzService;
|
|
|
|
|
+import com.zswl.dataservice.type.FunctionType;
|
|
|
import com.zswl.dataservice.type.OperationType;
|
|
import com.zswl.dataservice.type.OperationType;
|
|
|
import com.zswl.dataservice.utils.DateUtils;
|
|
import com.zswl.dataservice.utils.DateUtils;
|
|
|
import com.zswl.dataservice.utils.TokenUtil;
|
|
import com.zswl.dataservice.utils.TokenUtil;
|
|
@@ -42,6 +51,7 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import java.lang.reflect.Method;
|
|
import java.lang.reflect.Method;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -82,6 +92,15 @@ public class OperationMessageService {
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ApplicationContext applicationContext;
|
|
private ApplicationContext applicationContext;
|
|
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ IotMainDao iotMainDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ OperationMessageResultDao operationMessageResultDao;
|
|
|
|
|
+
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ ApiRequestService apiRequestService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 发送指令
|
|
* 发送指令
|
|
|
*
|
|
*
|
|
@@ -179,13 +198,6 @@ public class OperationMessageService {
|
|
|
// log.warn("回复消息不处理");
|
|
// log.warn("回复消息不处理");
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- log.info("Topic: {}", topicName);
|
|
|
|
|
- OperationMessage operationMessage = new OperationMessage();
|
|
|
|
|
- operationMessage.setMessageId(messageId);
|
|
|
|
|
- operationMessage.setClientId(clientId);
|
|
|
|
|
- operationMessage.setTopic(topicName);
|
|
|
|
|
- operationMessage.setOperationType(OperationType.Sub);
|
|
|
|
|
-
|
|
|
|
|
String messageClass = "";
|
|
String messageClass = "";
|
|
|
String msg = "";
|
|
String msg = "";
|
|
|
if (message instanceof ActiveMQBytesMessage) {
|
|
if (message instanceof ActiveMQBytesMessage) {
|
|
@@ -201,11 +213,16 @@ public class OperationMessageService {
|
|
|
TextMessage textMessage = (TextMessage) message;
|
|
TextMessage textMessage = (TextMessage) message;
|
|
|
msg = textMessage.getText();
|
|
msg = textMessage.getText();
|
|
|
}
|
|
}
|
|
|
|
|
+ // 提取内容里面的数据
|
|
|
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(msg);
|
|
cn.hutool.json.JSONObject jsonObject = JSONUtil.parseObj(msg);
|
|
|
String id = jsonObject.getStr("id");
|
|
String id = jsonObject.getStr("id");
|
|
|
Long time = jsonObject.getLong("time");
|
|
Long time = jsonObject.getLong("time");
|
|
|
Long ttl = jsonObject.getLong("ttl");
|
|
Long ttl = jsonObject.getLong("ttl");
|
|
|
String event = jsonObject.getStr("event");
|
|
String event = jsonObject.getStr("event");
|
|
|
|
|
+ if (event.equals("ping")) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ log.info("Topic: {}", topicName);
|
|
|
String gateWayId = jsonObject.getStr("gatewayId");
|
|
String gateWayId = jsonObject.getStr("gatewayId");
|
|
|
String deviceId = jsonObject.getStr("deviceId");
|
|
String deviceId = jsonObject.getStr("deviceId");
|
|
|
boolean isTimeOut = false;
|
|
boolean isTimeOut = false;
|
|
@@ -218,6 +235,11 @@ public class OperationMessageService {
|
|
|
jsonObject.set("timeStr", timeStr);
|
|
jsonObject.set("timeStr", timeStr);
|
|
|
|
|
|
|
|
// --------------------处理业务 start------------------
|
|
// --------------------处理业务 start------------------
|
|
|
|
|
+ OperationMessage operationMessage = new OperationMessage();
|
|
|
|
|
+ operationMessage.setMessageId(messageId);
|
|
|
|
|
+ operationMessage.setClientId(clientId);
|
|
|
|
|
+ operationMessage.setTopic(topicName); // top名称
|
|
|
|
|
+ operationMessage.setOperationType(OperationType.Sub);
|
|
|
operationMessage.setMessageClass(messageClass);
|
|
operationMessage.setMessageClass(messageClass);
|
|
|
operationMessage.setData(jsonObject);
|
|
operationMessage.setData(jsonObject);
|
|
|
operationMessage.setTtlTime(ttl);
|
|
operationMessage.setTtlTime(ttl);
|
|
@@ -263,7 +285,9 @@ public class OperationMessageService {
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
public ResultContent addOperationMessage(OperationMessage entity) {
|
|
public ResultContent addOperationMessage(OperationMessage entity) {
|
|
|
|
|
+ // 服务器接收消息的时间
|
|
|
entity.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
entity.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
|
|
+ // 消息的过期时间
|
|
|
entity.setTtl(new Date(System.currentTimeMillis() + ttlMill));
|
|
entity.setTtl(new Date(System.currentTimeMillis() + ttlMill));
|
|
|
if (entity.getEvent().equals("ping")) {
|
|
if (entity.getEvent().equals("ping")) {
|
|
|
Date da = new Date(System.currentTimeMillis() + 10 * 60 * 1000);
|
|
Date da = new Date(System.currentTimeMillis() + 10 * 60 * 1000);
|
|
@@ -298,8 +322,11 @@ public class OperationMessageService {
|
|
|
Object result = null;
|
|
Object result = null;
|
|
|
StopWatch stopWatch = new StopWatch();
|
|
StopWatch stopWatch = new StopWatch();
|
|
|
stopWatch.start();
|
|
stopWatch.start();
|
|
|
|
|
+
|
|
|
boolean isHandleSuccess = true;
|
|
boolean isHandleSuccess = true;
|
|
|
String handleMsg = "处理成功";
|
|
String handleMsg = "处理成功";
|
|
|
|
|
+
|
|
|
|
|
+ // 业务处理的消息内容
|
|
|
JSONObject jsonObject1 = (JSONObject) json.get("data");
|
|
JSONObject jsonObject1 = (JSONObject) json.get("data");
|
|
|
jsonObject1.put("mqttDataId", entity.getDataId());
|
|
jsonObject1.put("mqttDataId", entity.getDataId());
|
|
|
jsonObject1.put("GateWayId", entity.getGateWayId());
|
|
jsonObject1.put("GateWayId", entity.getGateWayId());
|
|
@@ -309,54 +336,165 @@ public class OperationMessageService {
|
|
|
jsonObject1.put("DeviceId", DeviceId);
|
|
jsonObject1.put("DeviceId", DeviceId);
|
|
|
}
|
|
}
|
|
|
entity.setDeviceId(DeviceId);
|
|
entity.setDeviceId(DeviceId);
|
|
|
- try {
|
|
|
|
|
- ExecuteMethodInfo executeMethodInfo = executeMethodInfoDao.findTopByEvent(event);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(executeMethodInfo)) {
|
|
|
|
|
- String dataStr = JSONUtil.toJsonStr(jsonObject1);
|
|
|
|
|
-
|
|
|
|
|
- String beanName = executeMethodInfo.getBeanName();
|
|
|
|
|
- String methodName = executeMethodInfo.getMethodName();
|
|
|
|
|
- Class c = applicationContext.getBean(beanName).getClass();
|
|
|
|
|
- SuperService t = (SuperService) applicationContext.getBean(beanName);
|
|
|
|
|
- Method method = c.getMethod(methodName, String.class);
|
|
|
|
|
- ResultContent<Object> resultContent = (ResultContent<Object>) method.invoke(t, dataStr);
|
|
|
|
|
- if (resultContent.isSuccess()) {
|
|
|
|
|
- result = resultContent.getContent();
|
|
|
|
|
|
|
+
|
|
|
|
|
+ // 查询有对应事件的设备
|
|
|
|
|
+ List<IotMain> events = iotMainDao.findByRealIotTopicAndFunctionTypeOrderByCreateTimeAsc(entity.getTopic(), FunctionType.Event);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(events)) {
|
|
|
|
|
+ String dataStr = JSONUtil.toJsonStr(jsonObject1);
|
|
|
|
|
+ for (IotMain iotMain : events) {
|
|
|
|
|
+ executeOperationMessage(entity, dataStr, iotMain);
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ isHandleSuccess = false;
|
|
|
|
|
+ handleMsg = "无对应物模型事件处理";
|
|
|
|
|
+ // 返回结果
|
|
|
|
|
+ entity.setResultData(result);
|
|
|
|
|
+ // 业务处理失败
|
|
|
|
|
+ entity.setIsHandleSuccess(isHandleSuccess);
|
|
|
|
|
+ entity.setHandleMsg(handleMsg);
|
|
|
|
|
+ entity.setReTime(System.currentTimeMillis());
|
|
|
|
|
+ entity.setReTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
|
|
+ operationMessageDao.save(entity);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ if (event.equals("ping")) {
|
|
|
|
|
+ // 查询业务处理端信息
|
|
|
|
|
+ try {
|
|
|
|
|
+ ExecuteMethodInfo executeMethodInfo = executeMethodInfoDao.findTopByEvent(event);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(executeMethodInfo)) {
|
|
|
|
|
+ String dataStr = JSONUtil.toJsonStr(jsonObject1);
|
|
|
|
|
+
|
|
|
|
|
+ String beanName = executeMethodInfo.getBeanName();
|
|
|
|
|
+ String methodName = executeMethodInfo.getMethodName();
|
|
|
|
|
+ Class c = applicationContext.getBean(beanName).getClass();
|
|
|
|
|
+ SuperService t = (SuperService) applicationContext.getBean(beanName);
|
|
|
|
|
+ Method method = c.getMethod(methodName, String.class);
|
|
|
|
|
+ ResultContent<Object> resultContent = (ResultContent<Object>) method.invoke(t, dataStr);
|
|
|
|
|
+ if (resultContent.isSuccess()) {
|
|
|
|
|
+ isHandleSuccess = true;
|
|
|
|
|
+ handleMsg = "处理成功";
|
|
|
|
|
+ result = resultContent.getContent();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ isHandleSuccess = false;
|
|
|
|
|
+ handleMsg = resultContent.getMsg();
|
|
|
|
|
+ }
|
|
|
|
|
+ entity.setBeanName(beanName);
|
|
|
|
|
+ entity.setMethodName(methodName);
|
|
|
} else {
|
|
} else {
|
|
|
isHandleSuccess = false;
|
|
isHandleSuccess = false;
|
|
|
- handleMsg = resultContent.getMsg();
|
|
|
|
|
|
|
+ handleMsg = "消息处理方法未找到";
|
|
|
}
|
|
}
|
|
|
- entity.setBeanName(beanName);
|
|
|
|
|
- entity.setMethodName(methodName);
|
|
|
|
|
- } else {
|
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
isHandleSuccess = false;
|
|
isHandleSuccess = false;
|
|
|
- handleMsg = "消息处理方法未找到";
|
|
|
|
|
|
|
+ handleMsg = String.format("业务处理出错:%S", e.getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ stopWatch.stop();
|
|
|
|
|
+ entity.setHandlerTime(stopWatch.getLastTaskTimeMillis());
|
|
|
|
|
+ // 返回结果
|
|
|
|
|
+ entity.setResultData(result);
|
|
|
|
|
+ // 业务处理失败
|
|
|
|
|
+ entity.setIsHandleSuccess(isHandleSuccess);
|
|
|
|
|
+ entity.setHandleMsg(handleMsg);
|
|
|
|
|
+ log.info("消息处理结果: {} {}", isHandleSuccess, handleMsg);
|
|
|
|
|
+ if (isHandleSuccess) {
|
|
|
|
|
+ // 处理成功,返回响应
|
|
|
|
|
+ responseMessage(entity);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ // 处理失败,记录数据
|
|
|
|
|
+ entity.setReTime(System.currentTimeMillis());
|
|
|
|
|
+ entity.setReTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
|
|
+ operationMessageDao.save(entity);
|
|
|
|
|
+ return ResultContent.buildFail(handleMsg);
|
|
|
}
|
|
}
|
|
|
- } catch (Exception e) {
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- isHandleSuccess = false;
|
|
|
|
|
- handleMsg = String.format("业务处理出错:%S", e.getMessage());
|
|
|
|
|
}
|
|
}
|
|
|
- stopWatch.stop();
|
|
|
|
|
- entity.setHandlerTime(stopWatch.getLastTaskTimeMillis());
|
|
|
|
|
- // 返回结果
|
|
|
|
|
- entity.setResultData(result);
|
|
|
|
|
- // 业务处理失败
|
|
|
|
|
- entity.setIsHandleSuccess(isHandleSuccess);
|
|
|
|
|
- entity.setHandleMsg(handleMsg);
|
|
|
|
|
- log.info("消息处理结果: {} {}", isHandleSuccess, handleMsg);
|
|
|
|
|
- if (isHandleSuccess) {
|
|
|
|
|
- // 处理成功,返回响应
|
|
|
|
|
- responseMessage(entity);
|
|
|
|
|
|
|
+ }
|
|
|
|
|
+ return ResultContent.buildSuccess();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 执行
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param entity
|
|
|
|
|
+ * @param dataStr
|
|
|
|
|
+ * @param iotMain
|
|
|
|
|
+ */
|
|
|
|
|
+ public void executeOperationMessage(OperationMessage entity, String dataStr, IotMain iotMain) {
|
|
|
|
|
+ OperationMessageResult messageResult = new OperationMessageResult();
|
|
|
|
|
+ messageResult.setOperationMessage(entity);
|
|
|
|
|
+ messageResult.setIotMain(iotMain);
|
|
|
|
|
+ messageResult.setDeviceId(iotMain.getDeviceId());
|
|
|
|
|
+ messageResult.setProjectCode(iotMain.getProjectCode());
|
|
|
|
|
+ messageResult.setGateWayId(entity.getGateWayId());
|
|
|
|
|
+ messageResult.setRealIotTopic(iotMain.getRealIotTopic());
|
|
|
|
|
+
|
|
|
|
|
+ boolean isHandleSuccess = true;
|
|
|
|
|
+ String handleMsg = "";
|
|
|
|
|
+ Long handlerTime = System.currentTimeMillis();
|
|
|
|
|
+
|
|
|
|
|
+ String remoteUrl = iotMain.getRemoteUrl();
|
|
|
|
|
+ if (StringUtils.isEmpty(remoteUrl)) {
|
|
|
|
|
+ isHandleSuccess = false;
|
|
|
|
|
+ handleMsg = "";
|
|
|
|
|
+ } else {
|
|
|
|
|
+ org.springframework.util.StopWatch stopWatch = new org.springframework.util.StopWatch();
|
|
|
|
|
+ stopWatch.start();
|
|
|
|
|
+
|
|
|
|
|
+ APIResponseModel apiResponseModel = apiRequestService.requestAPI(remoteUrl, dataStr);
|
|
|
|
|
+ messageResult.setResultData(apiResponseModel);
|
|
|
|
|
+
|
|
|
|
|
+ if (apiResponseModel.isSuccess()) {
|
|
|
|
|
+ // 处理成功
|
|
|
|
|
+ String content = apiResponseModel.getContent();
|
|
|
|
|
+ entity.setResultData(content);
|
|
|
|
|
+ if (iotMain.getIsReturnData() != null && iotMain.getIsReturnData()) {
|
|
|
|
|
+ // 返回
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
+ jsonObject.put("id", entity.getDataId());
|
|
|
|
|
+
|
|
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(content)) {
|
|
|
|
|
+ object = JSONUtil.parseObj(content);
|
|
|
|
|
+ }
|
|
|
|
|
+ jsonObject.put("data", object);
|
|
|
|
|
+ jsonObject.put("time", System.currentTimeMillis());
|
|
|
|
|
+ jsonObject.put("ttl", entity.getTtlTime());
|
|
|
|
|
+ jsonObject.put("event", entity.getEvent());
|
|
|
|
|
+ jsonObject.put("deviceId", entity.getDeviceId());
|
|
|
|
|
+ jsonObject.put("gateWayId", entity.getGateWayId());
|
|
|
|
|
+
|
|
|
|
|
+ String reTopic = String.format("%s/reply", entity.getTopic());
|
|
|
|
|
+ String reMsg = "响应成功";
|
|
|
|
|
+ Boolean reIsSuccess = Boolean.TRUE;
|
|
|
|
|
+ try {
|
|
|
|
|
+ mqClient.sendObject(reTopic, JSONUtil.toJsonStr(jsonObject), entity.getDataId());
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ reIsSuccess = Boolean.FALSE;
|
|
|
|
|
+ reMsg = "mqtt响应出错:" + e.getMessage();
|
|
|
|
|
+ }
|
|
|
|
|
+ messageResult.setIsResult(Boolean.TRUE);
|
|
|
|
|
+ messageResult.setReIsSuccess(reIsSuccess);
|
|
|
|
|
+ messageResult.setReMsg(reMsg);
|
|
|
|
|
+ messageResult.setReTime(System.currentTimeMillis());
|
|
|
|
|
+ messageResult.setReTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
|
|
+ messageResult.setReTopic(reTopic);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ messageResult.setIsResult(Boolean.TRUE);
|
|
|
|
|
+ messageResult.setReIsSuccess(Boolean.FALSE);
|
|
|
|
|
+ messageResult.setReMsg("无需返回");
|
|
|
|
|
+ }
|
|
|
} else {
|
|
} else {
|
|
|
- // 处理失败,记录数据
|
|
|
|
|
- entity.setReTime(System.currentTimeMillis());
|
|
|
|
|
- entity.setReTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyySSS));
|
|
|
|
|
- operationMessageDao.save(entity);
|
|
|
|
|
- return ResultContent.buildFail(handleMsg);
|
|
|
|
|
|
|
+ isHandleSuccess = false;
|
|
|
|
|
+ handleMsg = apiResponseModel.getMsg();
|
|
|
}
|
|
}
|
|
|
|
|
+ stopWatch.stop();
|
|
|
|
|
+ messageResult.setUseTime(stopWatch.getTotalTimeMillis());
|
|
|
}
|
|
}
|
|
|
- return ResultContent.buildSuccess();
|
|
|
|
|
|
|
+ messageResult.setIsHandleSuccess(isHandleSuccess);
|
|
|
|
|
+ messageResult.setHandleMsg(handleMsg);
|
|
|
|
|
+ messageResult.setHandlerTime(handlerTime);
|
|
|
|
|
+ operationMessageResultDao.save(messageResult);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -411,6 +549,33 @@ public class OperationMessageService {
|
|
|
return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 设备消息列表日志
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param pageable
|
|
|
|
|
+ * @param param
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResultContent<Page<OperationMessageResultModel>> pageMessage(Pageable pageable, OperationMessageResultSearch param) {
|
|
|
|
|
+ Page<OperationMessageResult> page = operationMessageResultDao.page(pageable, param);
|
|
|
|
|
+ return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 根据数据ID查询数据详情
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ResultContent<OperationMessageResultModel> getMessageById(String id) {
|
|
|
|
|
+ OperationMessageResult messageResult = operationMessageResultDao.findTopById(id);
|
|
|
|
|
+ if (ObjectUtils.isEmpty(messageResult)) {
|
|
|
|
|
+ return ResultContent.buildFail(String.format("数据ID不存在:%s", id));
|
|
|
|
|
+ }
|
|
|
|
|
+ OperationMessageResultModel model = toModel(messageResult);
|
|
|
|
|
+ return ResultContent.buildSuccess(model);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 标记消息已收到
|
|
* 标记消息已收到
|
|
|
*
|
|
*
|
|
@@ -443,4 +608,13 @@ public class OperationMessageService {
|
|
|
return model;
|
|
return model;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public OperationMessageResultModel toModel(OperationMessageResult entity) {
|
|
|
|
|
+ OperationMessageResultModel model = null;
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(entity)) {
|
|
|
|
|
+ model = new OperationMessageResultModel();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ return model;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
}
|
|
}
|