tplink摄像头变焦
This commit is contained in:
parent
6efc7cf8fe
commit
24b011fbf2
|
@ -130,6 +130,17 @@ public class CameraInfoController extends JeecgController<CameraInfo, ICameraInf
|
|||
return service.getIpcCapability(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步此项目下的IPC设备
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/syncProjectIpcDevice")
|
||||
public Result<String> syncProjectIpcDevice(CameraInfo cameraInfo) {
|
||||
return service.syncProjectIpcDevice(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取画面基本信息
|
||||
*
|
||||
|
@ -488,4 +499,15 @@ public class CameraInfoController extends JeecgController<CameraInfo, ICameraInf
|
|||
return service.getUploadToServerProcess(cameraInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 高速球机移动方向控制
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@GetMapping(value = "/motionCtrl")
|
||||
public Result motionCtrl(CameraInfo cameraInfo) throws Exception{
|
||||
return service.motionCtrl(cameraInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -292,4 +292,13 @@ public class CameraInfo implements Serializable {
|
|||
@ApiModelProperty(value = "IDS")
|
||||
@TableField(exist = false)
|
||||
private String ids;
|
||||
@ApiModelProperty(value = "移动方向;枚举:[0:左上,1:上,2:右上,3:左,4:持续水平转动,5:右,6:左下,7:下,8:右下,9:缩小画面,10:放大画面,11:聚焦近处,12:聚焦远处]")
|
||||
@TableField(exist = false)
|
||||
private String direction;
|
||||
@ApiModelProperty(value = "开始或停止移动;枚举:[0:停止,1:开始]")
|
||||
@TableField(exist = false)
|
||||
private String startOrNot;
|
||||
@ApiModelProperty(value = "球机移动速度")
|
||||
@TableField(exist = false)
|
||||
private String speed;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ public interface ICameraInfoService extends IService<CameraInfo> {
|
|||
void rebootDevice(CameraInfo cameraInfo);
|
||||
void sync(String jsonResponse);
|
||||
void syncCapability(String deviceIndex,String jsonResponse);
|
||||
Result<String> syncProjectIpcDevice(CameraInfo cameraInfo);
|
||||
Result<JSONObject> getIpcCapability(CameraInfo cameraInfo);
|
||||
Result<JSONObject> getImageCommon(Map<String,Object> map);
|
||||
Result setImageCommon(Map<String,Object> map);
|
||||
|
@ -59,4 +60,5 @@ public interface ICameraInfoService extends IService<CameraInfo> {
|
|||
Result uploadToServer(CameraInfo cameraInfo);
|
||||
Result<String> stopUploadToServer(CameraInfo cameraInfo);
|
||||
Result getUploadToServerProcess(CameraInfo cameraInfo);
|
||||
Result motionCtrl(CameraInfo cameraInfo);
|
||||
}
|
||||
|
|
|
@ -245,6 +245,111 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
return Result.OK(capability);
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步此项目下的IPC设备
|
||||
*
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result<String> syncProjectIpcDevice(CameraInfo cameraInfo){
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"start\"").append(":0").append(",");
|
||||
sb.append("\"limit\"").append(":1000").append(",");
|
||||
sb.append("\"filterAnd\"").append(":").append("{");
|
||||
sb.append("\"deviceTypeList\"").append(":[").append("\"SURVEILLANCECAMERA\"").append("],");
|
||||
sb.append("\"projectId\"").append(":").append("\"").append(cameraInfo.getProjectId()).append("\"");
|
||||
sb.append("},");
|
||||
sb.append("\"sort\"").append(":").append("[{");
|
||||
sb.append("\"key\"").append(":").append("\"deviceIndex\"").append(",");
|
||||
sb.append("\"value\"").append(":").append("\"asc\"");
|
||||
sb.append("}]");
|
||||
sb.append("}");
|
||||
String jsonResponse = tumsApi.getDeviceList(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
String errorCode = jsonObject.getStr("error_code");
|
||||
if(errorCode.equals("0")){
|
||||
syncProjectIpc(jsonResponse);
|
||||
return Result.OK("同步设备成功!");
|
||||
}else{
|
||||
ErrorCode errVo = errorCodeService.getByCode(errorCode);
|
||||
String errMsg = errVo.getErrorMsg();
|
||||
log.info("getImageCommon:{}",errMsg);
|
||||
return Result.error(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步IPC设备信息入库
|
||||
* @param jsonResponse
|
||||
* @return
|
||||
*/
|
||||
private void syncProjectIpc(String jsonResponse){
|
||||
JSONObject jsonObject = new JSONObject(jsonResponse);
|
||||
if(jsonObject.getInt("error_code").equals(0)){
|
||||
JSONObject result = (JSONObject)jsonObject.get("result");
|
||||
if(result.getInt("total")>0){
|
||||
JSONArray list = result.getJSONArray("list");
|
||||
for(int i=0;i<list.size();i++){
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String jsonString = list.get(i).toString();
|
||||
try {
|
||||
CameraInfo cameraInfo = mapper.readValue(jsonString, CameraInfo.class);
|
||||
CameraInfo entity = baseMapper.getByDeviceId(cameraInfo);
|
||||
if(entity==null){
|
||||
//新增
|
||||
baseMapper.insert(cameraInfo);
|
||||
}else{
|
||||
//修改
|
||||
cameraInfo.setId(entity.getId());
|
||||
baseMapper.updateById(cameraInfo);
|
||||
}
|
||||
//同步能力集
|
||||
syncIpcCapability(cameraInfo);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 同步IPC设备能力集入库
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
private void syncIpcCapability(CameraInfo cameraInfo){
|
||||
String deviceIndex = cameraInfo.getDeviceIndex();
|
||||
StringBuffer paramsSb = new StringBuffer();
|
||||
paramsSb.append("{");
|
||||
paramsSb.append("\"devId\"").append(":").append("\"").append(deviceIndex).append("\"");
|
||||
paramsSb.append("}");
|
||||
String ipcCapabilityRes = tumsApi.getIpcCapability(paramsSb.toString());
|
||||
JSONObject jsonObject = new JSONObject(ipcCapabilityRes);
|
||||
if(jsonObject.getInt("error_code").equals(0)){
|
||||
JSONObject result = (JSONObject)jsonObject.get("result");
|
||||
String capabilityStr = result.getStr("capability");
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
try {
|
||||
CameraInfo capability = mapper.readValue(capabilityStr, CameraInfo.class);
|
||||
capability.setDeviceIndex(deviceIndex);
|
||||
CameraInfo entity = baseMapper.getCapabilityByDeviceId(capability);
|
||||
if(entity==null){
|
||||
//新增
|
||||
baseMapper.insertCapability(capability);
|
||||
}else{
|
||||
//修改
|
||||
capability.setId(entity.getId());
|
||||
baseMapper.updateCapabilityById(capability);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取画面基本信息
|
||||
*
|
||||
|
@ -2360,4 +2465,42 @@ public class CameraInfoServiceImpl extends ServiceImpl<CameraInfoMapper, CameraI
|
|||
return Result.error(errMsg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 高速球机移动方向控制
|
||||
* @param cameraInfo
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Result motionCtrl(CameraInfo cameraInfo){
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("{");
|
||||
sb.append("\"id\"").append(":").append("\"").append(cameraInfo.getDeviceIndex()).append("\",");
|
||||
sb.append("\"direction\"").append(":").append(cameraInfo.getDirection()).append(",");
|
||||
sb.append("\"startOrNot\"").append(":").append(cameraInfo.getStartOrNot()).append(",");
|
||||
sb.append("\"speed\"").append(":").append("\"").append(cameraInfo.getSpeed()).append("\"");
|
||||
sb.append("}");
|
||||
String res = tumsApi.motionCtrl(sb.toString());
|
||||
JSONObject jsonObject = new JSONObject(res);
|
||||
int errorCode = jsonObject.getInt("error_code");
|
||||
if(errorCode == 0){
|
||||
// StringBuffer sb2 = new StringBuffer();
|
||||
// sb2.append("{");
|
||||
// sb2.append("\"id\"").append(":").append("\"").append(cameraInfo.getDeviceIndex()).append("\",");
|
||||
// sb2.append("\"direction\"").append(":").append(cameraInfo.getDirection()).append(",");
|
||||
// sb2.append("\"startOrNot\"").append(":").append(0).append(",");
|
||||
// sb2.append("\"speed\"").append(":").append("\"").append(cameraInfo.getSpeed()).append("\"");
|
||||
// sb2.append("}");
|
||||
// String res2 = tumsApi.motionCtrl(sb2.toString());
|
||||
return Result.OK();
|
||||
}else{
|
||||
String errMsg = jsonObject.getStr("msg");
|
||||
if(errMsg == null || errMsg.equals("")) {
|
||||
ErrorCode errVo = errorCodeService.getByCode(String.valueOf(errorCode));
|
||||
errMsg = errVo.getErrorMsg();
|
||||
}
|
||||
log.info("motionCtrl:{}-{}",errorCode,errMsg);
|
||||
return Result.error(errMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -60,8 +60,8 @@ public enum ApiEnum {
|
|||
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","操作高速球机的预置点"),
|
||||
IPC_GET_ALL_TOURS("/tums/ptz/v1/getAllTours","获取高速球机的所有巡航列表"),
|
||||
|
|
|
@ -584,4 +584,17 @@ public class TumsApi {
|
|||
return jsonResponse;
|
||||
}
|
||||
|
||||
/**
|
||||
* 高速球机移动方向控制
|
||||
* @param jsonRequest
|
||||
* @return
|
||||
*/
|
||||
public String motionCtrl(String jsonRequest){
|
||||
this.createTumsClient();
|
||||
log.info("motionCtrl:request:{}",jsonRequest);
|
||||
String jsonResponse = tumsClient.request(jsonRequest, ApiEnum.IPC_MOTION_CTRL.getValue());
|
||||
log.info("motionCtrl:response:{}",jsonResponse);
|
||||
return jsonResponse;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue