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
847f9218
提交
847f9218
authored
11月 30, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
32e71503
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
251 行增加
和
20 行删除
+251
-20
DatabaseTableMapper.java
src/main/java/com/system/dao/DatabaseTableMapper.java
+49
-0
DatabaseTableMapper.xml
src/main/java/com/system/dao/mapper/DatabaseTableMapper.xml
+53
-0
MallCommonSyncApi.java
src/main/java/com/system/mall/MallCommonSyncApi.java
+21
-0
InitConnectParam.java
src/main/java/com/system/model/InitConnectParam.java
+12
-12
MallLoginScheduler.java
src/main/java/com/system/scheduler/MallLoginScheduler.java
+1
-1
IMallSyncServiceImpl.java
...in/java/com/system/serivce/impl/IMallSyncServiceImpl.java
+14
-3
MallCommonSyncConfigServiceImpl.java
.../system/serivce/impl/MallCommonSyncConfigServiceImpl.java
+2
-2
TableStructureCreateInVoRecords.java
...m/transfer/configure/TableStructureCreateInVoRecords.java
+53
-0
TableStructureListOutVoRecords.java
...em/transfer/configure/TableStructureListOutVoRecords.java
+44
-0
HttpUtil.java
src/main/java/com/system/utils/HttpUtil.java
+2
-2
没有找到文件。
src/main/java/com/system/dao/DatabaseTableMapper.java
0 → 100644
浏览文件 @
847f9218
package
com
.
system
.
dao
;
import
com.system.transfer.configure.TableStructureListOutVoRecords
;
import
org.apache.ibatis.annotations.Mapper
;
import
org.apache.ibatis.annotations.Param
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author Inori
*/
@Mapper
public
interface
DatabaseTableMapper
{
/**
* 表单表结构列表
*
* @return 列表
*/
List
<
TableStructureListOutVoRecords
>
tableStructureList
();
/**
* 表单配置
*
* @param formId 表单标识
* @return 表单配置
*/
TableStructureListOutVoRecords
tableStructureOne
(
String
formId
);
/**
* 数据库表数据创建
*
* @param dbTableName 数据库表名称
* @param dbFiledList 数据库表字段列表
* @param dataList 数据库表数据列表
*/
void
databaseTableDataCreate
(
@Param
(
"dbTableName"
)
String
dbTableName
,
@Param
(
"dbFiledList"
)
List
<
String
>
dbFiledList
,
@Param
(
"dataList"
)
List
<
Map
<
String
,
Object
>>
dataList
);
/**
* 数据库表数据删除
*
* @param dbTableName 数据库表名称
* @param queueId 唯一标识
*/
void
databaseTableDataDelete
(
@Param
(
"dbTableName"
)
String
dbTableName
,
@Param
(
"queueId"
)
String
queueId
);
}
src/main/java/com/system/dao/mapper/DatabaseTableMapper.xml
0 → 100644
浏览文件 @
847f9218
<?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.DatabaseTableMapper"
>
<select
id=
"tableStructureList"
resultType=
"com.system.transfer.configure.TableStructureListOutVoRecords"
>
SELECT
id, form_id, db_table_name, db_table_comment, form_json
FROM tb_form_table_structure
</select>
<select
id=
"tableStructureOne"
parameterType=
"java.lang.String"
resultType=
"com.system.transfer.configure.TableStructureListOutVoRecords"
>
SELECT
id, form_id, db_table_name, db_table_comment, form_json
FROM tb_form_table_structure WHERE form_id = #{formId}
</select>
<insert
id=
"databaseTableDataCreate"
parameterType=
"java.lang.Object"
>
INSERT INTO ${dbTableName} (
<foreach
collection=
"dbFiledList"
item=
"item"
separator=
","
>
${item}
</foreach>
) VALUES
<foreach
collection=
"dataList"
item=
"item"
separator=
","
>
<foreach
collection=
"item.values"
item=
"value"
separator=
","
open=
"("
close=
")"
>
#{value}
</foreach>
</foreach>
</insert>
<delete
id=
"databaseTableDataDelete"
parameterType=
"java.lang.String"
>
DELETE FROM ${dbTableName} WHERE queue_id = #{queueId}
</delete>
</mapper>
\ No newline at end of file
src/main/java/com/system/mall/MallCommonSyncApi.java
浏览文件 @
847f9218
...
...
@@ -4,9 +4,12 @@ import com.system.api.CommonApi;
import
com.system.api.CommonHttpApi
;
import
com.system.constants.Constants
;
import
com.system.constants.MallConstants
;
import
com.system.dao.DatabaseTableMapper
;
import
com.system.transfer.configure.TableStructureListOutVoRecords
;
import
com.system.transfer.form.MallFieldMappingListOutVoRecords
;
import
com.system.utils.FormFieldMappingUtil
;
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
;
...
...
@@ -25,6 +28,9 @@ public class MallCommonSyncApi {
@Autowired
private
CommonHttpApi
commonHttpApi
;
@Autowired
private
DatabaseTableMapper
databaseTableMapper
;
public
Map
<
String
,
Object
>
synchronization
(
Map
<
String
,
String
>
config
,
String
queueId
,
String
name
,
Map
<
String
,
Object
>
where
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>(
3
);
...
...
@@ -40,6 +46,7 @@ public class MallCommonSyncApi {
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
());
this
.
databaseTableDataCreate
(
config
.
get
(
"sFormId"
),
queueId
,
dataList
,
fieldList
);
result
.
put
(
"data"
,
CommonApi
.
encapsulationData
(
config
,
dataList
,
fieldList
));
result
.
put
(
"success"
,
true
);
}
...
...
@@ -54,6 +61,13 @@ public class MallCommonSyncApi {
return
result
;
}
private
void
databaseTableDataCreate
(
String
sFormId
,
String
queueId
,
List
<
Map
<
String
,
Object
>>
dataList
,
List
<
MallFieldMappingListOutVoRecords
>
fieldList
)
{
TableStructureListOutVoRecords
records
=
databaseTableMapper
.
tableStructureOne
(
sFormId
);
if
(
StringUtil
.
isNotNull
(
records
))
{
}
}
/**
* 同步至第三方
*/
...
...
@@ -61,5 +75,12 @@ public class MallCommonSyncApi {
return
commonHttpApi
.
sendThirdParty
(
data
,
1
);
}
/**
* 删除表数据
*/
public
void
databaseTableDataDelete
(
String
dbTableName
,
String
queueId
)
{
databaseTableMapper
.
databaseTableDataDelete
(
dbTableName
,
queueId
);
}
}
src/main/java/com/system/model/InitConnectParam.java
浏览文件 @
847f9218
...
...
@@ -38,15 +38,15 @@ public class InitConnectParam {
/**
*
定时任务时长/分钟
*
接收地址
*/
p
rivate
Integer
duration
;
p
ublic
String
receiveAddress
;
/**
*
接收
地址
*
适配器
地址
*/
p
ublic
String
receive
Address
;
p
rivate
String
adapter
Address
;
/**
...
...
@@ -96,14 +96,6 @@ public class InitConnectParam {
this
.
password
=
password
;
}
public
Integer
getDuration
()
{
return
duration
;
}
public
void
setDuration
(
Integer
duration
)
{
this
.
duration
=
duration
;
}
public
String
getReceiveAddress
()
{
return
receiveAddress
;
}
...
...
@@ -112,6 +104,14 @@ public class InitConnectParam {
this
.
receiveAddress
=
receiveAddress
;
}
public
String
getAdapterAddress
()
{
return
adapterAddress
;
}
public
void
setAdapterAddress
(
String
adapterAddress
)
{
this
.
adapterAddress
=
adapterAddress
;
}
public
String
getCreateTime
()
{
return
createTime
;
}
...
...
src/main/java/com/system/scheduler/MallLoginScheduler.java
浏览文件 @
847f9218
...
...
@@ -40,7 +40,7 @@ public class MallLoginScheduler {
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
2
);
request
.
put
(
"mobile"
,
initConnectParam
.
getAccount
());
request
.
put
(
"password"
,
initConnectParam
.
getPassword
());
String
response
=
HttpUtil
.
httpPost
(
initConnectParam
.
getMallAddress
()
+
"auth/login_by_mobile"
,
JsonUtil
.
toString
(
request
)).
getBody
();
String
response
=
HttpUtil
.
httpPost
(
initConnectParam
.
getMallAddress
()
+
"
wx/
auth/login_by_mobile"
,
JsonUtil
.
toString
(
request
)).
getBody
();
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
...
...
src/main/java/com/system/serivce/impl/IMallSyncServiceImpl.java
浏览文件 @
847f9218
...
...
@@ -3,10 +3,11 @@ package com.system.serivce.impl;
import
com.system.constants.Constants
;
import
com.system.constants.MallCommonSyncConstants
;
import
com.system.constants.MallConstants
;
import
com.system.
constants.SynchronizationOperationConstants
;
import
com.system.
dao.DatabaseTableMapper
;
import
com.system.dao.SynchronizationRecordsMapper
;
import
com.system.mall.MallCommonSyncApi
;
import
com.system.serivce.IMallSyncService
;
import
com.system.transfer.configure.TableStructureListOutVoRecords
;
import
com.system.transfer.mall.SynchronizationRecordsUpdateInVo
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.ProductLogUtil
;
...
...
@@ -30,10 +31,10 @@ public class IMallSyncServiceImpl implements IMallSyncService {
private
MallCommonSyncConstants
mallCommonSyncConstants
;
@Autowired
private
SynchronizationOperationConstants
synchronizationOperationConstants
;
private
MallCommonSyncApi
mallCommonSyncApi
;
@Autowired
private
MallCommonSyncApi
mallCommonSyncApi
;
private
DatabaseTableMapper
databaseTableMapper
;
@Autowired
private
SynchronizationRecordsMapper
synchronizationRecordsMapper
;
...
...
@@ -84,11 +85,21 @@ public class IMallSyncServiceImpl implements IMallSyncService {
//记录第三方日志
productLogUtil
.
productHttpLogCreate
(
Integer
.
valueOf
(
config
.
get
(
"productId"
)),
queueId
,
id
,
config
.
get
(
"name"
),
config
.
get
(
"docType"
),
config
.
get
(
"direction"
),
JsonUtil
.
toString
(
request
),
response
);
TableStructureListOutVoRecords
records
=
databaseTableMapper
.
tableStructureOne
(
config
.
get
(
"sFormId"
));
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
if
(!
MallConstants
.
SUCCESS_CODE
.
equals
(
map
.
get
(
MallConstants
.
CODE_NAME
)))
{
if
(
StringUtil
.
isNotNull
(
records
))
{
mallCommonSyncApi
.
databaseTableDataDelete
(
records
.
getDbTableName
(),
queueId
);
}
}
if
(
MallConstants
.
OVERTIME_CODE
.
equals
(
map
.
get
(
MallConstants
.
CODE_NAME
)))
{
Thread
.
currentThread
().
interrupt
();
}
}
else
{
if
(
StringUtil
.
isNotNull
(
records
))
{
mallCommonSyncApi
.
databaseTableDataDelete
(
records
.
getDbTableName
(),
queueId
);
}
}
}
...
...
src/main/java/com/system/serivce/impl/MallCommonSyncConfigServiceImpl.java
浏览文件 @
847f9218
...
...
@@ -44,7 +44,7 @@ public class MallCommonSyncConfigServiceImpl implements IMallCommonSyncConfigSer
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
2
);
request
.
put
(
"mobile"
,
inVo
.
getAccount
());
request
.
put
(
"password"
,
inVo
.
getPassword
());
String
response
=
HttpUtil
.
httpPost
(
inVo
.
getMallAddress
()
+
"auth/login_by_mobile"
,
JsonUtil
.
toString
(
request
)).
getBody
();
String
response
=
HttpUtil
.
httpPost
(
inVo
.
getMallAddress
()
+
"
wx/
auth/login_by_mobile"
,
JsonUtil
.
toString
(
request
)).
getBody
();
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
...
...
@@ -68,7 +68,7 @@ public class MallCommonSyncConfigServiceImpl implements IMallCommonSyncConfigSer
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
2
);
request
.
put
(
"mobile"
,
inVo
.
getAccount
());
request
.
put
(
"password"
,
inVo
.
getPassword
());
String
response
=
HttpUtil
.
httpPost
(
inVo
.
getMallAddress
()
+
"auth/login_by_mobile"
,
JsonUtil
.
toString
(
request
)).
getBody
();
String
response
=
HttpUtil
.
httpPost
(
inVo
.
getMallAddress
()
+
"
wx/
auth/login_by_mobile"
,
JsonUtil
.
toString
(
request
)).
getBody
();
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
if
(
CollectionUtils
.
isEmpty
(
map
)
||
HttpStatus
.
OK
.
value
()
!=
Integer
.
parseInt
(
String
.
valueOf
(
map
.
get
(
Constants
.
CODE_NAME
))))
{
...
...
src/main/java/com/system/transfer/configure/TableStructureCreateInVoRecords.java
0 → 100644
浏览文件 @
847f9218
package
com
.
system
.
transfer
.
configure
;
import
lombok.Data
;
/**
* @author Inori
*/
@Data
public
class
TableStructureCreateInVoRecords
{
/**
* 标识
*/
private
String
key
;
/**
* 数据库表名称
*/
private
String
dbTableName
;
/**
* 数据库表字段名称
*/
private
String
dbFieldName
;
/**
* 旧数据库表字段名称
*/
private
String
oldDbFileName
;
/**
* 数据库表字段类型
*/
private
String
dbFieldType
;
/**
* 数据库表字段默认值
*/
private
String
dbFieldDefault
;
/**
* 数据库表字段注释
*/
private
String
dbFieldComment
;
}
src/main/java/com/system/transfer/configure/TableStructureListOutVoRecords.java
0 → 100644
浏览文件 @
847f9218
package
com
.
system
.
transfer
.
configure
;
import
lombok.Data
;
/**
* 表单记录
*
* @author Inori
*/
@Data
public
class
TableStructureListOutVoRecords
{
/**
* ID
*/
private
Integer
id
;
/**
* 表单标识
*/
private
String
formId
;
/**
* 数据库表名称
*/
private
String
dbTableName
;
/**
* 数据库表注释
*/
private
String
dbTableComment
;
/**
* 前端表单Json
*/
private
String
formJson
;
}
\ No newline at end of file
src/main/java/com/system/utils/HttpUtil.java
浏览文件 @
847f9218
...
...
@@ -24,12 +24,12 @@ public class HttpUtil {
/**
* 连接超时时间
*/
private
static
final
int
CONN_TIMEOUT
=
1
0000
;
private
static
final
int
CONN_TIMEOUT
=
2
0000
;
/**
* 请求超时时间
*/
private
static
final
int
READ_TIMEOUT
=
1
0000
;
private
static
final
int
READ_TIMEOUT
=
2
0000
;
/**
* 请求工具
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论