| | |
| | | * 模糊查询 |
| | | */ |
| | | public List<MonitorBo> listMonitorByKeyword(BaseConditionVO baseConditionVO, MonitorParam monitorParam) { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | List<Long> listAirEquipmentId; |
| | | |
| | | //绑定状态:已绑定/未绑定/全部 |
| | | if (monitorParam.getBindingState() == null || 2 == monitorParam.getBindingState()) { |
| | | //全部 |
| | | int bindingState = 2; |
| | | listAirEquipmentId = monitorMapper.listMonitorId(monitorParam.getKeyword(), clientId, bindingState); |
| | | List<String> list; |
| | | if (SecurityUtils.getClientId() == null) { |
| | | list = monitorMapper.listMonitorDeviceSerial(null); |
| | | } else { |
| | | listAirEquipmentId = monitorMapper.listMonitorId(monitorParam.getKeyword(), clientId, monitorParam.getBindingState()); |
| | | } |
| | | if (CollUtil.isEmpty(listAirEquipmentId)) { |
| | | return CollUtil.newArrayList(); |
| | | list = monitorMapper.listMonitorDeviceSerial(SecurityUtils.getUserId()); |
| | | } |
| | | |
| | | List<MonitorBo> monitorList = monitorMapper.listMonitorByIds(listAirEquipmentId); |
| | | MonitorParam monitorParam1; |
| | | for (String devices_serial : list) { |
| | | monitorParam1 = new MonitorParam(); |
| | | monitorParam1.setAccessToken(getAccessToken()); |
| | | monitorParam1.setDeviceSerial(devices_serial); |
| | | getYSYMonitorInfoAndaddMonitorToTable(monitorParam1); |
| | | } |
| | | |
| | | |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | if (baseConditionVO != null) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | } |
| | | List<MonitorBo> monitorList; |
| | | //绑定状态:已绑定/未绑定/全部 |
| | | if (monitorParam.getBindingState() == null) { |
| | | //全部 |
| | | monitorParam.setBindingState(2); |
| | | } |
| | | if (monitorParam.getEquipmentState() == null) { |
| | | //全部 |
| | | monitorParam.setEquipmentState(2); |
| | | } |
| | | |
| | | monitorList = monitorMapper.listMonitorByIds(list, monitorParam.getKeyword(), monitorParam.getBindingState(), monitorParam.getEquipmentState(), clientId); |
| | | |
| | | return monitorList; |
| | | } |
| | | |
| | | public Monitor getYSYMonitorInfoAndaddMonitorToTable(MonitorParam monitorParam) { |
| | | YSY_MonitorDto getMonitorDto = getYSYMonitorInfo(getAccessToken(), monitorParam.getDeviceSerial()); |
| | | |
| | | // /** |
| | | // * 查询全部摄像头 |
| | | // */ |
| | | // public List<Monitor> listMonitor() { |
| | | // LambdaQueryWrapper<Monitor> wrapper = Wrappers.lambdaQuery(Monitor.class); |
| | | // List<Monitor> list = list(wrapper); |
| | | // |
| | | // return list; |
| | | // } |
| | | // |
| | | // /** |
| | | // * 模糊查询 |
| | | // */ |
| | | // public List<Monitor> listMonitorByKeyword(MonitorParam monitorParam) { |
| | | // //设备状态:在线/离线/全部 |
| | | // int equipmentState1; |
| | | // int equipmentState2; |
| | | // if (2 == monitorParam.getEquipmentState()) { |
| | | // //在线 |
| | | // equipmentState1 = 1; |
| | | // //离线 |
| | | // equipmentState2 = 0; |
| | | // } else { |
| | | // equipmentState1 = monitorParam.getEquipmentState(); |
| | | // equipmentState2 = monitorParam.getEquipmentState(); |
| | | // } |
| | | // |
| | | // //绑定状态:已绑定/未绑定/全部 |
| | | // int bindingState1; |
| | | // int bindingState2; |
| | | // if (2 == monitorParam.getBindingState()) { |
| | | // //已绑定 |
| | | // bindingState1 = 1; |
| | | // //未绑定 |
| | | // bindingState2 = 0; |
| | | // } else { |
| | | // bindingState1 = monitorParam.getBindingState(); |
| | | // bindingState2 = monitorParam.getBindingState(); |
| | | // } |
| | | //// return monitorMapper.listMonitorByKeyword(monitorParam.getKeyword(), equipmentState1, equipmentState2, bindingState1, bindingState2); |
| | | // return monitorMapper.listMonitorByKeyword1(baseConditionVO, monitorParam.getKeyword(), bindingState1, bindingState2); |
| | | // } |
| | | if ("200".equals(getMonitorDto.getCode())) { |
| | | Monitor monitor = getOne(Wrappers.lambdaQuery(Monitor.class).eq(Monitor::getDeviceSerial, monitorParam.getDeviceSerial())); |
| | | if (monitor != null) { |
| | | monitor.setDeviceSerial(getMonitorDto.getData().getDeviceSerial()); |
| | | if (monitorParam.getValidateCode() != null) { |
| | | 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()); |
| | | //更新摄像头状态 |
| | | updateById(monitor); |
| | | } else { |
| | | monitor = new Monitor(); |
| | | monitor.setDeviceSerial(getMonitorDto.getData().getDeviceSerial()); |
| | | if (monitorParam.getValidateCode() != null) { |
| | | 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()); |
| | | //更新摄像头状态 |
| | | save(monitor); |
| | | } |
| | | |
| | | return monitor; |
| | | } else { |
| | | throw new BusinessException(getMonitorDto.getMsg()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除摄像头 |
| | |
| | | } |
| | | |
| | | //删除摄像头设备前需要先解绑 |
| | | poleBindingService.unBindPole(monitor.getDeviceSerial()); |
| | | poleBindingService.unBindPole(null, monitor.getDeviceSerial()); |
| | | return removeById(Id); |
| | | } |
| | | |
| | |
| | | return accessTokenDto.getData().getAccessToken(); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取萤石云摄像头信息 无需验证accessToken |
| | | * |
| | | * @return |
| | | */ |
| | | public YSY_MonitorDto.MonitorDto getMonitorInfo(String deviceSerial) { |
| | | String token = getAccessToken(); |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("accessToken", token); |
| | | paramMap.put("deviceSerial", deviceSerial); |
| | | String s = HttpUtil.post(YSY_URL + GET_DEVICE_URL, paramMap); |
| | | YSY_MonitorDto monitorDto = JSON.parseObject(s, YSY_MonitorDto.class); |
| | | return monitorDto.getData(); |
| | | } |
| | | |
| | | /** |
| | | * 添加萤石云摄像头 |
| | | * |
| | | * @param accessToken 授权过程获取的access_token |
| | | * @param deviceSerial 设备序列号,存在英文字母的设备序列号,字母需为大写 |
| | | * @param validateCode 设备验证码,设备机身上的六位大写字母 |
| | | * // * @param validateCode 设备验证码,设备机身上的六位大写字母 |
| | | */ |
| | | public YSY_MonitorDto addYSYMonitor(String accessToken, String deviceSerial, String validateCode) { |
| | | // public YSY_MonitorDto addYSYMonitor(String accessToken, String deviceSerial) { |
| | | |
| | | Map<String, Object> paramMap = new HashMap<>(); |
| | | paramMap.put("accessToken", accessToken); |
| | | paramMap.put("deviceSerial", deviceSerial); |
| | | paramMap.put("validateCode", validateCode); |
| | | if (validateCode != null && validateCode.trim().length() != 0) { |
| | | paramMap.put("validateCode", validateCode); |
| | | } |
| | | String s = HttpUtil.post(YSY_URL + ADD_DEVICE_URL, paramMap); |
| | | System.out.println(s); |
| | | YSY_MonitorDto monitorDto = JSON.parseObject(s, YSY_MonitorDto.class); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 修改设备绑定状态 |
| | | * |
| | | * @param flag true为绑定 false 为解绑 |
| | | */ |
| | | public void updateBingdingState(boolean flag, String deviceCode) { |
| | | if (flag) {//绑定 |
| | | Monitor monitor = getOne(Wrappers.lambdaQuery(Monitor.class).eq(Monitor::getDeviceSerial, deviceCode)); |
| | | if (monitor == null) { |
| | | return; |
| | | } |
| | | monitor.setBindingState(1); |
| | | updateById(monitor); |
| | | } else {//解绑 |
| | | Monitor monitor = getOne(Wrappers.lambdaQuery(Monitor.class).eq(Monitor::getDeviceSerial, deviceCode)); |
| | | if (monitor == null) { |
| | | return; |
| | | } |
| | | monitor.setBindingState(0); |
| | | updateById(monitor); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改note |
| | | * |
| | | * @param deviceSerial |
| | | * @param notes |
| | | * @return |
| | | */ |
| | | public boolean updateNotes(String deviceSerial, String notes) { |
| | | if (deviceSerial == null || deviceSerial.trim().length() == 0 || notes == null) { |
| | | throw new BusinessException("修改备注参数有误!"); |
| | | } |
| | | Monitor one = getOne(Wrappers.lambdaQuery(Monitor.class).eq(Monitor::getDeviceSerial, deviceSerial)); |
| | | if (one != null) { |
| | | one.setNote(notes); |
| | | return updateById(one); |
| | | } else { |
| | | throw new BusinessException("摄像头设备不存在!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |