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
acf6df7d
Commit
acf6df7d
authored
Mar 04, 2022
by
吴琼
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
动态读取appllop配置
parent
902e9b8b
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
70 additions
and
209 deletions
+70
-209
Bootstrap.java
src/main/java/cn/quantgroup/customer/Bootstrap.java
+2
-0
ApolloConfigListener.java
...group/customer/config/container/ApolloConfigListener.java
+46
-0
TransactionReceiptRecord.java
.../quantgroup/customer/entity/TransactionReceiptRecord.java
+5
-5
TransactionReceiptRecordRepo.java
...uantgroup/customer/repo/TransactionReceiptRecordRepo.java
+2
-2
TransactionReceiptRecordRest.java
...uantgroup/customer/rest/TransactionReceiptRecordRest.java
+0
-59
TransactionReceiptRecordServiceImpl.java
...mer/service/impl/TransactionReceiptRecordServiceImpl.java
+15
-143
No files found.
src/main/java/cn/quantgroup/customer/Bootstrap.java
View file @
acf6df7d
package
cn
.
quantgroup
.
customer
;
import
com.ctrip.framework.apollo.spring.annotation.EnableApolloConfig
;
import
com.github.tobato.fastdfs.FdfsClientConfig
;
import
org.springframework.boot.SpringApplication
;
import
org.springframework.boot.autoconfigure.SpringBootApplication
;
...
...
@@ -15,6 +16,7 @@ import org.springframework.jmx.support.RegistrationPolicy;
@Configuration
@ServletComponentScan
@EnableAspectJAutoProxy
@EnableApolloConfig
@SpringBootApplication
(
scanBasePackages
=
{
"cn.quantgroup.customer"
})
public
class
Bootstrap
{
...
...
src/main/java/cn/quantgroup/customer/config/container/ApolloConfigListener.java
0 → 100644
View file @
acf6df7d
package
cn
.
quantgroup
.
customer
.
config
.
container
;
import
com.ctrip.framework.apollo.model.ConfigChangeEvent
;
import
com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.BeansException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cloud.context.environment.EnvironmentChangeEvent
;
import
org.springframework.cloud.context.scope.refresh.RefreshScope
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.context.ApplicationContextAware
;
import
org.springframework.stereotype.Component
;
import
java.util.Set
;
/**
* 在此填写类的用途,注意事项
*
* @author xiaoshuai.ma
* @date 2022-02-18 2:29 下午
*/
@Component
@Slf4j
public
class
ApolloConfigListener
implements
ApplicationContextAware
{
private
ApplicationContext
applicationContext
;
@Autowired
RefreshScope
refreshScope
;
@ApolloConfigChangeListener
(
value
=
{
"application"
})
public
void
configChange
(
ConfigChangeEvent
event
)
{
Set
<
String
>
changedKeys
=
event
.
changedKeys
();
for
(
String
changedKey
:
changedKeys
)
{
log
.
info
(
"changed key = {}"
,
changedKey
);
log
.
info
(
"oldValue={},newValue= {}"
,
event
.
getChange
(
changedKey
).
getOldValue
(),
event
.
getChange
(
changedKey
).
getNewValue
());
this
.
applicationContext
.
publishEvent
(
new
EnvironmentChangeEvent
(
event
.
changedKeys
()));
refreshScope
.
refreshAll
();
}
}
@Override
public
void
setApplicationContext
(
ApplicationContext
applicationContext
)
throws
BeansException
{
this
.
applicationContext
=
applicationContext
;
}
}
src/main/java/cn/quantgroup/customer/entity/TransactionReceiptRecord.java
View file @
acf6df7d
...
...
@@ -27,22 +27,22 @@ public class TransactionReceiptRecord {
private
String
serialNo
;
@Column
(
name
=
"import_status"
)
private
Integer
importStatus
;
private
Integer
importStatus
=
0
;
@Column
(
name
=
"export_status"
)
private
Integer
exportStatus
;
private
Integer
exportStatus
=
0
;
@Column
(
name
=
"order_no"
)
private
String
orderNo
;
@Column
(
name
=
"batch_no"
)
private
Integer
batchNo
;
private
Integer
batchNo
=
0
;
@Column
(
name
=
"sign_status"
)
private
Integer
signStatus
;
private
Integer
signStatus
=
0
;
@Column
(
name
=
"export_batch_no"
)
private
Integer
exportBatchNo
;
private
Integer
exportBatchNo
=
0
;
public
TransactionReceiptRecord
()
{
...
...
src/main/java/cn/quantgroup/customer/repo/TransactionReceiptRecordRepo.java
View file @
acf6df7d
...
...
@@ -38,7 +38,7 @@ public interface TransactionReceiptRecordRepo extends JpaRepository<TransactionR
@Modifying
@Transactional
@Query
(
value
=
"update transaction_receipt_record set sign_status = ?1
where order_no =?2
"
,
nativeQuery
=
true
)
int
updatePDFStatusByOrderNo
(
Integer
status
,
String
orderNo
);
@Query
(
value
=
"update transaction_receipt_record set sign_status = ?1
,export_status = ?2 where order_no =?3 and import_status = 1 and export_status = 0
"
,
nativeQuery
=
true
)
int
updatePDFStatusByOrderNo
(
Integer
status
,
Integer
exportStatus
,
String
orderNo
);
}
src/main/java/cn/quantgroup/customer/rest/TransactionReceiptRecordRest.java
View file @
acf6df7d
...
...
@@ -72,65 +72,6 @@ public class TransactionReceiptRecordRest {
return
transactionReceiptRecordService
.
checkCanExport
();
}
@RequestMapping
(
"/test"
)
public
JsonResult
test
()
{
String
userIds
=
"70356056,70356055"
;
String
url
=
"http://passportapi-qa2.liangkebang.net/api/sync/listByUserIds"
;
Map
param
=
Maps
.
newHashMap
();
param
.
put
(
"userIds"
,
userIds
);
String
userResult
=
httpService
.
get
(
url
,
param
);
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
userResult
);
String
dataStr
=
jsonObject
.
getString
(
"data"
);
JSONArray
userArray
=
JSONArray
.
parseArray
(
dataStr
);
for
(
int
i
=
0
;
i
<
userArray
.
size
();
i
++){
JSONObject
object
=
(
JSONObject
)
userArray
.
get
(
i
);
}
return
JsonResult
.
buildSuccessResult
(
"success"
,
userArray
);
}
@RequestMapping
(
"/testKdsp"
)
public
JsonResult
testKdsp
()
{
String
url
=
"http://kdsp-operation-qa2.liangkebang.net/api/kdsp/op/fa-cui/transaction-proof/query"
;
try
{
Map
<
String
,
String
>
header
=
Maps
.
newHashMap
();
header
.
put
(
"Content-type"
,
"application/json"
);
header
.
put
(
"qg-tenant-id"
,
"560761"
);
Map
param
=
Maps
.
newHashMap
();
List
<
Map
>
paramList
=
new
ArrayList
<>();
//param.put("userId", 70356062);
//param.put("orderNo", "1495958974917529600");
param
.
put
(
"userId"
,
70356067
);
param
.
put
(
"orderNo"
,
"1496312159003762688"
);
paramList
.
add
(
param
);
//得到json字符串
String
result
=
httpService
.
post
(
url
,
header
,
paramList
);
//转换成json 对象
JSONObject
json
=
JSONObject
.
parseObject
(
result
);
String
jsonResult
=
json
.
getString
(
"data"
);
String
businessCode
=
json
.
getString
(
"businessCode"
);
if
(!
"0000"
.
equals
(
businessCode
)){
return
JsonResult
.
buildErrorStateResult
(
"订单信息查询报错"
);
}
if
(
jsonResult
!=
null
){
JSONObject
jsonObject
=
JSONObject
.
parseObject
(
jsonResult
);
JSONArray
jsonArray
=
jsonObject
.
getJSONArray
(
"dataList"
);
if
(
jsonArray
.
isEmpty
()){
return
JsonResult
.
buildErrorStateResult
(
"未查询到对应的订单信息"
);
}
List
<
TransactionReceiptVO
>
transactionReceiptVOList
=
jsonArray
.
toJavaList
(
TransactionReceiptVO
.
class
);
//生成pdf
String
basicPath
=
"D:\\交易凭证0222"
;
String
filePath
=
basicPath
+
"\\"
+
"wuq"
;
FileToZip
.
mkdir
(
filePath
);
filePath
=
filePath
+
"\\"
+
"1493905629528739840"
+
".pdf"
;
transactionReceiptRecordService
.
generatePDF
(
transactionReceiptVOList
.
get
(
0
),
filePath
);
}
return
JsonResult
.
buildSuccessResult
(
"success"
,
null
);
}
catch
(
Exception
e
)
{
log
.
error
(
"[TransactionReceiptRecordServiceImpl][exportZipFile] 网络通讯异常,userId:{},ex:{}"
,
e
.
getMessage
());
return
JsonResult
.
buildErrorStateResult
(
e
.
getMessage
());
}
}
/**
* 后台更新交易凭证状态
* @return
...
...
src/main/java/cn/quantgroup/customer/service/impl/TransactionReceiptRecordServiceImpl.java
View file @
acf6df7d
...
...
@@ -52,12 +52,12 @@ import javax.servlet.http.HttpServletRequest;
import
javax.servlet.http.HttpServletResponse
;
import
javax.transaction.Transactional
;
import
java.io.*
;
import
java.net.URLEncoder
;
import
java.util.*
;
import
java.util.List
;
@Slf4j
@RefreshScope
@Service
(
"transactionReceiptRecordService"
)
public
class
TransactionReceiptRecordServiceImpl
implements
ITransactionReceiptRecordService
{
...
...
@@ -352,7 +352,7 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
}
record
.
setExportBatchNo
(
maxExportBatchNo
.
intValue
()+
1
);
//生成pdf
String
directory
=
record
.
get
Batch
No
()+
record
.
getUserName
();
String
directory
=
record
.
get
Serial
No
()+
record
.
getUserName
();
String
pdfFileName
=
record
.
getOrderNo
()+
".pdf"
;
FileToZip
.
mkdir
(
uploadLocalPath
+
directory
);
generatePDF
(
transactionReceiptVOList
.
get
(
0
),
uploadLocalPath
+
"/"
+
directory
+
"/"
+
pdfFileName
);
...
...
@@ -426,14 +426,8 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
}
catch
(
Exception
e
)
{
throw
new
RuntimeException
(
"文件转换失败"
);
}
//返回给前端
//sreturn this.outputFile(response,"交易凭证.zip",fileData ,100,20);
}
/**
*将字节数组转换为file
*/
/**
* 根据byte数组,生成文件
*/
...
...
@@ -471,48 +465,6 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
}
}
public
JsonResult
outputFile
(
HttpServletResponse
response
,
String
fileName
,
byte
[]
file
,
Integer
successCount
,
Integer
failCount
){
if
(
ArrayUtils
.
isEmpty
(
file
))
{
log
.
info
(
"get file download url failed."
);
return
JsonResult
.
buildErrorStateResult
(
"file is null"
);
}
// 设置相关头信息
response
.
setContentType
(
"multipart/form-data"
);
try
{
fileName
=
URLEncoder
.
encode
(
fileName
,
"UTF8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
log
.
error
(
"fileName encode failed. errorMessage[{}]"
,
e
.
getMessage
());
return
JsonResult
.
buildErrorStateResult
(
"fileName encode failed"
);
}
response
.
setHeader
(
"Content-disposition"
,
"attachment;filename="
+
fileName
);
response
.
addHeader
(
"Pragma"
,
"no-cache"
);
response
.
addHeader
(
"Cache-Control"
,
"no-cache"
);
response
.
addDateHeader
(
"Expries"
,
0
);
// 返回文件
OutputStream
out
=
null
;
try
{
out
=
response
.
getOutputStream
();
out
.
write
(
file
);
out
.
flush
();
}
catch
(
IOException
e
)
{
log
.
error
(
"download file failed. errorMessage[{}]"
,
e
.
getMessage
());
return
JsonResult
.
buildErrorStateResult
(
"download file failed"
);
}
finally
{
if
(
null
!=
out
)
{
try
{
out
.
close
();
}
catch
(
IOException
e
)
{
log
.
error
(
"OutputStream close failed. errorMessage[{}]"
,
e
.
getMessage
());
}
}
}
Map
map
=
Maps
.
newHashMap
();
map
.
put
(
"successCount"
,
successCount
);
map
.
put
(
"failCount"
,
failCount
);
return
JsonResult
.
buildSuccessResult
(
"ok"
,
map
);
}
/**
* 校验是否可以导出
* @return
...
...
@@ -544,85 +496,6 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
List
<
TransactionReceiptRecord
>
failList
=
new
ArrayList
<>();
List
<
TransactionReceiptRecord
>
successList
=
new
ArrayList
<>();
if
(
CollectionUtils
.
isNotEmpty
(
transactionReceiptRecordList
)){
//创建线程池
//ThreadPoolExecutor threadPool = new ThreadPoolExecutor(20, 50,
// 4, TimeUnit.SECONDS, new ArrayBlockingQueue(10), new ThreadPoolExecutor.AbortPolicy());
// 记录单个任务的执行次数
//CountDownLatch countDownLatch = new CountDownLatch(splitNList.size());
// 对拆分的集合进行批量处理, 先拆分的集合, 再多线程执行
/*for (List<TransactionReceiptRecord> singleList : splitNList) {
// 线程池执行
threadPool.execute(new Thread(new Runnable(){
@Override
public void run() {
for (TransactionReceiptRecord record : singleList) {
// 将每一个对象进行数据封装, 并添加到一个用于存储更新数据的list
// ......
// 任务个数 - 1, 直至为0时唤醒await()
countDownLatch.countDown();
}
}
}));
}
try {
// 让当前线程处于阻塞状态,直到锁存器计数为零
countDownLatch.await();
} catch (InterruptedException e) {
throw new BusinessException("");
}*/
//为了性能每次最多传50个
//List<List<TransactionReceiptRecord>> splitNList= splitList(transactionReceiptRecordList,50);
//分组校验
/* for(List<TransactionReceiptRecord> recordList : splitNList){
//调用金融用户中心校验userId是否一致
String userIds ="";
HashMap<String,TransactionReceiptRecord> map =new HashMap();
//循环获取userid进行拼接
for(int i= 0;i < recordList.size();i++){
TransactionReceiptRecord record =recordList.get(i);
if(i != recordList.size()-1){
userIds += record.getUserId()+",";
}else{
userIds += record.getUserId()+"";
}
map.put(record.getUserId()+record.getUserName(),record);
}
Map<String, String> header = Maps.newHashMap();
header.put("Content-type", "application/x-www-form-urlencoded");
Map param = Maps.newHashMap();
param.put("userIds",userIds);
//String userUrl = userSysUrl + "/api/sync/listByUserIds";
String userUrl = "http://passportapi-qa2.liangkebang.net/api/sync/listByUserIds";
String userResult = httpService.get(userUrl, param);
if (StringUtils.isEmpty(userResult)) {
return JsonResult.buildErrorStateResult("批量查询userId报错");
}
//对比拿到的
JSONObject userJsonObject = JSONObject.parseObject(userResult);
String dataStr = userJsonObject.getString("data");
JSONArray userArray = JSONArray.parseArray(dataStr);
//未查询到信息的userid
List list =new ArrayList();
for(int i=0;i<userArray.size();i++){
JSONObject object= (JSONObject) userArray.get(i);
String userId =object.getString("userId");
String userName = object.getString("name");
}
//调用kdsp接口校验userId和交易单号是否一致
String kUrl = kdspOperationUrl + "/api/kdsp/op/fa-cui/transaction-proof/check";
//得到json字符串
String kResult = httpService.post(kUrl, header, param);
JSONObject kJson =JSONObject.parseObject(kResult);
String kJsonResult = kJson.getString("data");
String businessCode = kJson.getString("businessCode");
if(!"0000".equals(businessCode)){
return JsonResult.buildErrorStateResult("订单信息查询报错");
}
JSONObject kJsonObject = JSONObject.parseObject(kJsonResult);
failList = (List<TransactionReceiptRecord>) kJsonObject.get("verifyErrorList");
}*/
for
(
TransactionReceiptRecord
record
:
transactionReceiptRecordList
){
try
{
//调用天津自牧用户中心接口
...
...
@@ -703,35 +576,23 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
return
JsonResult
.
buildSuccessResult
(
"数据导入成功"
,
null
);
}
@Override
public
JsonResult
updatePDFSignStatus
(
List
<
String
>
sucessList
,
List
<
String
>
failList
)
{
//pdf签章成功
if
(!
sucessList
.
isEmpty
()){
for
(
String
orderNo
:
sucessList
){
transactionReceiptRecordRepo
.
updatePDFStatusByOrderNo
(
1
,
orderNo
);
transactionReceiptRecordRepo
.
updatePDFStatusByOrderNo
(
1
,
1
,
orderNo
);
}
}
//pdf签章失败
if
(!
failList
.
isEmpty
()){
for
(
String
orderNo
:
failList
){
transactionReceiptRecordRepo
.
updatePDFStatusByOrderNo
(
2
,
orderNo
);
transactionReceiptRecordRepo
.
updatePDFStatusByOrderNo
(
2
,
2
,
orderNo
);
}
}
return
JsonResult
.
buildSuccessResult
(
"pdf签章状态更新失败"
,
null
);
}
public
List
<
TransactionReceiptRecord
>
listrem
(
List
<
TransactionReceiptRecord
>
listA
,
List
<
TransactionReceiptRecord
>
listB
){
HashSet
hs1
=
new
HashSet
(
listA
);
HashSet
hs2
=
new
HashSet
(
listB
);
hs1
.
removeAll
(
hs2
);
List
<
TransactionReceiptRecord
>
listC
=
new
ArrayList
<>();
listC
.
addAll
(
hs1
);
return
listC
;
}
/**
* 切分list
* @param records
...
...
@@ -840,6 +701,17 @@ public class TransactionReceiptRecordServiceImpl implements ITransactionReceiptR
}
}
/**
* 生成pdf文件内容
* @param cell
* @param font
* @param table
* @param logisticsVOList
* @param skuVOList
* @param receiverVO
* @param count
* @return
*/
private
PdfPTable
generateMultiParagraph
(
PdfPCell
cell
,
Font
font
,
PdfPTable
table
,
List
<
LogisticsVO
>
logisticsVOList
,
List
<
SkuVO
>
skuVOList
,
ReceiverVO
receiverVO
,
int
count
){
//物流信息
...
...
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