瀏覽代碼

Merge branch 'master' into test

李进 1 年之前
父節點
當前提交
605de8c3e8

+ 0 - 5
device-api-service/src/main/java/com/xy/entity/DeviceStatus.java

@@ -93,11 +93,6 @@ public class DeviceStatus {
      */
     private Integer tempState;
 
-    /**
-     * 是否有温控仪
-     */
-    private Boolean isHaveTemp;
-
     /**
      * 音量
      */

+ 20 - 0
device-api-service/src/main/java/com/xy/entity/DeviceSysinfo.java

@@ -101,6 +101,26 @@ public class DeviceSysinfo {
      */
     private Integer memerySpace;
 
+    /**
+     * 是否有温控仪
+     */
+    private Boolean isHaveTemp;
+
+    /**
+     * 是否可调主灯
+     */
+    private Boolean isHaveLightMain;
+
+    /**
+     * 是否可调副灯
+     */
+    private Boolean isHaveLightSecond;
+
+    /**
+     * 设备型号
+     */
+    private String deviceVersion;
+
     /**
      * 创建时间
      */

+ 44 - 38
device-api-service/src/main/java/com/xy/service/DeviceStatusServiceImpl.java

@@ -13,6 +13,7 @@ import com.xy.dto.DeviceStatusDto;
 import com.xy.dto.DeviceTempRecordsDto;
 import com.xy.entity.DeviceConfig;
 import com.xy.entity.DeviceStatus;
+import com.xy.entity.DeviceSysinfo;
 import com.xy.mapper.DeviceStatusMapper;
 import com.xy.mapper.entity.DeviceStatusCount;
 import com.xy.utils.*;
@@ -55,6 +56,8 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
 
     private RedisService<Integer> redisService;
 
+    private DeviceSysinfoServiceImpl deviceSysinfoService;
+
     @Override
     @ApiOperation("上报信息")
     public R up(DeviceStatusDto.Up up) {
@@ -66,49 +69,52 @@ public class DeviceStatusServiceImpl extends ServiceImpl<DeviceStatusMapper, Dev
         DeviceStatus deviceStatus = copy(DeviceStatus.class, up).setUpdateTime(LocalDateTime.now());
         updateById(deviceStatus);
         //温度上报
-        if (Emptys.check(deviceStatus.getTempValue()) && deviceStatusInfo.getIsHaveTemp()) {
+        if (Emptys.check(deviceStatus.getTempValue())) {
+            DeviceSysinfo deviceSysinfo = deviceSysinfoService.getById(up.getDeviceId());
             //添加设备温度日志
-            DeviceTempRecordsDto.Save save = new DeviceTempRecordsDto.Save()
-                    .setDeviceId(up.getDeviceId());
-            save.setTempValue(deviceStatus.getTempValue());
-            deviceTempRecordsService.save(save);
-            //查询设备配置
-            DeviceConfig deviceConfig = deviceConfigService.getById(deviceStatus.getDeviceId());
-            Integer tempMax = deviceConfig.getTempMax();
-            Integer tempMin = deviceConfig.getTempMin();
-            //温度有异常
-            String key = String.format("device_temp_error:%s:%s", deviceStatus.getDeviceId(), deviceStatus.getTempValue() >= tempMax ? "max" : "min");
-            if (deviceStatus.getTempValue() > tempMax || deviceStatus.getTempValue() < tempMin) {
-                //校验异常次数
-                Integer errorSize = SysDictUtils.getValue(EnumDeviceTempConfig.Code.CODE.getCode(), EnumDeviceTempConfig.ERROR_SIZE.getCode(), Integer.class);
-                boolean fal = false;
-                Integer maxSize = redisService.get(key);
-                if (maxSize == null) {
-                    redisService.set(key, 1, 60 * 60);
-                } else {
-                    if (maxSize >= errorSize) {
-                        fal = true;
-                        redisService.remove(key);
+            if (deviceSysinfo.getIsHaveTemp()) {
+                DeviceTempRecordsDto.Save save = new DeviceTempRecordsDto.Save()
+                        .setDeviceId(up.getDeviceId());
+                save.setTempValue(deviceStatus.getTempValue());
+                deviceTempRecordsService.save(save);
+                //查询设备配置
+                DeviceConfig deviceConfig = deviceConfigService.getById(deviceStatus.getDeviceId());
+                Integer tempMax = deviceConfig.getTempMax();
+                Integer tempMin = deviceConfig.getTempMin();
+                //温度有异常
+                String key = String.format("device_temp_error:%s:%s", deviceStatus.getDeviceId(), deviceStatus.getTempValue() >= tempMax ? "max" : "min");
+                if (deviceStatus.getTempValue() > tempMax || deviceStatus.getTempValue() < tempMin) {
+                    //校验异常次数
+                    Integer errorSize = SysDictUtils.getValue(EnumDeviceTempConfig.Code.CODE.getCode(), EnumDeviceTempConfig.ERROR_SIZE.getCode(), Integer.class);
+                    boolean fal = false;
+                    Integer maxSize = redisService.get(key);
+                    if (maxSize == null) {
+                        redisService.set(key, 1, 60 * 60);
                     } else {
-                        redisService.set(key, maxSize + 1, 60 * 60);
+                        if (maxSize >= errorSize) {
+                            fal = true;
+                            redisService.remove(key);
+                        } else {
+                            redisService.set(key, maxSize + 1, 60 * 60);
+                        }
                     }
-                }
-                //添加事件
-                if (fal) {
-                    DeviceEventMsgDto.Save deviceEventMsg = new DeviceEventMsgDto.Save()
-                            .setDeviceId(deviceStatus.getDeviceId());
-                    deviceEventMsg.setCode(DeviceErrorRecordTypesEnum.T.getCode());
-                    String msg = "温度异常-温度阈值%d,当前温度%d";
-                    if (deviceStatus.getTempValue() >= tempMax) {
-                        deviceEventMsg.setMsg(String.format(msg, tempMax, deviceStatus.getTempValue()));
+                    //添加事件
+                    if (fal) {
+                        DeviceEventMsgDto.Save deviceEventMsg = new DeviceEventMsgDto.Save()
+                                .setDeviceId(deviceStatus.getDeviceId());
+                        deviceEventMsg.setCode(DeviceErrorRecordTypesEnum.T.getCode());
+                        String msg = "温度异常-温度阈值%d,当前温度%d";
+                        if (deviceStatus.getTempValue() >= tempMax) {
+                            deviceEventMsg.setMsg(String.format(msg, tempMax, deviceStatus.getTempValue()));
+                        }
+                        if (deviceStatus.getTempValue() <= tempMin) {
+                            deviceEventMsg.setMsg(String.format(msg, tempMin, deviceStatus.getTempValue()));
+                        }
+                        deviceEventMsgService.save(deviceEventMsg);
                     }
-                    if (deviceStatus.getTempValue() <= tempMin) {
-                        deviceEventMsg.setMsg(String.format(msg, tempMin, deviceStatus.getTempValue()));
-                    }
-                    deviceEventMsgService.save(deviceEventMsg);
+                } else {
+                    redisService.remove(key);
                 }
-            } else {
-                redisService.remove(key);
             }
         }
         //上报关门

+ 0 - 3
device-api/src/main/java/com/xy/dto/DeviceStatusDto.java

@@ -114,9 +114,6 @@ public class DeviceStatusDto {
         @ApiModelProperty("温控仪状态")
         private Integer tempState;
 
-        @ApiModelProperty("是否有温控仪")
-        private Boolean isHaveTemp;
-
         @ApiModelProperty("音量")
         private Integer voiceVolume;
 

+ 12 - 5
device-api/src/main/java/com/xy/dto/DeviceSysinfoDto.java

@@ -101,17 +101,24 @@ public class DeviceSysinfoDto {
         @ApiModelProperty("内存容量")
         private Integer memerySpace;
 
+        @ApiModelProperty("是否有温控仪")
+        private Boolean isHaveTemp;
+
+        @ApiModelProperty("是否可调主灯")
+        private Boolean isHaveLightMain;
+
+        @ApiModelProperty("是否可调副灯")
+        private Boolean isHaveLightSecond;
+
+        @ApiModelProperty("设备型号")
+        private String deviceVersion;
+
         @JsonDeserialize(using = LocalDateTimeDeserializer.class)
         @JsonSerialize(using = LocalDateTimeSerializer.class)
         @ApiModelProperty("创建时间")
         @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
         private LocalDateTime createTime;
 
-        @JsonDeserialize(using = LocalDateTimeDeserializer.class)
-        @JsonSerialize(using = LocalDateTimeSerializer.class)
-        @ApiModelProperty("更新时间")
-        @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
-        private LocalDateTime updateTime;
     }