瀏覽代碼

Merge remote-tracking branch 'origin/master' into prod

谭斌 2 年之前
父節點
當前提交
5814e0b0b1

+ 1 - 0
device-api-service-merc-mini/src/main/java/com/xy/controller/MercMiniDeviceController.java

@@ -157,4 +157,5 @@ public class MercMiniDeviceController {
         return R.ok();
         return R.ok();
     }
     }
 
 
+
 }
 }

+ 16 - 5
device-api-service/src/main/java/com/xy/service/DeviceInfoServiceImpl.java

@@ -27,6 +27,7 @@ import com.xy.mapper.entity.DeviceInfoQueryPage;
 import com.xy.util.ExcelUtils;
 import com.xy.util.ExcelUtils;
 import com.xy.util.FileUtils;
 import com.xy.util.FileUtils;
 import com.xy.utils.*;
 import com.xy.utils.*;
+import com.xy.utils.enums.DeviceActiveStateEnum;
 import com.xy.utils.enums.DeviceNetSateType;
 import com.xy.utils.enums.DeviceNetSateType;
 import com.xy.utils.enums.DictEnum;
 import com.xy.utils.enums.DictEnum;
 import com.xy.utils.enums.DictSonEnum;
 import com.xy.utils.enums.DictSonEnum;
@@ -145,6 +146,13 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         return R.ok(deviceInfoList.stream().collect(Collectors.toMap(DeviceInfo::getDeviceId, i -> Optional.ofNullable(i.getDeviceName()).orElse(""))));
         return R.ok(deviceInfoList.stream().collect(Collectors.toMap(DeviceInfo::getDeviceId, i -> Optional.ofNullable(i.getDeviceName()).orElse(""))));
     }
     }
 
 
+    @Override
+    public R<DeviceSysinfoDto.Vo> getDeviceSysinfo(DeviceSysinfoDto.DeviceSysInfo dto) {
+        String dtoDeviceSN = dto.getDeviceSN();
+        DeviceSysinfo one = deviceSysinfoService.getOne(Wrappers.<DeviceSysinfo>lambdaQuery().eq(DeviceSysinfo::getDeviceSn, dtoDeviceSN));
+        return R.ok(BeanUtil.copyProperties(one, DeviceSysinfoDto.Vo.class));
+    }
+
     @Override
     @Override
     @ApiOperation("设备访问历史添加")
     @ApiOperation("设备访问历史添加")
     public R history(DeviceInfoDto.Obj obj) {
     public R history(DeviceInfoDto.Obj obj) {
@@ -547,6 +555,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         List<DeviceInfoDto.MercHomeListVO> dataList = new ArrayList<>(list.size());
         List<DeviceInfoDto.MercHomeListVO> dataList = new ArrayList<>(list.size());
 
 
         LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<>();
         LambdaQueryWrapper<DeviceInfo> lqw = new LambdaQueryWrapper<>();
+        lqw.eq(DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode());
         lqw.eq(mercId != null, DeviceInfo::getMercId, mercId);
         lqw.eq(mercId != null, DeviceInfo::getMercId, mercId);
         lqw.eq(deviceId != null, DeviceInfo::getDeviceId, deviceId);
         lqw.eq(deviceId != null, DeviceInfo::getDeviceId, deviceId);
         lqw.like(StrUtil.isNotEmpty(deviceName), DeviceInfo::getDeviceName, deviceName);
         lqw.like(StrUtil.isNotEmpty(deviceName), DeviceInfo::getDeviceName, deviceName);
@@ -555,14 +564,16 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
         deviceInfoList.stream().filter(s -> s.getPlaceLineId() == null).forEach(s -> s.setPlaceLineId(-1L));
         deviceInfoList.stream().filter(s -> s.getPlaceLineId() == null).forEach(s -> s.setPlaceLineId(-1L));
         //根据线路id分组
         //根据线路id分组
         Map<Long, List<DeviceInfo>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfo::getPlaceLineId));
         Map<Long, List<DeviceInfo>> deviceMap = deviceInfoList.stream().collect(Collectors.groupingBy(DeviceInfo::getPlaceLineId));
-        list.forEach(v -> {
+        for (DeviceInfoDto.MercHomeCountVO v : list) {
             DeviceInfoDto.MercHomeListVO vo = new DeviceInfoDto.MercHomeListVO();
             DeviceInfoDto.MercHomeListVO vo = new DeviceInfoDto.MercHomeListVO();
             Long placeLineId = v.getPlaceLineId();
             Long placeLineId = v.getPlaceLineId();
             vo.setDeviceNum(v.getDeviceNum());
             vo.setDeviceNum(v.getDeviceNum());
             vo.setPlaceLineId(v.getPlaceLineId());
             vo.setPlaceLineId(v.getPlaceLineId());
             //线路下的设备列表
             //线路下的设备列表
-            List<DeviceInfoDto.MercHomeDeviceVo> deviceInfos = Beans.copy(DeviceInfoDto.MercHomeDeviceVo.class, deviceMap.get(placeLineId));
-
+            List<DeviceInfoDto.MercHomeDeviceVo> deviceInfos = BeanUtil.copyToList(deviceMap.get(placeLineId), DeviceInfoDto.MercHomeDeviceVo.class);
+            if (CollUtil.isEmpty(deviceInfos)) {
+                continue;
+            }
             //设备销售统计
             //设备销售统计
             String todayDate = DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN);
             String todayDate = DateUtil.format(new Date(), DatePattern.PURE_DATE_PATTERN);
             List<Long> deviceIds = deviceInfos.stream().map(DeviceInfoDto.MercHomeDeviceVo::getDeviceId).collect(Collectors.toList());
             List<Long> deviceIds = deviceInfos.stream().map(DeviceInfoDto.MercHomeDeviceVo::getDeviceId).collect(Collectors.toList());
@@ -613,7 +624,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
             }
             }
             vo.setDeviceInfos(deviceInfos);
             vo.setDeviceInfos(deviceInfos);
             dataList.add(vo);
             dataList.add(vo);
-        });
+        }
 
 
         return R.ok(dataList);
         return R.ok(dataList);
     }
     }
@@ -625,7 +636,7 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
      * @return
      * @return
      */
      */
     private List<DeviceInfo> getDevicesByMercId(Long mercId) {
     private List<DeviceInfo> getDevicesByMercId(Long mercId) {
-        return list(Wrappers.<DeviceInfo>lambdaQuery().eq(DeviceInfo::getMercId, mercId));
+        return list(Wrappers.<DeviceInfo>lambdaQuery().eq(DeviceInfo::getMercId, mercId).eq(DeviceInfo::getActiveState, DeviceActiveStateEnum.TRUE.getCode()));
     }
     }
 
 
 
 

+ 4 - 5
device-api-service/src/main/java/com/xy/service/MqttServiceImpl.java

@@ -115,12 +115,11 @@ public class MqttServiceImpl extends ServiceImpl<MqttCommandMapper, MqttCommand>
         QueryWrapper<MqttCommand> wrapper = new QueryWrapper<MqttCommand>()
         QueryWrapper<MqttCommand> wrapper = new QueryWrapper<MqttCommand>()
                 .select(String.format("max(%s) as %s", sn, sn));
                 .select(String.format("max(%s) as %s", sn, sn));
         MqttCommand mqttCommand = getOne(wrapper);
         MqttCommand mqttCommand = getOne(wrapper);
-        if (mqttCommand == null) {
-            return;
+        if (mqttCommand != null) {
+            redisService.setAtomic(CommConsts.CMD_ATOM_SN, mqttCommand.getSn() + 1);
+            MqttCommand byId = getById(mqttCommand.getSn());
+            redisService.setAtomic(CommConsts.CMD_ATOM_WK_SN, byId.getWkSn() + 1);
         }
         }
-        redisService.setAtomic(CommConsts.CMD_ATOM_SN, mqttCommand.getSn() + 1);
-        MqttCommand byId = getById(mqttCommand.getSn());
-        redisService.setAtomic(CommConsts.CMD_ATOM_WK_SN, byId.getWkSn() + 1);
         snInit = true;
         snInit = true;
     }
     }
 
 

+ 1 - 0
device-api-service/src/main/resources/mapper/DeviceInfoMapper.xml

@@ -263,6 +263,7 @@
         from device_info
         from device_info
 
 
         <where>
         <where>
+            active_state='1'
             <if test="query.mercId != null">
             <if test="query.mercId != null">
                 and merc_id = #{query.mercId}
                 and merc_id = #{query.mercId}
             </if>
             </if>

+ 11 - 0
device-api/src/main/java/com/xy/dto/DeviceInfoDto.java

@@ -657,6 +657,17 @@ public class DeviceInfoDto {
 
 
     }
     }
 
 
+
+    @Data
+    @Accessors(chain = true)
+    public static class CheckOwnerDTO {
+        @ApiModelProperty(value = "设备SN", required = false)
+        private String deviceSn;
+
+        @ApiModelProperty(value = "设备id", required = false)
+        private Long deviceId;
+    }
+
     @Data
     @Data
     @Accessors(chain = true)
     @Accessors(chain = true)
     public static class DeviceDataCountDTO {
     public static class DeviceDataCountDTO {

+ 8 - 0
device-api/src/main/java/com/xy/dto/DeviceSysinfoDto.java

@@ -35,6 +35,14 @@ public class DeviceSysinfoDto {
         private List<String> deviceSns;
         private List<String> deviceSns;
     }
     }
 
 
+    @Data
+    @Accessors(chain = true)
+    public static class DeviceSysInfo {
+    
+        @ApiModelProperty("设备SN")
+        private String deviceSN;
+    }
+
     @Data
     @Data
     @Accessors(chain = true)
     @Accessors(chain = true)
     public static class Vo {
     public static class Vo {

+ 12 - 0
device-api/src/main/java/com/xy/service/DeviceInfoService.java

@@ -2,6 +2,7 @@ package com.xy.service;
 
 
 import com.xy.annotate.RestMappingController;
 import com.xy.annotate.RestMappingController;
 import com.xy.dto.DeviceInfoDto;
 import com.xy.dto.DeviceInfoDto;
+import com.xy.dto.DeviceSysinfoDto;
 import com.xy.utils.PageBean;
 import com.xy.utils.PageBean;
 import com.xy.utils.R;
 import com.xy.utils.R;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.validation.annotation.Validated;
@@ -155,4 +156,15 @@ public interface DeviceInfoService {
      */
      */
     @PostMapping("getDeviceNameList")
     @PostMapping("getDeviceNameList")
     R<Map<Long, String>> getDeviceNameList(@RequestBody @Validated DeviceInfoDto.DeviceIdDto dto);
     R<Map<Long, String>> getDeviceNameList(@RequestBody @Validated DeviceInfoDto.DeviceIdDto dto);
+
+
+    /**
+     * 查询设备信息
+     *
+     * @param dto
+     * @return
+     */
+    @PostMapping("getDeviceSysinfo")
+    R<DeviceSysinfoDto.Vo> getDeviceSysinfo(@RequestBody @Validated DeviceSysinfoDto.DeviceSysInfo dto);
+
 }
 }

+ 24 - 0
device-api/src/main/java/com/xy/utils/enums/DeviceActiveStateEnum.java

@@ -0,0 +1,24 @@
+package com.xy.utils.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import lombok.ToString;
+
+/**
+ * <p>
+ * 设备激活状态
+ * </p>
+ *
+ * @author hechunping
+ * @since 2023/3/23
+ */
+@Getter
+@ToString
+@AllArgsConstructor
+public enum DeviceActiveStateEnum {
+    TRUE("1","已激活"),
+    FALSE("2", "未激活")
+    ;
+    private String code;
+    private String msg;
+}