diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/dal/mysql/region/RegionMapper.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/dal/mysql/region/RegionMapper.java new file mode 100644 index 000000000..c0c6de591 --- /dev/null +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/dal/mysql/region/RegionMapper.java @@ -0,0 +1,40 @@ +package cn.iocoder.yudao.module.datacenter.dal.mysql.region; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionPageReqVO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * 区域 Mapper + * + * @author 管理员 + */ +@Mapper +public interface RegionMapper extends BaseMapperX { + + default PageResult selectPage(RegionPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(RegionDO::getIndexCode, reqVO.getIndexCode()) + .likeIfPresent(RegionDO::getName, reqVO.getName()) + .eqIfPresent(RegionDO::getRegionType, reqVO.getRegionType()) + .eqIfPresent(RegionDO::getCatalogType, reqVO.getCatalogType()) + .betweenIfPresent(RegionDO::getCreateTime, reqVO.getCreateTime()) + .betweenIfPresent(RegionDO::getUpdateTime, reqVO.getUpdateTime()) + .eqIfPresent(RegionDO::getStatus, reqVO.getStatus()) + .orderByDesc(RegionDO::getId)); + } + + default RegionDO selectByIndexCode(String indexCode) { + return selectOne(new LambdaQueryWrapperX().eq(RegionDO::getIndexCode, indexCode)); + } + + default RegionDO selectByRegionName(String regionName) { + return selectOne(new LambdaQueryWrapperX().eq(RegionDO::getName, regionName)); + } + +} \ No newline at end of file diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/region/RegionService.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/region/RegionService.java new file mode 100644 index 000000000..a898e9212 --- /dev/null +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/region/RegionService.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.datacenter.service.region; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.RegionCameraListDTO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDTO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionPageReqVO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionSaveReqVO; + +import javax.validation.Valid; +import java.util.List; + +/** + * 区域 Service 接口 + * + * @author 管理员 + */ +public interface RegionService { + + /** + * 创建区域 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createRegion(@Valid RegionSaveReqVO createReqVO); + + /** + * 更新区域 + * + * @param updateReqVO 更新信息 + */ + void updateRegion(@Valid RegionSaveReqVO updateReqVO); + + /** + * 删除区域 + * + * @param id 编号 + */ + void deleteRegion(Long id); + + /** + * 获得区域 + * + * @param id 编号 + * @return 区域 + */ + RegionDO getRegion(Long id); + + /** + * 获得区域分页 + * + * @param pageReqVO 分页查询 + * @return 区域分页 + */ + PageResult getRegionPage(RegionPageReqVO pageReqVO); + List getRegionList(); + RegionDO selectByIndexCode(String indexCode); + RegionDO selectByRegionName(String regionName); +} \ No newline at end of file diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/region/RegionServiceImpl.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/region/RegionServiceImpl.java new file mode 100644 index 000000000..b7c7d53b6 --- /dev/null +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/service/region/RegionServiceImpl.java @@ -0,0 +1,146 @@ +package cn.iocoder.yudao.module.datacenter.service.region; + +import cn.iocoder.yudao.framework.common.exception.ErrorCode; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.CameraDTO; +import cn.iocoder.yudao.module.datacenter.controller.app.camera.vo.RegionCameraListDTO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionDTO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionPageReqVO; +import cn.iocoder.yudao.module.datacenter.controller.app.region.vo.RegionSaveReqVO; +import cn.iocoder.yudao.module.datacenter.dal.mysql.camera.CameraMapper; +import cn.iocoder.yudao.module.datacenter.dal.mysql.region.RegionMapper; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import javax.annotation.Resource; + +import java.util.*; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; + + +/** + * 区域 Service 实现类 + * + * @author 管理员 + */ +@Service +@Validated +public class RegionServiceImpl implements RegionService { + + @Resource + private RegionMapper regionMapper; + + @Resource + private CameraMapper cameraMapper; + + @Override + public Long createRegion(RegionSaveReqVO createReqVO) { + // 插入 + RegionDO region = BeanUtils.toBean(createReqVO, RegionDO.class); + regionMapper.insert(region); + // 返回 + return region.getId(); + } + + @Override + public void updateRegion(RegionSaveReqVO updateReqVO) { + // 校验存在 + validateRegionExists(updateReqVO.getId()); + // 更新 + RegionDO updateObj = BeanUtils.toBean(updateReqVO, RegionDO.class); + regionMapper.updateById(updateObj); + } + + @Override + public void deleteRegion(Long id) { + // 校验存在 + validateRegionExists(id); + // 删除 + regionMapper.deleteById(id); + } + + private void validateRegionExists(Long id) { + if (regionMapper.selectById(id) == null) { + throw exception(new ErrorCode(99999, "区域不存在")); + } + } + + @Override + public RegionDO getRegion(Long id) { + return regionMapper.selectById(id); + } + + @Override + public PageResult getRegionPage(RegionPageReqVO pageReqVO) { + return regionMapper.selectPage(pageReqVO); + } + + @Override + public List getRegionList() { + List regionDOListResult = regionMapper.selectList(); + List regions = new ArrayList<>(); + Map regionMap = new HashMap<>(); + for (RegionDO regionDO : regionDOListResult) { + RegionCameraListDTO temp = new RegionCameraListDTO(); + temp.setRegionIndexCode(regionDO.getIndexCode()); + temp.setRegionName(regionDO.getName()); + temp.setParentIndexCode(regionDO.getParentIndexCode()); + temp.setLeaf(regionDO.getLeaf()); + System.out.println("regionDO.getLeaf(): " + regionDO.getLeaf() + " temp.getLeaf(): " + temp.getLeaf()); + if(temp.getLeaf() == 1) { + cameraMapper.selectCameraByRegionIndexCode(temp.getRegionIndexCode()).forEach(cameraDO -> { + temp.getCameraList().add(BeanUtils.toBean(cameraDO, CameraDTO.class)); + }); + } + regions.add(temp); + regionMap.put(regionDO.getIndexCode(), temp); + } + + System.out.println("regionMap:"+regionMap); + + // 用于存储已经添加到 parent 的子区域,避免重复添加 + Set addedChildren = new HashSet<>(); + + for (RegionCameraListDTO regionDTO : regions) { + if(regionDTO.getParentIndexCode() != null && !"-1".equals(regionDTO.getParentIndexCode())) { + System.out.println("regionchild:"+regionDTO); + RegionCameraListDTO parentRegion = regionMap.get(regionDTO.getParentIndexCode()); + if (parentRegion != null) { + parentRegion.getChildren().add(regionDTO); + addedChildren.add(regionDTO); // 记录该子节点已经被添加到父区域 + } + } + } + + List result = new ArrayList<>(); + for (RegionCameraListDTO region : regions) { + // 只保留根节点 + if ("-1".equals(region.getParentIndexCode())) { + result.add(buildTree(region, regionMap)); + } + } + return result; + } + + private RegionCameraListDTO buildTree(RegionCameraListDTO region, Map regionMap) { + // 递归子节点 + for (RegionCameraListDTO child : region.getChildren()) { + buildTree(child, regionMap); // 递归构建子树 + } + return region; + } + + @Override + public RegionDO selectByIndexCode(String indexCode) { + return regionMapper.selectByIndexCode(indexCode); + } + + @Override + public RegionDO selectByRegionName(String regionName) { + return regionMapper.selectByRegionName(regionName); + } + +} \ No newline at end of file diff --git a/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/utlis/IntegrationURL.java b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/utlis/IntegrationURL.java new file mode 100644 index 000000000..5671fd404 --- /dev/null +++ b/ludu-module-datacenter/ludu-module-datacenter-biz/src/main/java/cn/iocoder/yudao/module/datacenter/utlis/IntegrationURL.java @@ -0,0 +1,511 @@ +package cn.iocoder.yudao.module.datacenter.utlis; + +import com.alibaba.fastjson.JSONObject; +import com.hikvision.artemis.sdk.ArtemisHttpUtil; +import com.hikvision.artemis.sdk.config.ArtemisConfig; + +import java.util.HashMap; +import java.util.Map; + +public class IntegrationURL { + + + //设置平台参数,根据实际情况,设置host appKey appSecret 三个参数. + static { + ArtemisConfig.host = "127.0.0.1:443"; // 平台的ip端口 + ArtemisConfig.appKey = "29180881"; // 密钥appkey + ArtemisConfig.appSecret = "XO0wCAYGi4KV70ybjznx";// 密钥appSecret + } + + //设置OpenAPI接口的上下文 + public static final String ARTEMIS_PATH = "/artemis"; + + + // 获取根区域信息 + public static String getRegionsRootURL(String accessToken) { + + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/regions/root"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, null, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + //查询区域列表v2 + public static String getRegionListURL(String resourceType,int pageNo,int pageSize,String accessToken) { + + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/irds/v2/region/nodesByParams"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("resourceType",resourceType); + jsonBody.put("pageNo", pageNo); + jsonBody.put("pageSize", pageSize); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 根据区域编号获取下一级区域列表v2 + public static String getRegionListByParentIndexCodeURL(String parentIndexCode, String resourceType,int pageNo,int pageSize,String accessToken) { + + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v2/regions/subRegions"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("parentIndexCode", parentIndexCode); + jsonBody.put("resourceType",resourceType); + jsonBody.put("pageNo", pageNo); + jsonBody.put("pageSize", pageSize); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 分页获取区域列表 + public static String getRegionListPageURL(int pageNo,int pageSize,String accessToken) { + + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/regions"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("pageNo", pageNo); + jsonBody.put("pageSize", pageSize); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 根据编号获取区域详细信息 + public static String getRegionByIndexCodesURL(String[] indexCodes,String accessToken) { + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/region/regionCatalog/regionInfo"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("indexCodes", indexCodes); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 增量获取区域数据 + public static String getRegionTimeRangeURL(String startTime, String pageNo, String pageSize,String accessToken) { + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/region/timeRange"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("startTime", startTime); + jsonBody.put("pageNo", pageNo); + jsonBody.put("pageSize", pageSize); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + //查询监控点列表v2 + public static String getCameraListURL(int pageNo,int pageSize,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v2/camera/search"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("pageNo", pageNo); //当前页码 + jsonBody.put("pageSize", pageSize); //分页大小 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //分页获取监控点资源 + public static String getCameraResourceURL(int pageNo,int pageSize,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/cameras"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("pageNo", pageNo); //当前页码 + jsonBody.put("pageSize", pageSize); //分页大小 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 根据区域编号获取下级监控点列表 + public static String getCameraListByRegionIndexCodeURL(String regionIndexCode, int pageNo,int pageSize,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/regions/regionIndexCode/cameras"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("regionIndexCode", regionIndexCode); //区域编号 + jsonBody.put("pageNo", pageNo); //当前页码 + jsonBody.put("pageSize", pageSize); //分页大小 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 根据编号获取监控点详细信息 + public static String getCameraByCameraIndexCodeURL(String cameraIndexCode,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/cameras/indexCode"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", cameraIndexCode); //监控点唯一标识 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + // 增量获取监控点数据 + public static String getCameraTimeRangeURL(String startTime, int pageNo, int pageSize, String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v1/camera/timeRange"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("startTime", startTime); + jsonBody.put("pageNo", pageNo); //当前页码 + jsonBody.put("pageSize", pageSize); //分页大小 + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //获取监控点预览取流URLv2 + public static String getPreviewURL(String cameraIndexCode, Integer streamType, String protocol, Integer transmode, String expand, String streamform, String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/video/v2/cameras/previewURLs"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", cameraIndexCode); //监控点唯一标识,分页获取监控点资源接口获取返回参数cameraIndexCode + jsonBody.put("streamType", streamType); + jsonBody.put("protocol", protocol); + jsonBody.put("transmode", transmode); + jsonBody.put("expand", expand); + jsonBody.put("streamform", streamform); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //获取监控点回放取流URLv2 + public static String getPlaybackURL(String cameraIndexCode, Integer recordLocation, String protocol, Integer transmode, String beginTime, String endTime, String uuid, String expand, String streamform, Integer lockType,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/video/v2/cameras/playbackURLs"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", cameraIndexCode);//监控点唯一标识,分页获取监控点资源接口获取返回参数cameraIndexCode + jsonBody.put("recordLocation", recordLocation); + jsonBody.put("protocol", protocol); + jsonBody.put("transmode", transmode); + jsonBody.put("beginTime",beginTime );//开始查询时间(IOS8601格式:yyyy-MM-dd’T’HH:mm:ss.SSSXXX)例如北京时间:2017-06-14T00:00:00.000+08:00, + jsonBody.put("endTime",endTime);//结束时间 + jsonBody.put("uuid",uuid ); + jsonBody.put("expand",expand ); + jsonBody.put("streamform",streamform ); + jsonBody.put("lockType",lockType ); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //监控点3D放大 + public static String getControlURL(String cameraIndexCode,int startX,int startY,int endX,int endY,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/video/v1/ptzs/selZoom"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode",cameraIndexCode ); + jsonBody.put("startX",startX ); + jsonBody.put("startY",startY ); + jsonBody.put("endX",endX ); + jsonBody.put("endY",endY ); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //根据监控点编号进行云台操作 + public static String getYunTaiOperationURL(String cameraIndexCode, Integer action, String command, Integer speed, Integer presetIndex,String accessToken) { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/video/v1/ptzs/controlling"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + jsonBody.put("cameraIndexCode", cameraIndexCode); + jsonBody.put("action",action ); + jsonBody.put("command",command ); + jsonBody.put("speed",speed ); + jsonBody.put("presetIndex",presetIndex ); + String body = jsonBody.toJSONString(); + + //请求头添加 access_token认证 + Map attributesMap = new HashMap<>(); + attributesMap.put("access_token", accessToken); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , attributesMap);// post请求application/json类型参数 + return result; + } + + + //access_token认证 + public static String getAccessTokenURL() { + + //设置接口的URI地址 + final String previewURLsApi = ARTEMIS_PATH + "/api/v1/oauth/token"; + Map path = new HashMap(2) { + { + put("https://", previewURLsApi);//根据现场环境部署确认是http还是https + } + }; + + //设置参数提交方式 + String contentType = "application/json"; + + //组装请求参数 + JSONObject jsonBody = new JSONObject(); + String body = jsonBody.toJSONString(); + + //调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, null, null, null, contentType , null);// post请求application/json类型参数 + + return result; + } + + + + + +}