| | |
| | | } |
| | | |
| | | @ApiOperation("删除用户wav语音文件") |
| | | @DeleteMapping("wavRead") |
| | | @PostMapping("deleteWavRead") |
| | | public void deleteWavRead(@RequestParam(required = false) String fileFullName){ |
| | | //过滤特殊字符,避免路径遍历攻击 |
| | | fileFullName = ActionUtil.filterFileName(fileFullName); |
| | | UserInf user = ActionUtil.getUser(); |
| | | //获取绝对文件夹路径 |
| | | String unreadSuffixPath = "wav" + File.separator + "alarm" + File.separator + user.getUId() + File.separator + "unread"; |
| | |
| | | } |
| | | |
| | | @ApiOperation("用户wav语音文件播放完毕") |
| | | @PutMapping("wavRead") |
| | | @PostMapping("wavRead") |
| | | public void updateWavRead(@RequestParam(required = false) String fileFullName){ |
| | | //过滤特殊字符,避免路径遍历攻击 |
| | | fileFullName = ActionUtil.filterFileName(fileFullName); |
| | | UserInf user = ActionUtil.getUser(); |
| | | long currentTimeMillis = System.currentTimeMillis(); |
| | | Long specialId = null; |
| | |
| | | String[] nameSplit = fileFullName.split("_"); |
| | | specialId = Long.parseLong(nameSplit[3]); |
| | | alarmType = Integer.parseInt(nameSplit[4]); |
| | | String readableVoiceTimeWithWav = nameSplit[5]+".wav"; |
| | | String readableVoiceTimeWithWav = nameSplit[5]; |
| | | AlarmVoiceSet nextTimeIntervalSet = alarmVoiceSetService.getNextTimeInterval(user.getUId(), type, specialId, alarmType); |
| | | int addedTimeMillis = 0; |
| | | if(nextTimeIntervalSet !=null){ |
| | |
| | | alarmVoiceSetService.delete(nextTimeIntervalSet.getId()); |
| | | }else{ //默认5分钟 |
| | | addedTimeMillis = 5*60*1000; |
| | | //addedTimeMillis = 1*60*1000; |
| | | } |
| | | String readableVoiceTimeWithWavNew = currentTimeMillis+addedTimeMillis+".wav"; |
| | | //文件下次播放时间确定新的文件名 |
| | |
| | | @ApiOperation("查询用户目前可读的wav语音文件列表") |
| | | @GetMapping("wavRead") |
| | | public Response getWavRead(){ |
| | | UserInf user = ActionUtil.getUser(); |
| | | //获取绝对文件夹路径 |
| | | String readSuffixPath = "wav" + File.separator + "alarm" + File.separator + user.getUId() + File.separator; |
| | | String readDirPath = CommonUtil.getRootFile() + readSuffixPath; |
| | | File readDir = new File(readDirPath); |
| | | //监控用户的告警,包含生成,内存信息更新 |
| | | alarmDataService.monitorAlarm(readDirPath); |
| | | if(!readDir.exists()){ |
| | | return new Response().set(1,false,"无未读告警语音"); |
| | | }else{ |
| | | String[] arr = readDir.list(); |
| | | if(arr.length==0){ |
| | | return new Response().set(1,false,"无未读告警语音"); |
| | | } |
| | | List<String> fileNameList = new LinkedList<>(); |
| | | for (String fileName : arr) { |
| | | long currentTimeMillis = System.currentTimeMillis(); |
| | | long readableVoiceTime = Long.parseLong(fileName.substring(fileName.lastIndexOf("_") + 1, fileName.lastIndexOf("."))); |
| | | //可播放时间<当前时间,输出播放 |
| | | if(readableVoiceTime<currentTimeMillis) { |
| | | fileName = "fg_file" + File.separator + readSuffixPath + File.separator + fileName; |
| | | fileNameList.add(fileName); |
| | | } |
| | | } |
| | | return new Response().setII(1,true,fileNameList,null); |
| | | } |
| | | return alarmDataService.getWavRead(); |
| | | } |
| | | |
| | | } |