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
d4ac15df
提交
d4ac15df
authored
11月 23, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
303f56ee
显示空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
43 行增加
和
31 行删除
+43
-31
CommonHttpApi.java
src/main/java/com/system/api/CommonHttpApi.java
+10
-13
Constants.java
src/main/java/com/system/constants/Constants.java
+3
-0
MallCommonConfigMapper.xml
...ain/java/com/system/dao/mapper/MallCommonConfigMapper.xml
+6
-3
SynchronizationOperationMapper.xml
.../com/system/dao/mapper/SynchronizationOperationMapper.xml
+2
-2
SynchronizationRecordsMapper.xml
...va/com/system/dao/mapper/SynchronizationRecordsMapper.xml
+2
-2
MallCommonApi.java
src/main/java/com/system/mall/MallCommonApi.java
+1
-0
MallCommonSyncApi.java
src/main/java/com/system/mall/MallCommonSyncApi.java
+5
-3
IMallSyncServiceImpl.java
...in/java/com/system/serivce/impl/IMallSyncServiceImpl.java
+3
-4
SynchronizationServiceImpl.java
...a/com/system/serivce/impl/SynchronizationServiceImpl.java
+2
-2
SynchronizationRecordsListOutVoRecords.java
...transfer/mall/SynchronizationRecordsListOutVoRecords.java
+2
-2
JsonUtil.java
src/main/java/com/system/utils/JsonUtil.java
+1
-0
ProductLogUtil.java
src/main/java/com/system/utils/ProductLogUtil.java
+6
-0
没有找到文件。
src/main/java/com/system/api/CommonHttpApi.java
浏览文件 @
d4ac15df
...
...
@@ -9,7 +9,7 @@ import com.system.model.DelayedElement;
import
com.system.model.InitConnectParam
;
import
com.system.utils.HttpUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.
Mall
LogUtil
;
import
com.system.utils.
Product
LogUtil
;
import
com.system.utils.StringUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
...
...
@@ -45,13 +45,12 @@ public class CommonHttpApi {
private
InitConnectParamMapper
initConnectParamMapper
;
@Autowired
private
MallLogUtil
mall
LogUtil
;
private
ProductLogUtil
product
LogUtil
;
@PostConstruct
public
void
init
()
{
initConnectParam
=
initConnectParamMapper
.
selectOne
(
new
QueryWrapper
<
InitConnectParam
>().
last
(
"LIMIT 1"
));
System
.
out
.
println
(
"++++++"
+
initConnectParam
);
if
(
StringUtil
.
isNotNull
(
initConnectParam
))
{
mallAddress
=
initConnectParam
.
getMallAddress
();
}
...
...
@@ -113,22 +112,20 @@ public class CommonHttpApi {
}
}
public
String
commonHttp
Get
(
Map
<
String
,
String
>
config
,
String
queueId
,
String
name
,
List
<
String
>
keyList
,
Map
<
String
,
Object
>
where
)
{
public
String
commonHttp
SyncData
(
Map
<
String
,
String
>
config
,
String
queueId
,
String
name
,
List
<
String
>
keyList
,
Map
<
String
,
Object
>
where
)
{
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
3
);
request
.
put
(
"form
Id
"
,
config
.
get
(
"sFormId"
));
request
.
put
(
"field
Key
s"
,
String
.
join
(
","
,
keyList
));
request
.
put
(
"filterString"
,
this
.
stringWhere
(
where
)
);
request
.
put
(
"form"
,
config
.
get
(
"sFormId"
));
request
.
put
(
"fields"
,
String
.
join
(
","
,
keyList
));
request
.
put
All
(
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
);
String
response
=
HttpUtil
.
httpPost
(
"http://192.168.0.9:8089/wx/"
+
"api/dataSyn/synData"
,
JsonUtil
.
toString
(
request
)).
getBody
();
productLogUtil
.
productSyncLogCreate
(
Integer
.
valueOf
(
config
.
get
(
"productId"
)),
queueId
,
name
,
config
.
get
(
"docType"
),
config
.
get
(
"direction"
),
JsonUtil
.
toString
(
request
),
response
);
return
response
;
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
}
return
response
;
}
public
String
sendThirdParty
(
String
receiveAddress
,
String
data
,
int
index
)
{
...
...
@@ -154,7 +151,7 @@ public class CommonHttpApi {
}
//TODO 开启同步
HttpUtil
.
httpGet
(
"http://integrate-system:8090/integrate/api/start/synchronization"
);
//
HttpUtil.httpGet("http://integrate-system:8090/integrate/api/start/synchronization");
});
}
...
...
src/main/java/com/system/constants/Constants.java
浏览文件 @
d4ac15df
...
...
@@ -20,6 +20,9 @@ public interface Constants {
String
SUCCESS_NAME
=
"success"
;
String
CODE_NAME
=
"code"
;
String
DATE_NAME
=
"data"
;
...
...
src/main/java/com/system/dao/mapper/MallCommonConfigMapper.xml
浏览文件 @
d4ac15df
...
...
@@ -7,7 +7,8 @@
<select
id=
"mallCommonConfigList"
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
id, platform_product_relation_id, doc_type, s_form_id, `name`, direction,
operation, encapsulation_format, entry_name, custom_sql, create_time
FROM tb_mall_common_config WHERE operation = #{operation}
</select>
...
...
@@ -17,7 +18,8 @@
<select
id=
"mallCommonConfigGetList"
resultType=
"com.system.transfer.form.MallCommonConfigListOutVoRecords"
>
SELECT
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
m1.id, m1.platform_product_relation_id, m1.doc_type, m1.s_form_id, m1.name, m1.direction,
m1.operation, m1.encapsulation_format, m1.entry_name, m1.custom_sql, m1.create_time
FROM tb_mall_common_config AS m1 INNER JOIN (
SELECT
platform_product_relation_id, s_form_id, MIN(operation) AS operation
...
...
@@ -31,7 +33,8 @@
<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
id, platform_product_relation_id, doc_type, s_form_id, `name`, direction,
operation, encapsulation_format, entry_name, custom_sql, create_time
FROM tb_mall_common_config WHERE id = #{id}
</select>
...
...
src/main/java/com/system/dao/mapper/SynchronizationOperationMapper.xml
浏览文件 @
d4ac15df
...
...
@@ -8,9 +8,9 @@
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
m.doc_type, m
.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
LEFT JOIN tb_
mall_common_config AS m ON s.common_config_id = m
.id
WHERE job_class_name = "com.system.quartz.job.mallSynchronizationJob"
</select>
...
...
src/main/java/com/system/dao/mapper/SynchronizationRecordsMapper.xml
浏览文件 @
d4ac15df
...
...
@@ -22,7 +22,7 @@
INSERT INTO tb_mall_synchronization_record_temp (fid, data_id, entry_id, form, operation) VALUES
<foreach
collection=
"tempList"
item=
"item"
separator=
","
>
(#{item.
fid}, #{item.dataId}, #{item.entryId}, #{item.sFormId
}, #{item.operation})
(#{item.
id}, #{item.dataId}, #{item.entryId}, #{item.form
}, #{item.operation})
</foreach>
ON DUPLICATE KEY UPDATE
fid = VALUES (fid), data_id = VALUES (data_id), entry_id = VALUES (entry_id),
...
...
@@ -46,7 +46,7 @@
INSERT INTO tb_mall_synchronization_record (fid, data_id, entry_id, form, operation) VALUES
<foreach
collection=
"tempList"
item=
"item"
separator=
","
>
(#{item.
fid}, #{item.dataId}, #{item.entryId}, #{item.sFormId
}, #{item.operation})
(#{item.
id}, #{item.dataId}, #{item.entryId}, #{item.form
}, #{item.operation})
</foreach>
ON DUPLICATE KEY UPDATE
fid = VALUES (fid), data_id = VALUES (data_id), entry_id = VALUES (entry_id),
...
...
src/main/java/com/system/mall/MallCommonApi.java
浏览文件 @
d4ac15df
...
...
@@ -25,6 +25,7 @@ public class MallCommonApi {
public
List
<
Map
<
String
,
Object
>>
getSynchronizationRecords
()
{
try
{
String
response
=
commonHttpApi
.
commonHttpSync
();
System
.
out
.
println
(
"同步记录: "
+
response
);
List
<
Object
>
objectList
=
JsonUtil
.
toList
(
response
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
objectList
))
{
...
...
src/main/java/com/system/mall/MallCommonSyncApi.java
浏览文件 @
d4ac15df
...
...
@@ -3,6 +3,7 @@ package com.system.mall;
import
com.system.api.CommonApi
;
import
com.system.api.CommonHttpApi
;
import
com.system.constants.Constants
;
import
com.system.constants.MallConstants
;
import
com.system.transfer.form.MallFieldMappingListOutVoRecords
;
import
com.system.utils.FormFieldMappingUtil
;
import
com.system.utils.JsonUtil
;
...
...
@@ -30,18 +31,19 @@ public class MallCommonSyncApi {
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
);
String
response
=
commonHttpApi
.
commonHttpSyncData
(
config
,
queueId
,
name
,
keyList
,
where
);
System
.
out
.
println
(
"同步记录详细数据: "
+
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
))))
{
if
(
MallConstants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
CODE
_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
))
{
}
else
if
(!
MallConstants
.
SUCCESS_CODE
.
equals
(
String
.
valueOf
(
map
.
get
(
Constants
.
CODE
_NAME
)))
&&
map
.
containsKey
(
Constants
.
ERROR_MESSAGE
))
{
result
.
put
(
"message"
,
map
.
get
(
Constants
.
ERROR_MESSAGE
));
result
.
put
(
"success"
,
false
);
}
else
{
...
...
src/main/java/com/system/serivce/impl/IMallSyncServiceImpl.java
浏览文件 @
d4ac15df
...
...
@@ -45,7 +45,7 @@ public class IMallSyncServiceImpl implements IMallSyncService {
@Override
public
void
synchronization
(
Integer
id
,
String
sFormId
,
Integer
dataId
,
Integer
entryId
)
{
List
<
Map
<
String
,
String
>>
configList
=
mallCommonSyncConstants
.
get
(
sFormId
);
if
(
!
CollectionUtils
.
isEmpty
(
configList
))
{
if
(
CollectionUtils
.
isEmpty
(
configList
))
{
synchronizationRecordsMapper
.
synchronizationRecordsUpdate
(
new
SynchronizationRecordsUpdateInVo
(
id
,
SnowFlakeIdUtil
.
generateId
().
toString
(),
"商城同步失败! sFormId为: "
+
sFormId
+
" 的商城表单不存在"
,
2
));
return
;
}
...
...
@@ -61,7 +61,6 @@ public class IMallSyncServiceImpl implements IMallSyncService {
}
Map
<
String
,
Object
>
where
=
new
HashMap
<>(
3
);
where
.
put
(
"form"
,
sFormId
);
where
.
put
(
"dataId"
,
dataId
);
if
(
StringUtil
.
isNotNull
(
entryId
))
{
where
.
put
(
"entryId"
,
entryId
);
...
...
@@ -78,10 +77,10 @@ public class IMallSyncServiceImpl implements IMallSyncService {
}
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
<>();
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
3
);
request
.
put
(
"docType"
,
config
.
get
(
"docType"
));
request
.
put
(
"updateType"
,
"update"
);
request
.
put
(
"data"
,
data
.
get
(
Constants
.
DATE_NAME
));
request
.
put
(
"data"
,
JsonUtil
.
toList
(
JsonUtil
.
toString
(
data
.
get
(
Constants
.
DATE_NAME
)),
Object
.
class
));
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
);
...
...
src/main/java/com/system/serivce/impl/SynchronizationServiceImpl.java
浏览文件 @
d4ac15df
...
...
@@ -74,8 +74,8 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
}
for
(
SynchronizationRecordsListOutVoRecords
records
:
recordsList
)
{
if
(!
"LQKJ_IMSSync"
.
equals
(
records
.
get
SFormId
()))
{
mallSyncService
.
synchronization
(
records
.
getId
(),
records
.
get
SFormId
(),
records
.
getDataId
(),
records
.
getEntryId
());
if
(!
"LQKJ_IMSSync"
.
equals
(
records
.
get
Form
()))
{
mallSyncService
.
synchronization
(
records
.
getId
(),
records
.
get
Form
(),
records
.
getDataId
(),
records
.
getEntryId
());
}
if
(
Thread
.
currentThread
().
isInterrupted
())
{
break
;
...
...
src/main/java/com/system/transfer/mall/SynchronizationRecordsListOutVoRecords.java
浏览文件 @
d4ac15df
...
...
@@ -33,9 +33,9 @@ public class SynchronizationRecordsListOutVoRecords {
/**
*
金蝶
标识
*
商城
标识
*/
private
String
sFormId
;
private
String
form
;
/**
...
...
src/main/java/com/system/utils/JsonUtil.java
浏览文件 @
d4ac15df
...
...
@@ -72,6 +72,7 @@ public class JsonUtil {
try
{
return
MAPPER
.
readValue
(
json
,
MAPPER
.
getTypeFactory
().
constructMapType
(
Map
.
class
,
kClass
,
vClass
));
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
log
.
error
(
"Json解析出错: JsonUtil.toMap(), Json: "
+
json
);
return
new
HashMap
<>(
10
);
}
...
...
src/main/java/com/system/utils/ProductLogUtil.java
浏览文件 @
d4ac15df
...
...
@@ -126,6 +126,12 @@ public class ProductLogUtil {
encapsulationOperation
(
response
,
inVo
);
}
public
void
productSyncLogCreate
(
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
);
productLogMapper
.
productLogCreate
(
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
);
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论