| | |
| | | // 录像查询以channelId作为deviceId查询 |
| | | String key = DeferredResultHolder.UPLOAD_FILE_CHANNEL; |
| | | String uuid = UUID.randomUUID().toString(); |
| | | |
| | | logger.warn("通道导入文件类型: {}",file.getContentType() ); |
| | | if (file.isEmpty()) { |
| | | logger.warn("通道导入文件为空"); |
| | | WVPResult<Object> wvpResult = new WVPResult<>(); |
| | |
| | | result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult)); |
| | | return result; |
| | | } |
| | | if (!file.getContentType().endsWith(".xls") |
| | | && !file.getContentType().endsWith(".csv") |
| | | && !file.getContentType().endsWith(".xlsx") ) { |
| | | logger.warn("通道导入文件类型错误"); |
| | | WVPResult<Object> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(-1); |
| | | wvpResult.setMsg("文件类型错误,请使用"); |
| | | result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult)); |
| | | return result; |
| | | } |
| | | // if (!file.getContentType().endsWith(".xls") |
| | | // && !file.getContentType().endsWith(".csv") |
| | | // && !file.getContentType().endsWith(".xlsx") ) { |
| | | // logger.warn("通道导入文件类型错误: {}",file.getContentType() ); |
| | | // WVPResult<Object> wvpResult = new WVPResult<>(); |
| | | // wvpResult.setCode(-1); |
| | | // wvpResult.setMsg("文件类型错误,请使用"); |
| | | // result.setResult(ResponseEntity.status(HttpStatus.BAD_REQUEST).body(wvpResult)); |
| | | // return result; |
| | | // } |
| | | // 同时只处理一个文件 |
| | | if (resultHolder.exist(key, null)) { |
| | | logger.warn("已有导入任务正在执行"); |
| | |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | try { |
| | | //传入参数 |
| | | ExcelReader excelReader = EasyExcel.read(inputStream, StreamPushExcelDto.class, |
| | | new StreamPushUploadFileHandler(streamPushService, mediaServerService.getDefaultMediaServer().getId(), (errorStreams, errorGBs)->{ |
| | |
| | | ReadSheet readSheet = EasyExcel.readSheet(0).build(); |
| | | excelReader.read(readSheet); |
| | | excelReader.finish(); |
| | | }catch (Exception e) { |
| | | logger.warn("通道导入失败:", e); |
| | | RequestMessage msg = new RequestMessage(); |
| | | msg.setKey(key); |
| | | WVPResult<Object> wvpResult = new WVPResult<>(); |
| | | wvpResult.setCode(-1); |
| | | wvpResult.setMsg("通道导入失败: " + e.getMessage() ); |
| | | msg.setData(wvpResult); |
| | | resultHolder.invokeAllResult(msg); |
| | | } |
| | | |
| | | |
| | | return result; |
| | | } |
| | | |