lxw
2023-05-25 f3c27fb78447449a950ba73c5e72ceda64ad8a12
src/main/java/com/whyc/controller/VoiceController.java
@@ -114,6 +114,7 @@
            alarmVoiceSetService.delete(nextTimeIntervalSet.getId());
        }else{ //默认5分钟
            addedTimeMillis = 5*60*1000;
            //addedTimeMillis = 1*60*1000;
        }
        String readableVoiceTimeWithWavNew = currentTimeMillis+addedTimeMillis+".wav";
        //文件下次播放时间确定新的文件名
@@ -133,32 +134,7 @@
    @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();
    }
}