Merge remote-tracking branch 'origin/master'

master
luoyang 5 years ago
commit bb6f49fe3c

@ -13,7 +13,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jib-maven-plugin.version>1.1.2</jib-maven-plugin.version>
<docker-image.version>1.0.41</docker-image.version>
<docker-image.version>1.0.43</docker-image.version>
</properties>
<dependencies>

@ -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);
}

@ -80,6 +80,7 @@ public class TradeSecureFile {
for (TradeItem item : tradeItems) {
writer.println(item.line());
}
writer.flush();
content = bos.toByteArray();
return content;
} catch (IOException e) {

@ -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 (!upload && 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