瀚银上传文件被截断问题排查

master
yixian 6 years ago
parent 09209d9b88
commit 26c5c6c72d

@ -25,7 +25,6 @@ import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.permission.manager.ManagerMapping;
import au.com.royalpay.payment.manage.system.core.TradeSecureService;
import au.com.royalpay.payment.manage.system.core.beans.TradeSecureFile;
import au.com.royalpay.payment.manage.tradelog.core.TradeLogService;
import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.defines.TradeType;
@ -62,8 +61,6 @@ import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
@ -446,8 +443,8 @@ public class TestController implements ApplicationEventPublisherAware {
}
@ManagerMapping(value = "/secure/hanyin_reports/{date}", role = ManagerRole.DEVELOPER, method = RequestMethod.GET)
public void downloadHanyinSecureReports(@PathVariable String date) {
tradeSecureService.uploadSecureReport(DateTime.parse(date).toDate());
public void downloadHanyinSecureReports(@PathVariable String date, @RequestParam(defaultValue = "false") boolean upload, HttpServletResponse resp) {
tradeSecureService.manualDownloadHanyinSecureReport(DateTime.parse(date).toDate(), upload, resp);
}
@ManagerMapping(value = "/register/alipayOnlineGms", role = ManagerRole.DEVELOPER, method = RequestMethod.POST)

@ -2,6 +2,7 @@ package au.com.royalpay.payment.manage.system.core;
import au.com.royalpay.payment.manage.system.core.beans.TradeSecureFile;
import javax.servlet.http.HttpServletResponse;
import java.util.Date;
/**
@ -12,6 +13,7 @@ public interface TradeSecureService {
void uploadSecureReport(Date date);
TradeSecureFile getSecureReportFile(Date date);
void manualDownloadHanyinSecureReport(Date date, boolean upload, HttpServletResponse resp);
TradeSecureFile getSecureReportFile(Date date);
}

@ -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 {

Loading…
Cancel
Save