Browse Source

修复查询bug

yangjingjing 5 years ago
parent
commit
73984306b0

+ 26 - 24
febs-server/gbd-demp-info/src/main/java/com/gbd/demp/info/service/impl/DeviceInfoServiceImpl.java

@@ -40,8 +40,8 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
     private SensorInfoMapper sensorInfoMapper;
 
     //  传感器类型(一一对应)
-    static  final String[] codeArray = {"7301","7302","7304","7303","7305","7306","7307","7308","7309","7310","5301","5401"};
-    static  final String[] typeNameArray = {"灰斗温度","压力","入口温度","出口温度","压差","风速","灰斗清扫时间","液位","流量","氢气浓度","火花信号","锁气卸灰阀开关状态"};
+    static final String[] codeArray = {"7301", "7302", "7304", "7303", "7305", "7306", "7307", "7308", "7309", "7310", "5301", "5401"};
+    static final String[] typeNameArray = {"灰斗温度", "压力", "入口温度", "出口温度", "压差", "风速", "灰斗清扫时间", "液位", "流量", "氢气浓度", "火花信号", "锁气卸灰阀开关状态"};
 
 
     @Override
@@ -95,45 +95,46 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
 
     /**
      * 查询  2.	监测企业点位信息
+     *
      * @return
      */
     @Override
     public Map getMonitorMap() {
-        Map<String,String> resultMap = new HashMap<>();
+        Map<String, String> resultMap = new HashMap<>();
         List<DeviceInfo> deviceInfos = deviceInfoMapper.findAll();
         String deviceCodes = "";
         String deviceIds = "";
         // 10.31修改 返回企业ID
         String companyIds = "";
-        if(!CollectionUtils.isEmpty(deviceInfos)) {
+        if (!CollectionUtils.isEmpty(deviceInfos)) {
             List<String> deviceCodeList = deviceInfos.stream().map(v -> v.getLongitude() + "," + v.getLatitude()).collect(Collectors.toList());
             deviceCodes = String.join(";", deviceCodeList);
             List<String> deviceIdList = deviceInfos.stream().map(v -> v.getDeviceId()).collect(Collectors.toList());
-            deviceIds = String.join(",",deviceIdList);
+            deviceIds = String.join(",", deviceIdList);
             //10.31 修改
             List<String> companyIdList = deviceInfos.stream().map(v -> v.getCompanyId()).collect(Collectors.toList());
-            companyIds = String.join(",",companyIdList);
+            companyIds = String.join(",", companyIdList);
         }
-        resultMap.put("deviceCodes",deviceCodes);
-        resultMap.put("deviceIds",deviceIds);
-        resultMap.put("companyIds",companyIds);
+        resultMap.put("deviceCodes", deviceCodes);
+        resultMap.put("deviceIds", deviceIds);
+        resultMap.put("companyIds", companyIds);
         return resultMap;
     }
 
     /**
-     *    3.监测图层点击详情
+     * 3.监测图层点击详情
      */
     @Override
     public List<DeviceEventRespone> getMonitorLayerClickMap(String companyId, String alarmId, String deviceId) {
         List<DeviceEventRespone> respone = new ArrayList<>();
         List<DeviceEventVO> deviceEventVOS = deviceInfoMapper.getMonitorLayerClickMap(companyId, alarmId, deviceId);
         System.out.println(deviceEventVOS);
-        if(CollectionUtils.isEmpty(deviceEventVOS)) {
+        if (CollectionUtils.isEmpty(deviceEventVOS)) {
             return respone;
         }
         //   1、根据设备分组
-        Map<String,List<DeviceEventVO>> deviceMapList = deviceEventVOS.stream().collect(Collectors.groupingBy(DeviceEventVO::getDeviceId));
-        deviceMapList.forEach((k,v) -> {
+        Map<String, List<DeviceEventVO>> deviceMapList = deviceEventVOS.stream().collect(Collectors.groupingBy(DeviceEventVO::getDeviceId));
+        deviceMapList.forEach((k, v) -> {
             DeviceEventRespone deviceEventRespone = new DeviceEventRespone();
             List<DeviceEventVO> monitorValue = new ArrayList<>();
             respone.add(deviceEventRespone);
@@ -144,14 +145,14 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
             deviceEventRespone.setVideoId("");
             //  2、根据传感器分组
             deviceEventRespone.setMonitorValue(monitorValue);
-            Map<String,List<DeviceEventVO>> sensorMap = v.stream().collect(Collectors.groupingBy(DeviceEventVO::getSensorId));
+            Map<String, List<DeviceEventVO>> sensorMap = v.stream().collect(Collectors.groupingBy(DeviceEventVO::getSensorId));
             // m ->sensorId  n -> 分组之后的对象
-            sensorMap.forEach((m,n) ->{
+            sensorMap.forEach((m, n) -> {
                 DeviceEventVO deviceEventVO = n.get(0);
                 Integer index = Arrays.asList(codeArray).indexOf(m);
                 deviceEventVO.setType(getType(index));  //得到type
                 monitorValue.add(deviceEventVO);
-                List<VideoEnentVO> videoEnentVOList = n.stream().map(vo -> {
+                List<VideoEnentVO> videoEnentVOList = n.stream().filter(vo -> Objects.nonNull(vo.getVideoCode())).map(vo -> {
                     VideoEnentVO videoEnentVO = new VideoEnentVO();
                     videoEnentVO.setCode(vo.getVideoCode());
                     videoEnentVO.setName(vo.getVideoName());
@@ -167,30 +168,31 @@ public class DeviceInfoServiceImpl extends ServiceImpl<DeviceInfoMapper, DeviceI
 
     /**
      * 获取类型code
+     *
      * @param codeIndex
      * @return
      */
     private String getType(Integer codeIndex) {
-        if(codeIndex == null || codeIndex == -1) {
-            return  null;
+        if (codeIndex == null || codeIndex == -1) {
+            return null;
         }
         String typeName = typeNameArray[codeIndex];
-        if(typeName.contains("温度")) {
+        if (typeName.contains("温度")) {
             return "1";
         }
-        if(typeName.contains("压力")) {
+        if (typeName.contains("压力")) {
             return "2";
         }
-        if(typeName.contains("风速")) {
+        if (typeName.contains("风速")) {
             return "3";
         }
-        if(typeName.contains("液位")) {
+        if (typeName.contains("液位")) {
             return "4";
         }
-        if(typeName.contains("流量")) {
+        if (typeName.contains("流量")) {
             return "5";
         }
-        if(typeName.contains("开关")) {
+        if (typeName.contains("开关")) {
             return "6";
         }
         return null;

+ 3 - 1
febs-server/gbd-demp-info/src/main/resources/mapper/DeviceInfoMapper.xml

@@ -127,7 +127,7 @@
         tdi.device_name AS monitorName,
         '0' AS ifShow,
         '' AS videoId,
-        tsv.sensor_id AS sensorId,
+        tld.sensor_id AS sensorId,
         tsi.sensor_name AS name,
         tsi.sensor_unit AS unit,
         tcar.value AS detail,
@@ -153,6 +153,8 @@
         <if test="alarmId != null and alarmId != ''">
             AND tae.third_party_id = #{alarmId}
         </if>
+        group by
+        tdi.device_id
     </sql>