临时提交

This commit is contained in:
lin
2025-10-09 15:55:13 +08:00
parent f9276cf1a5
commit bdf7ae5771
12 changed files with 266 additions and 111 deletions

View File

@@ -106,4 +106,12 @@ public class SpringDocConfig {
.packagesToScan("com.genersoft.iot.vmp.jt1078.controller")
.build();
}
@Bean
public GroupedOpenApi publicApi99() {
return GroupedOpenApi.builder()
.group("99. 第三方接口")
.packagesToScan("com.genersoft.iot.vmp.web.custom")
.build();
}
}

View File

@@ -101,7 +101,7 @@ public class CommonGBChannel {
@Schema(description = "国标-虚拟组织所属的业务分组ID")
private String gbBusinessGroupId;
@Schema(description = "国标-摄像机结构类型,标识摄像机类型: 1-球机; 2-半球; 3-固定枪机; 4-遥控枪机;5-遥控半球;6-多目设备的全景/拼接通道;7-多目设备的分割通道")
@Schema(description = "国标-摄像机结构类型,标识摄像机类型: 1-球机; 2-半球; 3-固定枪机; 4-遥控枪机;5-遥控半球;6-多目设备的全景/拼接通道;7-多目设备的分割通道; 99-移动设备(非标)")
private Integer gbPtzType;
// 2016

View File

@@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.gb28181.dao.provider.ChannelProvider;
import com.genersoft.iot.vmp.service.bean.GPSMsgInfo;
import com.genersoft.iot.vmp.streamPush.bean.StreamPush;
import com.genersoft.iot.vmp.web.custom.bean.CameraChannel;
import com.genersoft.iot.vmp.web.custom.bean.CameraGroup;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;
@@ -607,10 +608,15 @@ public interface CommonGBChannelMapper {
@SelectProvider(type = ChannelProvider.class, method = "queryListForSy")
List<CameraChannel> queryListForSy(@Param("query") String query, @Param("sortName") String sortName, @Param("order") String order,
@Param("groupDeviceId") String groupDeviceId, @Param("online") Boolean online, @Param("containMobileDevice") Boolean containMobileDevice);
List<CameraChannel> queryListForSy(@Param("groupDeviceId") String groupDeviceId, @Param("online") Boolean online);
@SelectProvider(type = ChannelProvider.class, method = "queryGbChannelByChannelDeviceIdAndGbDeviceId")
CommonGBChannel queryGbChannelByChannelDeviceIdAndGbDeviceId(String deviceId, String deviceCode);
CommonGBChannel queryGbChannelByChannelDeviceIdAndGbDeviceId(@Param("channelDeviceId") String channelDeviceId, @Param("gbDeviceId") String gbDeviceId);
@SelectProvider(type = ChannelProvider.class, method = "queryListByDeviceIds")
List<CameraChannel> queryListByDeviceIds(List<String> deviceIds);
@SelectProvider(type = ChannelProvider.class, method = "queryListWithChildForSy")
List<CameraChannel> queryListWithChildForSy(@Param("query") String query, @Param("sortName") String sortName, @Param("order") String order, @Param("groupList") List<CameraGroup> groupList, @Param("status") Boolean status);
}

View File

@@ -4,9 +4,11 @@ import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.bean.GroupTree;
import com.genersoft.iot.vmp.gb28181.bean.Platform;
import com.genersoft.iot.vmp.web.custom.bean.CameraGroup;
import org.apache.ibatis.annotations.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Mapper
@@ -120,6 +122,9 @@ public interface GroupMapper {
@Select("SELECT * from wvp_common_group WHERE business_group = #{businessGroup} ")
List<Group> queryByBusinessGroup(@Param("businessGroup") String businessGroup);
@Select("SELECT * from wvp_common_group WHERE business_group = #{businessGroup} ")
Map<Integer, CameraGroup> queryByBusinessGroupForMap(@Param("businessGroup") String businessGroup);
@Delete("DELETE FROM wvp_common_group WHERE business_group = #{businessGroup}")
int deleteByBusinessGroup(@Param("businessGroup") String businessGroup);
@@ -291,7 +296,7 @@ public interface GroupMapper {
void deletePlatformGroup(@Param("groupId") int groupId);
@Select("SELECT * from wvp_common_group WHERE alias = #{alias} ")
Group queryGroupByAlias(@Param("alias") String alias);
CameraGroup queryGroupByAlias(@Param("alias") String alias);
@Select("SELECT * from wvp_common_group WHERE alias = #{alias} and business_group = #{businessGroup}")
Group queryGroupByAliasAndBusinessGroup(@Param("alias") String alias, @Param("deviceId") String businessGroup);

View File

@@ -3,6 +3,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 com.genersoft.iot.vmp.streamPush.bean.StreamPush;
import com.genersoft.iot.vmp.web.custom.bean.CameraGroup;
import java.util.Collection;
import java.util.List;
@@ -194,7 +195,7 @@ public class ChannelProvider {
" 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 join wvp_device wd on wdc.data_type = 1 wd.id = wdc.data_device_id"
" left join wvp_device wd on wdc.data_type = 1 AND wd.id = wdc.data_device_id"
;
public String queryByDeviceId(Map<String, Object> params ){
@@ -536,55 +537,88 @@ public class ChannelProvider {
public String queryListForSy(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(BASE_SQL);
sqlBuild.append(" where channel_type = 0 ");
if (params.get("query") != null) {
sqlBuild.append(" AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') escape '/'" +
" OR coalesce(gb_name, name) LIKE concat('%',#{query},'%') escape '/' )")
;
}
sqlBuild.append(BASE_SQL_FOR_CAMERA_DEVICE);
sqlBuild.append(" where wdc.channel_type = 0 AND (wdc.gb_ptz_type is null || wdc.gb_ptz_type != 99) AND coalesce(gb_parent_id, parent_id) = #{groupDeviceId}");
if (params.get("online") != null && (Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'");
}
if (params.get("online") != null && !(Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'");
}
if (params.get("containMobileDevice") != null && !(Boolean)params.get("containMobileDevice")) {
sqlBuild.append(" AND gb_ptz_type = 99");
return sqlBuild.toString();
}
public String queryListWithChildForSy(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(BASE_SQL_FOR_CAMERA_DEVICE);
sqlBuild.append(" where wdc.channel_type = 0 AND (wdc.gb_ptz_type is null || wdc.gb_ptz_type != 99) " +
"AND coalesce(gb_parent_id, parent_id) = #{groupDeviceId} " +
"AND coalesce(gb_parent_id, parent_id) in (");
sqlBuild.append(" ");
List<CameraGroup> groupList = (List<CameraGroup>)params.get("groupList");
boolean first = true;
for (CameraGroup group : groupList) {
if (!first) {
sqlBuild.append(",");
}
sqlBuild.append(group.getId());
first = false;
}
if (params.get("groupDeviceId") != null) {
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) = #{groupDeviceId}");
}else {
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) is null");
sqlBuild.append(" )");
if (params.get("query") != null) {
sqlBuild.append(" AND (coalesce(wdc.gb_device_id, wdc.device_id) LIKE concat('%',#{query},'%') escape '/'" +
" OR coalesce(wdc.gb_name, wdc.name) LIKE concat('%',#{query},'%') escape '/' )")
;
}
if (params.get("online") != null && (Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'");
}
if (params.get("online") != null && !(Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'");
}
if (params.get("sortName") != null) {
if (params.get("order") == null) {
sqlBuild.append(" order by #{sortName} ");
}else {
sqlBuild.append(" order by #{sortName} #{order}");
}
}
return sqlBuild.toString();
}
public String queryGbChannelByChannelDeviceIdAndGbDeviceId(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(BASE_SQL_FOR_CAMERA_DEVICE);
sqlBuild.append(" where channel_type = 0 ");
if (params.get("query") != null) {
sqlBuild.append(" AND (coalesce(gb_device_id, device_id) LIKE concat('%',#{query},'%') escape '/'" +
" OR coalesce(gb_name, name) LIKE concat('%',#{query},'%') escape '/' )")
;
sqlBuild.append(" where coalesce(wdc.gb_device_id, wdc.device_id) = #{channelDeviceId}");
if (params.get("gbDeviceId") != null) {
sqlBuild.append(" AND wdc.data_type = 1 and wd.device_id = #{gbDeviceId}");
}
if (params.get("online") != null && (Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(gb_status, status) = 'ON'");
}
if (params.get("online") != null && !(Boolean)params.get("online")) {
sqlBuild.append(" AND coalesce(gb_status, status) = 'OFF'");
}
if (params.get("containMobileDevice") != null && !(Boolean)params.get("containMobileDevice")) {
sqlBuild.append(" AND gb_ptz_type = 99");
}
if (params.get("groupDeviceId") != null) {
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) = #{groupDeviceId}");
}else {
sqlBuild.append(" AND coalesce(gb_parent_id, parent_id) is null");
}
return sqlBuild.toString();
}
public String queryListByDeviceIds(Map<String, Object> params ){
StringBuilder sqlBuild = new StringBuilder();
sqlBuild.append(BASE_SQL_FOR_CAMERA_DEVICE);
sqlBuild.append(" where coalesce(wdc.gb_device_id, wdc.device_id) in");
List<String> deviceIds = (List<String>)params.get("deviceIds");
boolean first = true;
for (String deviceId : deviceIds) {
if (!first) {
sqlBuild.append(",");
}
sqlBuild.append(deviceId);
first = false;
}
sqlBuild.append(" )");
return sqlBuild.toString() ;
}
}

View File

@@ -11,6 +11,8 @@ public interface IGroupService {
void add(Group group);
List<Group> queryAllChildren(Integer id);
void update(Group group);
Group queryGroupByDeviceId(String regionDeviceId);

View File

@@ -90,7 +90,8 @@ public class GroupServiceImpl implements IGroupService {
groupManager.addBusinessGroup(group);
}
private List<Group> queryAllChildren(Integer id) {
@Override
public List<Group> queryAllChildren(Integer id) {
List<Group> children = groupManager.getChildren(id);
if (ObjectUtils.isEmpty(children)) {
return children;

View File

@@ -2,18 +2,13 @@ package com.genersoft.iot.vmp.web.custom;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.conf.security.JwtUtils;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.FrontEndControlCodeForPTZ;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.service.bean.InviteErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.StreamContent;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.web.custom.bean.CameraChannel;
import com.genersoft.iot.vmp.web.custom.bean.CameraStreamContent;
import com.genersoft.iot.vmp.web.custom.bean.IdsQueryParam;
import com.genersoft.iot.vmp.web.custom.bean.PolygonQueryParam;
import com.genersoft.iot.vmp.web.custom.service.CameraChannelService;
import com.github.pagehelper.PageInfo;
@@ -24,7 +19,6 @@ import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.context.request.async.DeferredResult;
@@ -51,35 +45,17 @@ public class CameraChannelController {
@Operation(summary = "查询摄像机列表, 只查询当前虚拟组织下的", security = @SecurityRequirement(name = JwtUtils.HEADER))
@Parameter(name = "page", description = "当前页")
@Parameter(name = "count", description = "每页查询数量")
@Parameter(name = "query", description = "查询内容")
@Parameter(name = "sortName", description = "排序字段名")
@Parameter(name = "order", description = "排序方式(升序 asc 或降序 desc ")
@Parameter(name = "groupAlias", description = "分组别名")
@Parameter(name = "geoCoordSys", description = "坐标系类型WGS84,GCJ02、BD09")
@Parameter(name = "status", description = "摄像头状态")
@Parameter(name = "containMobileDevice", description = "是否包含移动设备")
public PageInfo<CameraChannel> queryListInCurrentGroup(@RequestParam(required = false, value = "page", defaultValue = "1" )Integer page,
@RequestParam(required = false, value = "page", defaultValue = "100")Integer count,
@RequestParam(required = false) String query,
@RequestParam(required = false) String sortName,
@RequestParam(required = false) String order,
@RequestParam(required = true) String groupAlias,
@RequestParam(required = false) Boolean status,
@RequestParam(required = false) Boolean containMobileDevice){
if (ObjectUtils.isEmpty(query)) {
query = null;
}
if (ObjectUtils.isEmpty(sortName)) {
sortName = null;
}
if (ObjectUtils.isEmpty(order)) {
order = null;
}
if (ObjectUtils.isEmpty(groupAlias)) {
groupAlias = null;
}
public PageInfo<CameraChannel> queryList(@RequestParam(required = false, value = "page", defaultValue = "1" )Integer page,
@RequestParam(required = false, value = "count", defaultValue = "100")Integer count,
String groupAlias,
@RequestParam(required = false) String geoCoordSys,
@RequestParam(required = false) Boolean status){
return channelService.queryList(page, count, query, sortName, order, groupAlias, status, containMobileDevice);
return channelService.queryList(page, count, groupAlias, status, geoCoordSys);
}
@GetMapping(value = "/camera/list-with-child")
@@ -93,15 +69,14 @@ public class CameraChannelController {
@Parameter(name = "groupAlias", description = "分组别名")
@Parameter(name = "geoCoordSys", description = "坐标系类型WGS84,GCJ02、BD09")
@Parameter(name = "status", description = "摄像头状态")
@Parameter(name = "containMobileDevice", description = "是否包含移动设备")
public PageInfo<CameraChannel> list(@RequestParam(required = false, value = "page", defaultValue = "1" )Integer page,
public PageInfo<CameraChannel> queryListWithChild(@RequestParam(required = false, value = "page", defaultValue = "1" )Integer page,
@RequestParam(required = false, value = "page", defaultValue = "100")Integer count,
@RequestParam(required = false) String query,
@RequestParam(required = false) String sortName,
@RequestParam(required = false) String order,
@RequestParam(required = false) String groupAlias,
@RequestParam(required = false) Boolean status,
@RequestParam(required = false) Boolean containMobileDevice){
String groupAlias,
@RequestParam(required = false) String geoCoordSys,
@RequestParam(required = false) Boolean status){
if (ObjectUtils.isEmpty(query)) {
query = null;
}
@@ -115,7 +90,7 @@ public class CameraChannelController {
groupAlias = null;
}
return channelService.queryList(page, count, query, sortName, order, groupAlias, status, containMobileDevice);
return channelService.queryListWithChild(page, count, query, sortName, order, groupAlias, status, geoCoordSys);
}
@GetMapping(value = "/camera/one")
@@ -138,20 +113,20 @@ public class CameraChannelController {
@Parameter(name = "longitude", description = "经度")
@Parameter(name = "latitude", description = "纬度")
@Parameter(name = "geoCoordSys", description = "坐标系类型WGS84,GCJ02、BD09")
public CameraChannel updateCamera(String deviceId,
public void updateCamera(String deviceId,
@RequestParam(required = false) String deviceCode,
@RequestParam(required = false) String name,
@RequestParam(required = false) Double longitude,
@RequestParam(required = false) Double latitude,
@RequestParam(required = false) String geoCoordSys) {
return channelService.updateCamera(deviceId, deviceCode, name, longitude, latitude, geoCoordSys);
channelService.updateCamera(deviceId, deviceCode, name, longitude, latitude, geoCoordSys);
}
@PostMapping(value = "/camera/list/ids")
@ResponseBody
@Operation(summary = "根据编号查询多个摄像头信息", security = @SecurityRequirement(name = JwtUtils.HEADER))
public List<CameraChannel> queryListByNos(@RequestBody IdsQueryParam param) {
return channelService.queryListByNos(deviceId, deviceCode, name, longitude, latitude, geoCoordSys);;
public List<CameraChannel> queryListByDeviceIds(@RequestBody List<String> deviceIds) {
return channelService.queryListByDeviceIds(deviceIds);
}
@GetMapping(value = "/camera/list/box")

View File

@@ -13,4 +13,9 @@ public class CameraChannel extends CommonGBChannel {
@Setter
@Schema(description = "摄像头设备国标编号")
private String deviceCode;
@Getter
@Setter
@Schema(description = "图标路径")
private String icon;
}

View File

@@ -0,0 +1,31 @@
package com.genersoft.iot.vmp.web.custom.bean;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
public class CameraGroup extends Group {
@Getter
private CameraGroup parent;
@Getter
private final List<CameraGroup> child = new ArrayList<>();
public void setParent(CameraGroup parent) {
if (parent == null) {
return;
}
this.parent = parent;
parent.addChild(this);
}
public void addChild(CameraGroup child) {
this.child.add(child);
if (this.parent != null) {
this.parent.addChild(child);
}
}
}

View File

@@ -1,24 +1,24 @@
package com.genersoft.iot.vmp.web.custom.service;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.common.enums.ChannelDataType;
import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.conf.exception.ControllerException;
import com.genersoft.iot.vmp.gb28181.bean.CommonGBChannel;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.FrontEndControlCodeForPTZ;
import com.genersoft.iot.vmp.gb28181.bean.Group;
import com.genersoft.iot.vmp.gb28181.dao.CommonGBChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.gb28181.dao.DeviceMapper;
import com.genersoft.iot.vmp.gb28181.dao.GroupMapper;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelControlService;
import com.genersoft.iot.vmp.gb28181.service.IGbChannelPlayService;
import com.genersoft.iot.vmp.gb28181.service.IGroupService;
import com.genersoft.iot.vmp.service.bean.ErrorCallback;
import com.genersoft.iot.vmp.utils.Coordtransform;
import com.genersoft.iot.vmp.vmanager.bean.ErrorCode;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.genersoft.iot.vmp.web.custom.bean.CameraChannel;
import com.genersoft.iot.vmp.web.custom.bean.CameraGroup;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.core.util.Assert;
@@ -27,9 +27,11 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.context.request.async.DeferredResult;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
@@ -44,6 +46,9 @@ public class CameraChannelService implements CommandLineRunner {
@Autowired
private GroupMapper groupMapper;
@Autowired
private IGroupService groupService;
@Autowired
private RedisTemplate<Object, Object> redisTemplate;
@@ -62,13 +67,31 @@ public class CameraChannelService implements CommandLineRunner {
}
public PageInfo<CameraChannel> queryList(Integer page, Integer count, String query, String sortName, String order, String groupAlias, Boolean status, Boolean containMobileDevice) {
public PageInfo<CameraChannel> queryList(Integer page, Integer count, String groupAlias, Boolean status, String geoCoordSys) {
// 构建组织结构信息
Group group = groupMapper.queryGroupByAlias(groupAlias);
Assert.notNull(group, "获取组织结构失败");
String groupDeviceId = group.getDeviceId();
// 构建分页
PageHelper.startPage(page, count);
List<CameraChannel> all = channelMapper.queryListForSy(groupDeviceId, status);
PageInfo<CameraChannel> groupPageInfo = new PageInfo<>(all);
List<CameraChannel> list = addIconPathAndPositionForCameraChannelList(groupPageInfo.getList(), geoCoordSys);
groupPageInfo.setList(list);
return groupPageInfo;
}
public PageInfo<CameraChannel> queryListWithChild(Integer page, Integer count, String query, String sortName, String order, String groupAlias, Boolean status, String geoCoordSys) {
// 构建组织结构信息
CameraGroup group = groupMapper.queryGroupByAlias(groupAlias);
Assert.notNull(group, "获取组织结构失败");
String groupDeviceId = group.getDeviceId();
// 获取所有子节点
List<CameraGroup> groupList = queryAllGroupChildren(group.getId(), group.getBusinessGroup());
groupList.add(group);
// 构建分页
PageHelper.startPage(page, count);
if (query != null) {
@@ -77,35 +100,70 @@ public class CameraChannelService implements CommandLineRunner {
.replaceAll("_", "/_");
}
List<CameraChannel> all = channelMapper.queryListForSy(query, sortName, order, groupDeviceId, status, containMobileDevice);
List<CameraChannel> all = channelMapper.queryListWithChildForSy(query, sortName, order, groupList, status);
PageInfo<CameraChannel> groupPageInfo = new PageInfo<>(all);
List<CameraChannel> list = addIconPathForCameraChannelList(groupPageInfo.getList());
List<CameraChannel> list = addIconPathAndPositionForCameraChannelList(groupPageInfo.getList(), geoCoordSys);
groupPageInfo.setList(list);
return groupPageInfo;
}
// 获取所有子节点
private List<CameraGroup> queryAllGroupChildren(int groupId, String businessGroup) {
Map<Integer, CameraGroup> groupMap = groupMapper.queryByBusinessGroupForMap(businessGroup);
for (CameraGroup cameraGroup : groupMap.values()) {
cameraGroup.setParent(groupMap.get(cameraGroup.getParentId()));
}
CameraGroup cameraGroup = groupMap.get(groupId);
if (cameraGroup == null) {
return Collections.emptyList();
}else {
return cameraGroup.getChild();
}
}
/**
* 为通道增加图片信息
* 为通道增加图片信息和转换坐标系
*/
private List<CameraChannel> addIconPathForCameraChannelList(List<CameraChannel> channels) {
private List<CameraChannel> addIconPathAndPositionForCameraChannelList(List<CameraChannel> channels, String geoCoordSys) {
// 读取redis 图标信息
JSONArray jsonArray = (JSONArray) redisTemplate.opsForValue().get("machineInfo");
Map<String, String> pathMap = new HashMap<>();
if (jsonArray != null && !jsonArray.isEmpty()) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
String machineType = jsonObject.getString("machineType");
String imagesPath = jsonObject.getString("imagesPath");
if (machineType != null && imagesPath != null) {
pathMap.put(machineType, imagesPath);
}
}
}else {
log.warn("[读取通道图标信息失败]");
}
for (CameraChannel channel : channels) {
if (channel.getGbModel() != null && pathMap.get(channel.getGbModel()) != null) {
channel.setIcon(pathMap.get(channel.getGbModel()));
}
// 坐标系转换
if (geoCoordSys != null && channel.getGbLongitude() != null && channel.getGbLatitude() != null
&& channel.getGbLongitude() > 0 && channel.getGbLatitude() > 0) {
if (geoCoordSys.equalsIgnoreCase("GCJ02")) {
Double[] position = Coordtransform.WGS84ToGCJ02(channel.getGbLongitude(), channel.getGbLatitude());
channel.setGbLongitude(position[0]);
channel.setGbLatitude(position[1]);
}else if (geoCoordSys.equalsIgnoreCase("BD09")) {
Double[] gcj02Position = Coordtransform.WGS84ToGCJ02(channel.getGbLongitude(), channel.getGbLatitude());
Double[] position = Coordtransform.GCJ02ToBD09(gcj02Position[0], gcj02Position[1]);
channel.setGbLongitude(position[0]);
channel.setGbLatitude(position[1]);
}
}
}
return channels;
}
private CommonGBChannel queryChannelByDeviceIdAndDeviceCode(String deviceId, String deviceCode) {
CommonGBChannel channel = null;
if (deviceCode != null) {
// Device device = deviceMapper.getDeviceByDeviceId(deviceId);
// Assert.notNull(device, "设备不存在:" + deviceCode);
// Integer deviceDbId = device.getId();
channel = channelMapper.queryGbChannelByChannelDeviceIdAndGbDeviceId(deviceId, deviceCode);
}else {
channel = channelMapper.queryByDeviceId(deviceId);
}
return channel;
}
public CameraChannel queryOne(String deviceId, String deviceCode, String geoCoordSys) {
CommonGBChannel channel = queryChannelByDeviceIdAndDeviceCode(deviceId, deviceCode);
CommonGBChannel channel = channelMapper.queryGbChannelByChannelDeviceIdAndGbDeviceId(deviceId, deviceCode);
Assert.notNull(channel, "通道不存在");
if (geoCoordSys != null && channel.getGbLongitude() != null && channel.getGbLatitude() != null
@@ -135,7 +193,7 @@ public class CameraChannelService implements CommandLineRunner {
* @param callback 点播结果的回放
*/
public void play(String deviceId, String deviceCode, ErrorCallback<StreamInfo> callback) {
CommonGBChannel channel = queryChannelByDeviceIdAndDeviceCode(deviceId, deviceCode);
CommonGBChannel channel = channelMapper.queryGbChannelByChannelDeviceIdAndGbDeviceId(deviceId, deviceCode);
Assert.notNull(channel, "通道不存在");
channelPlayService.play(channel, null, userSetting.getRecordSip(), callback);
}
@@ -146,13 +204,13 @@ public class CameraChannelService implements CommandLineRunner {
* @param deviceCode 通道对应的国标设备的编号
*/
public void stopPlay(String deviceId, String deviceCode) {
CommonGBChannel channel = queryChannelByDeviceIdAndDeviceCode(deviceId, deviceCode);
CommonGBChannel channel = channelMapper.queryGbChannelByChannelDeviceIdAndGbDeviceId(deviceId, deviceCode);
Assert.notNull(channel, "通道不存在");
channelPlayService.stopPlay(channel);
}
public void ptz(String deviceId, String deviceCode, String command, Integer speed, ErrorCallback<String> callback) {
CommonGBChannel channel = queryChannelByDeviceIdAndDeviceCode(deviceId, deviceCode);
CommonGBChannel channel = channelMapper.queryGbChannelByChannelDeviceIdAndGbDeviceId(deviceId, deviceCode);
Assert.notNull(channel, "通道不存在");
if (speed == null) {
@@ -207,6 +265,36 @@ public class CameraChannelService implements CommandLineRunner {
channelControlService.ptz(channel, controlCode, callback);
}
public CameraChannel updateCamera(String deviceId, String deviceCode, String name, Double longitude, Double latitude, String geoCoordSys) {
public void updateCamera(String deviceId, String deviceCode, String name, Double longitude, Double latitude, String geoCoordSys) {
CommonGBChannel commonGBChannel = channelMapper.queryGbChannelByChannelDeviceIdAndGbDeviceId(deviceId, deviceCode);
Assert.notNull(commonGBChannel, "通道不存在");
commonGBChannel.setGbName(name);
if (geoCoordSys != null && longitude != null && latitude != null
&& longitude > 0 && latitude > 0) {
if (geoCoordSys.equalsIgnoreCase("GCJ02")) {
Double[] position = Coordtransform.WGS84ToGCJ02(longitude, latitude);
commonGBChannel.setGbLongitude(position[0]);
commonGBChannel.setGbLatitude(position[1]);
}else if (geoCoordSys.equalsIgnoreCase("BD09")) {
Double[] gcj02Position = Coordtransform.WGS84ToGCJ02(longitude, latitude);
Double[] position = Coordtransform.GCJ02ToBD09(gcj02Position[0], gcj02Position[1]);
commonGBChannel.setGbLongitude(position[0]);
commonGBChannel.setGbLatitude(position[1]);
}else {
commonGBChannel.setGbLongitude(longitude);
commonGBChannel.setGbLatitude(latitude);
}
}else {
commonGBChannel.setGbLongitude(longitude);
commonGBChannel.setGbLatitude(latitude);
}
channelMapper.update(commonGBChannel);
}
public List<CameraChannel> queryListByDeviceIds(List<String> deviceIds) {
return channelMapper.queryListByDeviceIds(deviceIds);
}
}