From 464aaf3f5947d68d537154070e81432476f778f9 Mon Sep 17 00:00:00 2001 From: baishou <2710684311@qq.com> Date: Fri, 31 May 2019 19:09:54 +0800 Subject: [PATCH] 萤石设备配置接口对接完成 --- springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceConfigController.java | 291 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceControl.java | 40 +--------------------------------------- 2 files changed, 292 insertions(+), 39 deletions(-) create mode 100644 springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceConfigController.java diff --git a/springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceConfigController.java b/springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceConfigController.java new file mode 100644 index 0000000..19fdaf5 --- /dev/null +++ b/springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceConfigController.java @@ -0,0 +1,291 @@ +package com.sincre.springboot.controller.Yinshi; + +import com.alibaba.fastjson.JSON; +import com.sincre.springboot.ApiModel.YinShiResResult; +import com.sincre.springboot.ApiPlatform.YinShiServiceConfig; +import com.sincre.springboot.common.ServerResponse; +import com.sincre.springboot.utils.ApiHelper; +import com.sincre.springboot.utils.ResultUtils; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.RestController; + +import java.util.HashMap; +import java.util.Map; + +@RestController +@RequestMapping("/YinShiDevice/Config/") +@Api(tags = "设备的配置管理") +public class DeviceConfigController { + + @ApiOperation(value = "对设备布撤防状态进行修改(活动检测开关),实现布防和撤防功能") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), + @ApiImplicitParam(name = "isDefence",value = "具有防护能力设备布撤防状态:0-睡眠,8-在家,16-外出,普通IPC设备布撤防状态:`0-撤防,1-布防",required = true) + }) + @GetMapping("setDefenceStatus") + public ServerResponse setDefenceStatus(@RequestParam String deviceSerial, @RequestParam Integer isDefence) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/defence/set"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + map.put("isDefence",isDefence); + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + @ApiOperation(value = "根据设备验证码关闭设备视频加密开关") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), + @ApiImplicitParam(name = "validateCode",value = "设备验证码,设备机身上的六位大写字母OLZKQU",required = true) + }) + @GetMapping("deviceVideoEncryptOff") + public ServerResponse deviceVideoEncryptOff(@RequestParam String deviceSerial,@RequestParam String validateCode) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/encrypt/off"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + map.put("validateCode",validateCode); + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + @ApiOperation(value = "开启设备视频加密") + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true) + @GetMapping("deviceVideoEncryptOn") + public ServerResponse deviceVideoEncryptOn(@RequestParam String deviceSerial) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/encrypt/on"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + @ApiOperation(value = "获取wifi配置提示音开关状态") + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true) + @GetMapping("getWifiSoundStatus") + public ServerResponse getWifiSoundStatus(@RequestParam String deviceSerial) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/sound/switch/status"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + + @ApiOperation(value = "设置wifi配置提示音开关") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), + @ApiImplicitParam(name = "enable",value = "状态:0-关闭,1-开启",required = true), + @ApiImplicitParam(name = "channelNo", value = "通道号,不传表示设备本身") + }) + @GetMapping("setWifiSoundStatus") + public ServerResponse setWifiSoundStatus(@RequestParam String deviceSerial,@RequestParam Integer enable,@RequestParam(required = false) Integer channelNo) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/sound/switch/set"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + map.put("enable",enable); + + if(channelNo != null){ + map.put("channelNo",channelNo); + } + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + @ApiOperation(value = "获取镜头遮蔽开关状态 ps:我们的设备暂时不支持这个功能。") + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true) + @GetMapping("getSceneStatus") + public ServerResponse getSceneStatus(@RequestParam String deviceSerial) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/scene/switch/status"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + + @ApiOperation(value = "获取移动侦测灵敏度配置(目前只支持移动侦测灵敏度配置)") + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true) + @GetMapping("getAlgorithm") + public ServerResponse getAlgorithm(@RequestParam String deviceSerial) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/algorithm/config/get"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + + @ApiOperation(value = "该接口用于设置智能算法模式(目前只支持移动侦测灵敏度配置)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), + @ApiImplicitParam(name = "channelNo", value = "通道号,不传表示设备本身"), + @ApiImplicitParam(name = "type", value = "智能算法模式:0-移动侦测灵敏度。非必选,默认为0",defaultValue = "0"), + @ApiImplicitParam(name = "value",value = "type为0时,该值为0~6,0表示灵敏度最低",required = true) + }) + @GetMapping("setAlgorithm") + public ServerResponse setAlgorithm(@RequestParam String deviceSerial,@RequestParam Integer value,@RequestParam(required = false) Integer channelNo,@RequestParam(defaultValue = "0") Integer type) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/algorithm/config/set"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + map.put("value",value); + map.put("type",type); + if(channelNo != null){ + map.put("channelNo",channelNo); + } + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + + + @ApiOperation(value = "设置告警声音模式") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), + @ApiImplicitParam(name = "type", value = "声音类型:0-短叫,1-长叫,2-静音",defaultValue = "0") + }) + @GetMapping("setAlarmSound") + public ServerResponse setAlarmSound(@RequestParam String deviceSerial,@RequestParam(defaultValue = "0") Integer type) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/alarm/sound/set"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + map.put("type",type); + + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + @ApiOperation(value = "开启或关闭设备下线通知") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), + @ApiImplicitParam(name = "enable", value = "状态:0-关闭,1-开启",defaultValue = "0") + }) + @GetMapping("notifySwitch") + public ServerResponse notifySwitch(@RequestParam String deviceSerial,@RequestParam(defaultValue = "0") Integer enable) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/notify/switch"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + map.put("enable",enable); + + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + + @ApiOperation(value = "获取设备麦克风开关状态") + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true) + @GetMapping("getMicrophoneStatus") + public ServerResponse getMicrophoneStatus(@RequestParam String deviceSerial) { + + String url = YinShiServiceConfig.HostUrl + "lapp/camera/video/sound/status"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + @ApiOperation(value = "设置设备麦克风开关状态") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), + @ApiImplicitParam(name = "enable",value = "状态:0-关闭,1-开启",required = true), + }) + @GetMapping("setMicrophoneStatus") + public ServerResponse setMicrophoneStatus(@RequestParam String deviceSerial,@RequestParam Integer enable) { + + String url = YinShiServiceConfig.HostUrl + "lapp/camera/video/sound/set"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + map.put("enable",enable); + + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } + + + @ApiOperation(value = "设置设备移动跟踪开关(萤石摄像头不支持该指令接口)") + @ApiImplicitParams({ + @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), + @ApiImplicitParam(name = "enable",value = "状态:0-关闭,1-开启",required = true), + @ApiImplicitParam(name = "channelNo", value = "通道号,不传表示设备本身") + }) + @GetMapping("setMoveStatus") + public ServerResponse setMoveStatus(@RequestParam String deviceSerial,@RequestParam Integer enable,@RequestParam(required = false) Integer channelNo) { + + String url = YinShiServiceConfig.HostUrl + "lapp/device/mobile/status/set"; + Map map = new HashMap<>(); + map.put("accessToken", YinShiServiceConfig.AccessToken); + map.put("deviceSerial", deviceSerial); + map.put("enable",enable); + + if(channelNo != null){ + map.put("channelNo",channelNo); + } + String result = ApiHelper.doPost(url, new HashMap(), map); + + YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); + + return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); + } +} diff --git a/springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceControl.java b/springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceControl.java index 6a0f553..9a01645 100644 --- a/springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceControl.java +++ b/springboot/src/main/java/com/sincre/springboot/controller/Yinshi/DeviceControl.java @@ -20,7 +20,7 @@ import java.util.Map; @RestController @RequestMapping("/YinShiDevice") -@Api(tags = "设备管理部分接口—楼宇设备和客流统计") +@Api(tags = "设备管理部分接口—楼宇设备和客流统计及设备升级") public class DeviceControl { @@ -184,43 +184,5 @@ public class DeviceControl { } - @ApiOperation(value = "对设备布撤防状态进行修改(活动检测开关),实现布防和撤防功能") - @ApiImplicitParams({ - @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), - @ApiImplicitParam(name = "isDefence",value = "具有防护能力设备布撤防状态:0-睡眠,8-在家,16-外出,普通IPC设备布撤防状态:`0-撤防,1-布防",required = true) - }) - @GetMapping("setDefenceStatus") - public ServerResponse setDefenceStatus(@RequestParam String deviceSerial,@RequestParam Integer isDefence) { - - String url = YinShiServiceConfig.HostUrl + "lapp/device/defence/set"; - Map map = new HashMap<>(); - map.put("accessToken", YinShiServiceConfig.AccessToken); - map.put("deviceSerial", deviceSerial); - map.put("isDefence",isDefence); - String result = ApiHelper.doPost(url, new HashMap(), map); - - YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); - - return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); - } - @ApiOperation(value = "根据设备验证码关闭设备视频加密开关") - @ApiImplicitParams({ - @ApiImplicitParam(name = "deviceSerial", value = "设备序列号", required = true), - @ApiImplicitParam(name = "validateCode",value = "设备验证码,设备机身上的六位大写字母OLZKQU",required = true) - }) - @GetMapping("deviceVideoEncryptOff") - public ServerResponse deviceVideoEncryptOff(@RequestParam String deviceSerial,@RequestParam String validateCode) { - - String url = YinShiServiceConfig.HostUrl + "lapp/device/encrypt/off"; - Map map = new HashMap<>(); - map.put("accessToken", YinShiServiceConfig.AccessToken); - map.put("deviceSerial", deviceSerial); - map.put("validateCode",validateCode); - String result = ApiHelper.doPost(url, new HashMap(), map); - - YinShiResResult yinShiResResult = JSON.parseObject(result,YinShiResResult.class); - - return ResultUtils.getInstance().returnResultYingshi(yinShiResResult); - } } -- libgit2 0.21.0