| | |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | * 模糊查询 |
| | | */ |
| | | public List<MonitorBo> listMonitorByKeyword(BaseConditionVO baseConditionVO, MonitorParam monitorParam) { |
| | | Long clientId = SecurityUtils.getClientId(); |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | List<String> list; |
| | | if (SecurityUtils.getClientId() == null) { |
| | | list = monitorMapper.listMonitorDeviceSerial(null, monitorParam.getKeyword()); |
| | | } else { |
| | | list = monitorMapper.listMonitorDeviceSerial(SecurityUtils.getUserId(), monitorParam.getKeyword()); |
| | | } |
| | | |
| | | //没有数据时候直接返回空数组 |
| | | if (list.size() == 0 || list == null) { |
| | | List<MonitorBo> nullList = new ArrayList<>(); |
| | | return nullList; |
| | | } |
| | | |
| | | MonitorParam monitorParam1; |
| | | for (String devices_serial : list) { |
| | | monitorParam1 = new MonitorParam(); |
| | | monitorParam1.setAccessToken(getAccessToken()); |
| | | monitorParam1.setDeviceSerial(devices_serial); |
| | | getYSYMonitorInfoAndaddMonitorToTable(monitorParam1); |
| | | } |
| | | |
| | | if (baseConditionVO != null) { |
| | | PageHelper.startPage(baseConditionVO.getPageNo(), baseConditionVO.getPageSize()); |
| | | } |
| | | List<MonitorBo> monitorList; |
| | | //绑定状态:已绑定/未绑定/全部 |
| | | if (monitorParam.getBindingState() == null) { |
| | |
| | | monitorParam.setEquipmentState(2); |
| | | } |
| | | |
| | | monitorList = monitorMapper.listMonitorByIds(monitorParam.getKeyword(), monitorParam.getBindingState(), monitorParam.getEquipmentState(), clientId); |
| | | monitorList = monitorMapper.listMonitorByIds(list, monitorParam.getBindingState(), monitorParam.getEquipmentState()); |
| | | |
| | | return monitorList; |
| | | } |
| | | |
| | | public Monitor getYSYMonitorInfoAndaddMonitorToTable(MonitorParam monitorParam) { |
| | | YSY_MonitorDto getMonitorDto = getYSYMonitorInfo(getAccessToken(), monitorParam.getDeviceSerial()); |
| | | |
| | | 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()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 修改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("摄像头设备不存在!"); |
| | | } |
| | | } |
| | | |
| | | |
| | | } |