Browse Source

修复国标设备/设备列表中行政区划的子节点查看

648540858 1 year ago
parent
commit
4c497ef411

+ 4 - 1
src/main/java/com/genersoft/iot/vmp/gb28181/dao/DeviceChannelMapper.java

@@ -85,7 +85,10 @@ public interface DeviceChannelMapper {
     int update(DeviceChannel channel);
 
     @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannels")
-    List<DeviceChannel> queryChannels(@Param("deviceDbId") int deviceDbId, @Param("parentChannelId") String parentChannelId, @Param("query") String query, @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online, @Param("channelIds") List<String> channelIds);
+    List<DeviceChannel> queryChannels(@Param("deviceDbId") int deviceDbId, @Param("civilCode") String civilCode,
+                                      @Param("parentChannelId") String parentChannelId, @Param("query") String query,
+                                      @Param("hasSubChannel") Boolean hasSubChannel, @Param("online") Boolean online,
+                                      @Param("channelIds") List<String> channelIds);
 
     @SelectProvider(type = DeviceChannelProvider.class, method = "queryChannelsByDeviceDbId")
     List<DeviceChannel> queryChannelsByDeviceDbId(@Param("deviceDbId") int deviceDbId);

+ 13 - 7
src/main/java/com/genersoft/iot/vmp/gb28181/dao/provider/DeviceChannelProvider.java

@@ -1,5 +1,7 @@
 package com.genersoft.iot.vmp.gb28181.dao.provider;
 
+import org.springframework.util.ObjectUtils;
+
 import java.util.List;
 import java.util.Map;
 
@@ -58,14 +60,18 @@ public class DeviceChannelProvider {
     public String queryChannels(Map<String, Object> params ){
         StringBuilder sqlBuild = new StringBuilder();
         sqlBuild.append(getBaseSelectSql());
-        sqlBuild.append(" where dc.device_db_id = #{deviceDbId}");
-        if (params.get("query") != null) {
-            sqlBuild.append(" AND coalesce(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%')" +
-                    " OR coalesce(dc.gb_name, dc.name) LIKE concat('%',#{query},'%')")
-            ;
-        }
+        sqlBuild.append(" where dc.device_db_id = #{deviceDbId} ");
         if (params.get("parentChannelId") != null ) {
-            sqlBuild.append(" AND (dc.parent_id=#{parentChannelId} OR coalesce(dc.gb_civil_code, dc.civil_code) = #{parentChannelId})");
+            sqlBuild.append(" AND coalesce(dc.gb_parent_id, dc.parent_id)=#{parentChannelId}");
+        }
+        if (params.get("civilCode") != null ) {
+            sqlBuild.append(" AND (coalesce(dc.gb_civil_code, dc.civil_code) = #{civilCode} " +
+                    "OR (LENGTH(coalesce(dc.gb_device_id, dc.device_id))=LENGTH(#{civilCode}) + 2) AND coalesce(dc.gb_device_id, dc.device_id) LIKE concat(#{civilCode},'%'))");
+        }
+        if (params.get("query") != null && !ObjectUtils.isEmpty(params.get("query"))) {
+            sqlBuild.append(" AND (coalesce(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%')" +
+                    " OR coalesce(dc.gb_name, dc.name) LIKE concat('%',#{query},'%'))")
+            ;
         }
         if (params.get("online") != null && (Boolean)params.get("online")) {
             sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'");

+ 9 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/service/impl/DeviceChannelServiceImpl.java

@@ -599,7 +599,14 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
     @Override
     public PageInfo<DeviceChannel> getSubChannels(int deviceDbId, String channelId, String query, Boolean channelType, Boolean online, int page, int count) {
         PageHelper.startPage(page, count);
-        List<DeviceChannel> all = channelMapper.queryChannels(deviceDbId, channelId, query, channelType, online,null);
+        String civilCode = null;
+        String parentId = null;
+        if (channelId.length() <= 8) {
+            civilCode = channelId;
+        }else {
+            parentId = channelId;
+        }
+        List<DeviceChannel> all = channelMapper.queryChannels(deviceDbId, civilCode, parentId, query, channelType, online,null);
         return new PageInfo<>(all);
     }
 
@@ -616,7 +623,7 @@ public class DeviceChannelServiceImpl implements IDeviceChannelService {
         }
         // 获取到所有正在播放的流
         PageHelper.startPage(page, count);
-        List<DeviceChannel> all = channelMapper.queryChannels(device.getId(), null, query, hasSubChannel, online,null);
+        List<DeviceChannel> all = channelMapper.queryChannels(device.getId(), null,null, query, hasSubChannel, online,null);
         return new PageInfo<>(all);
     }
 

+ 2 - 2
web_src/src/components/channelList.vue

@@ -129,10 +129,10 @@
               </el-button>
               <el-divider direction="vertical"></el-divider>
               <el-button size="medium" icon="el-icon-s-open" type="text"
-                         v-if="scope.row.subCount > 0 || scope.row.parental === 1"
+                         v-if="scope.row.subCount > 0 || scope.row.parental === 1 || scope.row.deviceId.length <= 8"
                          @click="changeSubchannel(scope.row)">查看
               </el-button>
-              <el-divider v-if="scope.row.subCount > 0 || scope.row.parental === 1" direction="vertical"></el-divider>
+              <el-divider v-if="scope.row.subCount > 0 || scope.row.parental === 1 || scope.row.deviceId.length <= 8" direction="vertical"></el-divider>
               <el-dropdown @command="(command)=>{moreClick(command, scope.row)}">
                 <el-button size="medium" type="text" >
                   更多功能<i class="el-icon-arrow-down el-icon--right"></i>