Commit 227cabc7 authored by 续晓东's avatar 续晓东 🤺

修改参数

parent 9ea7d2ab
......@@ -71,13 +71,14 @@ public class PullFileTask {
//每日23点执行;
@Scheduled(cron ="0 0 23 * * ?" )
@Scheduled(cron ="0 10 20 * * ?" )
//@Scheduled(fixedRate = 10000)
//@PostConstruct
public void PullFileAndSendDi() throws Exception {
FtpUtil.FtpConfig ftpConfig = new FtpUtil.FtpConfig().setHost(host).setPort(port).setUserName(userName).setPassword(password);
Calendar c = Calendar.getInstance();
c.setTime(new Date());
c.add(Calendar.DATE, -1);
c.add(Calendar.DATE, -2);
String fileName = "#"+dateFormat.format(c.getTime());
log.info("开始下载----"+fileName);
......@@ -90,18 +91,20 @@ public class PullFileTask {
PostGISMannager postGIS = new PostGISMannager(dbHost, dbPort,
dbName, tbName, dbUserName, dbPassword);
postGIS.createOlrDay(tbName);
if(postGIS.insertOlrToPG(tbName, localPath + fileName)>0){
// 发送Di
afterDown = System.currentTimeMillis();
Date start = new Date(beforeDown);
String diJson = sendDi(c.getTime(), new Date(beforeDown), new Date(afterDown), fileName, "1");
OkHttpClient httpClient = new OkHttpClient();
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), JSONObject.toJSONString(diJson));
RequestBody requestBody = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), diJson);
Request request = new Request.Builder()
.url("127.0.0.1:29999/transfer")
.url("http://127.0.0.1:29999/transfer")
.post(requestBody)
.build();
//发送请求获取响应
......@@ -111,6 +114,7 @@ public class PullFileTask {
if(response.isSuccessful()){
//打印服务端返回结果
log.info("请求代理返回结果==========:"+response.body().string());
log.info("请求di的Json========="+diJson);
}
} catch (IOException e) {
......@@ -157,11 +161,11 @@ public class PullFileTask {
}
// @PostConstruct
@PostConstruct
public void a() throws Exception {
FtpUtil.FtpConfig ftpConfig = new FtpUtil.FtpConfig().setHost(host).setPort(port).setUserName(userName).setPassword(password);
Date dateStart = dateFormat.parse("20191119");
Date dateEnd = dateFormat.parse("20191119");
Date dateStart = dateFormat.parse("20200325");
Date dateEnd = dateFormat.parse("20200325");
Calendar c = Calendar.getInstance();
PostGISMannager postGIS = new PostGISMannager(dbHost, dbPort,
dbName, tbName, dbUserName, dbPassword);
......
......@@ -144,6 +144,7 @@ public class FtpUtil {
try {
FTPClient ftpClient = connectClient(ftpConfig);
boolean changeResult = ftpClient.changeWorkingDirectory(remotePath);
if (!changeResult) {
throw new RuntimeException("切换目录失败");
}
......@@ -203,7 +204,7 @@ public class FtpUtil {
// 关闭本地文件流
inputStream.close();
// 退出FTP
ftpClient.logout();
// ftpClient.logout();
//归还对象
offer(ftpClient);
return result;
......@@ -221,6 +222,7 @@ public class FtpUtil {
*/
private static FTPClient connectClient(FtpConfig ftpConfig) throws IOException {
FTPClient ftpClient = getClient();
ftpClient.enterLocalPassiveMode();
// 连接FTP服务器
ftpClient.connect(ftpConfig.host, ftpConfig.port);
// 登录FTP
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment