临时提交
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
package com.genersoft.iot.vmp.gb28181.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Region;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
import org.springframework.stereotype.Repository;
|
||||
@@ -356,4 +354,14 @@ public interface CommonGBChannelMapper {
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryByGbDeviceIds")
|
||||
List<CommonGBChannel> queryByGbDeviceIds(List<Integer> deviceIds);
|
||||
|
||||
@SelectProvider(type = ChannelProvider.class, method = "queryByGroupList")
|
||||
List<CommonGBChannelWitchGroupChannelId> queryByGroupList(List<Group> groupList);
|
||||
|
||||
@Delete(value = {" <script>" +
|
||||
" delete from wvp_common_group_channel" +
|
||||
" where id in " +
|
||||
" <foreach collection='channels' item='item' open='(' separator=',' close=')' > #{item.groupChannelId}</foreach>" +
|
||||
"</script>"})
|
||||
int batchDeleteGroup(List<CommonGBChannelWitchGroupChannelId> channels);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
package com.genersoft.iot.vmp.gb28181.dao;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Group;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Group;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.GroupTree;
|
||||
import org.apache.ibatis.annotations.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface GroupMapper {
|
||||
|
||||
@Insert("INSERT INTO wvp_common_group (device_id, name, parent_device_id, business_group, create_time, update_time) " +
|
||||
"VALUES (#{deviceId}, #{name}, #{parentDeviceId}, #{businessGroup}, #{createTime}, #{updateTime})")
|
||||
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
|
||||
void add(Group group);
|
||||
|
||||
@Delete("DELETE FROM wvp_common_group WHERE id=#{id}")
|
||||
int delete(@Param("id") int id);
|
||||
|
||||
@Update(" UPDATE wvp_common_group " +
|
||||
" SET update_time=#{updateTime}, device_id=#{deviceId}, name=#{name}, parent_device_id=#{parentDeviceId}, business_group=#{businessGroup}" +
|
||||
" WHERE id = #{id}")
|
||||
int update(Group group);
|
||||
|
||||
@Select(value = {" <script>" +
|
||||
"SELECT * from wvp_common_group WHERE 1=1 " +
|
||||
" <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
|
||||
" <if test='parentId != null and businessGroupId != null '> AND parent_device_id = #{parentId} AND business_group=#{businessGroup} </if> " +
|
||||
"ORDER BY id " +
|
||||
" </script>"})
|
||||
List<Group> query(@Param("query") String query, @Param("parentId") String parentId, @Param("businessGroup") String businessGroup);
|
||||
|
||||
@Select("SELECT * from wvp_common_group WHERE parent_device_id = #{parentId} AND business_group=#{businessGroup} ORDER BY id ")
|
||||
List<Group> getChildren(@Param("parentId") String parentId , @Param("businessGroup") String businessGroup);
|
||||
|
||||
@Select("SELECT * from wvp_common_group WHERE id = #{id} ")
|
||||
Group queryOne(@Param("id") int id);
|
||||
|
||||
@Select(" select coalesce(dc.gb_civil_code, dc.civil_code) as civil_code " +
|
||||
" from wvp_device_channel dc " +
|
||||
" where coalesce(dc.gb_civil_code, dc.civil_code) not in " +
|
||||
" (select device_id from wvp_common_group)")
|
||||
List<String> getUninitializedCivilCode();
|
||||
|
||||
@Select(" <script>" +
|
||||
" SELECT device_id from wvp_common_group " +
|
||||
" where device_id in " +
|
||||
" <foreach collection='codes' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
|
||||
" </script>")
|
||||
List<String> queryInList(Set<String> codes);
|
||||
|
||||
|
||||
@Insert(" <script>" +
|
||||
" INSERT INTO wvp_common_group (" +
|
||||
" device_id," +
|
||||
" name, " +
|
||||
" parent_device_id," +
|
||||
" create_time," +
|
||||
" update_time) " +
|
||||
" VALUES " +
|
||||
" <foreach collection='groupList' index='index' item='item' separator=','> " +
|
||||
" (#{item.deviceId}, #{item.name}, #{item.parentDeviceId},#{item.createTime},#{item.updateTime})" +
|
||||
" </foreach> " +
|
||||
" </script>")
|
||||
int batchAdd(List<Group> groupList);
|
||||
|
||||
@Select(" <script>" +
|
||||
" SELECT " +
|
||||
" device_id as id," +
|
||||
" name as label, " +
|
||||
" parent_device_id," +
|
||||
" id as db_id," +
|
||||
" 0 as type," +
|
||||
" false as is_leaf" +
|
||||
" from wvp_common_group " +
|
||||
" where " +
|
||||
" <if test='parentId != null'> parent_device_id = #{parentId} </if> " +
|
||||
" <if test='parentId == null'> parent_device_id is null </if> " +
|
||||
" <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
|
||||
" </script>")
|
||||
List<GroupTree> queryForTree(@Param("query") String query, @Param("parentId") String parentId);
|
||||
|
||||
@Select("SELECT * from wvp_common_group WHERE device_id = #{deviceId} and business_group = #{businessGroup}")
|
||||
Group queryOneByDeviceId(@Param("deviceId") String deviceId, @Param("businessGroup") String businessGroup);
|
||||
|
||||
@Delete("<script>" +
|
||||
" DELETE FROM wvp_common_group WHERE id in " +
|
||||
" <foreach collection='allChildren' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
|
||||
" </script>")
|
||||
void batchDelete(List<Group> allChildren);
|
||||
|
||||
@Select("SELECT * from wvp_common_group WHERE device_id = #{businessGroup} and business_group = #{businessGroup} ")
|
||||
Group queryBusinessGroup(@Param("businessGroup") String businessGroup);
|
||||
|
||||
@Select("SELECT * from wvp_common_group WHERE business_group = #{businessGroup} ")
|
||||
List<Group> queryByBusinessGroup(@Param("businessGroup") String businessGroup);
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.genersoft.iot.vmp.gb28181.dao.provider;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.Group;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@@ -10,65 +11,68 @@ public class ChannelProvider {
|
||||
|
||||
public String getBaseSelectSql(){
|
||||
return "select\n" +
|
||||
" id as gb_id,\n" +
|
||||
" device_db_id as gb_device_db_id,\n" +
|
||||
" stream_push_id,\n" +
|
||||
" stream_proxy_id,\n" +
|
||||
" create_time,\n" +
|
||||
" update_time,\n" +
|
||||
" coalesce(gb_device_id, device_id) as gb_device_id,\n" +
|
||||
" coalesce(gb_name, name) as gb_name,\n" +
|
||||
" coalesce(gb_manufacturer, manufacturer) as gb_manufacturer,\n" +
|
||||
" coalesce(gb_model, model) as gb_model,\n" +
|
||||
" coalesce(gb_owner, owner) as gb_owner,\n" +
|
||||
" wdc.id as gb_id,\n" +
|
||||
" wdc.device_db_id as gb_device_db_id,\n" +
|
||||
" wcg.id as group_channel_id,\n" +
|
||||
" wdc.stream_push_id,\n" +
|
||||
" wdc.stream_proxy_id,\n" +
|
||||
" wdc.create_time,\n" +
|
||||
" wdc.update_time,\n" +
|
||||
" coalesce(wdc.gb_device_id, wdc.device_id) as gb_device_id,\n" +
|
||||
" coalesce(wdc.gb_name, wdc.name) as gb_name,\n" +
|
||||
" coalesce(wdc.gb_manufacturer, manufacturer) as gb_manufacturer,\n" +
|
||||
" coalesce(wdc.gb_model, wdc.model) as gb_model,\n" +
|
||||
" coalesce(wdc.gb_owner, wdc.owner) as gb_owner,\n" +
|
||||
" gb_civil_code,\n" +
|
||||
" coalesce(gb_block, block) as gb_block,\n" +
|
||||
" coalesce(gb_address, address) as gb_address,\n" +
|
||||
" coalesce(gb_parental, parental) as gb_parental,\n" +
|
||||
" coalesce(gb_parent_id, parent_id) as gb_parent_id,\n" +
|
||||
" coalesce(gb_safety_way, safety_way) as gb_safety_way,\n" +
|
||||
" coalesce(gb_register_way, register_way) as gb_register_way,\n" +
|
||||
" coalesce(gb_cert_num, cert_num) as gb_cert_num,\n" +
|
||||
" coalesce(gb_certifiable, certifiable) as gb_certifiable,\n" +
|
||||
" coalesce(gb_err_code, err_code) as gb_err_code,\n" +
|
||||
" coalesce(gb_end_time, end_time) as gb_end_time,\n" +
|
||||
" coalesce(gb_secrecy, secrecy) as gb_secrecy,\n" +
|
||||
" coalesce(gb_ip_address, ip_address) as gb_ip_address,\n" +
|
||||
" coalesce(gb_port, port) as gb_port,\n" +
|
||||
" coalesce(gb_password, password) as gb_password,\n" +
|
||||
" coalesce(gb_status, status) as gb_status,\n" +
|
||||
" coalesce(gb_longitude, longitude) as gb_longitude,\n" +
|
||||
" coalesce(gb_latitude, latitude) as gb_latitude,\n" +
|
||||
" coalesce(gb_ptz_type, ptz_type) as gb_ptz_type,\n" +
|
||||
" coalesce(gb_position_type, position_type) as gb_position_type,\n" +
|
||||
" coalesce(gb_room_type, room_type) as gb_room_type,\n" +
|
||||
" coalesce(gb_use_type, use_type) as gb_use_type,\n" +
|
||||
" coalesce(gb_supply_light_type, supply_light_type) as gb_supply_light_type,\n" +
|
||||
" coalesce(gb_direction_type, direction_type) as gb_direction_type,\n" +
|
||||
" coalesce(gb_resolution, resolution) as gb_resolution,\n" +
|
||||
" coalesce(gb_business_group_id, business_group_id) as gb_business_group_id,\n" +
|
||||
" coalesce(gb_download_speed, download_speed) as gb_download_speed,\n" +
|
||||
" coalesce(gb_svc_space_support_mod, svc_space_support_mod) as gb_svc_space_support_mod,\n" +
|
||||
" coalesce(gb_svc_time_support_mode,svc_time_support_mode) as gb_svc_time_support_mode\n" +
|
||||
" from wvp_device_channel\n"
|
||||
" coalesce(wdc.gb_block, wdc.block) as gb_block,\n" +
|
||||
" coalesce(wdc.gb_address, wdc.address) as gb_address,\n" +
|
||||
" coalesce(wdc.gb_parental, wdc.parental) as gb_parental,\n" +
|
||||
" wcg.device_id as gb_parent_id,\n" +
|
||||
" coalesce(wdc.gb_safety_way, wdc.safety_way) as gb_safety_way,\n" +
|
||||
" coalesce(wdc.gb_register_way, wdc.register_way) as gb_register_way,\n" +
|
||||
" coalesce(wdc.gb_cert_num, wdc.cert_num) as gb_cert_num,\n" +
|
||||
" coalesce(wdc.gb_certifiable, wdc.certifiable) as gb_certifiable,\n" +
|
||||
" coalesce(wdc.gb_err_code, wdc.err_code) as gb_err_code,\n" +
|
||||
" coalesce(wdc.gb_end_time, wdc.end_time) as gb_end_time,\n" +
|
||||
" coalesce(wdc.gb_secrecy, wdc.secrecy) as gb_secrecy,\n" +
|
||||
" coalesce(wdc.gb_ip_address, wdc.ip_address) as gb_ip_address,\n" +
|
||||
" coalesce(wdc.gb_port, port) wdc.as gb_port,\n" +
|
||||
" coalesce(wdc.gb_password, wdc.password) as gb_password,\n" +
|
||||
" coalesce(wdc.gb_status, wdc.status) as gb_status,\n" +
|
||||
" coalesce(wdc.gb_longitude, wdc.longitude) as gb_longitude,\n" +
|
||||
" coalesce(wdc.gb_latitude, wdc.latitude) as gb_latitude,\n" +
|
||||
" coalesce(wdc.gb_ptz_type, wdc.ptz_type) as gb_ptz_type,\n" +
|
||||
" coalesce(wdc.gb_position_type, wdc.position_type) as gb_position_type,\n" +
|
||||
" coalesce(wdc.gb_room_type, wdc.room_type) as gb_room_type,\n" +
|
||||
" coalesce(wdc.gb_use_type, wdc.use_type) as gb_use_type,\n" +
|
||||
" coalesce(wdc.gb_supply_light_type, wdc.supply_light_type) as gb_supply_light_type,\n" +
|
||||
" coalesce(wdc.gb_direction_type, wdc.direction_type) as gb_direction_type,\n" +
|
||||
" coalesce(wdc.gb_resolution, wdc.resolution) as gb_resolution,\n" +
|
||||
" wcg.business_group as gb_business_group_id,\n" +
|
||||
" coalesce(wdc.gb_download_speed, wdc.download_speed) as gb_download_speed,\n" +
|
||||
" coalesce(wdc.gb_svc_space_support_mod, wdc.svc_space_support_mod) as gb_svc_space_support_mod,\n" +
|
||||
" coalesce(wdc.gb_svc_time_support_mode, wdc.svc_time_support_mode) as gb_svc_time_support_mode\n" +
|
||||
" from wvp_device_channel wdc\n" +
|
||||
" left jon wvp_common_group_channel wcgc on wcgc.channel_id = wdc.id\n" +
|
||||
" left jon wvp_common_group wcg on wcgc.group_id = wcg.id\n"
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
public String queryByDeviceId(Map<String, Object> params ){
|
||||
return getBaseSelectSql() + " where gb_device_id = #{gbDeviceId} or device_id = #{gbDeviceId}";
|
||||
return getBaseSelectSql() + " where wdc.gb_device_id = #{gbDeviceId} or wdc.device_id = #{gbDeviceId}";
|
||||
}
|
||||
|
||||
public String queryById(Map<String, Object> params ){
|
||||
return getBaseSelectSql() + " where id = #{gbId}";
|
||||
return getBaseSelectSql() + " where wdc.id = #{gbId}";
|
||||
}
|
||||
|
||||
public String queryByStreamPushId(Map<String, Object> params ){
|
||||
return getBaseSelectSql() + " where stream_push_id = #{streamPushId}";
|
||||
return getBaseSelectSql() + " where wdc.stream_push_id = #{streamPushId}";
|
||||
}
|
||||
|
||||
public String queryByStreamProxyId(Map<String, Object> params ){
|
||||
return getBaseSelectSql() + " where stream_proxy_id = #{streamProxyId}";
|
||||
return getBaseSelectSql() + " where wdc.stream_proxy_id = #{streamProxyId}";
|
||||
}
|
||||
|
||||
|
||||
@@ -77,21 +81,21 @@ public class ChannelProvider {
|
||||
sqlBuild.append(getBaseSelectSql());
|
||||
sqlBuild.append(" where 1 = 1 ");
|
||||
if (params.get("query") != null) {
|
||||
sqlBuild.append(" AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%')" +
|
||||
" OR coalesce(gb_name, name) LIKE concat('%',#{query},'%') )")
|
||||
sqlBuild.append(" AND (coalesce(wdc.gb_device_id, device_id) LIKE concat('%',#{query},'%')" +
|
||||
" OR coalesce(wdc.gb_name, name) LIKE concat('%',#{query},'%') )")
|
||||
;
|
||||
}
|
||||
if (params.get("online") != null && (Boolean)params.get("online")) {
|
||||
sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'");
|
||||
sqlBuild.append(" AND coalesce(wdc.gb_status, status) = 'ON'");
|
||||
}
|
||||
if (params.get("online") != null && !(Boolean)params.get("online")) {
|
||||
sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'");
|
||||
sqlBuild.append(" AND coalesce(wdc.gb_status, status) = 'OFF'");
|
||||
}
|
||||
if (params.get("hasCivilCode") != null && (Boolean)params.get("hasCivilCode")) {
|
||||
sqlBuild.append(" AND gb_civil_code is not null");
|
||||
sqlBuild.append(" AND wdc.gb_civil_code is not null");
|
||||
}
|
||||
if (params.get("hasCivilCode") != null && !(Boolean)params.get("hasCivilCode")) {
|
||||
sqlBuild.append(" AND gb_civil_code is null");
|
||||
sqlBuild.append(" AND wdc.gb_civil_code is null");
|
||||
}
|
||||
return sqlBuild.toString();
|
||||
}
|
||||
@@ -99,7 +103,7 @@ public class ChannelProvider {
|
||||
public String queryInListByStatus(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(getBaseSelectSql());
|
||||
sqlBuild.append("where gb_status=#{status} and id in ( ");
|
||||
sqlBuild.append("where wdc.gb_status=#{status} and wdc.id in ( ");
|
||||
|
||||
List<CommonGBChannel> commonGBChannelList = (List<CommonGBChannel>)params.get("ids");
|
||||
boolean first = true;
|
||||
@@ -117,7 +121,7 @@ public class ChannelProvider {
|
||||
public String queryByIds(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(getBaseSelectSql());
|
||||
sqlBuild.append("where id in ( ");
|
||||
sqlBuild.append("where wdc.id in ( ");
|
||||
|
||||
Collection<Integer> ids = (Collection<Integer>)params.get("ids");
|
||||
boolean first = true;
|
||||
@@ -135,7 +139,7 @@ public class ChannelProvider {
|
||||
public String queryByGbDeviceIds(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(getBaseSelectSql());
|
||||
sqlBuild.append("where device_db_id in ( ");
|
||||
sqlBuild.append("where wdc.device_db_id in ( ");
|
||||
|
||||
Collection<Integer> ids = (Collection<Integer>)params.get("deviceIds");
|
||||
boolean first = true;
|
||||
@@ -155,13 +159,13 @@ public class ChannelProvider {
|
||||
sqlBuild.append(getBaseSelectSql());
|
||||
sqlBuild.append("where ");
|
||||
if (params.get("civilCode") != null) {
|
||||
sqlBuild.append(" gb_civil_code = #{civilCode} ");
|
||||
sqlBuild.append(" wdc.gb_civil_code = #{civilCode} ");
|
||||
if (params.get("ids") != null) {
|
||||
sqlBuild.append(" OR ");
|
||||
}
|
||||
}
|
||||
if (params.get("ids") != null) {
|
||||
sqlBuild.append(" id in ( ");
|
||||
sqlBuild.append(" wdc.id in ( ");
|
||||
Collection<Integer> ids = (Collection<Integer>)params.get("ids");
|
||||
boolean first = true;
|
||||
for (Integer id : ids) {
|
||||
@@ -179,7 +183,26 @@ public class ChannelProvider {
|
||||
public String queryByCivilCode(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(getBaseSelectSql());
|
||||
sqlBuild.append("where gb_civil_code = #{civilCode} ");
|
||||
sqlBuild.append("where wdc.gb_civil_code = #{civilCode} ");
|
||||
return sqlBuild.toString() ;
|
||||
}
|
||||
|
||||
public String queryByGroupList(Map<String, Object> params ){
|
||||
StringBuilder sqlBuild = new StringBuilder();
|
||||
sqlBuild.append(getBaseSelectSql());
|
||||
|
||||
sqlBuild.append(" wcg.id in ( ");
|
||||
Collection<Group> ids = (Collection<Group>)params.get("groupList");
|
||||
boolean first = true;
|
||||
for (Group group : ids) {
|
||||
if (!first) {
|
||||
sqlBuild.append(",");
|
||||
}
|
||||
sqlBuild.append(group.getId());
|
||||
first = false;
|
||||
}
|
||||
sqlBuild.append(" )");
|
||||
|
||||
return sqlBuild.toString() ;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user