|
|
@@ -3,12 +3,16 @@ package com.zswl.dataservice.service.mqtt;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.models.hxz.ConsumTransactionsModel;
|
|
|
import com.github.microservice.models.hxz.DevicePingInfoParam;
|
|
|
+import com.github.microservice.models.hxz.GateWayPingInfoParam;
|
|
|
+import com.github.microservice.models.hxz.PingResult;
|
|
|
import com.zswl.dataservice.dao.mqtt.DeviceInfoDao;
|
|
|
import com.zswl.dataservice.dao.mqtt.DevicePingInfoDao;
|
|
|
+import com.zswl.dataservice.dao.mqtt.GateWayInfoDao;
|
|
|
import com.zswl.dataservice.domain.ExecuteAnnotationService;
|
|
|
import com.zswl.dataservice.domain.ExecuteAnnotationServiceMethod;
|
|
|
import com.zswl.dataservice.domain.mqtt.DeviceInfo;
|
|
|
import com.zswl.dataservice.domain.mqtt.DevicePingInfo;
|
|
|
+import com.zswl.dataservice.domain.mqtt.GateWayInfo;
|
|
|
import com.zswl.dataservice.service.base.CommonService;
|
|
|
import com.zswl.dataservice.service.base.SuperService;
|
|
|
import com.zswl.dataservice.service.sync.DeviceSyncFullCardService;
|
|
|
@@ -48,6 +52,9 @@ public class DevicePingInfoService extends SuperService {
|
|
|
@Autowired
|
|
|
DeviceSyncFullCardService deviceSyncFullCardService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ GateWayInfoDao gateWayInfoDao;
|
|
|
+
|
|
|
@ExecuteAnnotationServiceMethod(value = "devicePing", remark = "设备心跳")
|
|
|
public ResultContent<Object> devicePing(String dataStr) {
|
|
|
DevicePingInfoParam param = JSONUtil.toBean(dataStr, DevicePingInfoParam.class);
|
|
|
@@ -77,6 +84,34 @@ public class DevicePingInfoService extends SuperService {
|
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
|
|
|
|
+ @ExecuteAnnotationServiceMethod(value = "ping", remark = "设备心跳")
|
|
|
+ public ResultContent<Object> ping(String dataStr) {
|
|
|
+ log.info("dataStr: {}", dataStr);
|
|
|
+ PingResult pingResult = new PingResult();
|
|
|
+ GateWayPingInfoParam param = JSONUtil.toBean(dataStr, GateWayPingInfoParam.class);
|
|
|
+ GateWayInfo gateWayInfo = gateWayInfoDao.findTopByGateWayId(param.getGateWayId());
|
|
|
+ if (ObjectUtils.isNotEmpty(gateWayInfo)) {
|
|
|
+ Map<String, Object> where = new HashMap<>();
|
|
|
+ where.put("gateWayId", gateWayInfo.getGateWayId());
|
|
|
+ Map<String, Object> standardData = new HashMap<>();
|
|
|
+ standardData.put("onLineState", OnLineState.OnLine);
|
|
|
+ standardData.put("lastOnlineTime", System.currentTimeMillis());
|
|
|
+ commonService.updateData(where, standardData, GateWayInfo.class.getSimpleName());
|
|
|
+
|
|
|
+ // ping记录
|
|
|
+ DevicePingInfo devicePingInfo = new DevicePingInfo();
|
|
|
+ devicePingInfo.setGateWayId(param.getGateWayId());
|
|
|
+ devicePingInfo.setProjectInfoCode(gateWayInfo.getProjectInfoCode());
|
|
|
+ devicePingInfo.setTTL(new Date(System.currentTimeMillis() + 1 * 24L * 60 * 60 * 1000L));
|
|
|
+ devicePingInfo.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|
|
|
+ devicePingInfoDao.save(devicePingInfo);
|
|
|
+ }
|
|
|
+ pingResult.setSuccess();
|
|
|
+ pingResult.setTime(System.currentTimeMillis());
|
|
|
+ return ResultContent.buildSuccess(pingResult);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* 检查
|
|
|
*/
|