add SAP系统 核销接口客户端代码
This commit is contained in:
parent
cea473d2f2
commit
95df5e1ec6
|
@ -26,10 +26,7 @@ import shkd.fi.fi.util.LogBillUtils;
|
||||||
import shkd.fi.fi.util.ParamsUtils;
|
import shkd.fi.fi.util.ParamsUtils;
|
||||||
import shkd.fi.fi.util.SFTPConnectUtil;
|
import shkd.fi.fi.util.SFTPConnectUtil;
|
||||||
|
|
||||||
import java.io.FileInputStream;
|
import java.io.*;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.UnsupportedEncodingException;
|
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.rmi.RemoteException;
|
import java.rmi.RemoteException;
|
||||||
|
@ -109,8 +106,18 @@ public class OAInvoiceImpl {
|
||||||
path = URLDecoder.decode(path,"UTF-8");
|
path = URLDecoder.decode(path,"UTF-8");
|
||||||
path = FilePathUtil.dealPath(path,"attach");
|
path = FilePathUtil.dealPath(path,"attach");
|
||||||
InputStream inputStream = FileServiceFactory.getAttachmentFileService().getInputStream(path);
|
InputStream inputStream = FileServiceFactory.getAttachmentFileService().getInputStream(path);
|
||||||
FileInputStream fileInputStream = (FileInputStream) inputStream;
|
String suffix = filename.substring(filename.lastIndexOf("."));
|
||||||
boolean flag = SFTPConnectUtil.uploadFile("/usr/local/nginx/html/", fileInputStream, filename, sftp);
|
File tempFile = File.createTempFile(filename,suffix);
|
||||||
|
tempFile.deleteOnExit();
|
||||||
|
try (FileOutputStream outputStream = new FileOutputStream(tempFile)) {
|
||||||
|
byte[] buffer = new byte[1024];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = inputStream.read(buffer)) != -1) {
|
||||||
|
outputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean flag = SFTPConnectUtil.uploadFile("/usr/local/nginx/html/", tempFile, sftp,filename);
|
||||||
|
|
||||||
if(flag){
|
if(flag){
|
||||||
String filenameEn = URLEncoder.encode(filename);
|
String filenameEn = URLEncoder.encode(filename);
|
||||||
|
@ -120,6 +127,10 @@ public class OAInvoiceImpl {
|
||||||
log.info("url参数转义后:"+url);
|
log.info("url参数转义后:"+url);
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -88,11 +88,11 @@ public class SFTPConnectUtil {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean uploadFile(String directory, File uploadFile,
|
public static boolean uploadFile(String directory, File uploadFile,
|
||||||
ChannelSftp sftp) {
|
ChannelSftp sftp,String fileName) {
|
||||||
try {
|
try {
|
||||||
// 进入指定目录
|
// 进入指定目录
|
||||||
sftp.cd(directory);
|
sftp.cd(directory);
|
||||||
sftp.put(new FileInputStream(uploadFile), uploadFile.getName());
|
sftp.put(new FileInputStream(uploadFile), fileName);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
logger.error("uploadFile -- FileNotFoundException:" + e.toString());
|
logger.error("uploadFile -- FileNotFoundException:" + e.toString());
|
||||||
return false;
|
return false;
|
||||||
|
@ -292,7 +292,7 @@ public class SFTPConnectUtil {
|
||||||
/**
|
/**
|
||||||
* 判断对象是否为空
|
* 判断对象是否为空
|
||||||
*
|
*
|
||||||
* @param str
|
* @param
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public static boolean isEmpty(Object obj) {
|
public static boolean isEmpty(Object obj) {
|
||||||
|
|
Loading…
Reference in New Issue