Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
M
mall-adapter
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
inroi
mall-adapter
Commits
303f56ee
提交
303f56ee
authored
11月 23, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
bbbb9d0b
隐藏空白字符变更
内嵌
并排
正在显示
42 个修改的文件
包含
1495 行增加
和
310 行删除
+1495
-310
CommonApi.java
src/main/java/com/system/api/CommonApi.java
+30
-6
CommonGetApi.java
src/main/java/com/system/api/CommonGetApi.java
+0
-95
CommonHttpApi.java
src/main/java/com/system/api/CommonHttpApi.java
+169
-0
CommonPostApi.java
src/main/java/com/system/api/CommonPostApi.java
+19
-24
Constants.java
src/main/java/com/system/constants/Constants.java
+4
-7
MallCommonGetConstants.java
...ain/java/com/system/constants/MallCommonGetConstants.java
+26
-12
MallCommonPostConstants.java
...in/java/com/system/constants/MallCommonPostConstants.java
+26
-12
MallCommonSyncConstants.java
...in/java/com/system/constants/MallCommonSyncConstants.java
+48
-19
MallConstants.java
src/main/java/com/system/constants/MallConstants.java
+32
-0
SynchronizationOperationConstants.java
...m/system/constants/SynchronizationOperationConstants.java
+74
-0
InitConnectParamMapper.java
src/main/java/com/system/dao/InitConnectParamMapper.java
+10
-0
MallCommonConfigMapper.java
src/main/java/com/system/dao/MallCommonConfigMapper.java
+8
-0
ProductLogMapper.java
src/main/java/com/system/dao/ProductLogMapper.java
+33
-0
SynchronizationOperationMapper.java
...n/java/com/system/dao/SynchronizationOperationMapper.java
+28
-0
SynchronizationRecordsMapper.java
...ain/java/com/system/dao/SynchronizationRecordsMapper.java
+3
-3
InitConnectParamMapper.xml
...ain/java/com/system/dao/mapper/InitConnectParamMapper.xml
+7
-0
MallCommonConfigMapper.xml
...ain/java/com/system/dao/mapper/MallCommonConfigMapper.xml
+14
-4
ProductLogMapper.xml
src/main/java/com/system/dao/mapper/ProductLogMapper.xml
+37
-0
SynchronizationOperationMapper.xml
.../com/system/dao/mapper/SynchronizationOperationMapper.xml
+33
-0
SynchronizationRecordsMapper.xml
...va/com/system/dao/mapper/SynchronizationRecordsMapper.xml
+3
-3
MallCommonException.java
src/main/java/com/system/exception/MallCommonException.java
+32
-0
MallCommonApi.java
src/main/java/com/system/mall/MallCommonApi.java
+54
-0
MallCommonSyncApi.java
src/main/java/com/system/mall/MallCommonSyncApi.java
+63
-0
DelayedElement.java
src/main/java/com/system/model/DelayedElement.java
+43
-0
InitConnectParam.java
src/main/java/com/system/model/InitConnectParam.java
+118
-0
MallLoginScheduler.java
src/main/java/com/system/scheduler/MallLoginScheduler.java
+52
-0
SecretScheduler.java
src/main/java/com/system/scheduler/SecretScheduler.java
+0
-36
IMallSyncServiceImpl.java
...in/java/com/system/serivce/impl/IMallSyncServiceImpl.java
+51
-36
MallCommonGetServiceImpl.java
...ava/com/system/serivce/impl/MallCommonGetServiceImpl.java
+3
-3
SynchronizationServiceImpl.java
...a/com/system/serivce/impl/SynchronizationServiceImpl.java
+8
-42
MallCommonConfigListOutVoRecords.java
...ystem/transfer/form/MallCommonConfigListOutVoRecords.java
+14
-2
ProductLogCreateInVo.java
...in/java/com/system/transfer/log/ProductLogCreateInVo.java
+77
-0
SynchronizationRecordsDeleteInVo.java
...ystem/transfer/mall/SynchronizationRecordsDeleteInVo.java
+1
-1
SynchronizationRecordsListInVo.java
.../system/transfer/mall/SynchronizationRecordsListInVo.java
+1
-1
SynchronizationRecordsListOutVo.java
...system/transfer/mall/SynchronizationRecordsListOutVo.java
+1
-1
SynchronizationRecordsListOutVoRecords.java
...transfer/mall/SynchronizationRecordsListOutVoRecords.java
+1
-1
SynchronizationRecordsUpdateInVo.java
...ystem/transfer/mall/SynchronizationRecordsUpdateInVo.java
+1
-1
SynchronizationOperationListOutVoRecords.java
...hronization/SynchronizationOperationListOutVoRecords.java
+59
-0
DesHelperUtil.java
src/main/java/com/system/utils/DesHelperUtil.java
+110
-0
FormFieldMappingUtil.java
src/main/java/com/system/utils/FormFieldMappingUtil.java
+1
-1
MallLogUtil.java
src/main/java/com/system/utils/MallLogUtil.java
+28
-0
ProductLogUtil.java
src/main/java/com/system/utils/ProductLogUtil.java
+173
-0
没有找到文件。
src/main/java/com/system/api/CommonApi.java
浏览文件 @
303f56ee
...
...
@@ -2,6 +2,7 @@ package com.system.api;
import
com.system.constants.Constants
;
import
com.system.transfer.form.MallFieldMappingListOutVoRecords
;
import
com.system.utils.JsonUtil
;
import
org.springframework.util.CollectionUtils
;
import
java.math.BigDecimal
;
...
...
@@ -15,16 +16,39 @@ import java.util.Map;
*/
public
class
CommonApi
{
public
static
Map
<
String
,
Object
>
purchaseData
(
Map
<
String
,
String
>
config
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
MallFieldMappingListOutVoRecords
>
fieldList
)
{
public
static
String
encapsulationData
(
Map
<
String
,
String
>
config
,
String
queueId
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
MallFieldMappingListOutVoRecords
>
fieldList
)
{
if
(
Integer
.
parseInt
(
config
.
get
(
Constants
.
ENCAPSULATION_FORMAT
))
==
1
)
{
return
encapsulationDataOnWhole
(
queueId
,
dataList
,
fieldList
);
}
else
{
return
encapsulationDataOnPolymerization
(
queueId
,
config
.
get
(
"entryName"
),
dataList
,
fieldList
);
}
}
private
static
String
encapsulationDataOnWhole
(
String
queueId
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
MallFieldMappingListOutVoRecords
>
fieldList
)
{
List
<
Map
<
String
,
Object
>>
request
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
data
:
dataList
)
{
Map
<
String
,
Object
>
temp
=
new
LinkedHashMap
<>();
temp
.
put
(
"QUEUE_ID"
,
queueId
);
for
(
MallFieldMappingListOutVoRecords
records
:
fieldList
)
{
encapsulationFieldData
(
data
,
temp
,
records
);
}
request
.
add
(
temp
);
}
return
JsonUtil
.
toString
(
request
);
}
private
static
String
encapsulationDataOnPolymerization
(
String
queueId
,
String
entryName
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
MallFieldMappingListOutVoRecords
>
fieldList
)
{
Map
<
String
,
Object
>
request
=
new
LinkedHashMap
<>(
2
);
List
<
Map
<
String
,
Object
>>
tempList
=
new
ArrayList
<>();
for
(
Map
<
String
,
Object
>
data
:
dataList
)
{
request
.
put
(
"QUEUE_ID"
,
queueId
);
Map
<
String
,
Object
>
temp
=
new
LinkedHashMap
<>();
for
(
MallFieldMappingListOutVoRecords
records
:
fieldList
)
{
if
(
Constants
.
SUCCESS_CODE
.
equals
(
records
.
getIsEntryField
()))
{
purchase
FieldData
(
data
,
temp
,
records
);
encapsulation
FieldData
(
data
,
temp
,
records
);
}
else
{
purchase
FieldData
(
data
,
request
,
records
);
encapsulation
FieldData
(
data
,
request
,
records
);
}
}
if
(!
CollectionUtils
.
isEmpty
(
temp
))
{
...
...
@@ -33,12 +57,12 @@ public class CommonApi {
}
if
(!
CollectionUtils
.
isEmpty
(
tempList
))
{
request
.
put
(
config
.
get
(
"entryName"
)
,
tempList
);
request
.
put
(
entryName
,
tempList
);
}
return
request
;
return
JsonUtil
.
toString
(
request
)
;
}
private
static
void
purchase
FieldData
(
Map
<
String
,
Object
>
temp
,
Map
<
String
,
Object
>
data
,
MallFieldMappingListOutVoRecords
records
)
{
private
static
void
encapsulation
FieldData
(
Map
<
String
,
Object
>
temp
,
Map
<
String
,
Object
>
data
,
MallFieldMappingListOutVoRecords
records
)
{
String
fieldType
=
records
.
getFieldType
();
String
fieldBeforeMapping
=
records
.
getFieldBeforeMapping
();
String
fieldAfterMapping
=
records
.
getFieldAfterMapping
();
...
...
src/main/java/com/system/api/CommonGetApi.java
deleted
100644 → 0
浏览文件 @
bbbb9d0b
package
com
.
system
.
api
;
import
com.system.constants.Constants
;
import
com.system.transfer.form.MallFieldMappingListOutVoRecords
;
import
com.system.utils.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author Inori
*/
@Component
public
class
CommonGetApi
{
@Autowired
private
ThirdPartyLogUtil
thirdPartyLogUtil
;
public
String
commonGet
(
Map
<
String
,
String
>
config
,
Map
<
String
,
Object
>
data
,
String
queueId
)
{
Map
<
String
,
Object
>
response
=
new
HashMap
<>(
3
);
List
<
MallFieldMappingListOutVoRecords
>
fieldList
=
FormFieldMappingUtil
.
purchaseMapping
(
config
.
get
(
"formFieldMappingDetail"
));
List
<
String
>
tempList
=
fieldList
.
stream
().
map
(
MallFieldMappingListOutVoRecords:
:
getFieldBeforeMapping
).
collect
(
Collectors
.
toList
());
Map
<
String
,
Object
>
request
=
new
HashMap
<>();
request
.
put
(
"formId"
,
config
.
get
(
"docType"
));
request
.
put
(
"fieldKeys"
,
String
.
join
(
","
,
tempList
));
request
.
put
(
"filterString"
,
this
.
stringWhere
(
data
));
String
result
=
""
;
try
{
result
=
HttpUtil
.
httpPost
(
config
.
get
(
"requestAddress"
),
JsonUtil
.
toString
(
request
)).
getBody
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
response
.
put
(
"message"
,
"Http请求异常"
);
response
.
put
(
"success"
,
false
);
return
JsonUtil
.
toString
(
response
);
}
int
flag
=
0
;
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
result
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
if
(
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
))))
{
List
<
Object
>
objectList
=
JsonUtil
.
toList
(
JsonUtil
.
toString
(
map
.
get
(
"data"
)),
Object
.
class
);
List
<
Map
<
String
,
Object
>>
dataList
=
objectList
.
stream
().
map
(
m
->
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
m
),
String
.
class
,
Object
.
class
)).
collect
(
Collectors
.
toList
());
response
.
put
(
"data"
,
CommonApi
.
purchaseData
(
config
,
dataList
,
fieldList
));
response
.
put
(
"success"
,
true
);
flag
=
1
;
}
}
else
if
(!
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
)))
&&
map
.
containsKey
(
Constants
.
ERROR_MESSAGE
))
{
response
.
put
(
"message"
,
map
.
get
(
Constants
.
ERROR_MESSAGE
));
response
.
put
(
"success"
,
false
);
}
else
{
response
.
put
(
"message"
,
""
);
response
.
put
(
"success"
,
false
);
}
thirdPartyLogUtil
.
thirdPartyLogCreate
(
config
.
get
(
"name"
),
config
.
get
(
"docType"
),
queueId
,
config
.
get
(
"configureDirection"
),
JsonUtil
.
toString
(
request
),
result
,
flag
);
return
JsonUtil
.
toString
(
response
);
}
private
String
stringWhere
(
Map
<
String
,
Object
>
map
)
{
StringBuilder
where
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
map
.
entrySet
())
{
if
(
StringUtil
.
isNotBlank
(
where
))
{
where
.
append
(
" AND "
).
append
(
entry
.
getKey
()).
append
(
"='"
).
append
(
entry
.
getValue
()).
append
(
"'"
);
}
else
{
where
=
new
StringBuilder
(
entry
.
getKey
()
+
"='"
+
entry
.
getValue
()
+
"'"
);
}
}
if
(
StringUtil
.
isNotBlank
(
where
.
toString
()))
{
return
where
.
toString
();
}
return
""
;
}
public
String
commonSync
(
String
responseAddress
,
Map
<
String
,
String
>
config
,
String
queueId
,
String
json
)
{
try
{
String
result
=
HttpUtil
.
httpPost
(
responseAddress
,
json
).
getBody
();
thirdPartyLogUtil
.
thirdPartyLogCreate
(
config
.
get
(
"name"
),
config
.
get
(
"docType"
),
queueId
,
config
.
get
(
"configureDirection"
),
json
,
result
);
return
result
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
""
;
}
}
}
src/main/java/com/system/api/CommonHttpApi.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
api
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.google.common.util.concurrent.ThreadFactoryBuilder
;
import
com.system.constants.MallConstants
;
import
com.system.dao.InitConnectParamMapper
;
import
com.system.exception.MallCommonException
;
import
com.system.model.DelayedElement
;
import
com.system.model.InitConnectParam
;
import
com.system.utils.HttpUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.MallLogUtil
;
import
com.system.utils.StringUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
javax.annotation.PostConstruct
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.*
;
/**
* @author Inori
*/
@Component
public
class
CommonHttpApi
{
private
ExecutorService
threadPool
=
new
ThreadPoolExecutor
(
10
,
10
,
0L
,
TimeUnit
.
MILLISECONDS
,
new
LinkedBlockingQueue
<
Runnable
>(
1024
),
new
ThreadFactoryBuilder
().
setNameFormat
(
"http-pool-%d"
).
build
(),
new
ThreadPoolExecutor
.
AbortPolicy
());
private
static
final
String
LOGIN_MESSAGE
=
"商城服务器连接异常"
;
public
InitConnectParam
initConnectParam
;
public
String
mallAddress
;
public
boolean
flag
=
false
;
@Autowired
private
InitConnectParamMapper
initConnectParamMapper
;
@Autowired
private
MallLogUtil
mallLogUtil
;
@PostConstruct
public
void
init
()
{
initConnectParam
=
initConnectParamMapper
.
selectOne
(
new
QueryWrapper
<
InitConnectParam
>().
last
(
"LIMIT 1"
));
System
.
out
.
println
(
"++++++"
+
initConnectParam
);
if
(
StringUtil
.
isNotNull
(
initConnectParam
))
{
mallAddress
=
initConnectParam
.
getMallAddress
();
}
}
public
InitConnectParam
getInitConnectParam
()
{
return
initConnectParam
;
}
public
void
setFlag
(
boolean
flag
)
{
this
.
flag
=
flag
;
}
private
String
stringKey
(
Map
<
String
,
String
>
map
)
{
StringBuilder
keys
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
String
>
entry
:
map
.
entrySet
())
{
if
(
StringUtil
.
isNotBlank
(
keys
))
{
keys
.
append
(
", "
).
append
(
entry
.
getKey
());
}
else
{
keys
=
new
StringBuilder
(
entry
.
getKey
());
}
}
if
(
StringUtil
.
isNotBlank
(
keys
.
toString
()))
{
return
keys
.
toString
();
}
return
""
;
}
private
String
stringWhere
(
Map
<
String
,
Object
>
map
)
{
StringBuilder
where
=
new
StringBuilder
();
for
(
Map
.
Entry
<
String
,
Object
>
entry
:
map
.
entrySet
())
{
if
(
StringUtil
.
isNotBlank
(
where
))
{
where
.
append
(
" AND "
).
append
(
entry
.
getKey
()).
append
(
"='"
).
append
(
entry
.
getValue
()).
append
(
"'"
);
}
else
{
where
=
new
StringBuilder
(
entry
.
getKey
()
+
"='"
+
entry
.
getValue
()
+
"'"
);
}
}
if
(
StringUtil
.
isNotBlank
(
where
.
toString
()))
{
return
where
.
toString
();
}
return
""
;
}
public
String
commonHttpSync
()
{
try
{
return
HttpUtil
.
httpPost
(
"http://192.168.0.9:8089/wx/"
+
"api/dataSyn/getSyn"
,
""
).
getBody
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
}
}
public
String
commonHttpPostByUpdate
(
String
data
)
{
try
{
return
HttpUtil
.
httpPost
(
"http://192.168.0.9:8089/wx/"
+
"api/dataSyn/success"
,
data
).
getBody
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
}
}
public
String
commonHttpGet
(
Map
<
String
,
String
>
config
,
String
queueId
,
String
name
,
List
<
String
>
keyList
,
Map
<
String
,
Object
>
where
)
{
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
3
);
request
.
put
(
"formId"
,
config
.
get
(
"sFormId"
));
request
.
put
(
"fieldKeys"
,
String
.
join
(
","
,
keyList
));
request
.
put
(
"filterString"
,
this
.
stringWhere
(
where
));
String
response
;
try
{
response
=
HttpUtil
.
httpPost
(
""
,
JsonUtil
.
toString
(
request
)).
getBody
();
mallLogUtil
.
mallLogCreate
(
name
,
config
.
get
(
"docType"
),
queueId
,
Integer
.
valueOf
(
config
.
get
(
"operation"
)),
JsonUtil
.
toString
(
request
),
response
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
}
return
response
;
}
public
String
sendThirdParty
(
String
receiveAddress
,
String
data
,
int
index
)
{
try
{
return
HttpUtil
.
httpPost
(
receiveAddress
,
data
).
getBody
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
if
(
index
!=
0
)
{
this
.
sendThirdParty
(
receiveAddress
,
data
,
index
-
1
);
}
else
{
//TODO 关闭同步
//HttpUtil.httpGet("http://integrate-system:8090/integrate/api/turn/off/synchronization");
DelayQueue
<
DelayedElement
>
delayQueue
=
new
DelayQueue
<>();
threadPool
.
execute
(()
->
{
//take方法将阻塞线程
delayQueue
.
add
(
new
DelayedElement
(
60
));
try
{
delayQueue
.
take
();
}
catch
(
InterruptedException
ex
)
{
ex
.
printStackTrace
();
}
//TODO 开启同步
HttpUtil
.
httpGet
(
"http://integrate-system:8090/integrate/api/start/synchronization"
);
});
}
Map
<
String
,
Object
>
map
=
new
HashMap
<>(
2
);
map
.
put
(
"resultCode"
,
MallConstants
.
OVERTIME_CODE
);
map
.
put
(
"resultMsg"
,
"第三方请求超时"
);
return
JsonUtil
.
toString
(
map
);
}
}
}
src/main/java/com/system/api/CommonPostApi.java
浏览文件 @
303f56ee
...
...
@@ -2,10 +2,7 @@ package com.system.api;
import
com.system.constants.Constants
;
import
com.system.transfer.form.MallFieldMappingListOutVoRecords
;
import
com.system.utils.FormFieldMappingUtil
;
import
com.system.utils.HttpUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.ThirdPartyLogUtil
;
import
com.system.utils.*
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -21,40 +18,38 @@ import java.util.Map;
public
class
CommonPostApi
{
@Autowired
private
ThirdPartyLogUtil
thirdParty
LogUtil
;
private
MallLogUtil
mall
LogUtil
;
public
String
commonPost
(
Map
<
String
,
String
>
config
,
List
<
Map
<
String
,
Object
>>
dataList
,
String
queueId
)
{
int
flag
=
0
;
Map
<
String
,
Object
>
response
=
new
HashMap
<>(
3
);
public
String
commonPost
(
Map
<
String
,
String
>
config
,
String
queueId
,
List
<
Map
<
String
,
Object
>>
dataList
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
3
);
try
{
List
<
MallFieldMappingListOutVoRecords
>
fieldList
=
FormFieldMappingUtil
.
purchaseMapping
(
config
.
get
(
"formFieldMappingDetail"
));
Map
<
String
,
Object
>
data
=
CommonApi
.
purchaseData
(
config
,
dataList
,
fieldList
);
List
<
MallFieldMappingListOutVoRecords
>
fieldList
=
FormFieldMappingUtil
.
encapsulationMapping
(
config
.
get
(
"formFieldMappingDetail"
));
Map
<
String
,
Object
>
request
=
new
HashMap
<>();
request
.
put
(
"formId"
,
config
.
get
(
"docType"
));
request
.
put
(
"model"
,
data
);
String
result
=
HttpUtil
.
httpPost
(
config
.
get
(
"requestAddress"
),
JsonUtil
.
toString
(
request
)).
getBody
();
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
result
,
String
.
class
,
Object
.
class
);
request
.
put
(
"model"
,
CommonApi
.
encapsulationData
(
config
,
queueId
,
dataList
,
fieldList
));
String
response
=
HttpUtil
.
httpPost
(
config
.
get
(
"requestAddress"
),
JsonUtil
.
toString
(
request
)).
getBody
();
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
if
(
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
))))
{
flag
=
1
;
response
.
put
(
"success"
,
true
);
result
.
put
(
"success"
,
true
);
}
}
else
if
(!
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
)))
&&
map
.
containsKey
(
Constants
.
ERROR_MESSAGE
))
{
res
ponse
.
put
(
"success"
,
false
);
res
ponse
.
put
(
"message"
,
map
.
get
(
Constants
.
ERROR_MESSAGE
));
res
ult
.
put
(
"success"
,
false
);
res
ult
.
put
(
"message"
,
map
.
get
(
Constants
.
ERROR_MESSAGE
));
}
else
{
res
ponse
.
put
(
"message"
,
""
);
res
ponse
.
put
(
"success"
,
false
);
res
ult
.
put
(
"message"
,
""
);
res
ult
.
put
(
"success"
,
false
);
}
thirdPartyLogUtil
.
thirdPartyLogCreate
(
config
.
get
(
"name"
),
config
.
get
(
"docType"
),
queueId
,
config
.
get
(
"configureDirection"
),
JsonUtil
.
toString
(
request
),
result
,
flag
);
return
JsonUtil
.
toString
(
res
ponse
);
mallLogUtil
.
mallLogCreate
(
config
.
get
(
"name"
),
config
.
get
(
"docType"
),
queueId
,
Integer
.
valueOf
(
config
.
get
(
"operation"
)),
JsonUtil
.
toString
(
request
),
response
);
return
JsonUtil
.
toString
(
res
ult
);
}
catch
(
Exception
e
)
{
res
ponse
.
put
(
"message"
,
e
.
getMessage
());
res
ponse
.
put
(
"success"
,
false
);
return
JsonUtil
.
toString
(
res
ponse
);
res
ult
.
put
(
"message"
,
e
.
getMessage
());
res
ult
.
put
(
"success"
,
false
);
return
JsonUtil
.
toString
(
res
ult
);
}
}
...
...
src/main/java/com/system/constants/Constants.java
浏览文件 @
303f56ee
...
...
@@ -8,13 +8,7 @@ public interface Constants {
String
TIME_FORMAT
=
"yyyy-MM-dd HH:mm:ss"
;
String
FILE_FORMAT
=
"lic.tmp"
;
String
EFFECTIVE_TIME
=
"effectiveTime"
;
String
VERIFICATION_INTERVAL
=
"verificationInterval"
;
String
ENCAPSULATION_FORMAT
=
"encapsulationFormat"
;
Integer
ROOT_MENU_CODE
=
-
1
;
...
...
@@ -26,6 +20,9 @@ public interface Constants {
String
SUCCESS_NAME
=
"success"
;
String
DATE_NAME
=
"data"
;
String
ERROR_MESSAGE
=
"message"
;
...
...
src/main/java/com/system/constants/MallCommonGetConstants.java
浏览文件 @
303f56ee
...
...
@@ -3,6 +3,7 @@ package com.system.constants;
import
com.system.dao.MallCommonConfigMapper
;
import
com.system.transfer.form.MallCommonConfigListOutVoRecords
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.StringUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -13,6 +14,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* @author Inori
...
...
@@ -34,7 +36,7 @@ public class MallCommonGetConstants {
List
<
Map
<
String
,
Object
>>
fieldMappingList
=
mallCommonConfigMapper
.
mallFieldMappingList
(
idList
);
for
(
MallCommonConfigListOutVoRecords
records
:
recordsList
)
{
List
<
Map
<
String
,
Object
>>
tempList
=
fieldMappingList
.
stream
().
filter
(
m
->
records
.
getId
().
equals
(
m
.
get
(
"id"
))).
collect
(
Collectors
.
toList
());
this
.
map
.
put
(
records
.
getDocType
(),
this
.
purchaseCustomForm
Config
(
records
,
tempList
));
this
.
map
.
put
(
records
.
getDocType
(),
this
.
encapsulationMallField
Config
(
records
,
tempList
));
}
}
}
...
...
@@ -46,20 +48,32 @@ public class MallCommonGetConstants {
return
this
.
map
.
get
(
docType
);
}
public
void
refresh
(
Integer
id
,
String
docType
)
{
this
.
map
.
remove
(
docType
);
MallCommonConfigListOutVoRecords
records
=
mallCommonConfigMapper
.
getMallCommonConfigById
(
id
);
if
(
StringUtil
.
isNotNull
(
records
))
{
List
<
Map
<
String
,
Object
>>
tempList
=
mallCommonConfigMapper
.
mallFieldMappingList
(
Stream
.
of
(
records
.
getId
()).
collect
(
Collectors
.
toList
()));
this
.
map
.
put
(
records
.
getSFormId
(),
this
.
encapsulationMallFieldConfig
(
records
,
tempList
));
}
}
/**
* 封装自定义表单配置
*/
private
Map
<
String
,
String
>
purchaseCustomFormConfig
(
MallCommonConfigListOutVoRecords
records
,
List
<
Map
<
String
,
Object
>>
tempList
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<>(
10
);
result
.
put
(
"docType"
,
records
.
getDocType
());
result
.
put
(
"sFormId"
,
records
.
getSFormId
());
result
.
put
(
"name"
,
records
.
getName
());
result
.
put
(
"operation"
,
String
.
valueOf
(
records
.
getOperation
()));
result
.
put
(
"requestAddress"
,
records
.
getRequestAddress
());
result
.
put
(
"entryName"
,
records
.
getEntryName
());
result
.
put
(
"customSql"
,
records
.
getCustomSql
());
result
.
put
(
"formFieldMappingDetail"
,
JsonUtil
.
toString
(
tempList
));
return
result
;
private
Map
<
String
,
String
>
encapsulationMallFieldConfig
(
MallCommonConfigListOutVoRecords
records
,
List
<
Map
<
String
,
Object
>>
tempList
)
{
Map
<
String
,
String
>
temp
=
new
HashMap
<>(
10
);
temp
.
put
(
"productId"
,
records
.
getPlatformProductRelationId
().
toString
());
temp
.
put
(
"docType"
,
records
.
getDocType
());
temp
.
put
(
"sFormId"
,
records
.
getSFormId
());
temp
.
put
(
"name"
,
records
.
getName
());
temp
.
put
(
"direction"
,
records
.
getDirection
());
temp
.
put
(
"operation"
,
String
.
valueOf
(
records
.
getOperation
()));
temp
.
put
(
"encapsulationFormat"
,
String
.
valueOf
(
records
.
getEncapsulationFormat
()));
temp
.
put
(
"entryName"
,
records
.
getEntryName
());
temp
.
put
(
"customSql"
,
records
.
getCustomSql
());
temp
.
put
(
"formFieldMappingDetail"
,
JsonUtil
.
toString
(
tempList
));
return
temp
;
}
...
...
src/main/java/com/system/constants/MallCommonPostConstants.java
浏览文件 @
303f56ee
...
...
@@ -3,6 +3,7 @@ package com.system.constants;
import
com.system.dao.MallCommonConfigMapper
;
import
com.system.transfer.form.MallCommonConfigListOutVoRecords
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.StringUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
...
...
@@ -13,6 +14,7 @@ import java.util.List;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* @author Inori
...
...
@@ -34,7 +36,7 @@ public class MallCommonPostConstants {
List
<
Map
<
String
,
Object
>>
fieldMappingList
=
mallCommonConfigMapper
.
mallFieldMappingList
(
idList
);
for
(
MallCommonConfigListOutVoRecords
records
:
recordsList
)
{
List
<
Map
<
String
,
Object
>>
tempList
=
fieldMappingList
.
stream
().
filter
(
m
->
records
.
getId
().
equals
(
m
.
get
(
"id"
))).
collect
(
Collectors
.
toList
());
this
.
map
.
put
(
records
.
getDocType
(),
this
.
purchaseCustomForm
Config
(
records
,
tempList
));
this
.
map
.
put
(
records
.
getDocType
(),
this
.
encapsulationMallField
Config
(
records
,
tempList
));
}
}
}
...
...
@@ -46,20 +48,32 @@ public class MallCommonPostConstants {
return
this
.
map
.
get
(
docType
);
}
public
void
refresh
(
Integer
id
,
String
docType
)
{
this
.
map
.
remove
(
docType
);
MallCommonConfigListOutVoRecords
records
=
mallCommonConfigMapper
.
getMallCommonConfigById
(
id
);
if
(
StringUtil
.
isNotNull
(
records
))
{
List
<
Map
<
String
,
Object
>>
tempList
=
mallCommonConfigMapper
.
mallFieldMappingList
(
Stream
.
of
(
records
.
getId
()).
collect
(
Collectors
.
toList
()));
this
.
map
.
put
(
records
.
getSFormId
(),
this
.
encapsulationMallFieldConfig
(
records
,
tempList
));
}
}
/**
* 封装自定义表单配置
*/
private
Map
<
String
,
String
>
purchaseCustomFormConfig
(
MallCommonConfigListOutVoRecords
records
,
List
<
Map
<
String
,
Object
>>
tempList
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<>(
10
);
result
.
put
(
"docType"
,
records
.
getDocType
());
result
.
put
(
"sFormId"
,
records
.
getSFormId
());
result
.
put
(
"name"
,
records
.
getName
());
result
.
put
(
"operation"
,
String
.
valueOf
(
records
.
getOperation
()));
result
.
put
(
"requestAddress"
,
records
.
getRequestAddress
());
result
.
put
(
"entryName"
,
records
.
getEntryName
());
result
.
put
(
"customSql"
,
records
.
getCustomSql
());
result
.
put
(
"formFieldMappingDetail"
,
JsonUtil
.
toString
(
tempList
));
return
result
;
private
Map
<
String
,
String
>
encapsulationMallFieldConfig
(
MallCommonConfigListOutVoRecords
records
,
List
<
Map
<
String
,
Object
>>
tempList
)
{
Map
<
String
,
String
>
temp
=
new
HashMap
<>(
10
);
temp
.
put
(
"productId"
,
records
.
getPlatformProductRelationId
().
toString
());
temp
.
put
(
"docType"
,
records
.
getDocType
());
temp
.
put
(
"sFormId"
,
records
.
getSFormId
());
temp
.
put
(
"name"
,
records
.
getName
());
temp
.
put
(
"direction"
,
records
.
getDirection
());
temp
.
put
(
"operation"
,
String
.
valueOf
(
records
.
getOperation
()));
temp
.
put
(
"encapsulationFormat"
,
String
.
valueOf
(
records
.
getEncapsulationFormat
()));
temp
.
put
(
"entryName"
,
records
.
getEntryName
());
temp
.
put
(
"customSql"
,
records
.
getCustomSql
());
temp
.
put
(
"formFieldMappingDetail"
,
JsonUtil
.
toString
(
tempList
));
return
temp
;
}
...
...
src/main/java/com/system/constants/MallCommonSyncConstants.java
浏览文件 @
303f56ee
...
...
@@ -8,11 +8,13 @@ import org.springframework.stereotype.Component;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.PostConstruct
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
/**
* @author Inori
...
...
@@ -20,7 +22,7 @@ import java.util.stream.Collectors;
@Component
public
class
MallCommonSyncConstants
{
private
Map
<
String
,
Map
<
String
,
String
>>
map
=
new
ConcurrentHashMap
<>();
private
Map
<
Integer
,
Map
<
String
,
Map
<
String
,
String
>
>>
map
=
new
ConcurrentHashMap
<>();
@Autowired
private
MallCommonConfigMapper
mallCommonConfigMapper
;
...
...
@@ -32,34 +34,61 @@ public class MallCommonSyncConstants {
if
(!
CollectionUtils
.
isEmpty
(
recordsList
))
{
List
<
Integer
>
idList
=
recordsList
.
stream
().
map
(
MallCommonConfigListOutVoRecords:
:
getId
).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
Object
>>
fieldMappingList
=
mallCommonConfigMapper
.
mallFieldMappingList
(
idList
);
for
(
MallCommonConfigListOutVoRecords
records
:
recordsList
)
{
List
<
Map
<
String
,
Object
>>
tempList
=
fieldMappingList
.
stream
().
filter
(
m
->
records
.
getId
().
equals
(
m
.
get
(
"id"
))).
collect
(
Collectors
.
toList
());
this
.
map
.
put
(
records
.
getSFormId
(),
this
.
purchaseCustomFormConfig
(
records
,
tempList
));
List
<
Integer
>
keyList
=
recordsList
.
stream
().
map
(
MallCommonConfigListOutVoRecords:
:
getPlatformProductRelationId
).
distinct
().
collect
(
Collectors
.
toList
());
for
(
Integer
key
:
keyList
)
{
this
.
map
.
put
(
key
,
new
ConcurrentHashMap
<>(
5
));
Map
<
String
,
Map
<
String
,
String
>>
config
=
this
.
map
.
get
(
key
);
List
<
MallCommonConfigListOutVoRecords
>
temp01List
=
recordsList
.
stream
().
filter
(
m
->
key
.
equals
(
m
.
getPlatformProductRelationId
())).
collect
(
Collectors
.
toList
());
for
(
MallCommonConfigListOutVoRecords
records
:
temp01List
)
{
List
<
Map
<
String
,
Object
>>
temp02List
=
fieldMappingList
.
stream
().
filter
(
m
->
records
.
getId
().
equals
(
m
.
get
(
"id"
))).
collect
(
Collectors
.
toList
());
config
.
put
(
records
.
getSFormId
(),
this
.
encapsulationMallFieldConfig
(
records
,
temp02List
));
}
}
}
}
public
List
<
Map
<
String
,
String
>>
get
(
String
sFormId
)
{
List
<
Map
<
String
,
String
>>
configList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
Integer
,
Map
<
String
,
Map
<
String
,
String
>>>
entry
:
this
.
map
.
entrySet
())
{
Map
<
String
,
Map
<
String
,
String
>>
temp
=
entry
.
getValue
();
Map
<
String
,
String
>
result
=
temp
.
get
(
sFormId
);
if
(!
CollectionUtils
.
isEmpty
(
result
))
{
configList
.
add
(
result
);
}
}
return
configList
;
}
public
Map
<
String
,
String
>
get
(
String
sFormId
)
{
if
(
CollectionUtils
.
isEmpty
(
this
.
map
))
{
return
new
HashMap
<>(
1
);
public
void
refresh
(
Integer
id
,
String
sFormId
)
{
MallCommonConfigListOutVoRecords
records
=
mallCommonConfigMapper
.
getMallCommonConfigById
(
id
);
Map
<
String
,
Map
<
String
,
String
>>
temp
=
this
.
map
.
get
(
records
.
getPlatformProductRelationId
());
if
(!
CollectionUtils
.
isEmpty
(
temp
))
{
temp
.
remove
(
sFormId
);
List
<
Map
<
String
,
Object
>>
tempList
=
mallCommonConfigMapper
.
mallFieldMappingList
(
Stream
.
of
(
records
.
getId
()).
collect
(
Collectors
.
toList
()));
temp
.
put
(
records
.
getSFormId
(),
this
.
encapsulationMallFieldConfig
(
records
,
tempList
));
}
return
this
.
map
.
get
(
sFormId
);
}
/**
* 封装自定义表单配置
*/
private
Map
<
String
,
String
>
purchaseCustomFormConfig
(
MallCommonConfigListOutVoRecords
records
,
List
<
Map
<
String
,
Object
>>
tempList
)
{
Map
<
String
,
String
>
result
=
new
HashMap
<>(
10
);
result
.
put
(
"docType"
,
records
.
getDocType
());
result
.
put
(
"sFormId"
,
records
.
getSFormId
());
result
.
put
(
"name"
,
records
.
getName
());
result
.
put
(
"operation"
,
String
.
valueOf
(
records
.
getOperation
()));
result
.
put
(
"requestAddress"
,
records
.
getRequestAddress
());
result
.
put
(
"entryName"
,
records
.
getEntryName
());
result
.
put
(
"customSql"
,
records
.
getCustomSql
());
result
.
put
(
"formFieldMappingDetail"
,
JsonUtil
.
toString
(
tempList
));
return
result
;
private
Map
<
String
,
String
>
encapsulationMallFieldConfig
(
MallCommonConfigListOutVoRecords
records
,
List
<
Map
<
String
,
Object
>>
tempList
)
{
Map
<
String
,
String
>
temp
=
new
HashMap
<>(
10
);
temp
.
put
(
"productId"
,
records
.
getPlatformProductRelationId
().
toString
());
temp
.
put
(
"docType"
,
records
.
getDocType
());
temp
.
put
(
"sFormId"
,
records
.
getSFormId
());
temp
.
put
(
"name"
,
records
.
getName
());
temp
.
put
(
"direction"
,
records
.
getDirection
());
temp
.
put
(
"operation"
,
String
.
valueOf
(
records
.
getOperation
()));
temp
.
put
(
"encapsulationFormat"
,
String
.
valueOf
(
records
.
getEncapsulationFormat
()));
temp
.
put
(
"entryName"
,
records
.
getEntryName
());
temp
.
put
(
"customSql"
,
records
.
getCustomSql
());
temp
.
put
(
"formFieldMappingDetail"
,
JsonUtil
.
toString
(
tempList
));
return
temp
;
}
...
...
src/main/java/com/system/constants/MallConstants.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
constants
;
/**
* @author Inori
*/
public
interface
MallConstants
{
String
CODE_NAME
=
"resultCode"
;
String
DATA_NAME
=
"resultData"
;
String
MSG_NAME
=
"resultMsg"
;
String
SUCCESS_CODE
=
"0000"
;
String
ERROR_CODE
=
"0002"
;
String
OVERTIME_CODE
=
"0101"
;
String
NOT_LOGGED_IN_CODE
=
"0010"
;
String
DATA
=
"data"
;
}
src/main/java/com/system/constants/SynchronizationOperationConstants.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
constants
;
import
com.system.dao.SynchronizationOperationMapper
;
import
com.system.transfer.synchronization.SynchronizationOperationListOutVoRecords
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
javax.annotation.PostConstruct
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ConcurrentHashMap
;
import
java.util.stream.Collectors
;
/**
* @author Inori
*/
@Component
public
class
SynchronizationOperationConstants
{
private
Map
<
Integer
,
Map
<
String
,
Map
<
String
,
String
>>>
map
=
new
ConcurrentHashMap
<>();
@Autowired
private
SynchronizationOperationMapper
synchronizationOperationMapper
;
@PostConstruct
public
void
init
()
{
List
<
SynchronizationOperationListOutVoRecords
>
recordsList
=
synchronizationOperationMapper
.
synchronizationOperationList
();
if
(!
CollectionUtils
.
isEmpty
(
recordsList
))
{
List
<
Integer
>
keyList
=
recordsList
.
stream
().
map
(
SynchronizationOperationListOutVoRecords:
:
getPlatformProductRelationId
).
distinct
().
collect
(
Collectors
.
toList
());
for
(
Integer
key
:
keyList
)
{
this
.
map
.
put
(
key
,
new
ConcurrentHashMap
<>(
5
));
Map
<
String
,
Map
<
String
,
String
>>
config
=
this
.
map
.
get
(
key
);
List
<
SynchronizationOperationListOutVoRecords
>
tempList
=
recordsList
.
stream
().
filter
(
m
->
key
.
equals
(
m
.
getPlatformProductRelationId
())).
collect
(
Collectors
.
toList
());
for
(
SynchronizationOperationListOutVoRecords
records
:
tempList
)
{
config
.
put
(
records
.
getSFormId
(),
this
.
encapsulationSynchronizationOperation
(
records
));
}
}
}
}
public
Map
<
String
,
String
>
get
(
Integer
platformProductRelationId
,
String
sFormId
)
{
Map
<
String
,
Map
<
String
,
String
>>
config
=
this
.
map
.
get
(
platformProductRelationId
);
if
(
CollectionUtils
.
isEmpty
(
config
))
{
return
new
HashMap
<>(
1
);
}
return
config
.
get
(
sFormId
);
}
public
void
refresh
(
Integer
id
,
String
sFormId
)
{
SynchronizationOperationListOutVoRecords
records
=
synchronizationOperationMapper
.
getSynchronizationOperationById
(
id
);
Map
<
String
,
Map
<
String
,
String
>>
temp
=
this
.
map
.
get
(
records
.
getPlatformProductRelationId
());
if
(!
CollectionUtils
.
isEmpty
(
temp
))
{
temp
.
remove
(
sFormId
);
temp
.
put
(
records
.
getSFormId
(),
this
.
encapsulationSynchronizationOperation
(
records
));
}
}
private
Map
<
String
,
String
>
encapsulationSynchronizationOperation
(
SynchronizationOperationListOutVoRecords
records
)
{
Map
<
String
,
String
>
temp
=
new
HashMap
<>(
6
);
temp
.
put
(
"productId"
,
records
.
getPlatformProductRelationId
().
toString
());
temp
.
put
(
"jobClassName"
,
records
.
getJobClassName
());
temp
.
put
(
"sFormId"
,
records
.
getSFormId
());
temp
.
put
(
"docType"
,
records
.
getDocType
());
temp
.
put
(
"receiveAddress"
,
records
.
getReceiveAddress
());
return
temp
;
}
}
src/main/java/com/system/dao/InitConnectParamMapper.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
dao
;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.system.model.InitConnectParam
;
/**
* @author Inori
*/
public
interface
InitConnectParamMapper
extends
BaseMapper
<
InitConnectParam
>
{
}
src/main/java/com/system/dao/MallCommonConfigMapper.java
浏览文件 @
303f56ee
...
...
@@ -26,6 +26,14 @@ public interface MallCommonConfigMapper {
List
<
MallCommonConfigListOutVoRecords
>
mallCommonConfigGetList
();
/**
* 商城通用配置
*
* @param id ID
* @return 商城通用配置
*/
MallCommonConfigListOutVoRecords
getMallCommonConfigById
(
Integer
id
);
/**
* 商城通用配置字段映射列表
*
* @param idList id列表
...
...
src/main/java/com/system/dao/ProductLogMapper.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
dao
;
import
com.system.transfer.log.ProductLogCreateInVo
;
/**
* @author Inori
*/
public
interface
ProductLogMapper
{
/**
* 根据唯一标识查询是否存在
*
* @param queueId 唯一标识
* @return 是否存在
*/
Integer
getProductLogByQueueId
(
String
queueId
);
/**
* 产品日志创建
*
* @param inVo 条件
*/
void
productLogCreate
(
ProductLogCreateInVo
inVo
);
/**
* 产品日志更
*
* @param inVo 条件
*/
void
productLogUpdate
(
ProductLogCreateInVo
inVo
);
}
src/main/java/com/system/dao/SynchronizationOperationMapper.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
dao
;
import
com.system.transfer.synchronization.SynchronizationOperationListOutVoRecords
;
import
java.util.List
;
/**
* @author Inori
*/
public
interface
SynchronizationOperationMapper
{
/**
* 金蝶定时任务同步操作列表
*
* @return 列表
*/
List
<
SynchronizationOperationListOutVoRecords
>
synchronizationOperationList
();
/**
* 金蝶定时任务同步操作
*
* @param id ID
* @return 同步操作
*/
SynchronizationOperationListOutVoRecords
getSynchronizationOperationById
(
Integer
id
);
}
src/main/java/com/system/dao/SynchronizationRecordsMapper.java
浏览文件 @
303f56ee
package
com
.
system
.
dao
;
import
com.system.transfer.
synchronization
.SynchronizationRecordsDeleteInVo
;
import
com.system.transfer.
synchronization
.SynchronizationRecordsListOutVoRecords
;
import
com.system.transfer.
synchronization
.SynchronizationRecordsUpdateInVo
;
import
com.system.transfer.
mall
.SynchronizationRecordsDeleteInVo
;
import
com.system.transfer.
mall
.SynchronizationRecordsListOutVoRecords
;
import
com.system.transfer.
mall
.SynchronizationRecordsUpdateInVo
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
...
...
src/main/java/com/system/dao/mapper/InitConnectParamMapper.xml
0 → 100644
浏览文件 @
303f56ee
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.system.dao.InitConnectParamMapper"
>
</mapper>
src/main/java/com/system/dao/mapper/MallCommonConfigMapper.xml
浏览文件 @
303f56ee
...
...
@@ -7,7 +7,7 @@
<select
id=
"mallCommonConfigList"
parameterType=
"java.lang.Integer"
resultType=
"com.system.transfer.form.MallCommonConfigListOutVoRecords"
>
SELECT
id,
doc_type, s_form_id, name, operation, request_address
, entry_name, custom_sql, create_time
id,
platform_product_relation_id, doc_type, s_form_id, `name`,direction, operation
, entry_name, custom_sql, create_time
FROM tb_mall_common_config WHERE operation = #{operation}
</select>
...
...
@@ -17,17 +17,27 @@
<select
id=
"mallCommonConfigGetList"
resultType=
"com.system.transfer.form.MallCommonConfigListOutVoRecords"
>
SELECT
m1.id, m1.
doc_type, m1.s_form_id, m1.name, m1.operation, m1.request_address
, m1.entry_name, m1.custom_sql, m1.create_time
m1.id, m1.
platform_product_relation_id, m1.doc_type, m1.s_form_id, m1.name, m1.direction, m1.operation
, m1.entry_name, m1.custom_sql, m1.create_time
FROM tb_mall_common_config AS m1 INNER JOIN (
SELECT
s_form_id, MIN(operation) AS operation
FROM tb_mall_common_config WHERE operation IN (1, 3) GROUP BY s_form_id
platform_product_relation_id,
s_form_id, MIN(operation) AS operation
FROM tb_mall_common_config WHERE operation IN (1, 3) GROUP BY
platform_product_relation_id,
s_form_id
) AS m2 ON m1.s_form_id = m2.s_form_id AND m1.operation = m2.operation
</select>
<select
id=
"getMallCommonConfigById"
parameterType=
"java.lang.Integer"
resultType=
"com.system.transfer.form.MallCommonConfigListOutVoRecords"
>
SELECT
id, platform_product_relation_id, doc_type, s_form_id, `name`,direction, operation, entry_name, custom_sql, create_time
FROM tb_mall_common_config WHERE id = #{id}
</select>
<select
id=
"mallFieldMappingList"
parameterType=
"java.util.List"
resultType=
"java.util.Map"
>
SELECT
...
...
src/main/java/com/system/dao/mapper/ProductLogMapper.xml
0 → 100644
浏览文件 @
303f56ee
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.system.dao.ProductLogMapper"
>
<select
id=
"getProductLogByQueueId"
parameterType=
"java.lang.String"
resultType=
"java.lang.Integer"
>
SELECT COUNT(*) FROM tb_product_log WHERE queue_id = #{queueId} LIMIT 1
</select>
<insert
id=
"productLogCreate"
parameterType=
"com.system.transfer.log.ProductLogCreateInVo"
useGeneratedKeys=
"true"
keyProperty=
"id"
>
INSERT INTO tb_product_log (
platform_product_relation_id, queue_id, `name`, code, direction, request, flag, response, message, cost_time
) VALUES (
#{platformProductRelationId}, #{queueId}, #{name}, #{code}, #{direction}, #{request}, #{flag}, #{response}, #{message}, #{costTime}
)
</insert>
<update
id=
"productLogUpdate"
parameterType=
"com.system.transfer.log.ProductLogCreateInVo"
>
UPDATE tb_product_log SET
flag = #{flag}, response = #{response}, message = #{message}, cost_time = #{costTime}
WHERE id = #{id}
</update>
</mapper>
src/main/java/com/system/dao/mapper/SynchronizationOperationMapper.xml
0 → 100644
浏览文件 @
303f56ee
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.system.dao.SynchronizationOperationMapper"
>
<select
id=
"synchronizationOperationList"
resultType=
"com.system.transfer.synchronization.SynchronizationOperationListOutVoRecords"
>
SELECT
s.id, s.platform_product_relation_id, s.job_class_name, s.common_config_id,
k.doc_type, k.s_form_id, s.receive_address, s.create_time
FROM tb_synchronization_operation AS s
LEFT JOIN tb_kingdee_common_config AS k ON s.common_config_id = k.id
WHERE job_class_name = "com.system.quartz.job.mallSynchronizationJob"
</select>
<select
id=
"getSynchronizationOperationById"
parameterType=
"java.lang.Integer"
resultType=
"com.system.transfer.synchronization.SynchronizationOperationListOutVoRecords"
>
SELECT
s.id, s.platform_product_relation_id, s.job_class_name, s.common_config_id,
k.doc_type, k.s_form_id, s.receive_address, s.create_time
FROM tb_synchronization_operation AS s
LEFT JOIN tb_kingdee_common_config AS k ON s.common_config_id = k.id
WHERE s.id = #{id}
</select>
</mapper>
src/main/java/com/system/dao/mapper/SynchronizationRecordsMapper.xml
浏览文件 @
303f56ee
...
...
@@ -4,7 +4,7 @@
<select
id=
"synchronizationRecordsListByStatus"
parameterType=
"java.lang.Integer"
resultType=
"com.system.transfer.
synchronization
.SynchronizationRecordsListOutVoRecords"
>
<select
id=
"synchronizationRecordsListByStatus"
parameterType=
"java.lang.Integer"
resultType=
"com.system.transfer.
mall
.SynchronizationRecordsListOutVoRecords"
>
SELECT
id, fid, data_id, entry_id, form, operation
...
...
@@ -82,7 +82,7 @@
<update
id=
"synchronizationRecordsUpdate"
parameterType=
"com.system.transfer.
synchronization
.SynchronizationRecordsUpdateInVo"
>
<update
id=
"synchronizationRecordsUpdate"
parameterType=
"com.system.transfer.
mall
.SynchronizationRecordsUpdateInVo"
>
UPDATE tb_mall_synchronization_record SET queue_id = #{queueId}, message = #{message}, status = #{status} WHERE id = #{id} LIMIT 1
...
...
@@ -90,7 +90,7 @@
<delete
id=
"synchronizationRecordsDelete"
parameterType=
"com.system.transfer.
synchronization
.SynchronizationRecordsDeleteInVo"
>
<delete
id=
"synchronizationRecordsDelete"
parameterType=
"com.system.transfer.
mall
.SynchronizationRecordsDeleteInVo"
>
DELETE FROM tb_mall_synchronization_record WHERE id = #{id}
...
...
src/main/java/com/system/exception/MallCommonException.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
exception
;
import
lombok.Data
;
import
lombok.EqualsAndHashCode
;
/**
* 金蝶云连接异常
*
* @author Inori
*/
@Data
@EqualsAndHashCode
(
callSuper
=
true
)
public
class
MallCommonException
extends
RuntimeException
{
private
String
result
;
public
MallCommonException
(
String
message
)
{
super
(
message
);
this
.
result
=
message
;
}
public
String
getResult
()
{
return
result
;
}
public
void
setResult
(
String
result
)
{
this
.
result
=
result
;
}
}
src/main/java/com/system/mall/MallCommonApi.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
mall
;
import
com.system.api.CommonHttpApi
;
import
com.system.utils.JsonUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author Inori
*/
@Component
public
class
MallCommonApi
{
@Autowired
private
CommonHttpApi
commonHttpApi
;
public
List
<
Map
<
String
,
Object
>>
getSynchronizationRecords
()
{
try
{
String
response
=
commonHttpApi
.
commonHttpSync
();
List
<
Object
>
objectList
=
JsonUtil
.
toList
(
response
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
objectList
))
{
return
objectList
.
stream
().
map
(
m
->
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
m
),
String
.
class
,
Object
.
class
)).
collect
(
Collectors
.
toList
());
}
return
new
ArrayList
<>();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
new
ArrayList
<>();
}
}
public
void
mallSynchronizedRecordsUpdate
(
List
<
Map
<
String
,
Object
>>
tempList
)
{
List
<
String
>
idList
=
tempList
.
stream
().
filter
(
m
->
!
"LQKJ_IMSSync"
.
equals
(
m
.
get
(
"formId"
))).
map
(
m
->
String
.
valueOf
(
m
.
get
(
"fid"
))).
collect
(
Collectors
.
toList
());
if
(!
CollectionUtils
.
isEmpty
(
idList
))
{
//修改商城是否同步
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
map
.
put
(
"ids"
,
idList
);
String
response
=
commonHttpApi
.
commonHttpPostByUpdate
(
JsonUtil
.
toString
(
map
));
System
.
out
.
println
(
"更新订单状态: "
+
response
);
}
}
}
src/main/java/com/system/mall/MallCommonSyncApi.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
mall
;
import
com.system.api.CommonApi
;
import
com.system.api.CommonHttpApi
;
import
com.system.constants.Constants
;
import
com.system.transfer.form.MallFieldMappingListOutVoRecords
;
import
com.system.utils.FormFieldMappingUtil
;
import
com.system.utils.JsonUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author Inori
*/
@Component
public
class
MallCommonSyncApi
{
@Autowired
private
CommonHttpApi
commonHttpApi
;
public
Map
<
String
,
Object
>
synchronization
(
Map
<
String
,
String
>
config
,
String
queueId
,
String
name
,
Map
<
String
,
Object
>
where
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
3
);
List
<
MallFieldMappingListOutVoRecords
>
fieldList
=
FormFieldMappingUtil
.
encapsulationMapping
(
config
.
get
(
"formFieldMappingDetail"
));
List
<
String
>
keyList
=
fieldList
.
stream
().
map
(
MallFieldMappingListOutVoRecords:
:
getFieldBeforeMapping
).
collect
(
Collectors
.
toList
());
String
response
=
commonHttpApi
.
commonHttpGet
(
config
,
queueId
,
name
,
keyList
,
where
);
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
if
(
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
))))
{
List
<
Object
>
objectList
=
JsonUtil
.
toList
(
JsonUtil
.
toString
(
map
.
get
(
"data"
)),
Object
.
class
);
List
<
Map
<
String
,
Object
>>
dataList
=
objectList
.
stream
().
map
(
m
->
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
m
),
String
.
class
,
Object
.
class
)).
collect
(
Collectors
.
toList
());
result
.
put
(
"data"
,
CommonApi
.
encapsulationData
(
config
,
queueId
,
dataList
,
fieldList
));
result
.
put
(
"success"
,
true
);
}
}
else
if
(!
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
)))
&&
map
.
containsKey
(
Constants
.
ERROR_MESSAGE
))
{
result
.
put
(
"message"
,
map
.
get
(
Constants
.
ERROR_MESSAGE
));
result
.
put
(
"success"
,
false
);
}
else
{
result
.
put
(
"message"
,
""
);
result
.
put
(
"success"
,
false
);
}
return
result
;
}
/**
* 同步至第三方
*/
public
String
sendThirdParty
(
String
receiveAddress
,
String
data
)
{
return
commonHttpApi
.
sendThirdParty
(
receiveAddress
,
data
,
3
);
}
}
src/main/java/com/system/model/DelayedElement.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
model
;
import
java.util.concurrent.Delayed
;
import
java.util.concurrent.TimeUnit
;
/**
* @author Inori
*/
public
class
DelayedElement
implements
Delayed
{
private
long
mills
;
public
DelayedElement
(
Integer
min
)
{
this
.
mills
=
System
.
currentTimeMillis
()
/
1000
+
(
60
*
min
);
}
/**
* 当方法返回小于或等于0的数值时, 元素将会被消耗
*/
@Override
public
long
getDelay
(
TimeUnit
unit
)
{
return
mills
-
(
System
.
currentTimeMillis
()
/
1000
);
}
/**
* DelayQueue底层是优先队列,需要实现compareTo方法,
* 用于在入列的时候与容器中的数据进行比较,以便确定元素位置。
*/
@Override
public
int
compareTo
(
Delayed
o
)
{
return
(
int
)
(
mills
-
((
DelayedElement
)
o
).
getMills
());
}
public
long
getMills
()
{
return
mills
;
}
public
void
setMills
(
long
mills
)
{
this
.
mills
=
mills
;
}
}
src/main/java/com/system/model/InitConnectParam.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
model
;
import
com.baomidou.mybatisplus.annotation.IdType
;
import
com.baomidou.mybatisplus.annotation.TableId
;
import
com.baomidou.mybatisplus.annotation.TableName
;
/**
* 金蝶配置表
*
* @author Inori
*/
@TableName
(
"tb_mall_init_connect_param"
)
public
class
InitConnectParam
{
/**
* 主键ID
*/
@TableId
(
value
=
"id"
,
type
=
IdType
.
AUTO
)
private
Integer
id
;
/**
* 金蝶地址
*/
private
String
mallAddress
;
/**
* 用户名
*/
private
String
account
;
/**
* 密码
*/
private
String
password
;
/**
* 定时任务时长/分钟
*/
private
Integer
duration
;
/**
* 创建时间
*/
private
String
createTime
;
/**
* 更新时间
*/
private
String
updateTime
;
public
InitConnectParam
()
{
}
public
Integer
getId
()
{
return
id
;
}
public
void
setId
(
Integer
id
)
{
this
.
id
=
id
;
}
public
String
getMallAddress
()
{
return
mallAddress
;
}
public
void
setMallAddress
(
String
mallAddress
)
{
this
.
mallAddress
=
mallAddress
;
}
public
String
getAccount
()
{
return
account
;
}
public
void
setAccount
(
String
account
)
{
this
.
account
=
account
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
Integer
getDuration
()
{
return
duration
;
}
public
void
setDuration
(
Integer
duration
)
{
this
.
duration
=
duration
;
}
public
String
getCreateTime
()
{
return
createTime
;
}
public
void
setCreateTime
(
String
createTime
)
{
this
.
createTime
=
createTime
;
}
public
String
getUpdateTime
()
{
return
updateTime
;
}
public
void
setUpdateTime
(
String
updateTime
)
{
this
.
updateTime
=
updateTime
;
}
}
src/main/java/com/system/scheduler/MallLoginScheduler.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
scheduler
;
import
com.system.api.CommonHttpApi
;
import
com.system.model.InitConnectParam
;
import
com.system.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
/**
* @author Inori
*/
@Configuration
@EnableScheduling
public
class
MallLoginScheduler
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
MallLoginScheduler
.
class
);
@Autowired
private
CommonHttpApi
commonHttpApi
;
@Scheduled
(
fixedRate
=
1000
*
60
*
15
)
public
void
configureTasks
()
{
InitConnectParam
initConnectParam
=
commonHttpApi
.
getInitConnectParam
();
if
(
StringUtil
.
isNotNull
(
initConnectParam
))
{
Boolean
flag
;
try
{
flag
=
true
;
}
catch
(
Exception
e
)
{
flag
=
false
;
log
.
info
(
"商城登录失败!"
);
}
if
(
flag
)
{
log
.
info
(
"商城登录成功!"
);
}
else
{
log
.
info
(
"商城登录失败!"
);
}
commonHttpApi
.
setFlag
(
flag
);
}
else
{
commonHttpApi
.
setFlag
(
false
);
}
}
}
src/main/java/com/system/scheduler/SecretScheduler.java
deleted
100644 → 0
浏览文件 @
bbbb9d0b
package
com
.
system
.
scheduler
;
import
com.system.serivce.impl.DockingDistributionServiceImpl
;
import
com.system.utils.HttpUtil
;
import
com.system.utils.JsonUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
java.util.Map
;
/**
* @author Inori
*/
@Configuration
@EnableScheduling
public
class
SecretScheduler
{
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
SecretScheduler
.
class
);
@Autowired
private
DockingDistributionServiceImpl
dockingDistributionServiceImpl
;
@Scheduled
(
fixedRate
=
1000
*
60
*
15
)
public
void
configureTasks
()
{
String
result
=
HttpUtil
.
httpGet
(
"http://192.168.0.34:8080/api/v1/getSign"
).
getBody
();
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
result
,
String
.
class
,
Object
.
class
);
dockingDistributionServiceImpl
.
setSecret
(
String
.
valueOf
(
map
.
get
(
"data"
)));
}
}
src/main/java/com/system/serivce/impl/IMallSyncServiceImpl.java
浏览文件 @
303f56ee
package
com
.
system
.
serivce
.
impl
;
import
com.system.api.CommonGetApi
;
import
com.system.constants.Constants
;
import
com.system.constants.MallCommonSyncConstants
;
import
com.system.constants.MallConstants
;
import
com.system.constants.SynchronizationOperationConstants
;
import
com.system.dao.SynchronizationRecordsMapper
;
import
com.system.mall.MallCommonSyncApi
;
import
com.system.serivce.IMallSyncService
;
import
com.system.transfer.mall.SynchronizationRecordsUpdateInVo
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.
Mall
LogUtil
;
import
com.system.utils.
Product
LogUtil
;
import
com.system.utils.SnowFlakeIdUtil
;
import
com.system.utils.
ThirdPartyLo
gUtil
;
import
com.system.utils.
Strin
gUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
...
...
@@ -25,58 +30,68 @@ public class IMallSyncServiceImpl implements IMallSyncService {
private
MallCommonSyncConstants
mallCommonSyncConstants
;
@Autowired
private
CommonGetApi
commonGetApi
;
private
SynchronizationOperationConstants
synchronizationOperationConstants
;
@Autowired
private
Mall
LogUtil
mallLogUtil
;
private
Mall
CommonSyncApi
mallCommonSyncApi
;
@Autowired
private
ThirdPartyLogUtil
thirdPartyLogUtil
;
private
SynchronizationRecordsMapper
synchronizationRecordsMapper
;
@Autowired
private
ProductLogUtil
productLogUtil
;
@Override
public
void
synchronization
(
Integer
id
,
String
sFormId
,
Integer
dataId
,
Integer
entryId
)
{
String
queueId
=
SnowFlakeIdUtil
.
generateId
().
toString
();
Map
<
String
,
String
>
config
=
mallCommonSyncConstants
.
get
(
sFormId
);
if
(!
CollectionUtils
.
isEmpty
(
config
))
{
mallLogUtil
.
thirdPartyErrorLogCreate
(
"商城同步失败"
,
sFormId
,
queueId
,
3
,
""
,
"sFormId为: "
+
sFormId
+
" 的商城表单不存在"
);
List
<
Map
<
String
,
String
>>
configList
=
mallCommonSyncConstants
.
get
(
sFormId
);
if
(!
CollectionUtils
.
isEmpty
(
configList
))
{
synchronizationRecordsMapper
.
synchronizationRecordsUpdate
(
new
SynchronizationRecordsUpdateInVo
(
id
,
SnowFlakeIdUtil
.
generateId
().
toString
(),
"商城同步失败! sFormId为: "
+
sFormId
+
" 的商城表单不存在"
,
2
));
return
;
}
Map
<
String
,
Object
>
data
=
new
HashMap
<>();
String
result
=
commonGetApi
.
commonGet
(
config
,
data
,
queueId
);
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
result
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
if
(!
map
.
containsKey
(
Constants
.
SUCCESS_NAME
)
||
!
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
))))
{
for
(
Map
<
String
,
String
>
config
:
configList
)
{
String
queueId
=
SnowFlakeIdUtil
.
generateId
().
toString
();
//查询同步操作
Map
<
String
,
String
>
operation
=
synchronizationOperationConstants
.
get
(
Integer
.
valueOf
(
config
.
get
(
"productId"
)),
sFormId
);
if
(
com
.
baomidou
.
mybatisplus
.
core
.
toolkit
.
CollectionUtils
.
isEmpty
(
operation
))
{
productLogUtil
.
productSyncErrorLogCreate
(
Integer
.
valueOf
(
config
.
get
(
"productId"
)),
queueId
,
config
.
get
(
"name"
)
+
"的同步取消"
,
config
.
get
(
"docType"
),
config
.
get
(
"direction"
),
""
,
"表单标识为: "
+
sFormId
+
" 的表单同步操作不存在"
);
synchronizationRecordsMapper
.
synchronizationRecordsUpdate
(
new
SynchronizationRecordsUpdateInVo
(
id
,
queueId
,
"sFormId为: "
+
sFormId
+
" 的同步操作不存在"
,
2
));
return
;
}
}
else
{
return
;
Map
<
String
,
Object
>
where
=
new
HashMap
<>(
3
);
where
.
put
(
"form"
,
sFormId
);
where
.
put
(
"dataId"
,
dataId
);
if
(
StringUtil
.
isNotNull
(
entryId
))
{
where
.
put
(
"entryId"
,
entryId
);
}
Map
<
String
,
Object
>
map
=
mallCommonSyncApi
.
synchronization
(
config
,
queueId
,
config
.
get
(
"name"
),
where
);
if
(!
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
))))
{
synchronizationRecordsMapper
.
synchronizationRecordsUpdate
(
new
SynchronizationRecordsUpdateInVo
(
id
,
queueId
,
String
.
valueOf
(
map
.
get
(
Constants
.
ERROR_MESSAGE
)),
2
));
return
;
}
this
.
encapsulationRequest
(
config
,
operation
,
queueId
,
id
,
map
);
}
}
private
void
encapsulationRequest
(
Map
<
String
,
String
>
config
,
Map
<
String
,
String
>
operation
,
String
queueId
,
Integer
id
,
Map
<
String
,
Object
>
data
)
{
Map
<
String
,
Object
>
request
=
new
HashMap
<>();
request
.
put
(
"docType"
,
config
.
get
(
"docType"
));
request
.
put
(
"update"
,
""
);
request
.
put
(
"data"
,
map
.
get
(
"data"
));
//TODO 同步至某某地址
String
response
=
commonGetApi
.
commonSync
(
""
,
config
,
queueId
,
JsonUtil
.
toString
(
request
));
/*List<Object> objectList = JsonUtil.toList(responseEntity.getBody(), Object.class);
for (Object object : objectList) {
Map<String, Object> temp = JsonUtil.toMap(JsonUtil.toString(object), String.class, Object.class);
Map<String, String> config = commonGetConstants.get(String.valueOf(temp.get("form")));
if (!CollectionUtils.isEmpty(config)) {
continue;
}
String queueId = SnowFlakeIdUtil.generateId().toString();
String result = commonGetApi.commonGet(config, "", queueId);
request
.
put
(
"updateType"
,
"update"
);
request
.
put
(
"data"
,
data
.
get
(
Constants
.
DATE_NAME
));
String
response
=
mallCommonSyncApi
.
sendThirdParty
(
operation
.
get
(
"receiveAddress"
),
JsonUtil
.
toString
(
request
));
//记录第三方日志
productLogUtil
.
productHttpLogCreate
(
Integer
.
valueOf
(
config
.
get
(
"productId"
)),
queueId
,
id
,
config
.
get
(
"name"
),
config
.
get
(
"docType"
),
config
.
get
(
"direction"
),
JsonUtil
.
toString
(
request
),
response
);
Map<String, Object> map = JsonUtil.toMap(result
, String.class, Object.class);
if (!CollectionUtils.isEmpty(map) && Constants.SUCCESS_CODE.equals(String.valueOf(map.get(Constants.SUCCESS_NAME))
)) {
Map<String, Object> data = JsonUtil.toMap(JsonUtil.toString(map.get("data")), String.class, Object.class);
commonGetApi.commonSync(String.valueOf(temp.get("response_address")), queueId, config, JsonUtil.toString(data)
);
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
if
(
MallConstants
.
OVERTIME_CODE
.
equals
(
map
.
get
(
MallConstants
.
CODE_NAME
)))
{
Thread
.
currentThread
().
interrupt
(
);
}
}
*/
}
}
...
...
src/main/java/com/system/serivce/impl/MallCommonGetServiceImpl.java
浏览文件 @
303f56ee
package
com
.
system
.
serivce
.
impl
;
import
com.system.api.Common
Get
Api
;
import
com.system.api.Common
Http
Api
;
import
com.system.constants.MallCommonGetConstants
;
import
com.system.serivce.IMallCommonGetService
;
import
com.system.transfer.common.MallCommonGetInVo
;
...
...
@@ -18,7 +18,7 @@ import java.util.Map;
public
class
MallCommonGetServiceImpl
implements
IMallCommonGetService
{
@Autowired
private
Common
GetApi
commonGet
Api
;
private
Common
HttpApi
commonHttp
Api
;
@Autowired
private
MallCommonGetConstants
mallCommonGetConstants
;
...
...
@@ -31,7 +31,7 @@ public class MallCommonGetServiceImpl implements IMallCommonGetService {
return
RestResponse
.
fail
(
"操作失败!第三方标识为: "
+
inVo
.
getDocType
()
+
"的标识不存在"
);
}
String
result
=
commonGetApi
.
common
Get
(
config
,
inVo
.
getData
(),
inVo
.
getQueueId
());
//String result = commonGetApi.commonHttp
Get(config, inVo.getData(), inVo.getQueueId());
return
null
;
}
...
...
src/main/java/com/system/serivce/impl/SynchronizationServiceImpl.java
浏览文件 @
303f56ee
...
...
@@ -2,18 +2,14 @@ package com.system.serivce.impl;
import
com.google.common.util.concurrent.ThreadFactoryBuilder
;
import
com.system.dao.SynchronizationRecordsMapper
;
import
com.system.mall.MallCommonApi
;
import
com.system.serivce.ISynchronizationService
;
import
com.system.transfer.synchronization.SynchronizationRecordsListOutVoRecords
;
import
com.system.utils.HttpUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.transfer.mall.SynchronizationRecordsListOutVoRecords
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.util.CollectionUtils
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.ExecutorService
;
...
...
@@ -42,6 +38,9 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
@Autowired
private
IMallSyncServiceImpl
mallSyncService
;
@Autowired
private
MallCommonApi
mallCommonApi
;
@Override
public
void
mallSynchronization
()
{
...
...
@@ -50,14 +49,14 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
synchronization
()
{
List
<
Map
<
String
,
Object
>>
tempList
=
this
.
getSynchronizationRecords
();
List
<
Map
<
String
,
Object
>>
tempList
=
mallCommonApi
.
getSynchronizationRecords
();
if
(!
CollectionUtils
.
isEmpty
(
tempList
))
{
synchronizationRecordsMapper
.
synchronizationRecordsTempCreate
(
tempList
);
}
//更新状态
this
.
mallSynchronizedRecordsUpdate
(
tempList
);
mallCommonApi
.
mallSynchronizedRecordsUpdate
(
tempList
);
List
<
Map
<
String
,
Object
>>
dataList
=
synchronizationRecordsMapper
.
synchronizationRecordsTempList
();
if
(!
CollectionUtils
.
isEmpty
(
dataList
))
{
...
...
@@ -76,7 +75,7 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
for
(
SynchronizationRecordsListOutVoRecords
records
:
recordsList
)
{
if
(!
"LQKJ_IMSSync"
.
equals
(
records
.
getSFormId
()))
{
//mallSyncService.synchronization(records.getId(), records.getSFormId(), records.getData
Id());
mallSyncService
.
synchronization
(
records
.
getId
(),
records
.
getSFormId
(),
records
.
getDataId
(),
records
.
getEntry
Id
());
}
if
(
Thread
.
currentThread
().
isInterrupted
())
{
break
;
...
...
@@ -85,38 +84,5 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
});
}
private
List
<
Map
<
String
,
Object
>>
getSynchronizationRecords
()
{
try
{
ResponseEntity
<
String
>
responseEntity
=
HttpUtil
.
httpPost
(
"http://192.168.0.9:8089/api/dataSyn/getSyn"
,
""
);
List
<
Object
>
objectList
=
JsonUtil
.
toList
(
responseEntity
.
getBody
(),
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
objectList
))
{
return
objectList
.
stream
().
map
(
m
->
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
m
),
String
.
class
,
Object
.
class
)).
collect
(
Collectors
.
toList
());
}
return
new
ArrayList
<>();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
new
ArrayList
<>();
}
}
private
void
mallSynchronizedRecordsUpdate
(
List
<
Map
<
String
,
Object
>>
tempList
)
{
List
<
String
>
idList
=
tempList
.
stream
().
filter
(
m
->
!
"LQKJ_IMSSync"
.
equals
(
m
.
get
(
"formId"
))).
map
(
m
->
String
.
valueOf
(
m
.
get
(
"fid"
))).
collect
(
Collectors
.
toList
());
List
<
Map
<
String
,
Object
>>
dataList
=
new
ArrayList
<>();
for
(
String
id
:
idList
)
{
//将商城的数据同步该成1
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
3
);
request
.
put
(
"id"
,
id
);
request
.
put
(
"status"
,
"1"
);
dataList
.
add
(
request
);
}
if
(!
CollectionUtils
.
isEmpty
(
dataList
))
{
//修改商城是否同步
//kingDeeSynchronizationApi.batchAdd(uList);
}
}
}
src/main/java/com/system/transfer/form/MallCommonConfigListOutVoRecords.java
浏览文件 @
303f56ee
...
...
@@ -18,6 +18,12 @@ public class MallCommonConfigListOutVoRecords {
/**
* 平台产品关系id
*/
private
Integer
platformProductRelationId
;
/**
* 第三方唯一标识
*/
private
String
docType
;
...
...
@@ -36,15 +42,21 @@ public class MallCommonConfigListOutVoRecords {
/**
* 方向
*/
private
String
direction
;
/**
* 操作(1-查询 2-创建/更新 3-同步)
*/
private
Integer
operation
;
/**
*
请求地址
*
封装格式(1-全部 2-聚合)
*/
private
String
requestAddress
;
private
Integer
encapsulationFormat
;
/**
...
...
src/main/java/com/system/transfer/log/ProductLogCreateInVo.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
transfer
.
log
;
import
lombok.Data
;
/**
* @author Inori
*/
@Data
public
class
ProductLogCreateInVo
{
/**
* ID
*/
private
Integer
id
;
/**
* 平台产品关系id
*/
private
Integer
platformProductRelationId
;
/**
* 唯一标识
*/
private
String
queueId
;
/**
* 业务名称
*/
private
String
name
;
/**
* 业务标识
*/
private
String
code
;
/**
* 方向
*/
private
String
direction
;
/**
* 请求参数
*/
private
String
request
;
/**
* 是否成功(0-失败,1-成功)
*/
private
Integer
flag
;
/**
* 响应信息
*/
private
String
response
;
/**
* 错误原因
*/
private
String
message
;
/**
* 耗时
*/
private
Integer
costTime
;
}
src/main/java/com/system/transfer/
synchronization
/SynchronizationRecordsDeleteInVo.java
→
src/main/java/com/system/transfer/
mall
/SynchronizationRecordsDeleteInVo.java
浏览文件 @
303f56ee
package
com
.
system
.
transfer
.
synchronization
;
package
com
.
system
.
transfer
.
mall
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
...
...
src/main/java/com/system/transfer/
synchronization
/SynchronizationRecordsListInVo.java
→
src/main/java/com/system/transfer/
mall
/SynchronizationRecordsListInVo.java
浏览文件 @
303f56ee
package
com
.
system
.
transfer
.
synchronization
;
package
com
.
system
.
transfer
.
mall
;
import
com.system.utils.StringUtil
;
...
...
src/main/java/com/system/transfer/
synchronization
/SynchronizationRecordsListOutVo.java
→
src/main/java/com/system/transfer/
mall
/SynchronizationRecordsListOutVo.java
浏览文件 @
303f56ee
package
com
.
system
.
transfer
.
synchronization
;
package
com
.
system
.
transfer
.
mall
;
import
lombok.Data
;
...
...
src/main/java/com/system/transfer/
synchronization
/SynchronizationRecordsListOutVoRecords.java
→
src/main/java/com/system/transfer/
mall
/SynchronizationRecordsListOutVoRecords.java
浏览文件 @
303f56ee
package
com
.
system
.
transfer
.
synchronization
;
package
com
.
system
.
transfer
.
mall
;
import
lombok.Data
;
...
...
src/main/java/com/system/transfer/
synchronization
/SynchronizationRecordsUpdateInVo.java
→
src/main/java/com/system/transfer/
mall
/SynchronizationRecordsUpdateInVo.java
浏览文件 @
303f56ee
package
com
.
system
.
transfer
.
synchronization
;
package
com
.
system
.
transfer
.
mall
;
import
lombok.AllArgsConstructor
;
import
lombok.Data
;
...
...
src/main/java/com/system/transfer/synchronization/SynchronizationOperationListOutVoRecords.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
transfer
.
synchronization
;
import
lombok.Data
;
/**
* @author Inori
*/
@Data
public
class
SynchronizationOperationListOutVoRecords
{
/**
* ID
*/
private
Integer
id
;
/**
* 平台产品关系id
*/
private
Integer
platformProductRelationId
;
/**
* 任务类名
*/
private
String
jobClassName
;
/**
* 金蝶通用配置id
*/
private
Integer
kingdeeCommonConfigId
;
/**
* 金蝶标识
*/
private
String
sFormId
;
/**
* 第三方唯一标识
*/
private
String
docType
;
/**
* 接收地址
*/
private
String
receiveAddress
;
/**
* 创建时间
*/
private
String
createTime
;
}
src/main/java/com/system/utils/DesHelperUtil.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
utils
;
import
javax.crypto.Cipher
;
import
javax.crypto.SecretKey
;
import
javax.crypto.SecretKeyFactory
;
import
javax.crypto.spec.DESKeySpec
;
import
javax.crypto.spec.IvParameterSpec
;
import
java.nio.charset.Charset
;
/**
* @author Inori
*/
public
class
DesHelperUtil
{
/**
* 加密
*/
public
static
String
encrypt
(
String
srcStr
,
Charset
charset
,
String
sKey
)
{
byte
[]
src
=
srcStr
.
getBytes
(
charset
);
byte
[]
buf
=
encrypt
(
src
,
sKey
);
return
parseByte2HexStr
(
buf
);
}
/**
* 解密
*/
public
static
String
decrypt
(
String
hexStr
,
Charset
charset
,
String
sKey
)
throws
Exception
{
byte
[]
src
=
parseHexStr2Byte
(
hexStr
);
byte
[]
buf
=
decrypt
(
src
,
sKey
);
return
new
String
(
buf
,
charset
);
}
/**
* 加密
*/
public
static
byte
[]
encrypt
(
byte
[]
data
,
String
sKey
)
{
try
{
byte
[]
key
=
sKey
.
getBytes
();
// 初始化向量
IvParameterSpec
iv
=
new
IvParameterSpec
(
key
);
DESKeySpec
desKey
=
new
DESKeySpec
(
key
);
// 创建一个密匙工厂,然后用它把DESKeySpec转换成securekey
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
"DES"
);
SecretKey
securekey
=
keyFactory
.
generateSecret
(
desKey
);
// Cipher对象实际完成加密操作
Cipher
cipher
=
Cipher
.
getInstance
(
"DES/CBC/PKCS5Padding"
);
// 用密匙初始化Cipher对象
cipher
.
init
(
Cipher
.
ENCRYPT_MODE
,
securekey
,
iv
);
// 现在,获取数据并加密
// 正式执行加密操作
return
cipher
.
doFinal
(
data
);
}
catch
(
Throwable
e
)
{
e
.
printStackTrace
();
}
return
null
;
}
/**
* 解密
*/
public
static
byte
[]
decrypt
(
byte
[]
src
,
String
sKey
)
throws
Exception
{
byte
[]
key
=
sKey
.
getBytes
();
// 初始化向量
IvParameterSpec
iv
=
new
IvParameterSpec
(
key
);
// 创建一个DESKeySpec对象
DESKeySpec
desKey
=
new
DESKeySpec
(
key
);
// 创建一个密匙工厂
SecretKeyFactory
keyFactory
=
SecretKeyFactory
.
getInstance
(
"DES"
);
// 将DESKeySpec对象转换成SecretKey对象
SecretKey
securekey
=
keyFactory
.
generateSecret
(
desKey
);
// Cipher对象实际完成解密操作
Cipher
cipher
=
Cipher
.
getInstance
(
"DES/CBC/PKCS5Padding"
);
// 用密匙初始化Cipher对象
cipher
.
init
(
Cipher
.
DECRYPT_MODE
,
securekey
,
iv
);
// 真正开始解密操作
return
cipher
.
doFinal
(
src
);
}
/**
* 将二进制转换成16进制
*/
public
static
String
parseByte2HexStr
(
byte
buf
[])
{
StringBuffer
sb
=
new
StringBuffer
();
for
(
int
i
=
0
;
i
<
buf
.
length
;
i
++)
{
String
hex
=
Integer
.
toHexString
(
buf
[
i
]
&
0xFF
);
if
(
hex
.
length
()
==
1
)
{
hex
=
'0'
+
hex
;
}
sb
.
append
(
hex
.
toUpperCase
());
}
return
sb
.
toString
();
}
/**
* 将16进制转换为二进制
*/
public
static
byte
[]
parseHexStr2Byte
(
String
hexStr
)
{
if
(
hexStr
.
length
()
<
1
)
return
null
;
byte
[]
result
=
new
byte
[
hexStr
.
length
()
/
2
];
for
(
int
i
=
0
;
i
<
hexStr
.
length
()
/
2
;
i
++)
{
int
high
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
,
i
*
2
+
1
),
16
);
int
low
=
Integer
.
parseInt
(
hexStr
.
substring
(
i
*
2
+
1
,
i
*
2
+
2
),
16
);
result
[
i
]
=
(
byte
)
(
high
*
16
+
low
);
}
return
result
;
}
}
\ No newline at end of file
src/main/java/com/system/utils/FormFieldMappingUtil.java
浏览文件 @
303f56ee
...
...
@@ -10,7 +10,7 @@ import java.util.stream.Collectors;
*/
public
class
FormFieldMappingUtil
{
public
static
List
<
MallFieldMappingListOutVoRecords
>
purchase
Mapping
(
String
formFieldMappingDetail
)
{
public
static
List
<
MallFieldMappingListOutVoRecords
>
encapsulation
Mapping
(
String
formFieldMappingDetail
)
{
List
<
Object
>
objectList
=
JsonUtil
.
toList
(
formFieldMappingDetail
,
Object
.
class
);
return
objectList
.
stream
().
map
(
m
->
JsonUtil
.
toBean
(
JsonUtil
.
toString
(
m
),
MallFieldMappingListOutVoRecords
.
class
)).
collect
(
Collectors
.
toList
());
}
...
...
src/main/java/com/system/utils/MallLogUtil.java
浏览文件 @
303f56ee
package
com
.
system
.
utils
;
import
com.system.constants.Constants
;
import
com.system.dao.MallLogMapper
;
import
com.system.transfer.log.MallLogCreateInVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.util.Map
;
/**
* @author Inori
...
...
@@ -15,6 +19,30 @@ public class MallLogUtil {
private
MallLogMapper
mallLogMapper
;
public
void
mallLogCreate
(
String
name
,
String
docType
,
String
queueId
,
Integer
operation
,
String
request
,
String
response
)
{
MallLogCreateInVo
inVo
=
new
MallLogCreateInVo
();
inVo
.
setName
(
name
);
inVo
.
setCode
(
docType
);
inVo
.
setQueueId
(
queueId
);
inVo
.
setOperation
(
operation
);
inVo
.
setRequest
(
request
);
inVo
.
setResponse
(
response
);
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
if
(
Constants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
SUCCESS_NAME
))))
{
inVo
.
setFlag
(
1
);
}
else
{
inVo
.
setFlag
(
0
);
inVo
.
setMessage
(
response
);
}
}
else
{
inVo
.
setFlag
(
0
);
}
mallLogMapper
.
mallLogCreate
(
inVo
);
}
public
void
thirdPartyErrorLogCreate
(
String
name
,
String
sFormId
,
String
queueId
,
Integer
operation
,
String
request
,
String
message
)
{
MallLogCreateInVo
inVo
=
new
MallLogCreateInVo
();
inVo
.
setName
(
name
);
...
...
src/main/java/com/system/utils/ProductLogUtil.java
0 → 100644
浏览文件 @
303f56ee
package
com
.
system
.
utils
;
import
com.system.config.ThreadLocalConfig
;
import
com.system.constants.MallConstants
;
import
com.system.dao.ProductLogMapper
;
import
com.system.dao.SynchronizationRecordsMapper
;
import
com.system.transfer.log.ProductLogCreateInVo
;
import
com.system.transfer.mall.SynchronizationRecordsDeleteInVo
;
import
com.system.transfer.mall.SynchronizationRecordsUpdateInVo
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.util.CollectionUtils
;
import
java.nio.charset.StandardCharsets
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* @author Inori
*/
@Component
public
class
ProductLogUtil
{
@Autowired
private
ProductLogMapper
productLogMapper
;
@Autowired
private
SynchronizationRecordsMapper
synchronizationRecordsMapper
;
public
Integer
isExist
(
String
queueId
)
{
return
productLogMapper
.
getProductLogByQueueId
(
queueId
);
}
public
Integer
productLogCreate
(
Integer
productId
,
String
queueId
,
String
name
,
String
code
,
String
direction
,
String
request
,
String
response
,
Integer
flag
,
Integer
costTime
)
{
ProductLogCreateInVo
inVo
=
this
.
encapsulationInVo
(
productId
,
queueId
,
name
,
code
,
direction
,
request
,
response
);
inVo
.
setFlag
(
flag
);
if
(
costTime
!=
0
)
{
inVo
.
setCostTime
(
costTime
);
}
productLogMapper
.
productLogCreate
(
inVo
);
return
inVo
.
getId
();
}
public
void
productLogUpdate
(
Integer
id
,
String
response
,
Integer
costTime
)
{
ProductLogCreateInVo
inVo
=
new
ProductLogCreateInVo
();
inVo
.
setId
(
id
);
inVo
.
setResponse
(
response
);
if
(
costTime
!=
0
)
{
inVo
.
setCostTime
(
costTime
);
}
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(
MallConstants
.
SUCCESS_CODE
.
equals
(
map
.
get
(
MallConstants
.
CODE_NAME
)))
{
inVo
.
setFlag
(
1
);
}
else
{
inVo
.
setFlag
(
0
);
String
message
=
String
.
valueOf
(
map
.
get
(
"resultMsg"
));
List
<
Object
>
tempList
=
JsonUtil
.
toList
(
JsonUtil
.
toString
(
map
.
get
(
"resultData"
)),
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
tempList
))
{
message
=
message
+
" "
+
tempList
.
stream
()
.
map
(
m
->
(
String
)
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
m
),
String
.
class
,
Object
.
class
).
get
(
"Msg"
))
.
collect
(
Collectors
.
joining
(
", "
));
}
inVo
.
setMessage
(
message
);
}
productLogMapper
.
productLogUpdate
(
inVo
);
}
public
void
productLogUpdate
(
Integer
id
,
String
response
,
String
message
,
Integer
costTime
)
{
ProductLogCreateInVo
inVo
=
new
ProductLogCreateInVo
();
inVo
.
setId
(
id
);
inVo
.
setResponse
(
response
);
inVo
.
setMessage
(
message
);
inVo
.
setCostTime
(
costTime
);
if
(
StringUtil
.
isNotBlank
(
message
))
{
inVo
.
setFlag
(
0
);
}
else
{
inVo
.
setFlag
(
1
);
}
productLogMapper
.
productLogUpdate
(
inVo
);
}
public
void
productHttpLogCreate
(
Integer
productId
,
String
queueId
,
Integer
id
,
String
name
,
String
code
,
String
direction
,
String
request
,
String
response
)
{
ProductLogCreateInVo
inVo
=
this
.
encapsulationInVo
(
productId
,
queueId
,
name
,
code
,
direction
,
request
,
response
);
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
if
(
map
.
containsKey
(
MallConstants
.
CODE_NAME
)
&&
MallConstants
.
SUCCESS_CODE
.
equals
(
map
.
get
(
MallConstants
.
CODE_NAME
)))
{
inVo
.
setFlag
(
1
);
synchronizationRecordsMapper
.
synchronizationRecordsDelete
(
new
SynchronizationRecordsDeleteInVo
(
id
));
}
else
{
inVo
.
setFlag
(
0
);
if
(
map
.
containsKey
(
MallConstants
.
MSG_NAME
))
{
inVo
.
setMessage
(
map
.
get
(
"resultMsg"
).
toString
());
}
synchronizationRecordsMapper
.
synchronizationRecordsUpdate
(
new
SynchronizationRecordsUpdateInVo
(
id
,
queueId
,
inVo
.
getMessage
(),
2
));
}
}
else
{
inVo
.
setFlag
(
0
);
inVo
.
setMessage
(
"请求响应信息错误"
);
synchronizationRecordsMapper
.
synchronizationRecordsUpdate
(
new
SynchronizationRecordsUpdateInVo
(
id
,
queueId
,
inVo
.
getMessage
(),
2
));
}
productLogMapper
.
productLogCreate
(
inVo
);
}
public
void
productPushLogCreate
(
Integer
productId
,
String
queueId
,
String
name
,
String
code
,
String
direction
,
String
request
,
String
response
)
{
ProductLogCreateInVo
inVo
=
this
.
encapsulationInVo
(
productId
,
queueId
,
name
,
code
,
direction
,
request
,
response
);
encapsulationOperation
(
response
,
inVo
);
}
public
void
productSqlLogCreate
(
Integer
productId
,
String
queueId
,
String
name
,
String
code
,
String
direction
,
String
request
,
String
response
)
{
ProductLogCreateInVo
inVo
=
this
.
encapsulationInVo
(
productId
,
queueId
,
name
,
code
,
direction
,
request
,
response
);
try
{
inVo
.
setRequest
(
DesHelperUtil
.
decrypt
(
request
,
StandardCharsets
.
UTF_8
,
"MES&&DES"
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
encapsulationOperation
(
response
,
inVo
);
}
public
void
productSyncErrorLogCreate
(
Integer
productId
,
String
queueId
,
String
name
,
String
code
,
String
direction
,
String
request
,
String
message
)
{
ProductLogCreateInVo
inVo
=
this
.
encapsulationInVo
(
productId
,
queueId
,
name
,
code
,
direction
,
request
,
message
);
inVo
.
setFlag
(
0
);
inVo
.
setMessage
(
message
);
productLogMapper
.
productLogCreate
(
inVo
);
}
private
ProductLogCreateInVo
encapsulationInVo
(
Integer
productId
,
String
queueId
,
String
name
,
String
code
,
String
direction
,
String
request
,
String
response
)
{
ProductLogCreateInVo
inVo
=
new
ProductLogCreateInVo
();
inVo
.
setPlatformProductRelationId
(
productId
);
inVo
.
setName
(
name
);
inVo
.
setCode
(
code
);
inVo
.
setDirection
(
direction
);
inVo
.
setQueueId
(
queueId
);
inVo
.
setRequest
(
request
);
inVo
.
setResponse
(
response
);
Map
<
String
,
Object
>
map
=
ThreadLocalConfig
.
get
();
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
int
costTime
=
StringUtil
.
isNotNull
(
map
.
get
(
"costTime"
))
?
Integer
.
parseInt
(
map
.
get
(
"costTime"
).
toString
())
:
0
;
inVo
.
setCostTime
(
costTime
);
}
return
inVo
;
}
private
void
encapsulationOperation
(
String
response
,
ProductLogCreateInVo
inVo
)
{
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(
StringUtil
.
isNotBlank
(
response
)
&&
!
CollectionUtils
.
isEmpty
(
map
))
{
if
(
map
.
containsKey
(
MallConstants
.
CODE_NAME
)
&&
MallConstants
.
SUCCESS_CODE
.
equals
(
map
.
get
(
MallConstants
.
CODE_NAME
)))
{
inVo
.
setFlag
(
1
);
}
else
{
inVo
.
setFlag
(
0
);
inVo
.
setMessage
(
String
.
valueOf
(
map
.
get
(
"resultMsg"
)));
}
}
else
{
inVo
.
setFlag
(
0
);
}
productLogMapper
.
productLogCreate
(
inVo
);
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论