tplink摄像头录像计划
This commit is contained in:
parent
2a666b16ef
commit
3082a45686
|
@ -11,9 +11,13 @@
|
|||
*/
|
||||
package com.nu.modules.tplink.camera.controller;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.modules.tplink.camera.model.CameraTreeModel;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
|
@ -21,6 +25,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import com.nu.modules.tplink.camera.service.ICameraInfoService;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -62,6 +67,21 @@ public class CameraInfoController extends JeecgController<CameraInfo, ICameraInf
|
|||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/queryTreeList", method = RequestMethod.GET)
|
||||
public Result<List<CameraTreeModel>> queryTreeList(CameraInfo CameraInfo) {
|
||||
Result<List<CameraTreeModel>> result = new Result<>();
|
||||
try {
|
||||
List<CameraTreeModel> list = service.findModelList(CameraInfo);
|
||||
result.setResult(list);
|
||||
result.setSuccess(true);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(),e);
|
||||
result.setSuccess(false);
|
||||
result.setMessage("查询失败");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ApiOperation(value="护理单元分页列表查询", notes="护理单元分页列表查询")
|
||||
@GetMapping(value = "/nuList")
|
||||
public Result<IPage<CameraInfo>> queryNuPageList(CameraInfo CameraInfo,
|
||||
|
@ -210,29 +230,76 @@ public class CameraInfoController extends JeecgController<CameraInfo, ICameraInf
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取录像配置--暂无用
|
||||
* 获取存储设备列表
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getStorageDevice")
|
||||
public Result getStorageDevice(CameraInfo cameraInfo) throws Exception{
|
||||
return service.getStorageDevice(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有录像计划列表
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getAllRecordPlans")
|
||||
public Result getAllRecordPlans(CameraInfo cameraInfo) throws Exception{
|
||||
return service.getAllRecordPlans(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加录像计划
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/addRecordCfgs")
|
||||
public Result addRecordCfgs(@RequestBody CameraInfo cameraInfo) throws Exception{
|
||||
return service.addRecordCfgs(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置录像计划
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@PostMapping(value = "/setRecordCfgs")
|
||||
public Result setRecordCfgs(@RequestBody CameraInfo cameraInfo) throws Exception{
|
||||
return service.setRecordCfgs(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除录像计划
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/delRecordCfgs")
|
||||
public Result delRecordCfgs(CameraInfo cameraInfo) throws Exception{
|
||||
return service.delRecordCfgs(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取录像配置
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/getRecordCfgs")
|
||||
public Result getRecordCfgs(CameraInfo cameraInfo) throws Exception{
|
||||
return service.getRecordCfgs(cameraInfo);
|
||||
public Result<IPage<CameraInfo>> getRecordCfgs(CameraInfo cameraInfo,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) throws Exception{
|
||||
IPage<CameraInfo> pageList = service.getRecordCfgs(cameraInfo,pageNo,pageSize);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置录像计划--暂无用
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/setRecordCfgs")
|
||||
public Result setRecordCfgs(CameraInfo cameraInfo) throws Exception{
|
||||
return service.setRecordCfgs(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取批量操作录像计划进度--暂无用
|
||||
* 获取批量操作录像计划进度
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
|
|
|
@ -143,6 +143,14 @@ public class CameraInfo implements Serializable {
|
|||
@TableField(exist = false)
|
||||
private int streamType;
|
||||
|
||||
@ApiModelProperty(value = "录像计划ID")
|
||||
private String recordPlanId;
|
||||
@ApiModelProperty(value = "录像计划名称")
|
||||
@TableField(exist = false)
|
||||
private String planName;
|
||||
@ApiModelProperty(value = "批量处理类型 1:表示查询添加进度,2:表示查询设置进度,3:表示查询删除进度")
|
||||
@TableField(exist = false)
|
||||
private int batchType;
|
||||
/**
|
||||
* 能力集属性 ==>
|
||||
*/
|
||||
|
@ -269,6 +277,9 @@ public class CameraInfo implements Serializable {
|
|||
@ApiModelProperty(value = "录像开关;枚举:[0:表示关,1:表示开]")
|
||||
@TableField(exist = false)
|
||||
private String recordSwitch;
|
||||
@ApiModelProperty(value = "录像开关;枚举:[false:表示关,true:表示开]")
|
||||
@TableField(exist = false)
|
||||
private boolean recordSwitchBoolean;
|
||||
@ApiModelProperty(value = "任务taskId")
|
||||
@TableField(exist = false)
|
||||
private String taskId;
|
||||
|
@ -278,4 +289,7 @@ public class CameraInfo implements Serializable {
|
|||
@ApiModelProperty(value = "上传进度")
|
||||
@TableField(exist = false)
|
||||
private String process;
|
||||
@ApiModelProperty(value = "IDS")
|
||||
@TableField(exist = false)
|
||||
private String ids;
|
||||
}
|
||||
|
|
|
@ -19,10 +19,12 @@ import java.util.List;
|
|||
@Mapper
|
||||
public interface CameraInfoMapper extends BaseMapper<CameraInfo> {
|
||||
IPage<CameraInfo> findPage(Page<CameraInfo> page, @Param("params") CameraInfo cameraInfo);
|
||||
List<CameraInfo> findList(CameraInfo cameraInfo);
|
||||
List<CameraInfo> findAllList();
|
||||
IPage<CameraInfo> findNuPage(Page<CameraInfo> page, @Param("params") CameraInfo cameraInfo);
|
||||
CameraInfo getByDeviceId(CameraInfo cameraInfo);
|
||||
CameraInfo getCapabilityByDeviceId(CameraInfo cameraInfo);
|
||||
void insertCapability(CameraInfo cameraInfo);
|
||||
void updateCapabilityById(CameraInfo cameraInfo);
|
||||
void updatePlanByDevId(CameraInfo cameraInfo);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
location_name as locationName,
|
||||
system_type as systemType,
|
||||
protocol as protocol,
|
||||
record_plan_id as recordPlanId,
|
||||
a.nu_id as nuId,
|
||||
b.nu_name as nuName,
|
||||
ifnull(c.multitrans,0) as multitrans
|
||||
|
@ -58,6 +59,46 @@
|
|||
</where>
|
||||
</select>
|
||||
|
||||
<select id="findList" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
|
||||
select a.id,
|
||||
a.device_index as deviceIndex,
|
||||
device_name as deviceName,
|
||||
device_type as deviceType,
|
||||
device_status as deviceStatus,
|
||||
device_model as deviceModel,
|
||||
ip as ip,
|
||||
mac as mac,
|
||||
region_id as regionId,
|
||||
region_name as regionName,
|
||||
parent_id as parentId,
|
||||
parent_device_name as parentDeviceName,
|
||||
project_id as projectId,
|
||||
project_name as projectName,
|
||||
firmware_ver as firmwareVer,
|
||||
hardware_ver as hardwareVer,
|
||||
manager_auth_type as managerAuthType,
|
||||
msg_auth_type as msgAuthType,
|
||||
sip_code as sipCode,
|
||||
location_name as locationName,
|
||||
system_type as systemType,
|
||||
protocol as protocol,
|
||||
record_plan_id as recordPlanId,
|
||||
a.nu_id as nuId,
|
||||
b.nu_name as nuName
|
||||
from nu_iot_tplink_camera a left join nu_base_info b on a.nu_id = b.id
|
||||
<where>
|
||||
<if test="projectId != null and projectId != ''">
|
||||
AND a.project_id = #{projectId}
|
||||
</if>
|
||||
<if test="regionId != null and regionId != ''">
|
||||
AND a.region_id = #{regionId}
|
||||
</if>
|
||||
<if test="recordPlanId != null and recordPlanId != ''">
|
||||
AND ifnull(a.record_plan_id,'-1') = #{recordPlanId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="findAllList" parameterType="com.nu.modules.tplink.camera.entity.CameraInfo" resultType="com.nu.modules.tplink.camera.entity.CameraInfo">
|
||||
select a.id,
|
||||
device_index as deviceIndex,
|
||||
|
@ -81,6 +122,7 @@
|
|||
location_name as locationName,
|
||||
system_type as systemType,
|
||||
protocol as protocol,
|
||||
record_plan_id as recordPlanId,
|
||||
nu_id as nuId
|
||||
from nu_iot_tplink_camera a
|
||||
</select>
|
||||
|
@ -214,4 +256,10 @@
|
|||
where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="updatePlanByDevId">
|
||||
UPDATE nu_iot_tplink_camera
|
||||
SET record_plan_id = #{recordPlanId}
|
||||
where device_index = #{deviceIndex}
|
||||
</update>
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,149 @@
|
|||
package com.nu.modules.tplink.camera.model;
|
||||
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 摄像头表 存储摄像头结构数据的实体类
|
||||
* <p>
|
||||
*
|
||||
* @Author 曹磊
|
||||
* @Since 2025-02-27
|
||||
*/
|
||||
public class CameraTreeModel implements Serializable{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 对应SysDepart中的id字段,前端数据树中的key*/
|
||||
private String key;
|
||||
|
||||
/** 对应SysDepart中的id字段,前端数据树中的value*/
|
||||
private String value;
|
||||
|
||||
/** 对应depart_name字段,前端数据树中的title*/
|
||||
private String title;
|
||||
|
||||
private boolean isLeaf;
|
||||
|
||||
private String type;
|
||||
// 以下所有字段均与CameraInfo相同
|
||||
|
||||
private String deviceIndex;
|
||||
|
||||
private String deviceName;
|
||||
|
||||
private List<CameraTreeModel> children = new ArrayList<>();
|
||||
|
||||
|
||||
/**
|
||||
* 将CameraInfo对象转换成CameraTreeModel对象
|
||||
* @param cameraInfo
|
||||
*/
|
||||
public CameraTreeModel(CameraInfo cameraInfo) {
|
||||
this.key = cameraInfo.getDeviceIndex();
|
||||
this.value = cameraInfo.getDeviceIndex();
|
||||
this.title = cameraInfo.getDeviceName();
|
||||
this.type = "camera";
|
||||
this.deviceIndex = cameraInfo.getDeviceIndex();
|
||||
this.deviceName = cameraInfo.getDeviceName();
|
||||
this.isLeaf = true;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
return key;
|
||||
}
|
||||
|
||||
public void setKey(String key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public boolean getIsLeaf() {
|
||||
return isLeaf;
|
||||
}
|
||||
|
||||
public void setIsLeaf(boolean isleaf) {
|
||||
this.isLeaf = isleaf;
|
||||
}
|
||||
|
||||
public List<CameraTreeModel> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<CameraTreeModel> children) {
|
||||
if (children==null){
|
||||
this.isLeaf=true;
|
||||
}
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getDeviceIndex() {
|
||||
return deviceIndex;
|
||||
}
|
||||
|
||||
public void setDeviceIndex(String deviceIndex) {
|
||||
this.deviceIndex = deviceIndex;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写equals方法
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
CameraTreeModel model = (CameraTreeModel) o;
|
||||
return Objects.equals(deviceIndex, model.deviceIndex) &&
|
||||
Objects.equals(deviceName, model.deviceName) &&
|
||||
Objects.equals(children, model.children);
|
||||
}
|
||||
|
||||
/**
|
||||
* 重写hashCode方法
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(deviceIndex, deviceName, children);
|
||||
}
|
||||
|
||||
}
|
|
@ -3,6 +3,7 @@ package com.nu.modules.tplink.camera.service;
|
|||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.tplink.camera.model.CameraTreeModel;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import com.nu.modules.tplink.camera.entity.CameraInfo;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
@ -18,6 +19,7 @@ import java.util.Map;
|
|||
*/
|
||||
public interface ICameraInfoService extends IService<CameraInfo> {
|
||||
IPage<CameraInfo> findPage(Page<CameraInfo> page, CameraInfo cameraInfo);
|
||||
List<CameraTreeModel> findModelList(CameraInfo cameraInfo);
|
||||
List<CameraInfo> findAllList();
|
||||
IPage<CameraInfo> findNuPage(Page<CameraInfo> page, CameraInfo cameraInfo);
|
||||
void edit(CameraInfo cameraInfo);
|
||||
|
@ -34,8 +36,12 @@ public interface ICameraInfoService extends IService<CameraInfo> {
|
|||
Result setVideoParams(Map<String,Object> map);
|
||||
Result configRecovery(Map<String,Object> map);
|
||||
Result<Map<String,String>> getPreviewUrl(CameraInfo cameraInfo);
|
||||
Result getRecordCfgs(CameraInfo cameraInfo) throws Exception;
|
||||
Result getStorageDevice(CameraInfo cameraInfo) throws Exception;
|
||||
Result getAllRecordPlans(CameraInfo cameraInfo) throws Exception;
|
||||
Result addRecordCfgs(CameraInfo cameraInfo) throws Exception;
|
||||
Result setRecordCfgs(CameraInfo cameraInfo) throws Exception;
|
||||
Result delRecordCfgs(CameraInfo cameraInfo) throws Exception;
|
||||
IPage<CameraInfo> getRecordCfgs(CameraInfo cameraInfo,Integer pageNo,Integer pageSize) throws Exception;
|
||||
Result getBatchProgress(CameraInfo cameraInfo) throws Exception;
|
||||
Result<JSONObject> getTamperDet(Map<String,Object> map);
|
||||
Result<String> setTamperDet(Map<String,Object> map);
|
||||
|
|
|
@ -5,6 +5,7 @@ import cn.hutool.json.JSONObject;
|
|||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.nu.modules.tplink.camera.model.CameraTreeModel;
|
||||
import com.nu.modules.tplink.common.entity.TumsConfig;
|
||||
import com.nu.modules.tplink.common.mapper.TumsConfigMapper;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
|
@ -54,6 +55,17 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
return baseMapper.findPage(page,cameraInfo);
|
||||
}
|
||||
|
||||
public List<CameraTreeModel> findModelList(CameraInfo cameraInfo){
|
||||
List<CameraTreeModel> modelList = Lists.newArrayList();
|
||||
List<CameraInfo> list = baseMapper.findList(cameraInfo);
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
CameraInfo entity = list.get(i);
|
||||
CameraTreeModel treeModel = new CameraTreeModel(entity);
|
||||
modelList.add(treeModel);
|
||||
}
|
||||
return modelList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有摄像头信息
|
||||
* @return
|
||||
|
@ -906,43 +918,137 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取录像配置
|
||||
* 获取存储设备列表
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Result getRecordCfgs(CameraInfo cameraInfo) throws Exception{
|
||||
public Result getStorageDevice(CameraInfo cameraInfo) throws Exception{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"start\"").append(":").append("0,");
|
||||
sb.append("\"limit\"").append(":").append("10,");
|
||||
sb.append("\"filterAnd\"").append(":").append("{");
|
||||
sb.append("\"projectId\"").append(":").append("\"").append(cameraInfo.getProjectId()).append("\",");
|
||||
sb.append("\"regionId\"").append(":").append("\"").append(cameraInfo.getRegionId()).append("\"");
|
||||
// sb.append("\"ipFloor\"").append(":").append("\"").append(cameraInfo.getIp()).append("\",");
|
||||
// sb.append("\"ipCeiling\"").append(":").append("\"").append(cameraInfo.getIp()).append("\",");
|
||||
// if(cameraInfo.getParentId()!=null&&!cameraInfo.getParentId().equals("")&&!cameraInfo.getParentId().equals("0")){
|
||||
// //存储设备ID
|
||||
// sb.append("\"storageDevId\"").append(":").append("\"").append(cameraInfo.getParentId()).append("\"");
|
||||
// }else{
|
||||
// //SK卡,取自身设备ID
|
||||
// sb.append("\"storageDevId\"").append(":").append("\"").append(cameraInfo.getDeviceIndex()).append("\"");
|
||||
// }
|
||||
sb.append("},");
|
||||
sb.append("\"sort\"").append(":").append("[{");
|
||||
sb.append("\"key\"").append(":").append("\"ip\",");
|
||||
sb.append("\"value\"").append(":").append("\"desc\"");
|
||||
sb.append("}]");
|
||||
sb.append("}");
|
||||
String res = tumsApi.getRecordCfgs(sb.toString());
|
||||
String res = tumsApi.getStorageDevice(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
int errorCode = jsonObject.getInt("error_code");
|
||||
if(errorCode == 0){
|
||||
return Result.OK("获取录像配置成功!");
|
||||
JSONArray result = jsonObject.getJSONArray("result");
|
||||
List list = Lists.newArrayList();
|
||||
if(result.size() == 0){
|
||||
CameraInfo ci = new CameraInfo();
|
||||
ci.setStorageDevId("0");
|
||||
ci.setStorageDevName("默认存储位置");
|
||||
list.add(ci);
|
||||
}else{
|
||||
return Result.error("获取录像配置失败!");
|
||||
for(int i=0;i<result.size();i++){
|
||||
JSONObject json = (JSONObject)result.get(i);
|
||||
CameraInfo ci = new CameraInfo();
|
||||
String storageDevId = json.getStr("storageDevId");
|
||||
ci.setStorageDevId(storageDevId);
|
||||
String storageDevName = json.getStr("storageDevName");
|
||||
ci.setStorageDevName(storageDevName);
|
||||
list.add(ci);
|
||||
}
|
||||
}
|
||||
return Result.OK(list);
|
||||
}else{
|
||||
return Result.error("获取存储设备列表失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有录像计划列表
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Result getAllRecordPlans(CameraInfo cameraInfo) throws Exception{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{}");
|
||||
String res = tumsApi.getAllRecordPlans(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
int errorCode = jsonObject.getInt("error_code");
|
||||
if(errorCode == 0){
|
||||
JSONArray result = jsonObject.getJSONArray("result");
|
||||
List list = Lists.newArrayList();
|
||||
if(result.size() == 0){
|
||||
CameraInfo ci = new CameraInfo();
|
||||
ci.setStorageDevId("1");
|
||||
ci.setStorageDevName("全天候模板");
|
||||
list.add(ci);
|
||||
}else{
|
||||
for(int i=0;i<result.size();i++){
|
||||
JSONObject json = (JSONObject)result.get(i);
|
||||
CameraInfo ci = new CameraInfo();
|
||||
String recordPlanId = json.getStr("recordPlanId");
|
||||
ci.setRecordPlanId(recordPlanId);
|
||||
String planName = json.getStr("planName");
|
||||
ci.setPlanName(planName);
|
||||
list.add(ci);
|
||||
}
|
||||
}
|
||||
return Result.OK(list);
|
||||
}else{
|
||||
return Result.error("获取所有录像计划列表失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加录像计划
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Result addRecordCfgs(CameraInfo cameraInfo) throws Exception{
|
||||
String ids = cameraInfo.getIds();
|
||||
String[] idArr = ids.split(",");
|
||||
StringBuffer idSb = new StringBuffer();
|
||||
for(int i=0;i<idArr.length;i++){
|
||||
idSb.append("\"").append(idArr[i]).append("\",");
|
||||
}
|
||||
String idsStr = idSb.toString();
|
||||
if(idsStr.length()>0){
|
||||
idsStr = idsStr.substring(0,idsStr.length()-1);
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"devIds\"").append(":").append("[").append(idsStr).append("],");
|
||||
sb.append("\"storageList\"").append(":").append("[");
|
||||
sb.append("{");
|
||||
if(cameraInfo.getStorageDevId()!=null&&!cameraInfo.getStorageDevId().equals("")){
|
||||
//存储设备ID
|
||||
sb.append("\"storageDevId\"").append(":").append(cameraInfo.getStorageDevId()).append(",");
|
||||
if(cameraInfo.getStorageDevId().equals("0")){
|
||||
sb.append("\"storageType\"").append(":").append("1").append(",");
|
||||
}else{
|
||||
sb.append("\"storageType\"").append(":").append("2").append(",");
|
||||
}
|
||||
}
|
||||
sb.append("\"recordPlanId\"").append(":").append(cameraInfo.getRecordPlanId()).append(",");
|
||||
sb.append("\"streamType\"").append(":").append(cameraInfo.getStreamType());
|
||||
sb.append("}");
|
||||
sb.append("]");
|
||||
sb.append("}");
|
||||
String res = tumsApi.addRecordCfgs(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
int errorCode = jsonObject.getInt("error_code");
|
||||
if(errorCode == 0){
|
||||
for(int i=0;i<idArr.length;i++){
|
||||
CameraInfo entity = new CameraInfo();
|
||||
entity.setDeviceIndex(idArr[i]);
|
||||
entity.setRecordPlanId(cameraInfo.getRecordPlanId());
|
||||
baseMapper.updatePlanByDevId(entity);
|
||||
}
|
||||
return Result.OK("添加录像计划成功!计划生效有延迟,请刷新查看!");
|
||||
}else{
|
||||
return Result.error("添加录像计划失败!");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -957,28 +1063,152 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
public Result setRecordCfgs(CameraInfo cameraInfo) throws Exception{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"ids\"").append(":").append("[").append(cameraInfo.getDeviceIndex()).append("],");
|
||||
sb.append("\"recordSwitch\"").append(":").append(cameraInfo.getRecordSwitch()).append(",");
|
||||
sb.append("\"streamType\"").append(":").append(cameraInfo.getStreamType()).append(",");
|
||||
sb.append("\"recordPlanId\"").append(":").append("1,");
|
||||
if(cameraInfo.getParentId()!=null&&!cameraInfo.getParentId().equals("")&&!cameraInfo.getParentId().equals("0")){
|
||||
//存储设备ID
|
||||
sb.append("\"storageDevId\"").append(":").append("\"").append(cameraInfo.getParentId()).append("\"");
|
||||
}else{
|
||||
//SK卡,取自身设备ID
|
||||
sb.append("\"storageDevId\"").append(":").append("\"").append(cameraInfo.getDeviceIndex()).append("\"");
|
||||
}
|
||||
sb.append("\"ids\"").append(":").append("[").append(cameraInfo.getIds()).append("],");
|
||||
// sb.append("\"streamType\"").append(":").append(cameraInfo.getStreamType()).append(",");
|
||||
// if(cameraInfo.getStorageDevId()!=null&&!cameraInfo.getStorageDevId().equals("")&&!cameraInfo.getStorageDevId().equals("0")){
|
||||
// //存储设备ID
|
||||
// sb.append("\"storageDevId\"").append(":").append("\"").append(cameraInfo.getStorageDevId()).append("\",");
|
||||
// }
|
||||
// sb.append("\"recordPlanId\"").append(":").append(cameraInfo.getRecordPlanId()).append(",");
|
||||
sb.append("\"recordSwitch\"").append(":").append(cameraInfo.getRecordSwitch());
|
||||
sb.append("}");
|
||||
String res = tumsApi.setRecordCfgs(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
int errorCode = jsonObject.getInt("error_code");
|
||||
if(errorCode == 0){
|
||||
return Result.OK("设置录像计划成功!");
|
||||
return Result.OK("设置录像计划成功!计划生效有延迟,请刷新查看!");
|
||||
}else{
|
||||
return Result.error("设置录像计划失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除录像计划
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public Result delRecordCfgs(CameraInfo cameraInfo) throws Exception{
|
||||
String ids = cameraInfo.getIds();
|
||||
String devIds = cameraInfo.getDeviceIndex();
|
||||
String[] idArr = ids.split(",");
|
||||
String[] devIdArr = devIds.split(",");
|
||||
StringBuffer idSb = new StringBuffer();
|
||||
for(int i=0;i<idArr.length;i++){
|
||||
idSb.append("\"").append(idArr[i]).append("\",");
|
||||
}
|
||||
String idsStr = idSb.toString();
|
||||
if(idsStr.length()>0){
|
||||
idsStr = idsStr.substring(0,idsStr.length()-1);
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"ids\"").append(":").append("[").append(idsStr).append("]");
|
||||
sb.append("}");
|
||||
String res = tumsApi.delRecordCfgs(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
int errorCode = jsonObject.getInt("error_code");
|
||||
if(errorCode == 0){
|
||||
for(int i=0;i<devIdArr.length;i++){
|
||||
CameraInfo entity = new CameraInfo();
|
||||
entity.setDeviceIndex(devIdArr[i]);
|
||||
entity.setRecordPlanId("-1");
|
||||
baseMapper.updatePlanByDevId(entity);
|
||||
}
|
||||
return Result.OK("删除录像计划成功!计划生效有延迟,请刷新查看!");
|
||||
}else{
|
||||
return Result.error("删除录像计划失败!");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取录像配置
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public IPage<CameraInfo> getRecordCfgs(CameraInfo cameraInfo,Integer pageNo,Integer pageSize) throws Exception{
|
||||
IPage<CameraInfo> page = new Page<>();
|
||||
page.setSize(pageSize);
|
||||
page.setCurrent(pageNo);
|
||||
if(cameraInfo.getProjectId()==null||cameraInfo.getProjectId().equals("")){
|
||||
return page;
|
||||
}
|
||||
if(cameraInfo.getRegionId()==null||cameraInfo.getRegionId().equals("")){
|
||||
return page;
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"start\"").append(":").append((pageNo-1)*pageSize).append(",");
|
||||
sb.append("\"limit\"").append(":").append(pageSize).append(",");
|
||||
sb.append("\"filterAnd\"").append(":").append("{");
|
||||
sb.append("\"projectId\"").append(":").append("\"").append(cameraInfo.getProjectId()).append("\",");
|
||||
sb.append("\"regionId\"").append(":").append("\"").append(cameraInfo.getRegionId()).append("\"");
|
||||
sb.append("},");
|
||||
sb.append("\"sort\"").append(":").append("[{");
|
||||
sb.append("\"key\"").append(":").append("\"ip\",");
|
||||
sb.append("\"value\"").append(":").append("\"desc\"");
|
||||
sb.append("}]");
|
||||
sb.append("}");
|
||||
String res = tumsApi.getRecordCfgs(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
int errorCode = jsonObject.getInt("error_code");
|
||||
if(errorCode == 0){
|
||||
JSONObject result = (JSONObject)jsonObject.get("result");
|
||||
Long total = result.getLong("total");
|
||||
page.setTotal(total);
|
||||
if(total>0){
|
||||
List list = Lists.newArrayList();
|
||||
JSONArray array = result.getJSONArray("list");
|
||||
for(int i=0;i<array.size();i++){
|
||||
CameraInfo ci = new CameraInfo();
|
||||
JSONObject json = (JSONObject)array.get(i);
|
||||
String devId = json.getStr("devId");
|
||||
ci.setDeviceIndex(devId);
|
||||
String devName = json.getStr("devName");
|
||||
ci.setDeviceName(devName);
|
||||
String ip = json.getStr("ip");
|
||||
ci.setIp(ip);
|
||||
JSONArray expand = json.getJSONArray("expand");
|
||||
JSONObject expandJson = (JSONObject)expand.get(0);
|
||||
String id = expandJson.getStr("id");
|
||||
ci.setIds(id);
|
||||
String recordSwitch = expandJson.getStr("recordSwitch");
|
||||
ci.setRecordSwitch(recordSwitch);
|
||||
if(recordSwitch.equals("1")){
|
||||
ci.setRecordSwitchBoolean(true);
|
||||
}else{
|
||||
ci.setRecordSwitchBoolean(false);
|
||||
}
|
||||
int streamType = expandJson.getInt("streamType");
|
||||
ci.setStreamType(streamType);
|
||||
String recordPlanId = expandJson.getStr("recordPlanId");
|
||||
ci.setRecordPlanId(recordPlanId);
|
||||
String recordPlanName = expandJson.getStr("recordPlanName");
|
||||
ci.setPlanName(recordPlanName);
|
||||
String storageType = expandJson.getStr("storageType");
|
||||
ci.setStorageType(storageType);
|
||||
if(storageType.equals("0")){
|
||||
ci.setStorageDevId("0");
|
||||
ci.setStorageDevName("本设备");
|
||||
}else{
|
||||
String storageDevId = expandJson.getStr("storageDevId");
|
||||
ci.setStorageDevId(storageDevId);
|
||||
String storageDevName = expandJson.getStr("storageDevName");
|
||||
ci.setStorageDevName(storageDevName);
|
||||
}
|
||||
list.add(ci);
|
||||
}
|
||||
page.setRecords(list);
|
||||
}
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取批量操作录像计划进度
|
||||
*
|
||||
|
@ -990,7 +1220,7 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
public Result getBatchProgress(CameraInfo cameraInfo) throws Exception{
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"batchType\"").append(":1");
|
||||
sb.append("\"batchType\"").append(":").append(cameraInfo.getBatchType());
|
||||
sb.append("}");
|
||||
String res = tumsApi.getBatchProgress(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
|
|
|
@ -53,10 +53,14 @@ public enum ApiEnum {
|
|||
IPC_SEARCH_VIDEO("/tums/playback/v3/searchVideo","搜索当天的录像数据V3"),
|
||||
IPC_ADD_PLAYBACK_CHN("/tums/playback/v2/addPlaybackChn","添加回放通道V2"),
|
||||
IPC_GET_MULTITRANS_URL("/tums/playback/v1/getMultitransUrl","获取nvmp设备双向通信URL"),
|
||||
/** =================>暂时无用 **/
|
||||
IPC_GET_RECORD_CFGS("/tums/record/v1/getRecordCfgs","获取录像配置"),
|
||||
IPC_ADD_RECORD_CFGS("/tums/record/v1/addRecordCfgs","添加录像配置"),
|
||||
IPC_SET_RECORD_CFGS("/tums/record/v1/setRecordCfgs","设置录像计划"),
|
||||
IPC_DEL_RECORD_CFGS("/tums/record/v1/delRecordCfgs","删除录像计划"),
|
||||
IPC_GET_RECORD_CFGS("/tums/record/v1/getRecordCfgs","获取录像配置"),
|
||||
IPC_GET_BATCH_PROGRESS("/tums/record/v1/getBatchProgress","获取批量操作录像计划进度"),
|
||||
IPC_GET_STORAGE_DEVICE("/tums/record/v1/getStorageDevice","获取存储设备列表"),
|
||||
IPC_GET_ALL_RECORD_PLANS("/tums/record/v1/getAllRecordPlans","获取所有录像计划列表"),
|
||||
/** =================>暂时无用 **/
|
||||
IPC_MOTION_CTRL("/tums/ptz/v1/motionCtrl","高速球机移动方向控制"),
|
||||
IPC_GET_ALL_PRESETS("/tums/ptz/v1/getAllPresets","获取高速球机的所有预置点"),
|
||||
IPC_OPERATE_PRESET("/tums/ptz/v1/operatePreset","操作高速球机的预置点"),
|
||||
|
|
|
@ -457,14 +457,15 @@ public class TumsApi {
|
|||
}
|
||||
|
||||
/**
|
||||
* 获取录像配置
|
||||
* 添加录像计划
|
||||
* @param jsonRequest
|
||||
* @return
|
||||
*/
|
||||
public String getRecordCfgs(String jsonRequest){
|
||||
public String addRecordCfgs(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_GET_RECORD_CFGS.getValue());
|
||||
log.info("getRecordCfgs:{}",jsonResponse);
|
||||
log.info("addRecordCfgs:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_ADD_RECORD_CFGS.getValue());
|
||||
log.info("addRecordCfgs:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
|
@ -475,8 +476,35 @@ public class TumsApi {
|
|||
*/
|
||||
public String setRecordCfgs(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("setRecordCfgs:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_SET_RECORD_CFGS.getValue());
|
||||
log.info("setRecordCfgs:{}",jsonResponse);
|
||||
log.info("setRecordCfgs:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除录像计划
|
||||
* @param jsonRequest
|
||||
* @return
|
||||
*/
|
||||
public String delRecordCfgs(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("delRecordCfgs:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_DEL_RECORD_CFGS.getValue());
|
||||
log.info("delRecordCfgs:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取录像配置
|
||||
* @param jsonRequest
|
||||
* @return
|
||||
*/
|
||||
public String getRecordCfgs(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("getRecordCfgs:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_GET_RECORD_CFGS.getValue());
|
||||
log.info("getRecordCfgs:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
|
@ -487,8 +515,35 @@ public class TumsApi {
|
|||
*/
|
||||
public String getBatchProgress(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("getBatchProgress:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_GET_BATCH_PROGRESS.getValue());
|
||||
log.info("getBatchProgress:{}",jsonResponse);
|
||||
log.info("getBatchProgress:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取存储设备列表
|
||||
* @param jsonRequest
|
||||
* @return
|
||||
*/
|
||||
public String getStorageDevice(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("getStorageDevice:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_GET_STORAGE_DEVICE.getValue());
|
||||
log.info("getStorageDevice:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有录像计划列表
|
||||
* @param jsonRequest
|
||||
* @return
|
||||
*/
|
||||
public String getAllRecordPlans(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("getAllRecordPlans:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_GET_ALL_RECORD_PLANS.getValue());
|
||||
log.info("getAllRecordPlans:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue