|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
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;
|
|
|
|
@ -8,13 +9,16 @@ 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 曾文和
|
|
|
|
@ -38,6 +42,21 @@ public class TestController {
|
|
|
|
|
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 "完成";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除指定数据段的文件,
|
|
|
|
@ -45,37 +64,12 @@ public class TestController {
|
|
|
|
|
* @param args liuyu
|
|
|
|
|
*/
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Date date1 = new Date();
|
|
|
|
|
Calendar calendar = Calendar.getInstance(); //得到日历
|
|
|
|
|
calendar.setTime(date1);//把当前时间赋给日历
|
|
|
|
|
calendar.add(calendar.DATE, -15); //设置为前15天
|
|
|
|
|
Date date2 = calendar.getTime();//获取15天前的时间
|
|
|
|
|
DateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
Date date;
|
|
|
|
|
//转换成时间戳
|
|
|
|
|
long t1 = date2.getTime();
|
|
|
|
|
try {
|
|
|
|
|
File f = new File("D:\\docus\\caCopy");
|
|
|
|
|
File[] files = f.listFiles();
|
|
|
|
|
for (int i = 0; i < files.length; i++) {
|
|
|
|
|
//获取文件路径
|
|
|
|
|
String filePath = files[i].getCanonicalPath();
|
|
|
|
|
//获取文件名,文件名为yyyy--mm--dd格式时间
|
|
|
|
|
String lastTime = files[i].getName();
|
|
|
|
|
//将lastTime时间转为long类型
|
|
|
|
|
try {
|
|
|
|
|
date = format.parse(lastTime);
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
throw new RuntimeException(e);
|
|
|
|
|
}
|
|
|
|
|
Long timestamp = date.getTime();
|
|
|
|
|
if (timestamp < t1) {
|
|
|
|
|
//删除
|
|
|
|
|
FileSystemUtils.deleteRecursively(new File(filePath));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|