|
@@ -2,7 +2,6 @@ package com.zhongshu.card.server.core.service.devices;
|
|
|
|
|
|
|
|
import com.github.microservice.models.device.DeviceInfoSyncParam;
|
|
import com.github.microservice.models.device.DeviceInfoSyncParam;
|
|
|
import com.github.microservice.models.device.DeviceSyncListParam;
|
|
import com.github.microservice.models.device.DeviceSyncListParam;
|
|
|
-import com.github.microservice.models.device.GateWaySyncParam;
|
|
|
|
|
import com.github.microservice.models.hxz.DevicePingInfoParam;
|
|
import com.github.microservice.models.hxz.DevicePingInfoParam;
|
|
|
import com.github.microservice.net.ResultContent;
|
|
import com.github.microservice.net.ResultContent;
|
|
|
import com.zhongshu.card.client.service.school.DeviceInfoService;
|
|
import com.zhongshu.card.client.service.school.DeviceInfoService;
|
|
@@ -34,22 +33,19 @@ import java.util.List;
|
|
|
public class DeviceSyncFromIotService {
|
|
public class DeviceSyncFromIotService {
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- DeviceInfoService deviceInfoService;
|
|
|
|
|
|
|
+ private DeviceInfoService deviceInfoService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- OrganizationDao organizationDao;
|
|
|
|
|
|
|
+ private OrganizationDao organizationDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- OrganizationRelationDao organizationRelationDao;
|
|
|
|
|
|
|
+ private OrganizationRelationDao organizationRelationDao;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- OperationLogsService operationLogsService;
|
|
|
|
|
|
|
+ private OperationLogsService operationLogsService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
- GateWayInfoServiceImpl gateWayService;
|
|
|
|
|
-
|
|
|
|
|
- @Autowired
|
|
|
|
|
- CommonService commonService;
|
|
|
|
|
|
|
+ private CommonService commonService;
|
|
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private DeviceInfoDao deviceInfoDao;
|
|
private DeviceInfoDao deviceInfoDao;
|
|
@@ -85,22 +81,27 @@ public class DeviceSyncFromIotService {
|
|
|
public ResultContent syncDeviceOnLineState(DevicePingInfoParam param) {
|
|
public ResultContent syncDeviceOnLineState(DevicePingInfoParam param) {
|
|
|
HashMap<String, Object> where = new HashMap<>();
|
|
HashMap<String, Object> where = new HashMap<>();
|
|
|
where.put("deviceId", param.getDeviceId());
|
|
where.put("deviceId", param.getDeviceId());
|
|
|
|
|
+ OnLineState onLineState = CommonUtil.getEnumByName(OnLineState.class, param.getOnLineState());
|
|
|
|
|
|
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
HashMap<String, Object> map = new HashMap<>();
|
|
|
map.put("lastOnlineTime", param.getLastOnlineTime());
|
|
map.put("lastOnlineTime", param.getLastOnlineTime());
|
|
|
map.put("lastOfflineTime", param.getLastOfflineTime());
|
|
map.put("lastOfflineTime", param.getLastOfflineTime());
|
|
|
- map.put("onLineState", CommonUtil.getEnumByName(OnLineState.class, param.getOnLineState()));
|
|
|
|
|
- map.put("state", param.getState());
|
|
|
|
|
|
|
+ map.put("onLineState", onLineState);
|
|
|
|
|
+ if (param.getState() != null) {
|
|
|
|
|
+ map.put("state", param.getState());
|
|
|
|
|
+ }
|
|
|
map.put("lastOnlineTimeStr", DateUtils.paresTime(param.getLastOnlineTime(), DateUtils.FORMAT_LONG));
|
|
map.put("lastOnlineTimeStr", DateUtils.paresTime(param.getLastOnlineTime(), DateUtils.FORMAT_LONG));
|
|
|
|
|
|
|
|
commonService.updateData(where, map, DeviceInfo.class.getSimpleName());
|
|
commonService.updateData(where, map, DeviceInfo.class.getSimpleName());
|
|
|
commonService.updateData(where, map, DeviceBind.class.getSimpleName());
|
|
commonService.updateData(where, map, DeviceBind.class.getSimpleName());
|
|
|
|
|
|
|
|
HashMap<String, Object> bindMap = new HashMap<>();
|
|
HashMap<String, Object> bindMap = new HashMap<>();
|
|
|
- bindMap.put("onLineState", CommonUtil.getEnumByName(OnLineState.class, param.getOnLineState()));
|
|
|
|
|
|
|
+ bindMap.put("onLineState", onLineState);
|
|
|
commonService.updateData(where, bindMap, DevicePermiss.class.getSimpleName());
|
|
commonService.updateData(where, bindMap, DevicePermiss.class.getSimpleName());
|
|
|
|
|
|
|
|
- log.info("同步在线状态syncDeviceOnLineState: {}", param.getDeviceId());
|
|
|
|
|
|
|
+ log.info("同步在线状态syncDeviceOnLineState: {} {} {}", param.getDeviceId(),
|
|
|
|
|
+ DateUtils.paresTime(System.currentTimeMillis(), "HH:mm:ss SSS"),
|
|
|
|
|
+ onLineState);
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -116,26 +117,4 @@ public class DeviceSyncFromIotService {
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 同步网关列表
|
|
|
|
|
- *
|
|
|
|
|
- * @param param
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- public ResultContent syncGateWays(GateWaySyncParam param) {
|
|
|
|
|
- List<GateWaySyncParam.GateWaySyncInfo> list = param.getList();
|
|
|
|
|
- log.info("syncGateWays: {}", list.size());
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(list)) {
|
|
|
|
|
- for (GateWaySyncParam.GateWaySyncInfo syncInfo : list) {
|
|
|
|
|
- ResultContent content = gateWayService.syncGateWayInfo(syncInfo);
|
|
|
|
|
- if (content.isSuccess()) {
|
|
|
|
|
- log.info("同步网关成功:{}", syncInfo.getGateWayName());
|
|
|
|
|
- } else {
|
|
|
|
|
- log.warn("同步网关失败:{}", content.getMsg());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- return ResultContent.buildSuccess();
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
}
|
|
}
|