|
@@ -1,11 +1,10 @@
|
|
package com.jkcredit.asychronous.job;
|
|
package com.jkcredit.asychronous.job;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
-import com.jkcredit.asychronous.common.ResponseEntity;
|
|
|
|
import com.jkcredit.asychronous.entity.Man;
|
|
import com.jkcredit.asychronous.entity.Man;
|
|
import com.jkcredit.asychronous.service.ManService;
|
|
import com.jkcredit.asychronous.service.ManService;
|
|
import com.jkcredit.asychronous.util.ExcelUtil;
|
|
import com.jkcredit.asychronous.util.ExcelUtil;
|
|
-import com.jkcredit.asychronous.util.FtpUtil;
|
|
|
|
|
|
+import com.jkcredit.asychronous.util.SFTPUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
@@ -33,20 +32,21 @@ public class ManJob {
|
|
private Integer port;
|
|
private Integer port;
|
|
@Value("${ftp.username}")
|
|
@Value("${ftp.username}")
|
|
private String userName;
|
|
private String userName;
|
|
- @Value("${ftp.password}")
|
|
|
|
- private String passWord;
|
|
|
|
|
|
+ @Value("${ftp.passphrase}")
|
|
|
|
+ private String passphrase;
|
|
@Value("${ftp.dir.man}")
|
|
@Value("${ftp.dir.man}")
|
|
private String dir;
|
|
private String dir;
|
|
|
|
+ @Value("${ftp.keyFilePath}")
|
|
|
|
+ private String keyFilePath;
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private ManService manService;
|
|
private ManService manService;
|
|
|
|
|
|
@Scheduled(cron = "0/10 * * * * ?")
|
|
@Scheduled(cron = "0/10 * * * * ?")
|
|
- public void car() {
|
|
|
|
|
|
+ public void man() {
|
|
Long beginTime= System.currentTimeMillis() - 10000;
|
|
Long beginTime= System.currentTimeMillis() - 10000;
|
|
Long endTime = System.currentTimeMillis();
|
|
Long endTime = System.currentTimeMillis();
|
|
List<Man> list = manService.selectByTime(beginTime,endTime);
|
|
List<Man> list = manService.selectByTime(beginTime,endTime);
|
|
-// log.info("开始 公安不良excel 导出");
|
|
|
|
if (list.size() > 0) {
|
|
if (list.size() > 0) {
|
|
JSONArray ja = new JSONArray();
|
|
JSONArray ja = new JSONArray();
|
|
for(Man man : list){
|
|
for(Man man : list){
|
|
@@ -57,27 +57,25 @@ public class ManJob {
|
|
headMap.put("name","姓名");
|
|
headMap.put("name","姓名");
|
|
headMap.put("idCard","身份证号");
|
|
headMap.put("idCard","身份证号");
|
|
String fileName = localDir + File.separator + endTime.toString() + ".xlsx";
|
|
String fileName = localDir + File.separator + endTime.toString() + ".xlsx";
|
|
- // todo 异常 系统找不到路径
|
|
|
|
try {
|
|
try {
|
|
OutputStream outXlsx = new FileOutputStream(fileName);
|
|
OutputStream outXlsx = new FileOutputStream(fileName);
|
|
ExcelUtil.exportExcelX(headMap,ja,null,0,outXlsx);
|
|
ExcelUtil.exportExcelX(headMap,ja,null,0,outXlsx);
|
|
outXlsx.close();
|
|
outXlsx.close();
|
|
} catch (FileNotFoundException e) {
|
|
} catch (FileNotFoundException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
|
+ log.info("FileNotFoundException找不到路径");
|
|
} catch (IOException e) {
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
}
|
|
}
|
|
-// String fileName = ExcelUtil.export(list, Man.class, localDir,endTime.toString());
|
|
|
|
-// log.info("ManExcel:{}", fileName);
|
|
|
|
- FtpUtil.fileUpload(host, port, userName, passWord, dir, fileName);
|
|
|
|
|
|
+ try {
|
|
|
|
+ SFTPUtil.upload(host, port, userName, passphrase, File.separator + dir + File.separator + endTime.toString() + ".xlsx", fileName, keyFilePath);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
-// else {
|
|
|
|
-// log.error("error:{}1", new ResponseEntity(400, "公安不良信息未查到", ""));
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- //@Scheduled(cron = "0 0/30 * * * ?")
|
|
|
|
|
|
+ @Scheduled(cron = "0 19 16 * * ?", zone = "Asia/Shanghai")
|
|
public void test(){
|
|
public void test(){
|
|
|
|
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
|
|
SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");//设置日期格式
|
|
@@ -107,6 +105,6 @@ public class ManJob {
|
|
}
|
|
}
|
|
// String fileName = ExcelUtil.export(list, Man.class, localDir,endTime.toString());
|
|
// String fileName = ExcelUtil.export(list, Man.class, localDir,endTime.toString());
|
|
// log.info("ManExcel:{}", fileName);
|
|
// log.info("ManExcel:{}", fileName);
|
|
- FtpUtil.fileUpload(host, port, userName, passWord, dir, fileName);
|
|
|
|
|
|
+// SFTPUtil.upload(host, port, userName, passphrase, dir, fileName);
|
|
}
|
|
}
|
|
}
|
|
}
|