Browse Source

更新!

TRX 1 year ago
parent
commit
8e376d3af2

+ 3 - 3
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/mqtt/DeviceInfoDao.java

@@ -25,11 +25,11 @@ public interface DeviceInfoDao extends DeviceInfoDaoExtend, org.springframework.
 
     List<DeviceInfo> findByRegistTypeIn(List<RegistType> registTypes);
 
-    Long countByProductCode(String productCode);
+    Long countByProductCodeAndIsDelete(String productCode, Boolean isDelete);
 
-    List<DeviceInfo> findByDeviceCategory(DeviceCategory deviceCategory);
+    List<DeviceInfo> findByDeviceCategoryAndIsDelete(DeviceCategory deviceCategory, Boolean isDelete);
 
-    Long countByDeviceCategory(DeviceCategory deviceCategory);
+    Long countByDeviceCategoryAndIsDelete(DeviceCategory deviceCategory, Boolean isDelete);
 
     List<DeviceInfo> findByIsDelete(Boolean isDelete);
 

+ 6 - 3
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/DeviceInfoService.java

@@ -278,12 +278,15 @@ public class DeviceInfoService {
         // 更新设备权限
         jmxSyncService.syncDevicesSecurity(List.of(deviceInfo));
 
-        // 同步显示信息
+        // 同步设备信息(同步到业务平台)
         deviceSyncFullCardService.noticeSyncDevice(List.of(deviceInfo));
 
         // 设备信息改变时,更新 对应的物模型数据
         iotThingService.updateThingByDevice(deviceInfo);
 
+        // 添加操作日志
+        String logContent = String.format("改变了设备%s状态为%s", deviceInfo.getDeviceId(), deviceInfo.getState().getRemark());
+        operationLogsService.addLogs(logContent, OperationLogBusType.Device, deviceInfo);
         return ResultContent.buildSuccess();
     }
 
@@ -349,7 +352,7 @@ public class DeviceInfoService {
         deviceInfo.setIsDelete(Boolean.TRUE);
         deviceInfoDao.save(deviceInfo);
 
-        operationLogsService.addLogs(String.format("删除了设备;%s", deviceInfo.getDeviceName()), OperationLogBusType.Device, deviceInfo);
+        operationLogsService.addLogs(String.format("删除了设备;%s", deviceInfo.getDeviceId()), OperationLogBusType.Device, deviceInfo);
 
         // 更新设备信息
         deviceSyncFullCardService.noticeSyncDevice(List.of(deviceInfo));
@@ -413,7 +416,7 @@ public class DeviceInfoService {
         if (StringUtils.isEmpty(productCode)) {
             return 0L;
         }
-        return deviceInfoDao.countByProductCode(productCode);
+        return deviceInfoDao.countByProductCodeAndIsDelete(productCode, Boolean.FALSE);
     }
 
     public ResultContent<DeviceInfoModel> getDeviceById(String deviceId) {

+ 2 - 2
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/DeviceStatisticsService.java

@@ -64,7 +64,7 @@ public class DeviceStatisticsService {
      */
     public ResultContent deviceStatistics() {
         DeviceStatisticsModel model = new DeviceStatisticsModel();
-        Long deviceNumber = deviceInfoDao.countByDeviceCategory(DeviceCategory.DE);
+        Long deviceNumber = deviceInfoDao.countByDeviceCategoryAndIsDelete(DeviceCategory.DE, Boolean.FALSE);
         model.setDeviceNumber(deviceNumber);
 
         Long startTime = DateUtils.getDayStartTime(System.currentTimeMillis());
@@ -74,7 +74,7 @@ public class DeviceStatisticsService {
         Long toDayDeviceNumber = deviceInfoDao.count(param);
         model.setToDayDeviceNumber(toDayDeviceNumber);
 
-        Long gateWayNumber = deviceInfoDao.countByDeviceCategory(DeviceCategory.GW);
+        Long gateWayNumber = deviceInfoDao.countByDeviceCategoryAndIsDelete(DeviceCategory.GW, Boolean.FALSE);
         model.setGateWayNumber(gateWayNumber);
         param.setDeviceCategorys(List.of(DeviceCategory.GW));
         Long toDayGateWayNumber = deviceInfoDao.count(param);

+ 5 - 2
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/device/GateWayManagerService.java

@@ -12,7 +12,10 @@ import com.zhongshu.iot.client.type.IotDataType;
 import com.zhongshu.iot.server.core.dao.iot.IotTemplateDao;
 import com.zhongshu.iot.server.core.dao.mqtt.*;
 import com.zhongshu.iot.server.core.domain.iot.IotTemplate;
-import com.zhongshu.iot.server.core.domain.iot.device.*;
+import com.zhongshu.iot.server.core.domain.iot.device.DeviceInfo;
+import com.zhongshu.iot.server.core.domain.iot.device.GateWay2Device;
+import com.zhongshu.iot.server.core.domain.iot.device.GateWayUserInfo;
+import com.zhongshu.iot.server.core.domain.iot.device.ProjectInfo;
 import com.zhongshu.iot.server.core.domain.iot.message.OperationMessage;
 import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
 import com.zhongshu.iot.server.core.service.base.SuperService;
@@ -295,7 +298,7 @@ public class GateWayManagerService extends SuperService {
      * @return
      */
     public List<DeviceInfo> getAllGateWayDevices() {
-        return deviceInfoDao.findByDeviceCategory(DeviceCategory.GW);
+        return deviceInfoDao.findByDeviceCategoryAndIsDelete(DeviceCategory.GW, Boolean.FALSE);
     }
 
     public DeviceInfo getDeviceGateWayInfo(String deviceId) {

+ 1 - 1
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/sync/DeviceSyncFullCardService.java

@@ -68,7 +68,7 @@ public class DeviceSyncFullCardService extends SuperService {
     }
 
     /**
-     * 通知同步设备
+     * 通知同步设备信息()
      *
      * @param deviceInfos
      * @return