/*
|
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
|
*
|
* Redistribution and use in source and binary forms, with or without
|
* modification, are permitted provided that the following conditions are met:
|
*
|
* Redistributions of source code must retain the above copyright notice,
|
* this list of conditions and the following disclaimer.
|
* Redistributions in binary form must reproduce the above copyright
|
* notice, this list of conditions and the following disclaimer in the
|
* documentation and/or other materials provided with the distribution.
|
* Neither the name of the dreamlu.net developer nor the names of its
|
* contributors may be used to endorse or promote products derived from
|
* this software without specific prior written permission.
|
* Author: Chill 庄骞 (smallchill@163.com)
|
*/
|
package org.springblade.jfpt.equipment.controller;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
|
import io.swagger.annotations.*;
|
import lombok.AllArgsConstructor;
|
import org.omg.PortableInterceptor.INACTIVE;
|
import org.springblade.common.vo.DeptVo;
|
import org.springblade.core.boot.ctrl.BladeController;
|
import org.springblade.core.mp.support.Condition;
|
import org.springblade.core.mp.support.Query;
|
import org.springblade.core.tool.api.R;
|
import org.springblade.core.tool.constant.BladeConstant;
|
import org.springblade.core.tool.utils.Func;
|
import org.springblade.jfpt.catalog.entitly.catalog;
|
import org.springblade.jfpt.catalog.service.catalogService;
|
import org.springblade.jfpt.deploy.service.IDeployService;
|
import org.springblade.jfpt.equipment.entity.Equipment;
|
import org.springblade.jfpt.equipment.entity.EquipmentPlayInfo;
|
import org.springblade.jfpt.equipment.feign.DeptFeignApi;
|
import org.springblade.jfpt.equipment.feign.RegionFeignApi;
|
import org.springblade.jfpt.equipment.service.IEquipmentService;
|
import org.springblade.jfpt.equipment.vo.EquipmentVO;
|
import org.springblade.jfpt.equipment.vo.EquipmentVOS;
|
import org.springblade.jfpt.equipment.wrapper.EqWrapper;
|
import org.springblade.jfpt.hk.constant.HkConstant;
|
import org.springblade.jfpt.hk.constant.ProtocolConstant;
|
import org.springblade.jfpt.hk.util.GetCameraPreviewURL;
|
import org.springblade.system.entity.Region;
|
import org.springblade.system.user.entity.User;
|
import org.springframework.web.bind.annotation.*;
|
import springfox.documentation.annotations.ApiIgnore;
|
|
import javax.servlet.http.HttpServletResponse;
|
import javax.validation.Valid;
|
import java.text.ParseException;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
/**
|
* 设备管理控制器
|
*
|
* @author BladeX
|
* @since 2020-07-01
|
*/
|
@RestController
|
@AllArgsConstructor
|
@RequestMapping("equipment/equipment")
|
@Api(value = "", tags = "接口")
|
public class EquipmentController extends BladeController {
|
|
private final IEquipmentService equipmentService;
|
private final IDeployService iDeployService;
|
private final org.springblade.jfpt.catalog.service.catalogService catalogService;
|
|
private final DeptFeignApi deptFeignApi;
|
|
private final RegionFeignApi regionFeignApi;
|
|
/**
|
* 详情
|
*/
|
@GetMapping("/detail")
|
@ApiOperationSupport(order = 1)
|
@ApiOperation(value = "详情", notes = "传入equipment")
|
public R<EquipmentVOS> detail(Equipment equipment, HttpServletResponse response) {
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
response.setHeader("Access-Control-Allow-Credentials", "true");
|
/*Equipment detail = equipmentService.getOne(Condition.getQueryWrapper(equipment));*/
|
EquipmentVOS equipmentVOS = equipmentService.selectInfo(equipment);
|
//获取部门数据
|
List<DeptVo> deptVos = deptFeignApi.selDeptList();
|
if (null!=equipmentVOS.getDeptId()){
|
String[] split =equipmentVOS.getDeptId().split(",");
|
List<String> list = Arrays.asList(split);
|
StringBuffer deptNameBuiffer = new StringBuffer();
|
//数据匹配封装
|
for (String deptId:list) {
|
for (DeptVo deptVo:deptVos) {
|
if (deptId.equals(deptVo.getId().toString())){
|
deptNameBuiffer.append(deptVo.getDeptName()).append("/");
|
}
|
}
|
}
|
//封装部门名称数据
|
equipmentVOS.setDeptName(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1));
|
}
|
return R.data(equipmentVOS);
|
}
|
|
/**
|
* 分页
|
*/
|
@GetMapping("/list")
|
@ApiOperationSupport(order = 2)
|
@ApiOperation(value = "分页", notes = "传入equipment")
|
public R<IPage<Equipment>> list(Equipment equipment, Query query) {
|
IPage<Equipment> pages = equipmentService.page(Condition.getPage(query), Condition.getQueryWrapper(equipment));
|
return R.data(pages);
|
}
|
|
/**
|
* 查询所有
|
*/
|
@GetMapping("/listAll")
|
@ApiOperationSupport(order = 2)
|
@ApiOperation(value = "分页", notes = "传入equipment")
|
public R<List<EquipmentVO>> listAll(EquipmentVO equipment, Query query) throws ParseException {
|
List<EquipmentVO> pages = equipmentService.listAll(equipment);
|
|
for (int j = 0; j < pages.size(); j++) {
|
String expireTime = pages.get(j).getExpireTime();
|
//1.获取当前时间
|
Date dd = new Date();
|
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
String end = sim.format(dd);
|
//把string类型转换为long类型的
|
if (expireTime != null) {
|
long st = sim.parse(expireTime).getTime();
|
long en = sim.parse(end).getTime();
|
//计算天数
|
int day = (int) ((st - en) / 86400000);
|
if (day <= 30) {
|
pages.get(j).setType(1);
|
} else {
|
pages.get(j).setType(0);
|
}
|
}
|
|
|
//判断设备是否在线
|
String Heartbeat = pages.get(j).getHeartbeat();
|
if (Heartbeat != null){
|
long st = sim.parse(Heartbeat).getTime();
|
long en = sim.parse(end).getTime();
|
if ((en - st) >= (60 * 60 * 24 * 1000)){
|
pages.get(j).setOnlineStatus("0");
|
}else{
|
pages.get(j).setOnlineStatus("1");
|
}
|
}else{
|
pages.get(j).setOnlineStatus("0");
|
}
|
}
|
return R.data(pages);
|
}
|
|
/**
|
* 自定义分页
|
*/
|
@GetMapping("/pages")
|
@ApiOperationSupport(order = 3)
|
@ApiOperation(value = "分页", notes = "传入equipment")
|
public R<IPage<EquipmentVO>> pages(EquipmentVO equipment, Query query, String pid, HttpServletResponse response) throws ParseException {
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
response.setHeader("Access-Control-Allow-Credentials", "true");
|
|
IPage<EquipmentVO> page = null;
|
//清空全局参数
|
childMenu = new ArrayList();
|
|
if (pid == null || pid.equals("")) {
|
//根据查询条件得到所有设备
|
page = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment, null);
|
} else {
|
List<Map<String, Object>> treedatas = catalogService.selectCatalogEqNUmber(null);
|
//根据传入的id递归出该节点下所有的设备
|
List<Map<String, Object>> childList = treeIdList(treedatas, pid);
|
|
if (childList.size() > 0) {
|
//根据查询条件得到所有设备
|
page = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment, childList);
|
} else {
|
List<Map<String, Object>> ces = catalogService.selectCatalogEqNUmber(pid);
|
List list = new ArrayList();
|
list.add(ces.get(0).get("eqid"));
|
//根据查询条件得到所有设备
|
page = equipmentService.selectEquipmentPage(Condition.getPage(query), equipment, list);
|
}
|
}
|
|
if (page != null) {
|
for (int j = 0; j < page.getRecords().size(); j++) {
|
String expireTime = page.getRecords().get(j).getExpireTime();
|
//1.获取当前时间
|
Date dd = new Date();
|
SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
String end = sim.format(dd);
|
//把string类型转换为long类型的
|
|
if (expireTime != null) {
|
long st = sim.parse(expireTime).getTime();
|
long en = sim.parse(end).getTime();
|
//计算天数
|
int day = (int) ((st - en) / 86400000);
|
if (day <= 30) {
|
page.getRecords().get(j).setType(1);
|
} else {
|
page.getRecords().get(j).setType(0);
|
}
|
}
|
}
|
}
|
|
return R.data(page);
|
}
|
|
|
/**
|
* 自定义分页(部门挂接)
|
* @param dxtype ???
|
* @param equipment 设备对象信息
|
* @param query 查询参数
|
* @param pid 组织机构Id
|
* @param response servlet 响应对象
|
*/
|
@GetMapping("/pageDept")
|
@ApiOperationSupport(order = 3)
|
@ApiOperation(value = "分页", notes = "传入equipment")
|
public R<IPage<EquipmentVO>> pageDept(EquipmentVO equipment, Query query, String pid, String dxtype, HttpServletResponse response) throws ParseException {
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
response.setHeader("Access-Control-Allow-Credentials", "true");
|
//获取部门数据
|
List<DeptVo> deptVos = deptFeignApi.selDeptList();
|
//获取设备数据信息
|
IPage<EquipmentVO> page = equipmentService.selectDeptPages(Condition.getPage(query), equipment, pid, dxtype);
|
//遍历数据
|
for (int j = 0; j < page.getRecords().size(); j++) {
|
if (null!=page.getRecords().get(j).getDeptId()){
|
String[] split = page.getRecords().get(j).getDeptId().split(",");
|
List<String> list = Arrays.asList(split);
|
StringBuffer deptNameBuiffer = new StringBuffer();
|
//数据匹配封装
|
for (String deptId:list) {
|
for (DeptVo deptVo:deptVos) {
|
if (deptId.equals(deptVo.getId().toString())){
|
deptNameBuiffer.append(deptVo.getDeptName()).append(",");
|
}
|
}
|
}
|
//封装部门名称数据
|
page.getRecords().get(j).setDeptName(deptNameBuiffer.substring(0,deptNameBuiffer.length()-1));
|
}
|
|
// String expireTime = page.getRecords().get(j).getExpireTime();
|
// //1.获取当前时间
|
// Date dd = new Date();
|
// SimpleDateFormat sim = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
// String end = sim.format(dd);
|
// //把string类型转换为long类型的
|
//
|
// if (expireTime != null) {
|
// long st = sim.parse(expireTime).getTime();
|
// long en = sim.parse(end).getTime();
|
// //计算天数
|
// int day = (int) ((st - en) / 86400000);
|
// if (day <= 30) {
|
// page.getRecords().get(j).setType(1);
|
// } else {
|
// page.getRecords().get(j).setType(0);
|
// }
|
// }
|
//
|
// //判断设备是否在线
|
// String Heartbeat = page.getRecords().get(j).getHeartbeat();
|
// if (Heartbeat != null){
|
// long st = sim.parse(Heartbeat).getTime();
|
// long en = sim.parse(end).getTime();
|
// if ((en - st) >= (60 * 60 * 24 * 1000)){
|
// page.getRecords().get(j).setOnlineStatus("0");
|
// }else{
|
// page.getRecords().get(j).setOnlineStatus("1");
|
// }
|
// }else{
|
// page.getRecords().get(j).setOnlineStatus("0");
|
// }
|
}
|
|
|
return R.data(page);
|
}
|
|
|
//子节点
|
private static List childMenu = new ArrayList();
|
|
public static List treeMenuList(List<Map<String, Object>> menuList, String pid) {
|
for (int i = 0; i < menuList.size(); i++) {
|
//遍历出父id等于参数的id,add进子节点集合
|
|
if (!pid.equals(0)) {
|
if (menuList.get(i).get("pId").toString().equals(pid)) {
|
//递归遍历下一级
|
treeMenuList(menuList, menuList.get(i).get("id").toString());
|
childMenu.add(menuList.get(i));
|
}
|
}
|
|
}
|
return childMenu;
|
}
|
|
public static List treeIdList(List<Map<String, Object>> menuList, String pid) {
|
for (int i = 0; i < menuList.size(); i++) {
|
//遍历出父id等于参数的id,add进子节点集合
|
|
if (!pid.equals(0)) {
|
if (menuList.get(i).get("pId").toString().equals(pid)) {
|
//递归遍历下一级
|
treeIdList(menuList, menuList.get(i).get("id").toString());
|
if (menuList.get(i).get("eqid") != null && !menuList.get(i).get("eqid").equals("")) {
|
childMenu.add(menuList.get(i).get("eqid"));
|
}
|
}
|
}
|
|
}
|
return childMenu;
|
|
}
|
|
/**
|
* 新增
|
*/
|
@PostMapping("/save")
|
@ApiOperationSupport(order = 4)
|
@ApiOperation(value = "新增", notes = "传入equipment")
|
public R save(@Valid @RequestBody EquipmentVOS equipment) {
|
if (equipment.getParentId() == null && equipment.getId() == null) {
|
equipment.setParentId(BladeConstant.TOP_PARENT_ID);
|
}
|
Date day = new Date();
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
equipment.setStime(df.format(day));
|
equipmentService.s(equipment);
|
String deviceNumber = equipment.getDeviceNumber();
|
String deviceName = equipment.getDeviceName();
|
String bType = "0";
|
iDeployService.insterb(deviceNumber, deviceName, bType);
|
return R.success("成功");
|
}
|
|
/**
|
* 修改
|
*/
|
@PostMapping("/update")
|
@ApiOperationSupport(order = 5)
|
@ApiOperation(value = "修改", notes = "传入equipment")
|
public R update(@Valid @RequestBody EquipmentVOS equipment) {
|
Date day = new Date();
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
equipment.setStime(df.format(day));
|
equipmentService.updateOne(equipment);
|
return R.success("修改成功");
|
}
|
|
/**
|
* 新增或修改
|
*/
|
@PostMapping("/submit")
|
@ApiOperationSupport(order = 6)
|
@ApiOperation(value = "新增或修改", notes = "传入equipment")
|
public R submit(@Valid @RequestBody EquipmentVO equipment) {
|
if (equipment.getStime() != null && equipment.getStime().equals("")) {
|
equipment.setStime(null);
|
}
|
|
if (equipment.getExpireTime() != null && equipment.getExpireTime().equals("")) {
|
equipment.setExpireTime(null);
|
}
|
|
if (equipment.getHeartbeat() != null && equipment.getHeartbeat().equals("")) {
|
equipment.setHeartbeat(null);
|
}
|
|
if (equipment.getDtype() == null || equipment.getDtype().equals("")) {
|
equipment.setDtype("0");
|
}
|
|
//判断省市区的值是否为数字或者中文字符串
|
if(null!=equipment.getProvince()){
|
//如果不是数字,则需调用接口匹配数据(直接取区、县参数)
|
if (!equipment.getDistrict().matches("^[0-9]*$") && !equipment.getCity().matches("^[0-9]*$")){
|
Region region = regionFeignApi.selRegionDetail(equipment.getDistrict(),equipment.getCity());
|
if (null!=region){
|
//封装数据
|
equipment.setProvince(region.getProvinceCode());
|
equipment.setCity(region.getCityCode());
|
equipment.setDistrict(region.getDistrictCode());
|
}
|
}
|
}
|
|
// String deviceName = equipment.getDeviceName();
|
// String deviceNumber = equipment.getDeviceNumber();
|
// String pId = equipment.getPid();
|
// if (equipment.getId() == null){
|
// catalogService.addCatalog(deviceName,deviceNumber,pId);
|
// }else{
|
// catalogService.updateCatalog(deviceName,deviceNumber,pId);
|
// }
|
|
|
return R.status(equipmentService.saveOrUpdate(equipment));
|
}
|
|
/**
|
* APP新增或修改
|
*/
|
@PostMapping("/AppSubmit")
|
@ApiOperationSupport(order = 6)
|
@ApiOperation(value = "新增或修改", notes = "传入equipment")
|
public R AppSubmit(@Valid EquipmentVO equipment) {
|
if (equipment.getStime() != null && equipment.getStime().equals("")) {
|
equipment.setStime(null);
|
}
|
|
if (equipment.getExpireTime() != null && equipment.getExpireTime().equals("")) {
|
equipment.setExpireTime(null);
|
}
|
|
if (equipment.getHeartbeat() != null && equipment.getHeartbeat().equals("")) {
|
equipment.setHeartbeat(null);
|
}
|
|
if (equipment.getDtype() == null || equipment.getDtype().equals("")) {
|
equipment.setDtype("0");
|
}
|
|
// String deviceName = equipment.getDeviceName();
|
// String deviceNumber = equipment.getDeviceNumber();
|
// String pId = equipment.getPid();
|
// if (equipment.getId() == null){
|
// catalogService.addCatalog(deviceName,deviceNumber,pId);
|
// }else{
|
// catalogService.updateCatalog(deviceName,deviceNumber,pId);
|
// }
|
|
if (equipment.getPaddress() != null && !equipment.getPaddress().equals("")) {
|
equipmentService.saveImg(equipment);
|
}
|
|
return R.status(equipmentService.saveOrUpdate(equipment));
|
}
|
|
/**
|
* 删除
|
*/
|
@PostMapping("/remove")
|
@ApiOperationSupport(order = 8)
|
@ApiOperation(value = "删除", notes = "传入ids")
|
public R remove(@ApiParam(value = "主键集合", required = true) @RequestParam String ids) {
|
return R.status(equipmentService.removeByIds(Func.toLongList(ids)));
|
}
|
|
/**
|
* 获取树形结构
|
*/
|
@GetMapping("/tree")
|
@ApiOperationSupport(order = 4)
|
@ApiOperation(value = "树形结构", notes = "树形结构")
|
public R<List<EquipmentVOS>> tree() {
|
List<EquipmentVOS> tree = equipmentService.tree();
|
return R.data(tree);
|
}
|
|
|
/**
|
* 懒加载列表
|
*/
|
@GetMapping("/lazy-list")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "deptName", value = "部门名称", paramType = "query", dataType = "string"),
|
@ApiImplicitParam(name = "fullName", value = "部门全称", paramType = "query", dataType = "string")
|
})
|
@ApiOperationSupport(order = 3)
|
@ApiOperation(value = "懒加载列表", notes = "传入dept")
|
public R<List<EquipmentVOS>> lazyList(@ApiIgnore @RequestParam Map<String, Object> dept, Long parentId) {
|
List<EquipmentVOS> list = equipmentService.lazyList(parentId, dept);
|
return R.data(EqWrapper.build().listNodeLazyVO(list));
|
}
|
|
|
/**
|
* 设备列表
|
*
|
* @param deviceType 设备类型
|
* @return
|
*/
|
@GetMapping("/selectList")
|
public R<List<EquipmentVOS>> selectList(String deviceType, HttpServletResponse response) {
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
response.setHeader("Access-Control-Allow-Credentials", "true");
|
List<EquipmentVOS> list = equipmentService.selectList(deviceType);
|
return R.data(list);
|
}
|
|
/**
|
* 修改
|
*/
|
@PostMapping("/updateexpireTime")
|
@ApiOperationSupport(order = 5)
|
@ApiOperation(value = "修改", notes = "传入equipment")
|
public R updateexpireTime(String expireTime, String deviceNumber) {
|
equipmentService.updateexpireTime(expireTime, deviceNumber);
|
return R.success("修改成功");
|
}
|
|
/**
|
* 设备故障修改
|
*/
|
@PostMapping("/updateExstate")
|
@ApiOperationSupport(order = 5)
|
@ApiOperation(value = "修改", notes = "传入equipment")
|
public R updateExstate(String state, String reason, String deviceNumber) {
|
equipmentService.updateExstate(state, reason, deviceNumber);
|
return R.success("修改成功");
|
}
|
|
|
/**
|
* 监控台统计
|
*
|
* @return
|
*/
|
@PostMapping("/SeleC")
|
public R SeleC() {
|
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");//设置日期格式
|
String time = df.format(new Date());// new Date()为获取当前系统时间
|
//设备在线数量
|
Integer integerz = equipmentService.selectEqCz();
|
//设备掉线数量
|
Integer integerd = equipmentService.selectEqCd();
|
//设备预警数量
|
List<Map<String, Object>> list = equipmentService.selectEqCy(time);
|
//设备故障数量
|
Integer integerg = equipmentService.selectEqCg();
|
Map<String, Object> map = new HashMap<String, Object>();
|
map.put("zx", integerz);
|
map.put("dx", integerd);
|
map.put("yj", list.size());
|
map.put("gz", integerg);
|
return R.data(map);
|
}
|
|
/**
|
* 监控台统计
|
* @author arsn 2021-5-6
|
* @return
|
*/
|
@PostMapping("/SeleCs")
|
public R SeleCs() {
|
return R.data(equipmentService.selEqTypeSum());
|
}
|
|
/**
|
* 获取设备视频播放的信息
|
* @param equipmentPlayInfo 视频播放地址对象,只需包含设备编号,以及视频播放格式即可
|
* @param response 响应域,设置跨域
|
* @return
|
*/
|
@GetMapping("/selectEquimentPlayInfo")
|
public R selectEquimentPlayInfo(EquipmentPlayInfo equipmentPlayInfo,HttpServletResponse response){
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
response.setHeader("Access-Control-Allow-Credentials", "true");
|
//返回
|
// equipmentService.selectEquimentPlayInfo(equipmentPlayInfo)
|
|
JSONObject res = new JSONObject();
|
|
//根据设备id获取设备编号
|
String result1 = GetCameraPreviewURL.QueryCameraPreviewURL(HkConstant.camerasID, equipmentPlayInfo.getNumber(), "encodeDevice", "deviceCode");
|
|
JSONObject jsonObject1 = JSONObject.parseObject(result1);
|
JSONObject res1 = (JSONObject) jsonObject1.get("data");
|
JSONArray arr1 = JSON.parseArray(res1.getString("list"));
|
if (arr1.size() > 0){
|
JSONObject data1 = (JSONObject) arr1.get(0);
|
String code1 = data1.get("indexCode").toString();
|
|
//根据设备编号获取子节点编号
|
String result2 = GetCameraPreviewURL.QueryCameraPreviewURL(HkConstant.camerasID, code1, "camera", "parentIndexCode");
|
|
JSONObject jsonObject2 = JSONObject.parseObject(result2);
|
JSONObject res2 = (JSONObject) jsonObject2.get("data");
|
JSONArray arr2 = JSON.parseArray(res2.getString("list"));
|
JSONObject data2 = (JSONObject) arr2.get(0);
|
String code2 = data2.get("indexCode").toString();
|
|
//根据子节点编号获取设备播放地址
|
String result3 = GetCameraPreviewURL.GetCameraPreviewURL(HkConstant.previewURLshttps, code2, ProtocolConstant.HLSS);
|
res = JSONObject.parseObject(result3);
|
}
|
|
return R.data(res);
|
}
|
|
/**
|
* 获取设备语音对讲的信息
|
* @param equipmentPlayInfo 设备语音对讲对象,只需包含设备编号,以及设备语音对讲格式即可
|
* @param response 响应域,设置跨域
|
* @return
|
*/
|
@GetMapping("/EquimentVoice")
|
public R EquimentVoice(EquipmentPlayInfo equipmentPlayInfo,HttpServletResponse response){
|
response.setHeader("Access-Control-Allow-Origin", "*");
|
response.setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS, DELETE");
|
response.setHeader("Access-Control-Allow-Credentials", "true");
|
//返回
|
// equipmentService.selectEquimentPlayInfo(equipmentPlayInfo)
|
|
JSONObject res = new JSONObject();
|
|
//根据设备id获取设备编号
|
String result1 = GetCameraPreviewURL.QueryCameraPreviewURL(HkConstant.camerasID, equipmentPlayInfo.getNumber(), "encodeDevice", "deviceCode");
|
|
JSONObject jsonObject1 = JSONObject.parseObject(result1);
|
JSONObject res1 = (JSONObject) jsonObject1.get("data");
|
JSONArray arr1 = JSON.parseArray(res1.getString("list"));
|
if (arr1.size() > 0){
|
JSONObject data1 = (JSONObject) arr1.get(0);
|
String code1 = data1.get("indexCode").toString();
|
|
//根据设备编号获取子节点编号
|
String result2 = GetCameraPreviewURL.QueryCameraPreviewURL(HkConstant.camerasID, code1, "camera", "parentIndexCode");
|
|
JSONObject jsonObject2 = JSONObject.parseObject(result2);
|
JSONObject res2 = (JSONObject) jsonObject2.get("data");
|
JSONArray arr2 = JSON.parseArray(res2.getString("list"));
|
JSONObject data2 = (JSONObject) arr2.get(0);
|
String code2 = data2.get("indexCode").toString();
|
|
//根据子节点获取设备语音对讲的信息
|
String result4 = GetCameraPreviewURL.GetTalkURLs(HkConstant.talkURLs, code2);
|
res = JSONObject.parseObject(result4);
|
}
|
|
return R.data(res);
|
}
|
|
|
|
/**
|
* 新增或修改设备视频播放的信息
|
* @param equipmentPlayInfo 视频播放地址对象
|
* @return
|
*/
|
@PostMapping("/submitEquimentPlayInfo")
|
public R submitEquimentPlayInfo(EquipmentPlayInfo equipmentPlayInfo){
|
return R.status(equipmentService.saveOrUpdateEquipmentPlayInfo(equipmentPlayInfo));
|
}
|
|
}
|