Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-zx-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Jobs
Commits
Open sidebar
项目统一框架
一体化_户用光伏项目代码
amos-boot-zx-biz
Commits
ffdba4d4
Commit
ffdba4d4
authored
Dec 20, 2024
by
chenzhao
Committed by
hezhuozhi
Dec 20, 2024
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
工行代扣回盘下载接口修改
parent
630f3084
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
18 deletions
+83
-18
IcbcWithholdDto.java
...eejoin/amos/boot/module/hygf/api/dto/IcbcWithholdDto.java
+3
-0
SFTPUtil.java
.../com/yeejoin/amos/boot/module/hygf/api/util/SFTPUtil.java
+58
-8
IcbcWithholdController.java
...ot/module/hygf/biz/controller/IcbcWithholdController.java
+3
-3
IcbcWithholdServiceImpl.java
...module/hygf/biz/service/impl/IcbcWithholdServiceImpl.java
+19
-7
No files found.
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/dto/IcbcWithholdDto.java
View file @
ffdba4d4
...
...
@@ -73,6 +73,9 @@ public class IcbcWithholdDto extends BaseDto {
* 失败原因
*/
private
String
uploadErrorDesc
;
private
String
receiptFile
;
/**
* 失败原因
*/
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-api/src/main/java/com/yeejoin/amos/boot/module/hygf/api/util/SFTPUtil.java
View file @
ffdba4d4
...
...
@@ -257,8 +257,6 @@ public class SFTPUtil {
if
(
null
!=
output
)
{
output
.
close
();
}
// 关闭连接
disconnect
();
}
catch
(
IOException
e
)
{
logger
.
error
(
"关闭文件时出错!"
);
logger
.
error
(
e
.
getMessage
());
...
...
@@ -275,14 +273,57 @@ public class SFTPUtil {
* @param localZipPath 本地ZIP文件保存路径
* @return 是否成功
*/
public
boolean
downloadAndZipFiles
(
String
remotePath
,
String
filenamePattern
,
String
localZipPath
)
{
// public boolean downloadAndZipFiles(String remotePath, String filenamePattern, String localZipPath) {
// boolean success = false;
// Path tempDir = null;
// try {
// // 创建临时目录
// tempDir = Files.createTempDirectory("sftp_download_temp");
//
// // 列出远程目录中的所有文件`
// Vector<?> filesList = sftp.ls(remotePath);
//
// List<Path> downloadedFiles = new ArrayList<>();
// for (Object obj : filesList) {
// ChannelSftp.LsEntry entry = (ChannelSftp.LsEntry) obj;
// String filename = entry.getFilename();
// if (filename.contains(filenamePattern)) {
// Path localFilePath = tempDir.resolve(filename);
// downloadFile(remotePath, filename, localFilePath.toString());
// downloadedFiles.add(localFilePath);
// }
// }
//
// // 打包下载的文件到ZIP文件
// FileUtils.createZipFile(downloadedFiles, localZipPath);
// success = true;
// logger.info("成功接收文件并打包到ZIP文件: " + localZipPath);
// } catch (Exception e) {
// logger.error("下载或打包文件时发生异常!", e);
// } finally {
// try {
// // 删除临时目录及其内容
// if (tempDir != null) {
// FileUtils.cleanup(tempDir);
// }
// disconnect();
// } catch (IOException e) {
// logger.error("删除临时目录时出错!", e);
// } catch (Exception e) {
// e.printStackTrace();
// }
// }
// return success;
// }
public
boolean
downloadAndZipFiles
(
String
remotePath
,
String
filenamePattern
,
String
localZipPath
)
{
boolean
success
=
false
;
Path
tempDir
=
null
;
try
{
// 创建临时目录
tempDir
=
Files
.
createTempDirectory
(
"sftp_download_temp"
);
// 列出远程目录中的所有文件
`
// 列出远程目录中的所有文件
Vector
<?>
filesList
=
sftp
.
ls
(
remotePath
);
List
<
Path
>
downloadedFiles
=
new
ArrayList
<>();
...
...
@@ -295,13 +336,24 @@ public class SFTPUtil {
downloadedFiles
.
add
(
localFilePath
);
}
}
disconnect
();
// 确保本地ZIP路径的父目录存在
Path
localZipFilePath
=
Paths
.
get
(
localZipPath
);
Path
parentDir
=
localZipFilePath
.
getParent
();
if
(
parentDir
!=
null
&&
!
Files
.
exists
(
parentDir
))
{
Files
.
createDirectories
(
parentDir
);
}
// 打包下载的文件到ZIP文件
FileUtils
.
createZipFile
(
downloadedFiles
,
localZipPath
);
FileUtils
.
createZipFile
(
downloadedFiles
,
localZipPath
);
success
=
true
;
logger
.
info
(
"成功接收文件并打包到ZIP文件: "
+
localZipPath
);
}
catch
(
SftpException
e
)
{
logger
.
error
(
"下载文件时发生异常!"
,
e
);
}
catch
(
IOException
e
)
{
logger
.
error
(
"处理文件或创建目录时发生异常!"
,
e
);
}
catch
(
Exception
e
)
{
logger
.
error
(
"
下载或打包文件时发生
异常!"
,
e
);
logger
.
error
(
"
其他
异常!"
,
e
);
}
finally
{
try
{
// 删除临时目录及其内容
...
...
@@ -317,8 +369,6 @@ public class SFTPUtil {
}
return
success
;
}
/**
* 上传文件至远程sftp服务器
*
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/controller/IcbcWithholdController.java
View file @
ffdba4d4
...
...
@@ -180,7 +180,7 @@ public class IcbcWithholdController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
" 聚富通代扣信息回盘文件获取"
,
notes
=
" 聚富通代扣信息回盘文件获取"
)
@GetMapping
(
value
=
"/downLoadicbcFile"
)
public
ResponseModel
<
String
>
downLoadicbcFile
(
Long
sequenceNbr
,
String
batchNo
,
HttpServletResponse
response
)
throws
Exception
{
public
ResponseModel
downLoadicbcFile
(
Long
sequenceNbr
,
String
batchNo
,
HttpServletResponse
response
)
throws
Exception
{
icbcWithholdServiceImpl
.
downLoadicbcFile
(
batchNo
,
sequenceNbr
,
response
);
return
ResponseHelper
.
buildResponse
(
null
);
}
...
...
@@ -192,9 +192,9 @@ public class IcbcWithholdController extends BaseController {
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
" 聚富通代扣信息回盘文件获取"
,
notes
=
" 聚富通代扣信息回盘文件获取"
)
@GetMapping
(
value
=
"/updateWithholdStatus"
)
public
ResponseModel
updateWithholdStatus
(
)
throws
Exception
{
public
void
updateWithholdStatus
(
)
throws
Exception
{
icbcWithholdServiceImpl
.
updateWithholdStatus
();
return
CommonResponseNewUtil
.
success
();
}
/**
...
...
amos-boot-system-jxiop/amos-boot-module-hygf-biz/src/main/java/com/yeejoin/amos/boot/module/hygf/biz/service/impl/IcbcWithholdServiceImpl.java
View file @
ffdba4d4
...
...
@@ -328,7 +328,7 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
this
.
downloadAndSaveZipFile
(
model
.
getReceiptFile
(),
batchNo
,
"回盘文件"
,
response
);
}
String
path
=
new
ClassPathResource
(
file
+
"secretKey/
login
-gxjrid_rsa"
).
getPath
();
String
path
=
new
ClassPathResource
(
file
+
"secretKey/
登录
-gxjrid_rsa"
).
getPath
();
SFTPUtil
sftp
=
new
SFTPUtil
(
sftpIp
,
sftpPort
,
sftpUserName
,
path
,
null
);
...
...
@@ -340,6 +340,19 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
sftp
.
priKeyConnect
();
Path
currentWorkingDir
=
Paths
.
get
(
""
);
Path
dirPath
=
currentWorkingDir
.
resolve
(
batchNo
);
try
{
if
(!
Files
.
exists
(
dirPath
))
{
Files
.
createDirectories
(
dirPath
);
System
.
out
.
println
(
"Directory created: "
+
dirPath
);
}
else
{
System
.
out
.
println
(
"Directory already exists: "
+
dirPath
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
System
.
err
.
println
(
"Failed to create directory: "
+
dirPath
);
}
System
.
out
.
println
(
"Current working directory: "
+
System
.
getProperty
(
"user.dir"
));
if
(
sftp
.
isExist
(
downLoadPath
))
{
sftp
.
downloadAndZipFiles
(
downLoadPath
,
batchNo
,
dirPath
.
toString
()+
"/"
+
batchNo
+
".zip"
);
logger
.
info
(
"文件下载成功"
);
...
...
@@ -500,12 +513,11 @@ public class IcbcWithholdServiceImpl extends BaseService<IcbcWithholdDto,IcbcWit
public
void
upIcbcWithholdRecordWithholdStatus
()
{
LambdaQueryWrapper
<
IcbcWithhold
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
eq
(
IcbcWithhold:
:
getUploadStatus
,
UploadStatusEnum
.
成功
.
getCode
());
wrapper
.
eq
(
IcbcWithhold:
:
getWithholdStatus
,
UploadStatusEnum
.
代扣处理中
.
getCode
());
List
<
String
>
batchNos
=
this
.
getBaseMapper
().
selectList
(
wrapper
).
stream
()
.
map
(
IcbcWithhold:
:
getBatchNo
)
.
collect
(
Collectors
.
toList
());;
LambdaQueryWrapper
<
IcbcWithholdRecord
>
wrapper
=
new
LambdaQueryWrapper
<>();
wrapper
.
isNull
(
IcbcWithholdRecord:
:
getWithholdStatus
);
Set
<
String
>
batchNos
=
icbcWithholdRecordService
.
getBaseMapper
().
selectList
(
wrapper
).
stream
()
.
map
(
IcbcWithholdRecord:
:
getBatchNo
)
.
collect
(
Collectors
.
toSet
());;
String
APP_ID
=
"11000000000000028870"
;
String
MY_PRIVATE_KEY
=
"MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDAlcIeANdqipul3/qAIRlknSacHiFCMzLzUJisGcr9ipm3p2rir8WDsac2MxgtUt+f89SGNoWyjv4q0/QAKQQTd5U3KuGAksCJLBGVibuFe7G7YGYVezUksjvocvp8GIinCIkzq67KL2SOpGXAu3s+282rx8AxdTZA/EhXQvbORbWz5+DamyY+wS7Maa8KmIOb6WZPtiXgENZxDHAafrqW8Gt1BnVfJNf5yS5J9Wl+LcR1EPvi5iH8dSIdn1ZMVupoREjV/DvItSogVehsqTRZWuekAo2xH9YEli1UMG/l3deViRn/A4VmPPzdv0xXpn/yO+OTjWez+KmSmJ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YEArnEiPmL5g1Ca/qKK9ql8Q6P9gipIfGGpaFu23y0trbcFpVn8Oos/ic0Jgw4Xiz+rqvb6bW2V6lqBJ+9/kdn0i7zlZxKNpYsW2xFgi04OU3d5HkGL16Y1rpqMYYEhjFaOIn7J8P046UYR99yaybgQd18TE6oFrX8OL5uY8M4ge4Y="
;
String
icbcPulicKey
=
"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCMpjaWjngB4E3ATh+G1DVAmQnIpiPEFAEDqRfNGAVvvH35yDetqewKi0l7OEceTMN1C6NPym3zStvSoQayjYV+eIcZERkx31KhtFu9clZKgRTyPjdKMIth/wBtPKjL/5+PYalLdomM4ONthrPgnkN4x4R0+D4+EBpXo8gNiAFsNwIDAQAB"
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment