优化日志以及属性设置代码

This commit is contained in:
648540858
2024-07-03 17:09:49 +08:00
parent 799932f614
commit adf040ec4b
34 changed files with 184 additions and 1042 deletions

View File

@@ -1,87 +0,0 @@
package com.genersoft.iot.vmp.vmanager.bean;
import org.jetbrains.annotations.NotNull;
import java.text.Collator;
import java.util.Comparator;
/**
* @author lin
*/
public class BaseTree<T> implements Comparable<BaseTree>{
private String id;
private String deviceId;
private String pid;
private String name;
private boolean parent;
private T basicData;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getDeviceId() {
return deviceId;
}
public void setDeviceId(String deviceId) {
this.deviceId = deviceId;
}
public String getPid() {
return pid;
}
public void setPid(String pid) {
this.pid = pid;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public T getBasicData() {
return basicData;
}
public void setBasicData(T basicData) {
this.basicData = basicData;
}
public boolean isParent() {
return parent;
}
public void setParent(boolean parent) {
this.parent = parent;
}
@Override
public int compareTo(@NotNull BaseTree treeNode) {
if (this.parent || treeNode.isParent()) {
if (!this.parent && !treeNode.isParent()) {
Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
return cmp.compare(treeNode.getName(), this.getName());
}else {
if (this.isParent()) {
return 1;
}else {
return -1;
}
}
}else{
Comparator cmp = Collator.getInstance(java.util.Locale.CHINA);
return cmp.compare(treeNode.getName(), this.getName());
}
}
}

View File

@@ -18,7 +18,6 @@ import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.service.IInviteStreamService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.vmanager.bean.BaseTree;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo;
@@ -47,7 +46,10 @@ import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.text.ParseException;
import java.util.*;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@Tag(name = "国标设备查询", description = "国标设备查询")
@SuppressWarnings("rawtypes")
@@ -494,96 +496,4 @@ public class DeviceQuery {
resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
}
}
/**
* 查询国标树
* @param deviceId 设备ID
* @param parentId 父ID
* @param page 当前页
* @param count 每页条数
* @return 国标设备
*/
@Operation(summary = "查询国标树")
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "parentId", description = "父级国标编号")
@Parameter(name = "onlyCatalog", description = "只获取目录")
@Parameter(name = "page", description = "当前页", required = true)
@Parameter(name = "count", description = "每页条数", required = true)
@GetMapping("/tree/{deviceId}")
public ResponseEntity<PageInfo> getTree(@PathVariable String deviceId,
@RequestParam(required = false) String parentId,
@RequestParam(required = false) Boolean onlyCatalog,
int page, int count){
if (page <= 0) {
page = 1;
}
if (onlyCatalog == null) {
onlyCatalog = false;
}
List<BaseTree<DeviceChannel>> treeData = deviceService.queryVideoDeviceTree(deviceId, parentId, onlyCatalog);
if (treeData == null || (page - 1) * count > treeData.size()) {
PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>();
pageInfo.setPageNum(page);
pageInfo.setTotal(treeData == null? 0 : treeData.size());
pageInfo.setSize(0);
pageInfo.setList(new ArrayList<>());
return new ResponseEntity<>(pageInfo,HttpStatus.OK);
}
int toIndex = Math.min(page * count, treeData.size());
// 处理分页
List<BaseTree<DeviceChannel>> trees = treeData.subList((page - 1) * count, toIndex);
PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>();
pageInfo.setPageNum(page);
pageInfo.setTotal(treeData.size());
pageInfo.setSize(trees.size());
pageInfo.setList(trees);
return new ResponseEntity<>(pageInfo,HttpStatus.OK);
}
/**
* 查询国标树下的通道
* @param deviceId 设备ID
* @param parentId 父ID
* @param page 当前页
* @param count 每页条数
* @return 国标设备
*/
@Operation(summary = "查询国标树下的通道")
@Parameter(name = "deviceId", description = "设备国标编号", required = true)
@Parameter(name = "parentId", description = "父级国标编号")
@Parameter(name = "page", description = "当前页", required = true)
@Parameter(name = "count", description = "每页条数", required = true)
@GetMapping("/tree/channel/{deviceId}")
public ResponseEntity<PageInfo> getChannelInTreeNode(@PathVariable String deviceId, @RequestParam(required = false) String parentId, int page, int count){
if (page <= 0) {
page = 1;
}
List<DeviceChannel> treeData = deviceService.queryVideoDeviceInTreeNode(deviceId, parentId);
if (treeData == null || (page - 1) * count > treeData.size()) {
PageInfo<BaseTree<DeviceChannel>> pageInfo = new PageInfo<>();
pageInfo.setPageNum(page);
pageInfo.setTotal(treeData == null? 0 : treeData.size());
pageInfo.setSize(0);
pageInfo.setList(new ArrayList<>());
return new ResponseEntity<>(pageInfo,HttpStatus.OK);
}
int toIndex = Math.min(page * count, treeData.size());
// 处理分页
List<DeviceChannel> trees = treeData.subList((page - 1) * count, toIndex);
PageInfo<DeviceChannel> pageInfo = new PageInfo<>();
pageInfo.setPageNum(page);
pageInfo.setTotal(treeData.size());
pageInfo.setSize(trees.size());
pageInfo.setList(trees);
return new ResponseEntity<>(pageInfo,HttpStatus.OK);
}
}

View File

@@ -1,134 +0,0 @@
package com.genersoft.iot.vmp.vmanager.gb28181.gbStream;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.service.IGbStreamService;
import com.genersoft.iot.vmp.service.IPlatformService;
import com.genersoft.iot.vmp.streamPush.service.IStreamPushService;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean.GbStreamParam;
import com.github.pagehelper.PageInfo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "视频流关联到级联平台")
@RestController
@RequestMapping("/api/gbStream")
public class GbStreamController {
private final static Logger logger = LoggerFactory.getLogger(GbStreamController.class);
@Autowired
private IGbStreamService gbStreamService;
@Autowired
private IStreamPushService service;
@Autowired
private IPlatformService platformService;
/**
* 查询国标通道
* @param page 当前页
* @param count 每页条数
* @param platformId 平台ID
* @return
*/
@Operation(summary = "查询国标通道", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "page", description = "当前页", required = true)
@Parameter(name = "count", description = "每页条数", required = true)
@Parameter(name = "platformId", description = "平台ID", required = true)
@Parameter(name = "catalogId", description = "目录ID")
@Parameter(name = "query", description = "查询内容")
@Parameter(name = "mediaServerId", description = "流媒体ID")
@GetMapping(value = "/list")
@ResponseBody
public PageInfo<GbStream> list(@RequestParam(required = true)Integer page,
@RequestParam(required = true)Integer count,
@RequestParam(required = true)String platformId,
@RequestParam(required = false)String catalogId,
@RequestParam(required = false)String query,
@RequestParam(required = false)String mediaServerId){
if (ObjectUtils.isEmpty(catalogId)) {
catalogId = null;
}
if (ObjectUtils.isEmpty(query)) {
query = null;
}
if (ObjectUtils.isEmpty(mediaServerId)) {
mediaServerId = null;
}
// catalogId 为null 查询未在平台下分配的数据
// catalogId 不为null 查询平台下这个,目录下的通道
return gbStreamService.getAll(page, count, platformId, catalogId, query, mediaServerId);
}
/**
* 移除国标关联
* @param gbStreamParam
* @return
*/
@Operation(summary = "移除国标关联", security = @SecurityRequirement(name = JwtUtils.HEADER))
@DeleteMapping(value = "/del")
@ResponseBody
public void del(@RequestBody GbStreamParam gbStreamParam){
if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().isEmpty()) {
if (gbStreamParam.isAll()) {
gbStreamService.delAllPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId());
}
}else {
gbStreamService.delPlatformInfo(gbStreamParam.getPlatformId(), gbStreamParam.getGbStreams());
}
}
/**
* 保存国标关联
* @param gbStreamParam
* @return
*/
@Operation(summary = "保存国标关联", security = @SecurityRequirement(name = JwtUtils.HEADER))
@PostMapping(value = "/add")
@ResponseBody
public void add(@RequestBody GbStreamParam gbStreamParam){
if (gbStreamParam.getGbStreams() == null || gbStreamParam.getGbStreams().isEmpty()) {
if (gbStreamParam.isAll()) {
List<GbStream> allGBChannels = gbStreamService.getAllGBChannels(gbStreamParam.getPlatformId());
gbStreamService.addPlatformInfo(allGBChannels, gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId());
}
}else {
gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId());
}
}
/**
* 保存国标关联
* @param gbId
* @return
*/
@Operation(summary = "保存国标关联", security = @SecurityRequirement(name = JwtUtils.HEADER))
@GetMapping(value = "/addWithGbid")
@ResponseBody
public void add(String gbId, String platformGbId, @RequestParam(required = false) String catalogGbId){
List<GbStream> gbStreams = gbStreamService.getGbChannelWithGbid(gbId);
if (gbStreams.isEmpty()) {
throw new ControllerException(ErrorCode.ERROR100.getCode(), "gbId的信息未找到");
}
gbStreamService.addPlatformInfo(gbStreams, platformGbId, catalogGbId);
}
}

View File

@@ -1,54 +0,0 @@
package com.genersoft.iot.vmp.vmanager.gb28181.gbStream.bean;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import io.swagger.v3.oas.annotations.media.Schema;
import java.util.List;
@Schema(description = "国标关联参数")
public class GbStreamParam {
@Schema(description = "平台ID")
private String platformId;
@Schema(description = "目录ID")
private String catalogId;
@Schema(description = "关联所有通道")
private boolean all;
@Schema(description = "流国标信息列表")
private List<GbStream> gbStreams;
public String getPlatformId() {
return platformId;
}
public String getCatalogId() {
return catalogId;
}
public void setCatalogId(String catalogId) {
this.catalogId = catalogId;
}
public void setPlatformId(String platformId) {
this.platformId = platformId;
}
public List<GbStream> getGbStreams() {
return gbStreams;
}
public void setGbStreams(List<GbStream> gbStreams) {
this.gbStreams = gbStreams;
}
public boolean isAll() {
return all;
}
public void setAll(boolean all) {
this.all = all;
}
}

View File

@@ -77,9 +77,6 @@ public class PlatformController {
@Autowired
private IDeviceChannelService deviceChannelService;
@Autowired
private IGbStreamService gbStreamService;
/**
* 获取国标服务的配置
*