临时提交

pull/1642/head
648540858 2024-07-26 17:53:10 +08:00
parent a2b00a4f4e
commit b246fd6a20
15 changed files with 263 additions and 156 deletions

View File

@ -2,7 +2,6 @@ package com.genersoft.iot.vmp.gb28181.bean;
import com.genersoft.iot.vmp.gb28181.utils.MessageElement; import com.genersoft.iot.vmp.gb28181.utils.MessageElement;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.utils.CivilCodeUtil;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -225,11 +224,8 @@ public class DeviceChannel extends CommonGBChannel {
if (ObjectUtils.isEmpty(deviceChannel.getCivilCode()) if (ObjectUtils.isEmpty(deviceChannel.getCivilCode())
|| deviceChannel.getCivilCode().length() > 8 ){ || deviceChannel.getCivilCode().length() > 8 ){
deviceChannel.setCivilCode(null); deviceChannel.setCivilCode(null);
}else {
if (CivilCodeUtil.INSTANCE.getCivilCodePo(deviceChannel.getCivilCode()) == null) {
deviceChannel.setCivilCode(null);
}
} }
// 此处对于不在wvp缓存中的行政区划,默认直接存储.保证即使出现wvp的行政区划缓存过老,也可以通过用户自主创建的方式正常使用系统
} }
return XmlUtil.elementDecode(element, DeviceChannel.class); return XmlUtil.elementDecode(element, DeviceChannel.class);
} }

View File

@ -50,8 +50,6 @@ public class RegionTree {
return regionTree; return regionTree;
} }
public static RegionTree getInstance(CommonGBChannel channel) { public static RegionTree getInstance(CommonGBChannel channel) {
RegionTree regionTree = new RegionTree(); RegionTree regionTree = new RegionTree();
regionTree.setId(channel.getGbDeviceId()); regionTree.setId(channel.getGbDeviceId());

View File

@ -8,14 +8,13 @@ import com.genersoft.iot.vmp.gb28181.bean.NetworkIdentificationType;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.media.service.IMediaServerService; import com.genersoft.iot.vmp.media.service.IMediaServerService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.vmanager.bean.PageInfo; import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -23,7 +22,7 @@ import java.util.List;
@Tag(name = "全局通道管理") @Tag(name = "全局通道管理")
@Controller @RestController
@Slf4j @Slf4j
@RequestMapping(value = "/api/common/channel") @RequestMapping(value = "/api/common/channel")
public class CommonChannelController { public class CommonChannelController {
@ -41,48 +40,41 @@ public class CommonChannelController {
@Operation(summary = "查询通道信息", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "查询通道信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "id", description = "通道的数据库自增Id", required = true) @Parameter(name = "id", description = "通道的数据库自增Id", required = true)
@GetMapping(value = "/one") @GetMapping(value = "/one")
@ResponseBody
public CommonGBChannel getOne(int id){ public CommonGBChannel getOne(int id){
return channelService.getOne(id); return channelService.getOne(id);
} }
@Operation(summary = "获取行业编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "获取行业编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody
@GetMapping("/industry/list") @GetMapping("/industry/list")
public List<IndustryCodeType> getIndustryCodeList(){ public List<IndustryCodeType> getIndustryCodeList(){
return channelService.getIndustryCodeList(); return channelService.getIndustryCodeList();
} }
@Operation(summary = "获取编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "获取编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody
@GetMapping("/type/list") @GetMapping("/type/list")
public List<DeviceType> getDeviceTypeList(){ public List<DeviceType> getDeviceTypeList(){
return channelService.getDeviceTypeList(); return channelService.getDeviceTypeList();
} }
@Operation(summary = "获取编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "获取编码列表", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody
@GetMapping("/network/identification/list") @GetMapping("/network/identification/list")
public List<NetworkIdentificationType> getNetworkIdentificationTypeList(){ public List<NetworkIdentificationType> getNetworkIdentificationTypeList(){
return channelService.getNetworkIdentificationTypeList(); return channelService.getNetworkIdentificationTypeList();
} }
@Operation(summary = "更新通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "更新通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody
@PostMapping("/update") @PostMapping("/update")
public void update(@RequestBody CommonGBChannel channel){ public void update(@RequestBody CommonGBChannel channel){
channelService.update(channel); channelService.update(channel);
} }
@Operation(summary = "重置国标通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "重置国标通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody
@PostMapping("/reset") @PostMapping("/reset")
public void reset(Integer id){ public void reset(Integer id){
channelService.reset(id); channelService.reset(id);
} }
@Operation(summary = "增加通道", security = @SecurityRequirement(name = JwtUtils.HEADER)) @Operation(summary = "增加通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@ResponseBody
@PostMapping("/add") @PostMapping("/add")
public CommonGBChannel add(@RequestBody CommonGBChannel channel){ public CommonGBChannel add(@RequestBody CommonGBChannel channel){
channelService.add(channel); channelService.add(channel);
@ -94,8 +86,7 @@ public class CommonChannelController {
@Parameter(name = "count", description = "每页查询数量", required = true) @Parameter(name = "count", description = "每页查询数量", required = true)
@Parameter(name = "query", description = "查询内容") @Parameter(name = "query", description = "查询内容")
@Parameter(name = "online", description = "是否在线") @Parameter(name = "online", description = "是否在线")
@ResponseBody @GetMapping("/list")
@PostMapping("/list")
public PageInfo<CommonGBChannel> queryList(int page, int count, public PageInfo<CommonGBChannel> queryList(int page, int count,
@RequestParam(required = false) String query, @RequestParam(required = false) String query,
@RequestParam(required = false) Boolean online){ @RequestParam(required = false) Boolean online){

View File

@ -78,10 +78,10 @@ public class RegionController {
@Operation(summary = "删除区域") @Operation(summary = "删除区域")
@Parameter(name = "regionDeviceId", description = "区域编码", required = true) @Parameter(name = "regionDeviceId", description = "区域编码", required = true)
@ResponseBody @ResponseBody
@GetMapping("/delete") @DeleteMapping("/delete")
public void delete(String regionDeviceId){ public void delete(String deviceId){
assert regionDeviceId != null; assert !ObjectUtils.isEmpty(deviceId);
boolean result = regionService.deleteByDeviceId(regionDeviceId); boolean result = regionService.deleteByDeviceId(deviceId);
if (!result) { if (!result) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "移除失败"); throw new ControllerException(ErrorCode.ERROR100.getCode(), "移除失败");
} }

View File

@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.gb28181.dao; package com.genersoft.iot.vmp.gb28181.dao;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; 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.RegionTree;
import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider; import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider;
import org.apache.ibatis.annotations.*; import org.apache.ibatis.annotations.*;
@ -238,7 +239,7 @@ public interface CommonGBChannelMapper {
" coalesce(wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" + " coalesce(wdc.gb_manufacturer, wdc.manufacturer) as gb_manufacturer,\n" +
" coalesce(wdc.gb_model, wdc.model) as gb_model,\n" + " coalesce(wdc.gb_model, wdc.model) as gb_model,\n" +
" coalesce(wdc.gb_owner, wdc.owner) as gb_owner,\n" + " coalesce(wdc.gb_owner, wdc.owner) as gb_owner,\n" +
" coalesce(wpgc.civil_code, wdc.gb_civil_code, wdc.civil_code) as gb_civil_code,\n" + " wdc.gb_civil_code,\n" +
" coalesce(wdc.gb_block, wdc.block) as gb_block,\n" + " coalesce(wdc.gb_block, wdc.block) as gb_block,\n" +
" coalesce(wdc.gb_address, wdc.address) as gb_address,\n" + " coalesce(wdc.gb_address, wdc.address) as gb_address,\n" +
" coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" + " coalesce(wpgc.parental, wdc.gb_parental, wdc.parental) as gb_parental,\n" +
@ -275,7 +276,7 @@ public interface CommonGBChannelMapper {
@Update(value = {" <script>" + @Update(value = {" <script>" +
" UPDATE wvp_device_channel " + " UPDATE wvp_device_channel " +
" SET update_time=#{updateTime}, gb_device_id = null, gb_name = null, gb_manufacturer = null," + " SET update_time=#{updateTime}, gb_device_id = null, gb_name = null, gb_manufacturer = null," +
" gb_model = null, gb_owner = null, gb_civil_code = null, gb_block = null, gb_address = null," + " gb_model = null, gb_owner = null, gb_block = null, gb_address = null," +
" gb_parental = null, gb_parent_id = null, gb_safety_way = null, gb_register_way = null, gb_cert_num = null," + " gb_parental = null, gb_parent_id = null, gb_safety_way = null, gb_register_way = null, gb_cert_num = null," +
" gb_certifiable = null, gb_err_code = null, gb_end_time = null, gb_secrecy = null, gb_ip_address = null, " + " gb_certifiable = null, gb_err_code = null, gb_end_time = null, gb_secrecy = null, gb_ip_address = null, " +
" gb_port = null, gb_password = null, gb_status = null, gb_longitude = null, gb_latitude = null, " + " gb_port = null, gb_password = null, gb_status = null, gb_longitude = null, gb_latitude = null, " +
@ -314,9 +315,17 @@ public interface CommonGBChannelMapper {
" 1 as type, " + " 1 as type, " +
" true as is_leaf " + " true as is_leaf " +
" from wvp_device_channel " + " from wvp_device_channel " +
" where coalesce(gb_civil_code, civil_code) = #{parent} " + " where gb_civil_code = #{parent} " +
" <if test='query != null'> AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') " + " <if test='query != null'> AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') " +
" OR coalesce(gb_name, name) LIKE concat('%',#{query},'%'))</if> " + " OR coalesce(gb_name, name) LIKE concat('%',#{query},'%'))</if> " +
" </script>") " </script>")
List<RegionTree> queryForRegionTreeByCivilCode(@Param("query") String query, @Param("parent") String parent); List<RegionTree> queryForRegionTreeByCivilCode(@Param("query") String query, @Param("parent") String parent);
@Update(value = {" <script>" +
" UPDATE wvp_device_channel " +
" SET gb_civil_code = null" +
" WHERE gb_civil_code in "+
" <foreach collection='allChildren' item='item' open='(' separator=',' close=')' > #{item.deviceId}</foreach>" +
" </script>"})
int removeCivilCode(List<Region> allChildren);
} }

View File

@ -16,12 +16,12 @@ import java.util.List;
@Repository @Repository
public interface DeviceChannelMapper { public interface DeviceChannelMapper {
@Insert("INSERT INTO wvp_device_channel (device_id, device_db_id, name, manufacturer, model, owner, civil_code, block, " + @Insert("INSERT INTO wvp_device_channel (device_id, device_db_id, name, manufacturer, model, owner, civil_code, gb_civil_code, block, " +
"address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " + "address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " +
"ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " + "ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " +
"supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " + "supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " +
"svc_time_support_mode, create_time, update_time, sub_countstream_id, has_audio, gps_time, stream_identification) " + "svc_time_support_mode, create_time, update_time, sub_countstream_id, has_audio, gps_time, stream_identification) " +
"VALUES (#{deviceId}, #{deviceDbId}, #{name}, #{manufacturer}, #{model}, #{owner}, #{civilCode}, #{block}," + "VALUES (#{deviceId}, #{deviceDbId}, #{name}, #{manufacturer}, #{model}, #{owner}, #{civilCode}, #{civilCode}, #{block}," +
"#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{endTime}, #{secrecy}, " + "#{address}, #{parental}, #{parentId}, #{safetyWay}, #{registerWay}, #{certNum}, #{certifiable}, #{errCode}, #{endTime}, #{secrecy}, " +
"#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " + "#{ipAddress}, #{port}, #{password}, #{status}, #{longitude}, #{latitude}, #{ptzType}, #{positionType}, #{roomType}, #{useType}, " +
"#{supplyLightType}, #{directionType}, #{resolution}, #{businessGroupId}, #{downloadSpeed}, #{svcSpaceSupportMod}," + "#{supplyLightType}, #{directionType}, #{resolution}, #{businessGroupId}, #{downloadSpeed}, #{svcSpaceSupportMod}," +
@ -132,7 +132,7 @@ public interface DeviceChannelMapper {
" coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" + " coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" +
" coalesce(dc.gb_model, dc.model) as model,\n" + " coalesce(dc.gb_model, dc.model) as model,\n" +
" coalesce(dc.gb_owner, dc.owner) as owner,\n" + " coalesce(dc.gb_owner, dc.owner) as owner,\n" +
" coalesce(dc.gb_civil_code, dc.civil_code) as civil_code,\n" + " gb_civil_code as civil_code,\n" +
" coalesce(dc.gb_block, dc.block) as block,\n" + " coalesce(dc.gb_block, dc.block) as block,\n" +
" coalesce(dc.gb_address, dc.address) as address,\n" + " coalesce(dc.gb_address, dc.address) as address,\n" +
" coalesce(dc.gb_parental, dc.parental) as parental,\n" + " coalesce(dc.gb_parental, dc.parental) as parental,\n" +
@ -169,7 +169,7 @@ public interface DeviceChannelMapper {
"coalesce(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%') " + "coalesce(dc.gb_device_id, dc.device_id) LIKE concat('%',#{query},'%') " +
"OR coalesce(dc.gb_name, dc.name) LIKE concat('%',#{query},'%') " + "OR coalesce(dc.gb_name, dc.name) LIKE concat('%',#{query},'%') " +
")</if> " + ")</if> " +
" <if test='parentChannelId != null'> AND (dc.parent_id=#{parentChannelId} OR dc.civil_code = #{parentChannelId}) </if> " + " <if test='parentChannelId != null'> AND (dc.parent_id=#{parentChannelId} OR dc.gb_civil_code = #{parentChannelId}) </if> " +
" <if test='online == true' > AND dc.status= true</if>" + " <if test='online == true' > AND dc.status= true</if>" +
" <if test='online == false' > AND dc.status= false</if>" + " <if test='online == false' > AND dc.status= false</if>" +
" <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" + " <if test='hasSubChannel == true' > AND dc.sub_count > 0 </if>" +
@ -197,7 +197,7 @@ public interface DeviceChannelMapper {
" coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" +
" coalesce(gb_model, model) as model,\n" + " coalesce(gb_model, model) as model,\n" +
" coalesce(gb_owner, owner) as owner,\n" + " coalesce(gb_owner, owner) as owner,\n" +
" coalesce(gb_civil_code, civil_code) as civil_code,\n" + " gb_civil_code as civil_code,\n" +
" coalesce(gb_block, block) as block,\n" + " coalesce(gb_block, block) as block,\n" +
" coalesce(gb_address, address) as address,\n" + " coalesce(gb_address, address) as address,\n" +
" coalesce(gb_parental, parental) as parental,\n" + " coalesce(gb_parental, parental) as parental,\n" +
@ -269,7 +269,7 @@ public interface DeviceChannelMapper {
" coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" + " coalesce(dc.gb_manufacturer, dc.manufacturer) as manufacturer,\n" +
" coalesce(dc.gb_model, dc.model) as model,\n" + " coalesce(dc.gb_model, dc.model) as model,\n" +
" coalesce(dc.gb_owner, dc.owner) as owner,\n" + " coalesce(dc.gb_owner, dc.owner) as owner,\n" +
" coalesce(dc.gb_civil_code, dc.civil_code) as civil_code,\n" + " dc.gb_civil_code as civil_code,\n" +
" coalesce(dc.gb_block, dc.block) as block,\n" + " coalesce(dc.gb_block, dc.block) as block,\n" +
" coalesce(dc.gb_address, dc.address) as address,\n" + " coalesce(dc.gb_address, dc.address) as address,\n" +
" coalesce(dc.gb_parental, dc.parental) as parental,\n" + " coalesce(dc.gb_parental, dc.parental) as parental,\n" +
@ -359,7 +359,7 @@ public interface DeviceChannelMapper {
" coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" +
" coalesce(gb_model, model) as model,\n" + " coalesce(gb_model, model) as model,\n" +
" coalesce(gb_owner, owner) as owner,\n" + " coalesce(gb_owner, owner) as owner,\n" +
" coalesce(gb_civil_code, civil_code) as civil_code,\n" + " gb_civil_code as civil_code,\n" +
" coalesce(gb_block, block) as block,\n" + " coalesce(gb_block, block) as block,\n" +
" coalesce(gb_address, address) as address,\n" + " coalesce(gb_address, address) as address,\n" +
" coalesce(gb_parental, parental) as parental,\n" + " coalesce(gb_parental, parental) as parental,\n" +
@ -396,14 +396,14 @@ public interface DeviceChannelMapper {
@Insert("<script> " + @Insert("<script> " +
"insert into wvp_device_channel " + "insert into wvp_device_channel " +
"(device_id, device_db_id, name, manufacturer, model, owner, civil_code, block, " + "(device_id, device_db_id, name, manufacturer, model, owner, civil_code, gb_civil_code, block, " +
"address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " + "address, parental, parent_id, safety_way, register_way, cert_num, certifiable, err_code, end_time, secrecy, " +
"ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " + "ip_address, port, password, status, longitude, latitude, ptz_type, position_type, room_type, use_type, " +
"supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " + "supply_light_type, direction_type, resolution, business_group_id, download_speed, svc_space_support_mod, " +
"svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification) " + "svc_time_support_mode, create_time, update_time, sub_count, stream_id, has_audio, gps_time, stream_identification) " +
"values " + "values " +
"<foreach collection='addChannels' index='index' item='item' separator=','> " + "<foreach collection='addChannels' index='index' item='item' separator=','> " +
"(#{item.deviceId}, #{item.deviceDbId}, #{item.name}, #{item.manufacturer}, #{item.model}, #{item.owner}, #{item.civilCode}, #{item.block}, " + "(#{item.deviceId}, #{item.deviceDbId}, #{item.name}, #{item.manufacturer}, #{item.model}, #{item.owner}, #{item.civilCode}, #{item.gbCivilCode}, #{item.block}, " +
"#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, #{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.endTime}, #{item.secrecy}, " + "#{item.address}, #{item.parental}, #{item.parentId}, #{item.safetyWay}, #{item.registerWay}, #{item.certNum}, #{item.certifiable}, #{item.errCode}, #{item.endTime}, #{item.secrecy}, " +
"#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " + "#{item.ipAddress}, #{item.port}, #{item.password}, #{item.status}, #{item.longitude}, #{item.latitude}, #{item.ptzType}, #{item.positionType}, #{item.roomType}, #{item.useType}, " +
"#{item.supplyLightType}, #{item.directionType}, #{item.resolution}, #{item.businessGroupId}, #{item.downloadSpeed}, #{item.svcSpaceSupportMod}," + "#{item.supplyLightType}, #{item.directionType}, #{item.resolution}, #{item.businessGroupId}, #{item.downloadSpeed}, #{item.svcSpaceSupportMod}," +
@ -499,7 +499,7 @@ public interface DeviceChannelMapper {
" coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" +
" coalesce(gb_model, model) as model,\n" + " coalesce(gb_model, model) as model,\n" +
" coalesce(gb_owner, owner) as owner,\n" + " coalesce(gb_owner, owner) as owner,\n" +
" coalesce(gb_civil_code, civil_code) as civil_code,\n" + " gb_civil_code as civil_code,\n" +
" coalesce(gb_block, block) as block,\n" + " coalesce(gb_block, block) as block,\n" +
" coalesce(gb_address, address) as address,\n" + " coalesce(gb_address, address) as address,\n" +
" coalesce(gb_parental, parental) as parental,\n" + " coalesce(gb_parental, parental) as parental,\n" +
@ -579,7 +579,7 @@ public interface DeviceChannelMapper {
" coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" +
" coalesce(gb_model, model) as model,\n" + " coalesce(gb_model, model) as model,\n" +
" coalesce(gb_owner, owner) as owner,\n" + " coalesce(gb_owner, owner) as owner,\n" +
" coalesce(gb_civil_code, civil_code) as civil_code,\n" + " gb_civil_code as civil_code,\n" +
" coalesce(gb_block, block) as block,\n" + " coalesce(gb_block, block) as block,\n" +
" coalesce(gb_address, address) as address,\n" + " coalesce(gb_address, address) as address,\n" +
" coalesce(gb_parental, parental) as parental,\n" + " coalesce(gb_parental, parental) as parental,\n" +
@ -652,7 +652,7 @@ public interface DeviceChannelMapper {
" coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" +
" coalesce(gb_model, model) as model,\n" + " coalesce(gb_model, model) as model,\n" +
" coalesce(gb_owner, owner) as owner,\n" + " coalesce(gb_owner, owner) as owner,\n" +
" coalesce(gb_civil_code, civil_code) as civil_code,\n" + " gb_civil_code as civil_code,\n" +
" coalesce(gb_block, block) as block,\n" + " coalesce(gb_block, block) as block,\n" +
" coalesce(gb_address, address) as address,\n" + " coalesce(gb_address, address) as address,\n" +
" coalesce(gb_parental, parental) as parental,\n" + " coalesce(gb_parental, parental) as parental,\n" +
@ -702,7 +702,7 @@ public interface DeviceChannelMapper {
" coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" + " coalesce(gb_manufacturer, manufacturer) as manufacturer,\n" +
" coalesce(gb_model, model) as model,\n" + " coalesce(gb_model, model) as model,\n" +
" coalesce(gb_owner, owner) as owner,\n" + " coalesce(gb_owner, owner) as owner,\n" +
" coalesce(gb_civil_code, civil_code) as civil_code,\n" + " gb_civil_code as civil_code,\n" +
" coalesce(gb_block, block) as block,\n" + " coalesce(gb_block, block) as block,\n" +
" coalesce(gb_address, address) as address,\n" + " coalesce(gb_address, address) as address,\n" +
" coalesce(gb_parental, parental) as parental,\n" + " coalesce(gb_parental, parental) as parental,\n" +

View File

@ -79,4 +79,13 @@ public interface RegionMapper {
" <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " + " <if test='query != null'> AND (device_id LIKE concat('%',#{query},'%') OR name LIKE concat('%',#{query},'%'))</if> " +
" </script>") " </script>")
List<RegionTree> queryForTree(@Param("query") String query, @Param("parentId") String parentId); List<RegionTree> queryForTree(@Param("query") String query, @Param("parentId") String parentId);
@Select("SELECT * from wvp_common_region WHERE device_id = #{deviceId} ")
Region queryOneByDeviceId(@Param("deviceId") String deviceId);
@Delete("<script>" +
" DELETE FROM wvp_common_region WHERE id in " +
" <foreach collection='allChildren' item='item' open='(' separator=',' close=')' > #{item.id}</foreach>" +
" </script>")
void batchDelete(List<Region> allChildren);
} }

View File

@ -1,10 +1,7 @@
package com.genersoft.iot.vmp.gb28181.service; package com.genersoft.iot.vmp.gb28181.service;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel; import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.bean.DeviceType; import com.github.pagehelper.PageInfo;
import com.genersoft.iot.vmp.gb28181.bean.IndustryCodeType;
import com.genersoft.iot.vmp.gb28181.bean.NetworkIdentificationType;
import com.genersoft.iot.vmp.vmanager.bean.PageInfo;
import java.util.List; import java.util.List;
@ -45,4 +42,6 @@ public interface IGbChannelService {
void reset(int id); void reset(int id);
PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online); PageInfo<CommonGBChannel> queryList(int page, int count, String query, Boolean online);
void removeCivilCode(List<Region> allChildren);
} }

View File

@ -35,4 +35,6 @@ public interface IRegionService {
List<RegionTree> queryForTree(String query, String parent); List<RegionTree> queryForTree(String query, String parent);
void syncFromChannel(); void syncFromChannel();
boolean delete(int id);
} }

View File

@ -8,8 +8,8 @@ import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService; import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode; import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.PageInfo;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -324,4 +324,11 @@ public class GbChannelServiceImpl implements IGbChannelService {
List<CommonGBChannel> all = commonGBChannelMapper.queryList(query, online); List<CommonGBChannel> all = commonGBChannelMapper.queryList(query, online);
return new PageInfo<>(all); return new PageInfo<>(all);
} }
@Override
public void removeCivilCode(List<Region> allChildren) {
commonGBChannelMapper.removeCivilCode(allChildren);
// TODO 是否需要通知上级, 或者等添加新的行政区划时发送更新通知
}
} }

View File

@ -1,11 +1,11 @@
package com.genersoft.iot.vmp.gb28181.service.impl; package com.genersoft.iot.vmp.gb28181.service.impl;
import com.genersoft.iot.vmp.common.CivilCodePo; import com.genersoft.iot.vmp.common.CivilCodePo;
import com.genersoft.iot.vmp.conf.CivilCodeFileConf;
import com.genersoft.iot.vmp.gb28181.bean.Region; import com.genersoft.iot.vmp.gb28181.bean.Region;
import com.genersoft.iot.vmp.gb28181.bean.RegionTree; import com.genersoft.iot.vmp.gb28181.bean.RegionTree;
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper; import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.RegionMapper; import com.genersoft.iot.vmp.gb28181.dao.RegionMapper;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelService;
import com.genersoft.iot.vmp.gb28181.service.IRegionService; import com.genersoft.iot.vmp.gb28181.service.IRegionService;
import com.genersoft.iot.vmp.utils.CivilCodeUtil; import com.genersoft.iot.vmp.utils.CivilCodeUtil;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
@ -34,7 +34,7 @@ public class RegionServiceImpl implements IRegionService {
@Autowired @Autowired
private CivilCodeFileConf civilCodeFileConf; private IGbChannelService gbChannelService;
@Override @Override
public void add(Region region) { public void add(Region region) {
@ -51,10 +51,33 @@ public class RegionServiceImpl implements IRegionService {
@Override @Override
@Transactional @Transactional
public boolean deleteByDeviceId(String regionDeviceId) { public boolean deleteByDeviceId(String regionDeviceId) {
Region region = regionMapper.queryOneByDeviceId(regionDeviceId);
// 获取所有子节点
List<Region> allChildren = getAllChildren(regionDeviceId);
allChildren.add(region);
// 设置使用这些节点的通道的civilCode为null,
gbChannelService.removeCivilCode(allChildren);
regionMapper.batchDelete(allChildren);
return true; return true;
} }
private List<Region> getAllChildren(String deviceId) {
if (deviceId == null || deviceId.length() >= 8) {
return new ArrayList<>();
}
List<Region> children = regionMapper.getChildren(deviceId);
if (ObjectUtils.isEmpty(children)) {
return children;
}
List<Region> regions = new ArrayList<>(children);
for (Region region : children) {
if (region.getDeviceId().length() < 8) {
regions.addAll(getAllChildren(region.getDeviceId()));
}
}
return regions;
}
@Override @Override
public PageInfo<Region> query(String query, int page, int count) { public PageInfo<Region> query(String query, int page, int count) {
PageHelper.startPage(page, count); PageHelper.startPage(page, count);
@ -140,4 +163,9 @@ public class RegionServiceImpl implements IRegionService {
regionMapper.batchAdd(new ArrayList<>(regionMapForVerification.values())); regionMapper.batchAdd(new ArrayList<>(regionMapForVerification.values()));
} }
@Override
public boolean delete(int id) {
return regionMapper.delete(id) > 0;
}
} }

View File

@ -3,7 +3,7 @@ package com.genersoft.iot.vmp.vmanager.bean;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public class PageInfo<T> { public class TablePageInfo<T> {
//当前页 //当前页
private int pageNum; private int pageNum;
//每页的数量 //每页的数量
@ -19,11 +19,11 @@ public class PageInfo<T> {
private List<T> list; private List<T> list;
public PageInfo(List<T> resultData) { public TablePageInfo(List<T> resultData) {
this.resultData = resultData; this.resultData = resultData;
} }
public PageInfo() { public TablePageInfo() {
} }
public void startPage(int page, int count) { public void startPage(int page, int count) {

View File

@ -10,7 +10,7 @@
</div> </div>
</div> </div>
</div> </div>
<div > <div>
<vue-easy-tree <vue-easy-tree
ref="veTree" ref="veTree"
node-key="id" node-key="id"
@ -19,14 +19,19 @@
style="height: 78vh; padding: 2rem" style="height: 78vh; padding: 2rem"
:load="loadNode" :load="loadNode"
:data="treeData" :data="treeData"
:default-expanded-keys="['']"
@node-contextmenu="contextmenuEventHandler" @node-contextmenu="contextmenuEventHandler"
@node-click="nodeClickHandler" @node-click="nodeClickHandler"
> >
<span class="custom-tree-node" slot-scope="{ node, data }"> <span class="custom-tree-node" slot-scope="{ node, data }">
<span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span> <span @click.stop >
<span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-file-stream2"></span> <el-radio v-if="node.data.type === 0 && node.level !== 1 " style="margin-right: 0" v-model="chooseId" @input="chooseIdChange" :label="node.data.id">{{''}}</el-radio>
<span style=" padding-left: 1px">{{ node.label }}</span> </span>
</span> <span v-if="node.data.type === 0" style="color: #409EFF" class="iconfont icon-bianzubeifen3"></span>
<span v-if="node.data.type === 1" style="color: #409EFF" class="iconfont icon-file-stream2"></span>
<span style=" padding-left: 1px" v-if="node.data.id !==''">{{ node.label }}({{ node.data.id }})</span>
<span style=" padding-left: 1px" v-if="node.data.id ===''">{{ node.label }}</span>
</span>
</vue-easy-tree> </vue-easy-tree>
</div> </div>
<regionCode ref="regionCode"></regionCode> <regionCode ref="regionCode"></regionCode>
@ -47,13 +52,14 @@ export default {
data() { data() {
return { return {
searchSrt: "", searchSrt: "",
chooseId: "",
// props: { // props: {
// label: "name", // label: "name",
// }, // },
treeData: [], treeData: [],
} }
}, },
props: ['edit', 'clickEvent', 'contextMenuEvent'], props: ['edit', 'clickEvent', 'chooseIdChange'],
created() { created() {
// this.$axios({ // this.$axios({
// method: 'get', // method: 'get',
@ -107,7 +113,14 @@ export default {
loadNode: function (node, resolve) { loadNode: function (node, resolve) {
console.log(22222) console.log(22222)
console.log(node) console.log(node)
if (node.level === 0 || node.data.id.length < 8) { if (node.level === 0) {
resolve([{
id: "",
label: "根资源组",
isLeaf: false,
type: 0
}]);
} else if (node.data.id.length < 8) {
this.$axios({ this.$axios({
method: 'get', method: 'get',
url: `/api/region/tree/list`, url: `/api/region/tree/list`,
@ -115,7 +128,7 @@ export default {
query: this.searchSrt, query: this.searchSrt,
parent: node.data.id parent: node.data.id
} }
}).then((res)=> { }).then((res) => {
if (res.data.code === 0) { if (res.data.code === 0) {
resolve(res.data.data); resolve(res.data.data);
} }
@ -123,7 +136,7 @@ export default {
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
}); });
}else { } else {
resolve([]); resolve([]);
} }
}, },
@ -176,7 +189,8 @@ export default {
reset: function () { reset: function () {
this.$forceUpdate(); this.$forceUpdate();
}, },
contextmenuEventHandler: function (event,data,node,element){ contextmenuEventHandler: function (event, data, node, element) {
console.log(node.level)
if (node.data.type === 1) { if (node.data.type === 1) {
data.parentId = node.parent.data.id; data.parentId = node.parent.data.id;
this.$contextmenu({ this.$contextmenu({
@ -187,10 +201,10 @@ export default {
disabled: false, disabled: false,
onClick: () => { onClick: () => {
this.$axios({ this.$axios({
method:"delete", method: "delete",
url:"/api/platform/catalog/relation/del", url: "/api/platform/catalog/relation/del",
data: data data: data
}).then((res)=>{ }).then((res) => {
console.log("移除成功") console.log("移除成功")
node.parent.loaded = false node.parent.loaded = false
node.parent.expand(); node.parent.expand();
@ -204,7 +218,7 @@ export default {
customClass: "custom-class", // class customClass: "custom-class", // class
zIndex: 3000, // z-index zIndex: 3000, // z-index
}); });
}else if (node.data.type === 0){ } else if (node.data.type === 0) {
this.$contextmenu({ this.$contextmenu({
items: [ items: [
{ {
@ -224,9 +238,9 @@ export default {
} }
}, },
{ {
label: "修改节点", label: "重命名",
icon: "el-icon-edit", icon: "el-icon-edit",
disabled: false, disabled: node.level === 1,
onClick: () => { onClick: () => {
this.editCatalog(data, node); this.editCatalog(data, node);
} }
@ -234,14 +248,14 @@ export default {
{ {
label: "删除节点", label: "删除节点",
icon: "el-icon-delete", icon: "el-icon-delete",
disabled: false, disabled: node.level === 1,
onClick: () => { onClick: () => {
this.$confirm('确定删除?', '提示', { this.$confirm('确定删除?', '提示', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning' type: 'warning'
}).then(() => { }).then(() => {
this.removeCatalog(data.id, node) this.removeRegion(data.id, node)
}).catch(() => { }).catch(() => {
}); });
@ -276,30 +290,43 @@ export default {
return false; return false;
}, },
refreshNode: function (node){ removeRegion: function (id, node) {
this.$axios({
method: "delete",
url: `/api/region/delete`,
params: {
deviceId: id,
}
}).then((res) => {
if (res.data.code === 0) {
console.log("移除成功")
node.parent.loaded = false
node.parent.expand();
}
})
.catch(function (error) {
console.log(error);
});
},
refreshNode: function (node) {
node.loaded = false node.loaded = false
node.expand(); node.expand();
}, },
addRegion: function (id, node){ addRegion: function (id, node) {
console.log(node) console.log(node)
this.$refs.regionCode.openDialog(code=>{ this.$refs.regionCode.openDialog(form => {
console.log(this.form)
console.log("code===> " + code)
this.form.gbDeviceId = code;
console.log("code22===> " + code)
node.loaded = false node.loaded = false
node.expand(); node.expand();
}, id); }, id);
}, },
nodeClickHandler: function (data, node, tree){ nodeClickHandler: function (data, node, tree) {
console.log(data) console.log(data)
console.log(node) console.log(node)
this.chooseId = data.id; // this.chooseId = data.id;
this.chooseName = data.name; // this.chooseName = data.name;
if (this.catalogIdChange)this.catalogIdChange(this.chooseId, this.chooseName); // if (this.catalogIdChange)this.catalogIdChange(this.chooseId, this.chooseName);
} }
}, },
destroyed() { destroyed() {
@ -325,4 +352,7 @@ export default {
.device-offline { .device-offline {
color: #727272; color: #727272;
} }
.custom-tree-node .el-radio__label {
padding-left: 4px !important;
}
</style> </style>

View File

@ -14,39 +14,33 @@
<div class="show-code-item">{{ allVal[0].val }}</div> <div class="show-code-item">{{ allVal[0].val }}</div>
<div style="text-align: center">{{ allVal[0].meaning }}</div> <div style="text-align: center">{{ allVal[0].meaning }}</div>
</div> </div>
<el-radio-group v-model="allVal[0].val" @input="deviceChange"> <el-radio v-for="item in regionList" v-model="allVal[0].val" :key="item.deviceId" :name="item.name" :label="item.deviceId" @input="deviceChange(item)" style="line-height: 2rem">
<el-radio v-for="item in regionList" :key="item.deviceId" :label="item.deviceId" style="line-height: 2rem"> {{ item.name }} - {{ item.deviceId }}
{{ item.name }} - {{ item.deviceId }} </el-radio>
</el-radio>
</el-radio-group>
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="1"> <el-tab-pane name="1">
<div slot="label"> <div slot="label">
<div class="show-code-item">{{ allVal[1].val?allVal[1].val:"--" }}</div> <div class="show-code-item">{{ allVal[1].val?allVal[1].val:"--" }}</div>
<div style="text-align: center">{{ allVal[1].meaning }}</div> <div style="text-align: center">{{ allVal[1].meaning }}</div>
</div> </div>
<el-radio-group v-model="allVal[1].val" :disabled="allVal[1].lock" @input="deviceChange"> <el-radio :key="-1" v-model="allVal[1].val" @input="deviceChange" label="" style="line-height: 2rem">
<el-radio :key="-1" label="" style="line-height: 2rem"> 不添加
不添加 </el-radio>
</el-radio> <el-radio v-for="item in regionList" v-model="allVal[1].val" @input="deviceChange(item)" :key="item.deviceId" :label="item.deviceId.substring(2)" style="line-height: 2rem">
<el-radio v-for="item in regionList" :key="item.deviceId" :label="item.deviceId.substring(2)" style="line-height: 2rem"> {{ item.name }} - {{ item.deviceId.substring(2) }}
{{ item.name }} - {{ item.deviceId.substring(2) }} </el-radio>
</el-radio>
</el-radio-group>
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="2"> <el-tab-pane name="2">
<div slot="label"> <div slot="label">
<div class="show-code-item">{{ allVal[2].val?allVal[2].val:"--" }}</div> <div class="show-code-item">{{ allVal[2].val?allVal[2].val:"--" }}</div>
<div style="text-align: center">{{ allVal[2].meaning }}</div> <div style="text-align: center">{{ allVal[2].meaning }}</div>
</div> </div>
<el-radio-group v-model="allVal[2].val" :disabled="allVal[2].lock" @input="deviceChange"> <el-radio :key="-1" label="" v-model="allVal[2].val" style="line-height: 2rem" @input="deviceChange">
<el-radio :key="-1" label="" style="line-height: 2rem"> 不添加
不添加 </el-radio>
</el-radio> <el-radio v-for="item in regionList" v-model="allVal[2].val" @input="deviceChange(item)" :key="item.deviceId" :label="item.deviceId.substring(4)" style="line-height: 2rem">
<el-radio v-for="item in regionList" :key="item.deviceId" :label="item.deviceId.substring(4)" style="line-height: 2rem"> {{ item.name }} - {{ item.deviceId.substring(4) }}
{{ item.name }} - {{ item.deviceId.substring(4) }} </el-radio>
</el-radio>
</el-radio-group>
</el-tab-pane> </el-tab-pane>
<el-tab-pane name="3"> <el-tab-pane name="3">
请手动输入基层接入单位编码,两位数字 请手动输入基层接入单位编码,两位数字
@ -136,21 +130,64 @@ export default {
}, },
methods: { methods: {
openDialog: function (endCallBck, parentDeviceId, code, lockContent) { openDialog: function (endCallBck, parentDeviceId, code, lockContent) {
console.log(code)
console.log(parentDeviceId)
this.showVideoDialog = true this.showVideoDialog = true
this.activeKey= '0'; this.activeKey= '0';
this.regionList = [] this.regionList = []
this.form.parentDeviceId = parentDeviceId this.form.parentDeviceId = parentDeviceId
this.allVal = [
this.getRegionList() {
if (typeof code != 'undefined' && code.length === 8) { id: [1, 2],
console.log(111) meaning: '省级编码',
this.allVal[0].val = code.substring(0, 2) val: '11',
this.allVal[1].val = code.substring(2, 4) type: '中心编码',
this.allVal[2].val = code.substring(4, 6) lock: false,
this.allVal[3].val = code.substring(6, 8) },
{
id: [3, 4],
meaning: '市级编码',
val: '',
type: '中心编码',
lock: false,
},
{
id: [5, 6],
meaning: '区级编码',
val: '',
type: '中心编码',
lock: false,
},
{
id: [7, 8],
meaning: '基层接入单位编码',
val: '',
type: '中心编码',
lock: false,
}
]
if (parentDeviceId) {
console.log(parentDeviceId)
console.log(parentDeviceId.length)
if (parentDeviceId.length >= 2) {
this.allVal[0].val = parentDeviceId.substring(0, 2)
this.activeKey = "1"
}
if (parentDeviceId.length >= 4) {
this.allVal[1].val = parentDeviceId.substring(2, 4)
this.activeKey = "2"
}
if (parentDeviceId.length >= 6) {
this.allVal[2].val = parentDeviceId.substring(4, 6)
this.activeKey = "3"
}
} }
this.getRegionList()
// if (typeof code != 'undefined' && code.length === 8) {
// this.allVal[0].val = code.substring(0, 2)
// this.allVal[1].val = code.substring(2, 4)
// this.allVal[2].val = code.substring(4, 6)
// this.allVal[3].val = code.substring(6, 8)
// }
console.log(this.allVal) console.log(this.allVal)
this.endCallBck = endCallBck; this.endCallBck = endCallBck;
}, },
@ -246,7 +283,8 @@ export default {
closeModel: function (){ closeModel: function (){
this.showVideoDialog = false this.showVideoDialog = false
}, },
deviceChange: function (){ deviceChange: function (item){
console.log(item)
let code = this.allVal[0].val let code = this.allVal[0].val
if (this.allVal[1].val) { if (this.allVal[1].val) {
code += this.allVal[1].val code += this.allVal[1].val
@ -263,22 +301,29 @@ export default {
this.allVal[3].val = "" this.allVal[3].val = ""
} }
this.form.deviceId = code this.form.deviceId = code
if (item) {
this.form.name = item.name
}
}, },
handleOk: function() { handleOk: function() {
const code = this.$axios({
this.allVal[0].val + method: 'post',
this.allVal[1].val + url: "/api/region/add/",
this.allVal[2].val + data: this.form
this.allVal[3].val + }).then((res) => {
this.allVal[4].val + if (res.data.code === 0) {
this.allVal[5].val + if (typeof this.endCallBck == "function") {
this.allVal[6].val + this.endCallBck(this.form)
this.allVal[7].val }
console.log(code) this.showVideoDialog = false
if (this.endCallBck) { } else {
this.endCallBck(code) this.$message.error(res.data.msg);
} }
this.showVideoDialog = false }).catch((error) => {
this.$message.error(error);
});
} }
}, },
}; };

View File

@ -2,7 +2,7 @@
<div id="region" style="width: 100%"> <div id="region" style="width: 100%">
<el-container v-loading="loading" > <el-container v-loading="loading" >
<el-aside width="400px" > <el-aside width="400px" >
<RegionTree ref="regionTree" :edit="true" :clickEvent="treeNodeClickEvent"></RegionTree> <RegionTree ref="regionTree" :edit="true" :clickEvent="treeNodeClickEvent" :chooseIdChange="chooseIdChange"></RegionTree>
</el-aside> </el-aside>
<el-main style="padding: 5px;"> <el-main style="padding: 5px;">
<div class="page-header"> <div class="page-header">
@ -27,7 +27,9 @@
</div> </div>
</div> </div>
<el-table ref="channelListTable" :data="channelList" :height="winHeight" style="width: 100%" <el-table ref="channelListTable" :data="channelList" :height="winHeight" style="width: 100%"
header-row-class-name="table-header"> header-row-class-name="table-header" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55">
</el-table-column>
<el-table-column prop="gbName" label="名称" min-width="180"> <el-table-column prop="gbName" label="名称" min-width="180">
</el-table-column> </el-table-column>
<el-table-column prop="gbDeviceId" label="编号" min-width="180"> <el-table-column prop="gbDeviceId" label="编号" min-width="180">
@ -84,27 +86,23 @@ export default {
searchSrt: "", searchSrt: "",
channelType: "", channelType: "",
online: "", online: "",
winHeight: window.innerHeight - 200, winHeight: window.innerHeight - 180,
currentPage: 1, currentPage: 1,
count: 15, count: 15,
total: 0, total: 0,
loading: false, loading: false,
loadSnap: {}, loadSnap: {},
regionId: ""
}; };
}, },
mounted() { created() {
this.initData(); this.initData();
}, },
destroyed() {}, destroyed() {},
methods: { methods: {
initData: function () { initData: function () {
if (typeof (this.parentChannelId) == "undefined" || this.parentChannelId == 0) { this.getChannelList();
this.getChannelList();
} else {
this.showSubchannels();
}
}, },
currentChange: function (val) { currentChange: function (val) {
this.currentPage = val; this.currentPage = val;
@ -116,28 +114,19 @@ export default {
}, },
getChannelList: function () { getChannelList: function () {
let that = this; let that = this;
if (typeof (this.$route.params.deviceId) == "undefined") return;
this.$axios({ this.$axios({
method: 'get', method: 'get',
url: `/api/device/query/devices/${this.$route.params.deviceId}/channels`, url: `/api/common/channel/list`,
params: { params: {
page: that.currentPage, page: that.currentPage,
count: that.count, count: that.count,
query: that.searchSrt, query: that.searchSrt,
online: that.online, online: that.online
channelType: that.channelType
} }
}).then(function (res) { }).then(function (res) {
if (res.data.code === 0) { if (res.data.code === 0) {
that.total = res.data.data.total; that.total = res.data.data.total;
that.deviceChannelList = res.data.data.list; that.channelList = res.data.data.list;
that.deviceChannelList.forEach(e => {
e.ptzType = e.ptzType + "";
that.$set(e, "location", "");
if (e.longitude && e.latitude) {
that.$set(e, "location", e.longitude + "," + e.latitude);
}
});
// //
that.$nextTick(() => { that.$nextTick(() => {
that.$refs.channelListTable.doLayout(); that.$refs.channelListTable.doLayout();
@ -148,7 +137,14 @@ export default {
console.log(error); console.log(error);
}); });
}, },
handleSelectionChange: function (val){
console.log(val)
},
add: function (row) { add: function (row) {
if (!this.regionId) {
this.$message.info("请选择左侧行政区划节点")
}
}, },
remove: function (row) { remove: function (row) {
}, },
@ -165,13 +161,10 @@ export default {
this.initData(); this.initData();
}, },
treeNodeClickEvent: function (device, data, isCatalog) { treeNodeClickEvent: function (device, data, isCatalog) {
console.log(device)
if (!!!data.channelId) { },
this.parentChannelId = device.deviceId; chooseIdChange: function (id) {
} else { this.regionId = id;
this.parentChannelId = data.channelId;
}
this.initData();
}, },
} }
}; };