|
|
@@ -65,10 +65,10 @@ public class DevicePingInfoService extends SuperService {
|
|
|
|
|
|
public ResultContent<Object> ping(String dataId, String dataStr) {
|
|
|
PingResult pingResult = new PingResult();
|
|
|
- GateWayPingInfoParam param = JSONUtil.toBean(dataStr, GateWayPingInfoParam.class);
|
|
|
+ DevicePingInfoParam param = JSONUtil.toBean(dataStr, DevicePingInfoParam.class);
|
|
|
|
|
|
- if (StringUtils.isNotEmpty(param.getDeviceId())) {
|
|
|
- ResultContent resultContent = devicePing(dataId, dataStr);
|
|
|
+ if (StringUtils.isNotEmpty(param.getDeviceId()) || StringUtils.isNotEmpty(param.getGatewayId())) {
|
|
|
+ ResultContent resultContent = devicePing(dataId, param);
|
|
|
if (resultContent.isFailed()) {
|
|
|
pingResult.setFailed(resultContent.getMsg());
|
|
|
return ResultContent.buildSuccess(pingResult);
|
|
|
@@ -86,13 +86,16 @@ public class DevicePingInfoService extends SuperService {
|
|
|
* 设备ping
|
|
|
*
|
|
|
* @param dataId
|
|
|
- * @param dataStr
|
|
|
+ * @param param
|
|
|
* @return
|
|
|
*/
|
|
|
- private ResultContent<Object> devicePing(String dataId, String dataStr) {
|
|
|
- DevicePingInfoParam param = JSONUtil.toBean(dataStr, DevicePingInfoParam.class);
|
|
|
+ private ResultContent<Object> devicePing(String dataId, DevicePingInfoParam param) {
|
|
|
String deviceId = param.getDeviceId();
|
|
|
- ResultContent resultContent = deviceInfoService.deviceCanUse(param.getDeviceId());
|
|
|
+ if (StringUtils.isEmpty(deviceId)) {
|
|
|
+ deviceId = param.getGatewayId();
|
|
|
+ }
|
|
|
+
|
|
|
+ ResultContent resultContent = deviceInfoService.deviceCanUse(deviceId);
|
|
|
if (resultContent.isFailed()) {
|
|
|
return ResultContent.buildFail(resultContent.getMsg());
|
|
|
}
|
|
|
@@ -106,7 +109,7 @@ public class DevicePingInfoService extends SuperService {
|
|
|
devicePingInfo.setPingType(deviceInfo.getDeviceType().name());
|
|
|
devicePingInfo.setDeviceId(deviceId);
|
|
|
devicePingInfo.setDeviceName(deviceInfo.getDeviceName());
|
|
|
- devicePingInfo.setGateWayId(param.getGateWayId());
|
|
|
+ devicePingInfo.setGateWayId(param.getGatewayId());
|
|
|
devicePingInfo.setProjectInfoCode(deviceInfo.getProjectInfoCode());
|
|
|
devicePingInfo.setTTL(new Date(System.currentTimeMillis() + CommonTTLTimeConfig.pingTTl));
|
|
|
devicePingInfo.setTimeStr(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
|