package com.emr.controller;

import com.emr.service.ipml.CaSignServiceImpl;
import com.emr.util.Jpg2PdfUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.util.FileSystemUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author 曾文和
 * @description: XXX类
 * @createTime 2023/7/25 11:02
 */
@Controller
public class TestController {
    @Resource
    private CaSignServiceImpl caSignService;
    @Value("${caCopyPath}")
    private String caCopyPath;

    @RequestMapping("font/test")
    @ResponseBody
    public String test(String masterId) throws Exception {
        long start = System.currentTimeMillis();
        caSignService.caSignByMasterId(masterId);
        long end = System.currentTimeMillis();
        System.out.println("执行后：" + (end - start));
        return "完成";
    }

    @RequestMapping("font/testPdf")
    @ResponseBody
    public String testPdf(HttpServletResponse response) throws Exception {
        String path = "F:\\isDelete\\mr_file\\pdf\\pdf";
        File file = new File(path);
        File[] files = file.listFiles();
        List<String> list = new ArrayList<>();
        for(File file1 : files){
            String absolutePath = file1.getAbsolutePath();
            list.add(absolutePath);
        }
        Jpg2PdfUtil.mulFile2One(response,list,null);
        return "完成";
    }


    /**
     * 删除指定数据段的文件，
     *
     * @param args liuyu
     */
    public static void main(String[] args) {
        String path = "F:\\isDelete\\mr_file\\pdf\\pdf";
        File file = new File(path);
        File[] files = file.listFiles();
        for(File file1 : files){
            String absolutePath = file1.getAbsolutePath();
            System.out.println(absolutePath);
        }
    }
}
