Merge remote-tracking branch 'origin/master'

master
luoyang 6 years ago
commit 404b3825a8

@ -458,9 +458,8 @@ public class TestController implements ApplicationEventPublisherAware {
}
@ManagerMapping(value = "/secure/hanyin_reports/{date}", role = ManagerRole.DEVELOPER, method = RequestMethod.GET)
public void downloadHanyinSecureReports(@PathVariable String date, HttpServletResponse response) {
TradeSecureFile file = tradeSecureService.getSecureReportFile(DateTime.parse(date).toDate());
file.writeToHttp(response);
public void downloadHanyinSecureReports(@PathVariable String date) {
tradeSecureService.uploadSecureReport(DateTime.parse(date).toDate());
}
}

@ -21,6 +21,7 @@ import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Vector;
/**
* Create by yixian at 2019-01-08 3:26
@ -66,15 +67,15 @@ public class TradeSecureServiceHanyinImpl implements TradeSecureService {
Channel channel = session.openChannel("sftp");
channel.connect();
command = (ChannelSftp) channel;
command.ls("/royalpay");
String dir = "/royalpay/" + file.getTransDate().toString("yyyyMMdd");
logger.debug("removing dir:{}", dir);
command.rmdir(dir);
logger.debug("rmdir success");
logger.debug("mk dir:{}", dir);
command.mkdir(dir);
String dest = dir + file.filename();
logger.debug("rmdir success, start uploading file:{}", dest);
String dateString = file.getTransDate().toString("yyyyMMdd");
Vector<ChannelSftp.LsEntry> folders = command.ls("/royalpay");
String dir = "/royalpay/" + dateString;
if (folders.parallelStream().noneMatch(entry -> entry.getFilename().endsWith(dateString))) {
logger.debug("mk dir:{}", dir);
command.mkdir(dir);
}
String dest = dir + "/" + file.filename();
logger.debug("find dir, start uploading file:{}", dest);
command.put(new ByteArrayInputStream(file.content()), dest);
} catch (IOException | JSchException | SftpException e) {
throw new ChannelNetworkException("Upload Secure file failed", e);

Loading…
Cancel
Save