|
|
|
@ -17,6 +17,7 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.util.Date;
|
|
|
|
@ -59,6 +60,17 @@ public class TradeSecureServiceHanyinImpl implements TradeSecureService {
|
|
|
|
|
sftpUpload(file);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void manualDownloadHanyinSecureReport(Date date, boolean upload, HttpServletResponse resp) {
|
|
|
|
|
TradeSecureFile file = getSecureReportFile(date);
|
|
|
|
|
if (upload) {
|
|
|
|
|
sftpUpload(file);
|
|
|
|
|
}
|
|
|
|
|
if (resp != null) {
|
|
|
|
|
file.writeToHttp(resp);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void sftpUpload(TradeSecureFile file) {
|
|
|
|
|
Session session = null;
|
|
|
|
|
ChannelSftp command = null;
|
|
|
|
@ -75,8 +87,10 @@ public class TradeSecureServiceHanyinImpl implements TradeSecureService {
|
|
|
|
|
command.mkdir(dir);
|
|
|
|
|
}
|
|
|
|
|
String dest = dir + "/" + file.filename();
|
|
|
|
|
logger.debug("find dir, start uploading file:{}", dest);
|
|
|
|
|
command.put(new ByteArrayInputStream(file.content()), dest);
|
|
|
|
|
byte[] content = file.content();
|
|
|
|
|
logger.debug("find dir, start uploading file:{}(length:{})", dest, content.length);
|
|
|
|
|
command.put(new ByteArrayInputStream(content), dest);
|
|
|
|
|
logger.debug("uploading file finished:{}", dest);
|
|
|
|
|
} catch (IOException | JSchException | SftpException e) {
|
|
|
|
|
throw new ChannelNetworkException("Upload Secure file failed", e);
|
|
|
|
|
} finally {
|
|
|
|
|