审查视图

src/main/java/com/tianbo/analysis/controller/IndexController.java 1.9 KB
朱兆平 authored
1
package com.tianbo.analysis.controller;
朱兆平 authored
2
朱兆平 authored
3 4
import com.tianbo.util.IO.FileTool;
import lombok.extern.slf4j.Slf4j;
朱兆平 authored
5 6
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
朱兆平 authored
7
import org.springframework.web.bind.annotation.RequestParam;
朱兆平 authored
8
朱兆平 authored
9 10 11 12
import java.io.File;
import java.util.List;

@Slf4j
朱兆平 authored
13 14 15 16 17 18 19
@Controller
public class IndexController {

    @RequestMapping("/")
    public String index(){
        return "index";
    }
20 21 22 23 24

    @RequestMapping("/flight/reseption")
    public String reception(){
        return "flight/res";
    }
朱兆平 authored
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61

    @RequestMapping("/devops/watchdir")
    public Integer singlewindow(@RequestParam(value = "dir",required = true,defaultValue = "D:\\系统部署\\imf_Warehouse_reader\\xmlFromImf") String dir){
        switch (dir){
            case "stcs" :
                dir = "D:\\TCSSingleWindow\\recive";
                break;
            case "tcs" :
                dir = "D:\\Data\\Receive";
                break;
            case "cfps" :
                dir = "D:\\系统部署\\imf_Warehouse_reader\\xmlFromImf";
                break;
            default:
                dir = "D:\\TCSSingleWindow\\recive";
                break;
        }
        try{
            File fileDirectory = new File(dir);
            if (!fileDirectory.exists()){
                log.error("目录{}不存在",dir);
            }else{
                log.info("{}{}{}","开始获取目录",dir,"文件数量");
                List<File> files = FileTool.readAllDirectoryFiles(fileDirectory);
                if(files!=null && !files.isEmpty()){
                    log.info("{}{}{}{}","目录",dir,"文件数量为:",files.size());
                    return files.size();
                }else {
                    return 0;
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            log.error("获取目录文件出错",e);
        }
        return 500;
    }
朱兆平 authored
62
}