|
|
|
@ -1,11 +1,20 @@
|
|
|
|
|
package com.emr.controller;
|
|
|
|
|
|
|
|
|
|
import com.emr.service.ipml.CaSignServiceImpl;
|
|
|
|
|
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 java.io.File;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Calendar;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @author 曾文和
|
|
|
|
@ -16,13 +25,57 @@ import javax.annotation.Resource;
|
|
|
|
|
public class TestController {
|
|
|
|
|
@Resource
|
|
|
|
|
private CaSignServiceImpl caSignService;
|
|
|
|
|
@Value("${caCopyPath}")
|
|
|
|
|
private String caCopyPath;
|
|
|
|
|
|
|
|
|
|
@RequestMapping("font/test")
|
|
|
|
|
@ResponseBody
|
|
|
|
|
public String test(String masterId) throws Exception{
|
|
|
|
|
public String test(String masterId) throws Exception {
|
|
|
|
|
long start = System.currentTimeMillis();
|
|
|
|
|
caSignService.caSignByMasterId(masterId);
|
|
|
|
|
long end = System.currentTimeMillis();
|
|
|
|
|
System.out.println("执行后:"+(end-start));
|
|
|
|
|
System.out.println("执行后:" + (end - start));
|
|
|
|
|
return "完成";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 删除指定数据段的文件,
|
|
|
|
|
*
|
|
|
|
|
* @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();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|