Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
customer-service
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
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
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
QG
customer-service
Commits
0245e681
Commit
0245e681
authored
Mar 02, 2022
by
吴琼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改
parent
7a717dda
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
248 additions
and
6 deletions
+248
-6
pom.xml
pom.xml
+25
-1
TransactionReceiptRecordRepo.java
...uantgroup/customer/repo/TransactionReceiptRecordRepo.java
+4
-1
TransactionReceiptRecordRest.java
...uantgroup/customer/rest/TransactionReceiptRecordRest.java
+2
-2
IFastDFSService.java
.../java/cn/quantgroup/customer/service/IFastDFSService.java
+65
-0
FastDFSServiceImpl.java
.../quantgroup/customer/service/impl/FastDFSServiceImpl.java
+149
-0
TransactionReceiptRecordServiceImpl.java
...mer/service/impl/TransactionReceiptRecordServiceImpl.java
+3
-2
No files found.
pom.xml
View file @
0245e681
...
@@ -273,7 +273,31 @@
...
@@ -273,7 +273,31 @@
<artifactId>
jsch
</artifactId>
<artifactId>
jsch
</artifactId>
<version>
0.1.54
</version>
<version>
0.1.54
</version>
</dependency>
</dependency>
<!-- <dependency>
<dependency>
<groupId>
org.springframework
</groupId>
<artifactId>
spring-test
</artifactId>
</dependency>
<!--fastdfs-->
<!--<dependency>
<groupId>com.github.tobato</groupId>
<artifactId>fastdfs-client</artifactId>
<version>1.25.2-RELEASE</version>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>log4j-over-slf4j</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
</exclusions>
</dependency>-->
<!-- <dependency>
<groupId>org.springframework</groupId>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<artifactId>spring-test</artifactId>
</dependency>-->
</dependency>-->
...
...
src/main/java/cn/quantgroup/customer/repo/TransactionReceiptRecordRepo.java
View file @
0245e681
...
@@ -16,9 +16,12 @@ public interface TransactionReceiptRecordRepo extends JpaRepository<TransactionR
...
@@ -16,9 +16,12 @@ public interface TransactionReceiptRecordRepo extends JpaRepository<TransactionR
@Query
(
value
=
"select count(1) from transaction_receipt_record where user_id =?1 and user_name =?2 and order_no =?3 "
,
nativeQuery
=
true
)
@Query
(
value
=
"select count(1) from transaction_receipt_record where user_id =?1 and user_name =?2 and order_no =?3 "
,
nativeQuery
=
true
)
Long
selectCountByUserIdAndOrderNo
(
Integer
userId
,
String
userName
,
String
orderNo
);
Long
selectCountByUserIdAndOrderNo
(
Integer
userId
,
String
userName
,
String
orderNo
);
@Query
(
value
=
"select * from transaction_receipt_record where import_status = ?1
"
,
nativeQuery
=
true
)
@Query
(
value
=
"select * from transaction_receipt_record where import_status = ?1"
,
nativeQuery
=
true
)
List
<
TransactionReceiptRecord
>
selectRecordsByImportStatus
(
Integer
status
);
List
<
TransactionReceiptRecord
>
selectRecordsByImportStatus
(
Integer
status
);
@Query
(
value
=
"select * from transaction_receipt_record where import_status = ?1 and export_status !=2 "
,
nativeQuery
=
true
)
List
<
TransactionReceiptRecord
>
selectRecordsByImportStatusAndExportStatus
(
Integer
status
);
@Query
(
value
=
"select count(1) from transaction_receipt_record where import_status =?1 "
,
nativeQuery
=
true
)
@Query
(
value
=
"select count(1) from transaction_receipt_record where import_status =?1 "
,
nativeQuery
=
true
)
Long
selectCountByImportStatus
(
Integer
status
);
Long
selectCountByImportStatus
(
Integer
status
);
...
...
src/main/java/cn/quantgroup/customer/rest/TransactionReceiptRecordRest.java
View file @
0245e681
...
@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -14,7 +14,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.multipart.MultipartFile
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -58,7 +57,7 @@ public class TransactionReceiptRecordRest {
...
@@ -58,7 +57,7 @@ public class TransactionReceiptRecordRest {
@RequestMapping
(
"/orderQuery/importTransactionReceiptRecord"
)
@RequestMapping
(
"/orderQuery/importTransactionReceiptRecord"
)
@ResponseBody
@ResponseBody
@Synchronized
@Synchronized
public
JsonResult
importTransactionReceiptRecord
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
public
JsonResult
importTransactionReceiptRecord
(
@RequestParam
(
"file"
)
MultipartFile
file
)
{
try
{
try
{
return
transactionReceiptRecordService
.
importTransactionReceiptRecord
(
file
);
return
transactionReceiptRecordService
.
importTransactionReceiptRecord
(
file
);
}
catch
(
IOException
e
){
}
catch
(
IOException
e
){
...
@@ -146,6 +145,7 @@ public class TransactionReceiptRecordRest {
...
@@ -146,6 +145,7 @@ public class TransactionReceiptRecordRest {
//导出压缩包
//导出压缩包
@RequestMapping
(
"/orderQuery/exportTransactionZipFile"
)
@RequestMapping
(
"/orderQuery/exportTransactionZipFile"
)
@ResponseBody
@ResponseBody
@Synchronized
public
JsonResult
exportTransactionZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
public
JsonResult
exportTransactionZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
//try{
//try{
return
transactionReceiptRecordService
.
exportZipFile
(
request
,
response
);
return
transactionReceiptRecordService
.
exportZipFile
(
request
,
response
);
...
...
src/main/java/cn/quantgroup/customer/service/IFastDFSService.java
0 → 100644
View file @
0245e681
package
cn
.
quantgroup
.
customer
.
service
;
import
java.io.IOException
;
import
java.io.InputStream
;
/**
* fastDFS 接入 http://confluence.quantgroup.cn/x/bMU5AQ
*
* @author jingfeng.guo
* @since 2019-08-24 17:04
*/
public
interface
IFastDFSService
{
/**
* 上传文件
*
* @param fileInput
* @param fileSize
* @param fileExtName 扩展名
* @return
* @throws IOException
*/
String
uploadFile
(
InputStream
fileInput
,
Long
fileSize
,
String
fileExtName
)
throws
IOException
;
/**
* 上传文件
*
* @param bytes
* @param fileExtName
* @return
* @throws IOException
*/
String
uploadFile
(
byte
[]
bytes
,
String
fileExtName
)
throws
IOException
;
/**
* 文件上传, 下载url 再传
*
* @param url
* @param fileExtName
* @return
* @throws IOException
*/
String
uploadFile
(
String
url
,
String
fileExtName
)
throws
IOException
;
/**
* 上传文件 base64
*
* @param base64String
* @param fileExtName
* @return
* @throws IOException
*/
String
uploadFileOfBase64String
(
String
base64String
,
String
fileExtName
)
throws
IOException
;
/**
* 下载文件
*
* @param path
* @return
* @throws IOException
*/
byte
[]
downloadFile
(
String
path
)
throws
IOException
;
}
src/main/java/cn/quantgroup/customer/service/impl/FastDFSServiceImpl.java
0 → 100644
View file @
0245e681
package
cn
.
quantgroup
.
customer
.
service
.
impl
;
import
cn.quantgroup.customer.service.IFastDFSService
;
import
com.github.tobato.fastdfs.domain.StorePath
;
import
com.github.tobato.fastdfs.proto.storage.DownloadByteArray
;
import
com.github.tobato.fastdfs.service.FastFileStorageClient
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.codec.binary.Base64
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.stereotype.Service
;
import
javax.annotation.Resource
;
import
java.io.ByteArrayInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.net.HttpURLConnection
;
import
java.net.URL
;
/**
* @author xing.yuan
*/
@Service
@Slf4j
public
class
FastDFSServiceImpl
implements
IFastDFSService
{
@Resource
private
FastFileStorageClient
storageClient
;
@Value
(
"${fdfs.secret_key}"
)
private
String
secretKey
;
@Value
(
"${fdfs.domain}"
)
private
String
fastDfsHttp
;
/**
* 文件上传
*
* @param fileInput
* @param fileSize
* @param fileExtName 扩展名
* @return
*/
@Override
public
String
uploadFile
(
InputStream
fileInput
,
Long
fileSize
,
String
fileExtName
)
throws
IOException
{
StorePath
storePath
=
null
;
try
{
storePath
=
storageClient
.
uploadFile
(
fileInput
,
fileSize
,
fileExtName
,
null
);
}
finally
{
if
(
fileInput
!=
null
)
{
try
{
fileInput
.
close
();
}
catch
(
IOException
e
)
{
}
}
}
if
(
storePath
!=
null
&&
StringUtils
.
isNotBlank
(
storePath
.
getFullPath
()))
{
return
storePath
.
getFullPath
();
}
else
{
throw
new
IOException
(
"文件上传失败"
);
}
}
/**
* 文件上传
*
* @param bytes
* @param fileExtName 扩展名
* @return
*/
@Override
public
String
uploadFile
(
byte
[]
bytes
,
String
fileExtName
)
throws
IOException
{
return
uploadFile
(
new
ByteArrayInputStream
(
bytes
),
(
long
)
bytes
.
length
,
fileExtName
);
}
/**
* 文件上传, 下载url 再传
*
* @param url
* @param fileExtName
* @return
* @throws IOException
*/
@Override
public
String
uploadFile
(
String
url
,
String
fileExtName
)
throws
IOException
{
InputStream
in
=
null
;
long
size
=
0
;
HttpURLConnection
conn
=
null
;
try
{
URL
httpUrl
=
new
URL
(
url
);
conn
=
(
HttpURLConnection
)
httpUrl
.
openConnection
();
//设置超时间为3秒
conn
.
setConnectTimeout
(
3
*
1000
);
conn
.
setRequestProperty
(
"User-Agent"
,
"Mozilla/4.0 (compatible; MSIE 5.0; Windows NT; DigExt)"
);
in
=
conn
.
getInputStream
();
size
=
in
.
available
();
}
catch
(
IOException
e
)
{
log
.
warn
(
"下载文件异常,url={},"
,
url
,
e
);
throw
e
;
}
log
.
info
(
"准备上传文件; url={}, "
,
url
);
try
{
String
path
=
uploadFile
(
in
,
size
,
fileExtName
);
return
path
;
}
finally
{
if
(
conn
!=
null
)
{
try
{
conn
.
disconnect
();
}
catch
(
Exception
e
)
{
}
}
}
}
/**
* 上传文件 base64
*
* @param base64String
* @param fileExtName
* @return
* @throws IOException
*/
@Override
public
String
uploadFileOfBase64String
(
String
base64String
,
String
fileExtName
)
throws
IOException
{
byte
[]
bytes
=
Base64
.
decodeBase64
(
base64String
);
return
uploadFile
(
bytes
,
fileExtName
);
}
/**
* 下载文件
*
* @param path
* @return
*/
@Override
public
byte
[]
downloadFile
(
String
path
)
throws
IOException
{
if
(
StringUtils
.
isBlank
(
path
))
{
return
null
;
}
String
[]
split
=
StringUtils
.
split
(
path
,
"/"
,
2
);
if
(
split
.
length
<
2
)
{
throw
new
IOException
(
"路径不对"
);
}
byte
[]
bytes
=
storageClient
.
downloadFile
(
split
[
0
],
split
[
1
],
new
DownloadByteArray
()
{
});
return
bytes
;
}
}
src/main/java/cn/quantgroup/customer/service/impl/TransactionReceiptRecordServiceImpl.java
View file @
0245e681
...
@@ -9,6 +9,7 @@ import cn.quantgroup.customer.repo.TransactionReceiptRecordRepo;
...
@@ -9,6 +9,7 @@ import cn.quantgroup.customer.repo.TransactionReceiptRecordRepo;
import
cn.quantgroup.customer.rest.param.transactionreceipt.TransactionReceiptRecordQuery
;
import
cn.quantgroup.customer.rest.param.transactionreceipt.TransactionReceiptRecordQuery
;
import
cn.quantgroup.customer.rest.vo.JsonResult
;
import
cn.quantgroup.customer.rest.vo.JsonResult
;
import
cn.quantgroup.customer.rest.vo.transaction.*
;
import
cn.quantgroup.customer.rest.vo.transaction.*
;
import
cn.quantgroup.customer.service.IFastDFSService
;
import
cn.quantgroup.customer.service.IFileService
;
import
cn.quantgroup.customer.service.IFileService
;
import
cn.quantgroup.customer.service.ITransactionReceiptRecordService
;
import
cn.quantgroup.customer.service.ITransactionReceiptRecordService
;
import
cn.quantgroup.customer.service.http.IHttpService
;
import
cn.quantgroup.customer.service.http.IHttpService
;
...
@@ -262,8 +263,8 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
...
@@ -262,8 +263,8 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
public
JsonResult
exportZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
public
JsonResult
exportZipFile
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
Exception
{
//调用电商接口获取对应数据
//调用电商接口获取对应数据
log
.
info
(
"[TransactionReceiptRecordServiceImpl.exportZipFile begin]"
);
log
.
info
(
"[TransactionReceiptRecordServiceImpl.exportZipFile begin]"
);
//查询需要导出的数据-导入成功的数据
//查询需要导出的数据-导入成功的数据
,但未导出成功的数据
List
<
TransactionReceiptRecord
>
transactionReceiptRecordList
=
transactionReceiptRecordRepo
.
selectRecordsByImportStatus
(
1
);
List
<
TransactionReceiptRecord
>
transactionReceiptRecordList
=
transactionReceiptRecordRepo
.
selectRecordsByImportStatus
AndExportStatus
(
1
);
if
(
CollectionUtils
.
isEmpty
(
transactionReceiptRecordList
)){
if
(
CollectionUtils
.
isEmpty
(
transactionReceiptRecordList
)){
return
JsonResult
.
buildErrorStateResult
(
"没有可以导出得数据"
);
return
JsonResult
.
buildErrorStateResult
(
"没有可以导出得数据"
);
}
}
...
...
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