| | |
| | | package com.sandu.ximon.admin.controller; |
| | | |
| | | import com.sandu.common.domain.CommonPage; |
| | | import com.sandu.common.domain.ResponseVO; |
| | | import com.sandu.common.execption.BusinessException; |
| | | import com.sandu.common.object.BaseConditionVO; |
| | | import com.sandu.common.util.ResponseUtil; |
| | | import com.sandu.ximon.admin.dto.YSY_MonitorDto; |
| | | import com.sandu.ximon.admin.param.MonitorParam; |
| | | import com.sandu.ximon.admin.security.PermissionConfig; |
| | | import com.sandu.ximon.admin.service.MonitorService; |
| | | import com.sandu.ximon.dao.bo.MonitorBo; |
| | | import com.sandu.ximon.dao.domain.Monitor; |
| | | import com.sandu.ximon.dao.enums.MenuEnum; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * 摄像头 |
| | |
| | | public class MonitorController { |
| | | private final MonitorService monitorService; |
| | | |
| | | private PermissionConfig permissionConfig; |
| | | |
| | | |
| | | /** |
| | | * 模糊查询 |
| | | * |
| | | * @return |
| | | */ |
| | | @PostMapping("/listMonitor") |
| | | public ResponseVO<Object> listMonitorByKeyword(BaseConditionVO baseConditionVO, @RequestBody(required = false) MonitorParam monitorParam) { |
| | | List<MonitorBo> list; |
| | | if (monitorParam == null) { |
| | | list = monitorService.listMonitorByKeyword(baseConditionVO, new MonitorParam()); |
| | | } else { |
| | | list = monitorService.listMonitorByKeyword(baseConditionVO, monitorParam); |
| | | public ResponseVO<Object> listMonitorByKeyword(BaseConditionVO baseConditionVO, |
| | | @RequestParam(value = "order", required = false) Integer order, |
| | | @RequestParam(value = "seq", required = false) Integer seq, |
| | | @RequestBody(required = false) MonitorParam monitorParam) { |
| | | if (!permissionConfig.check(MenuEnum.MONITOR_LIST.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | return ResponseUtil.successPage(list); |
| | | |
| | | //返回查询的摄像头信息列表 |
| | | CommonPage commonPage; |
| | | if (monitorParam == null) { |
| | | commonPage = monitorService.listMonitorByKeyword(baseConditionVO,order,seq, new MonitorParam()); |
| | | } else { |
| | | commonPage = monitorService.listMonitorByKeyword(baseConditionVO,order,seq, monitorParam); |
| | | } |
| | | |
| | | return ResponseUtil.success(commonPage); |
| | | } |
| | | |
| | | |
| | |
| | | */ |
| | | @PostMapping("/delete/{id}") |
| | | public ResponseVO<Object> deleteMonitor(@PathVariable Long id) { |
| | | if (!permissionConfig.check(MenuEnum.MONITOR_DELETE.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | boolean result = monitorService.deleteMonitor(id); |
| | | if (result) { |
| | | return ResponseUtil.success(null); |
| | |
| | | */ |
| | | @PostMapping("/addYSYMonitor") |
| | | public ResponseVO<Object> addYSYMonitor(@RequestBody MonitorParam monitorParam) { |
| | | YSY_MonitorDto addMonitorDto = monitorService.addYSYMonitor(monitorParam.getAccessToken(), monitorParam.getDeviceSerial(), monitorParam.getValidateCode()); |
| | | |
| | | if ("200".equals(addMonitorDto.getCode())) { |
| | | return ResponseUtil.success(addMonitorDto); |
| | | } else if ("20017".equals(addMonitorDto.getCode())) { |
| | | //已经被自己添加的摄像头需要添加到数据库 |
| | | boolean falg = getYSYMonitorInfoAndaddMonitorToTable(monitorParam); |
| | | if (falg) { |
| | | return ResponseUtil.success("添加摄像头成功!"); |
| | | |
| | | } else { |
| | | return ResponseUtil.fail("添加摄像头失败!"); |
| | | } |
| | | |
| | | } else { |
| | | return ResponseUtil.fail(addMonitorDto.getMsg()); |
| | | if (!permissionConfig.check(MenuEnum.MONITOR_ADD.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | } |
| | | if (monitorParam == null || monitorParam.getDeviceSerial() == null) { |
| | | throw new BusinessException("参数不正确!"); |
| | | } |
| | | boolean flag = monitorService.addYSYMonitor(monitorParam.getDeviceSerial(), monitorParam.getValidateCode()); |
| | | |
| | | /** |
| | | * 删除萤石云摄像头 |
| | | * |
| | | * @param monitorParam 添加摄像头结果 |
| | | * @return |
| | | */ |
| | | @PostMapping("/deleteYSYMonitor") |
| | | public ResponseVO<Object> deleteYSYMonitor(@RequestBody MonitorParam monitorParam) { |
| | | YSY_MonitorDto addMonitorDto = monitorService.deleteYSYMonitor(monitorParam.getAccessToken(), monitorParam.getDeviceSerial()); |
| | | if (flag) { |
| | | return ResponseUtil.success("添加摄像头成功!"); |
| | | |
| | | if ("200".equals(addMonitorDto.getCode())) { |
| | | return ResponseUtil.success(addMonitorDto); |
| | | } else { |
| | | return ResponseUtil.fail(addMonitorDto.getMsg()); |
| | | return ResponseUtil.fail("添加摄像头失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取单个设备信息 getYSYMonitorInfo |
| | | */ |
| | | @GetMapping("/getYSYMonitorInfo") |
| | | @PostMapping("/getYSYMonitorInfo") |
| | | public ResponseVO<Object> getYSYMonitorInfo(@RequestBody MonitorParam monitorParam) { |
| | | YSY_MonitorDto getMonitorDto = monitorService.getYSYMonitorInfo(monitorParam.getAccessToken(), monitorParam.getDeviceSerial()); |
| | | if (!permissionConfig.check(MenuEnum.MONITOR_INFO.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | YSY_MonitorDto getMonitorDto = monitorService.getYSYMonitorInfo(monitorService.getAccessToken(), monitorParam.getDeviceSerial()); |
| | | |
| | | if ("200".equals(getMonitorDto.getCode())) { |
| | | Monitor monitor = new Monitor(); |
| | | monitor.setDeviceSerial(getMonitorDto.getData().getDeviceSerial()); |
| | | // monitor.setDevicesCode(monitorParam.getValidateCode()); |
| | | monitor.setDeviceName(getMonitorDto.getData().getDeviceName()); |
| | | monitor.setDeviceType(getMonitorDto.getData().getModel()); |
| | | monitor.setEquipmentState(getMonitorDto.getData().getStatus()); |
| | | monitor.setIsEncrypt(getMonitorDto.getData().getIsEncrypt()); |
| | | monitor.setAddTime(getMonitorDto.getData().getUpdateTime()); |
| | | monitor.setNetAddress(getMonitorDto.getData().getNetAddress()); |
| | | monitorService.addMonitorInfoToTable(monitor); |
| | | |
| | | return ResponseUtil.success(getMonitorDto.getData()); |
| | | } else { |
| | | return ResponseUtil.fail(getMonitorDto.getMsg()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取摄像头URL播放地址 |
| | | */ |
| | | @PostMapping("/getMonitorVideoUrl") |
| | | public ResponseVO<Object> getMonitorVideoUrl(@RequestBody MonitorParam monitorParam) { |
| | | if (!permissionConfig.check(MenuEnum.MONITOR_VIDEO_URL.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | String URL = monitorService.getMonitorVideoUrl(monitorService.getAccessToken(), |
| | | monitorParam.getDeviceSerial(), monitorParam.getProtocol(), monitorParam.getExpireTime()); |
| | | |
| | | return ResponseUtil.success(URL); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取单个设备信息并且存储到数据库 |
| | | * 修改备注 |
| | | * |
| | | * @param monitorParam |
| | | * @return |
| | | */ |
| | | @PostMapping("/getYSYMonitorInfoAndaddMonitorToTable") |
| | | public boolean getYSYMonitorInfoAndaddMonitorToTable(@RequestBody MonitorParam monitorParam) { |
| | | YSY_MonitorDto getMonitorDto = monitorService.getYSYMonitorInfo(monitorParam.getAccessToken(), monitorParam.getDeviceSerial()); |
| | | |
| | | if ("200".equals(getMonitorDto.getCode())) { |
| | | Monitor monitor = new Monitor(); |
| | | monitor.setDeviceSerial(getMonitorDto.getData().getDeviceSerial()); |
| | | monitor.setDevicesCode(monitorParam.getValidateCode()); |
| | | monitor.setDeviceName(getMonitorDto.getData().getDeviceName()); |
| | | monitor.setDeviceType(getMonitorDto.getData().getModel()); |
| | | monitor.setEquipmentStatus(getMonitorDto.getData().getStatus()); |
| | | monitor.setIsEncrypt(getMonitorDto.getData().getIsEncrypt()); |
| | | monitor.setAddTime(getMonitorDto.getData().getUpdateTime()); |
| | | monitor.setNetAddress(getMonitorDto.getData().getNetAddress()); |
| | | |
| | | return monitorService.addMonitorInfoToTable(monitor); |
| | | } else { |
| | | throw new BusinessException(getMonitorDto.getMsg()); |
| | | @PostMapping("/updateNotes") |
| | | public ResponseVO<Object> updateNotes(@RequestBody MonitorParam monitorParam) { |
| | | if (!permissionConfig.check(MenuEnum.MONITOR_NOTES.getCode())) { |
| | | return ResponseUtil.fail("缺少对应用户权限"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 编辑摄像头设备信息 |
| | | */ |
| | | @PostMapping("/UpDateMonitorInfo") |
| | | public ResponseVO<Object> UpDateMonitorInfo(@RequestBody MonitorParam monitorParam) { |
| | | Monitor monitor = new Monitor(); |
| | | monitor.setId(monitorParam.getId()); |
| | | monitor.setDeviceSerial(monitorParam.getDeviceSerial()); |
| | | monitor.setDevicesCode(monitorParam.getDevicesCode()); |
| | | monitor.setWorkState(monitorParam.getWorkState()); |
| | | monitor.setNote(monitorParam.getNote()); |
| | | |
| | | boolean falg = monitorService.upDateMonitorInfo(monitorParam); |
| | | |
| | | if (falg) { |
| | | return ResponseUtil.success("更新数据成功"); |
| | | boolean flag = monitorService.updateNotes(monitorParam.getDeviceSerial(), monitorParam.getNotes()); |
| | | if (flag) { |
| | | return ResponseUtil.success("修改备注成功!"); |
| | | } else { |
| | | return ResponseUtil.fail("更新数据失败"); |
| | | return ResponseUtil.fail("修改备注失败!"); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 获取摄像头URL播放地址 |
| | | */ |
| | | @GetMapping("/getMonitorVideoUrl") |
| | | public ResponseVO<Object> getMonitorVideoUrl(@RequestParam MonitorParam monitorParam) { |
| | | String URL = monitorService.getMonitorVideoUrl(monitorParam.getAccessToken(), |
| | | monitorParam.getDeviceSerial(), monitorParam.getProtocol(), monitorParam.getExpireTime()); |
| | | |
| | | return ResponseUtil.success(URL); |
| | | } |
| | | |
| | | } |