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
efda1d33
提交
efda1d33
authored
11月 29, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
5ca392e4
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
129 行增加
和
40 行删除
+129
-40
CommonHttpApi.java
src/main/java/com/system/api/CommonHttpApi.java
+35
-17
MallCommonSyncConfigController.java
...com/system/controller/MallCommonSyncConfigController.java
+11
-3
MallLoginScheduler.java
src/main/java/com/system/scheduler/MallLoginScheduler.java
+29
-11
SynchronizationServiceImpl.java
...a/com/system/serivce/impl/SynchronizationServiceImpl.java
+0
-2
InitConnectParamCheckInVo.java
.../system/transfer/configure/InitConnectParamCheckInVo.java
+6
-7
InitConnectParamRefreshInVo.java
...ystem/transfer/configure/InitConnectParamRefreshInVo.java
+48
-0
没有找到文件。
src/main/java/com/system/api/CommonHttpApi.java
浏览文件 @
efda1d33
...
@@ -40,6 +40,8 @@ public class CommonHttpApi {
...
@@ -40,6 +40,8 @@ public class CommonHttpApi {
public
String
mallAddress
;
public
String
mallAddress
;
public
Map
<
String
,
Object
>
header
;
public
boolean
flag
=
false
;
public
boolean
flag
=
false
;
@Autowired
@Autowired
...
@@ -61,6 +63,10 @@ public class CommonHttpApi {
...
@@ -61,6 +63,10 @@ public class CommonHttpApi {
return
initConnectParam
;
return
initConnectParam
;
}
}
public
void
setHeader
(
Map
<
String
,
Object
>
header
)
{
this
.
header
=
header
;
}
public
void
setFlag
(
boolean
flag
)
{
public
void
setFlag
(
boolean
flag
)
{
this
.
flag
=
flag
;
this
.
flag
=
flag
;
}
}
...
@@ -97,7 +103,11 @@ public class CommonHttpApi {
...
@@ -97,7 +103,11 @@ public class CommonHttpApi {
public
String
commonHttpSync
(
List
<
Integer
>
idList
)
{
public
String
commonHttpSync
(
List
<
Integer
>
idList
)
{
try
{
try
{
return
HttpUtil
.
httpPost
(
mallAddress
+
"api/dataSyn/getSyn"
,
JsonUtil
.
toString
(
idList
)).
getBody
();
if
(
flag
)
{
return
HttpUtil
.
httpPost
(
mallAddress
+
"api/dataSyn/getSyn"
,
header
,
JsonUtil
.
toString
(
idList
)).
getBody
();
}
else
{
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
...
@@ -106,7 +116,11 @@ public class CommonHttpApi {
...
@@ -106,7 +116,11 @@ public class CommonHttpApi {
public
String
commonHttpPostByUpdate
(
String
data
)
{
public
String
commonHttpPostByUpdate
(
String
data
)
{
try
{
try
{
return
HttpUtil
.
httpPost
(
mallAddress
+
"api/dataSyn/success"
,
data
).
getBody
();
if
(
flag
)
{
return
HttpUtil
.
httpPost
(
mallAddress
+
"api/dataSyn/success"
,
header
,
data
).
getBody
();
}
else
{
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
...
@@ -114,22 +128,26 @@ public class CommonHttpApi {
...
@@ -114,22 +128,26 @@ public class CommonHttpApi {
}
}
public
String
commonHttpSyncData
(
Map
<
String
,
String
>
config
,
String
queueId
,
String
name
,
List
<
String
>
keyList
,
Map
<
String
,
Object
>
where
)
{
public
String
commonHttpSyncData
(
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"
,
config
.
get
(
"sFormId"
));
request
.
put
(
"fields"
,
String
.
join
(
","
,
keyList
));
request
.
putAll
(
where
);
try
{
try
{
long
start
=
System
.
currentTimeMillis
();
if
(
flag
)
{
String
response
=
HttpUtil
.
httpPost
(
mallAddress
+
"api/dataSyn/synData"
,
JsonUtil
.
toString
(
request
)).
getBody
();
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
3
);
long
costTime
=
System
.
currentTimeMillis
()
-
start
;
request
.
put
(
"form"
,
config
.
get
(
"sFormId"
));
request
.
put
(
"fields"
,
String
.
join
(
","
,
keyList
));
Map
<
String
,
Object
>
map
=
ThreadLocalConfig
.
get
();
request
.
putAll
(
where
);
map
.
put
(
"costTime"
,
costTime
);
ThreadLocalConfig
.
set
(
map
);
long
start
=
System
.
currentTimeMillis
();
String
response
=
HttpUtil
.
httpPost
(
mallAddress
+
"api/dataSyn/synData"
,
header
,
JsonUtil
.
toString
(
request
)).
getBody
();
productLogUtil
.
productSyncLogCreate
(
Integer
.
valueOf
(
config
.
get
(
"productId"
)),
queueId
,
name
,
config
.
get
(
"docType"
),
config
.
get
(
"direction"
),
JsonUtil
.
toString
(
request
),
response
);
long
costTime
=
System
.
currentTimeMillis
()
-
start
;
return
response
;
Map
<
String
,
Object
>
map
=
ThreadLocalConfig
.
get
();
map
.
put
(
"costTime"
,
costTime
);
ThreadLocalConfig
.
set
(
map
);
productLogUtil
.
productSyncLogCreate
(
Integer
.
valueOf
(
config
.
get
(
"productId"
)),
queueId
,
name
,
config
.
get
(
"docType"
),
config
.
get
(
"direction"
),
JsonUtil
.
toString
(
request
),
response
);
return
response
;
}
else
{
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
throw
new
MallCommonException
(
LOGIN_MESSAGE
);
...
...
src/main/java/com/system/controller/MallCommonSyncConfigController.java
浏览文件 @
efda1d33
package
com
.
system
.
controller
;
package
com
.
system
.
controller
;
import
com.system.transfer.configure.InitConnectParamCreateInVo
;
import
com.system.transfer.configure.InitConnectParamCheckInVo
;
import
com.system.transfer.configure.InitConnectParamRefreshInVo
;
import
com.system.transfer.response.RestResponse
;
import
com.system.transfer.response.RestResponse
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestBody
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
...
@@ -16,8 +18,14 @@ import org.springframework.web.bind.annotation.RestController;
...
@@ -16,8 +18,14 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping
(
"/api"
)
@RequestMapping
(
"/api"
)
public
class
MallCommonSyncConfigController
{
public
class
MallCommonSyncConfigController
{
@PostMapping
(
"/init/connect/param/create"
)
@ApiOperation
(
"商城配置刷新"
)
public
RestResponse
initConnectParamCreate
(
@RequestBody
InitConnectParamCreateInVo
inVo
)
{
@PostMapping
(
"/init/connect/param/refresh"
)
public
RestResponse
initConnectParamRefresh
(
@RequestBody
InitConnectParamRefreshInVo
inVo
)
{
return
RestResponse
.
success
();
}
@PostMapping
(
"/init/connect/param/check"
)
public
RestResponse
initConnectParamCheck
(
@RequestBody
InitConnectParamCheckInVo
inVo
)
{
return
RestResponse
.
success
();
return
RestResponse
.
success
();
}
}
...
...
src/main/java/com/system/scheduler/MallLoginScheduler.java
浏览文件 @
efda1d33
package
com
.
system
.
scheduler
;
package
com
.
system
.
scheduler
;
import
com.system.api.CommonHttpApi
;
import
com.system.api.CommonHttpApi
;
import
com.system.constants.Constants
;
import
com.system.model.InitConnectParam
;
import
com.system.model.InitConnectParam
;
import
com.system.utils.HttpUtil
;
import
com.system.utils.JsonUtil
;
import
com.system.utils.StringUtil
;
import
com.system.utils.StringUtil
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.HttpStatus
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.util.CollectionUtils
;
import
java.util.HashMap
;
import
java.util.Map
;
/**
/**
* @author Inori
* @author Inori
...
@@ -28,24 +36,34 @@ public class MallLoginScheduler {
...
@@ -28,24 +36,34 @@ public class MallLoginScheduler {
InitConnectParam
initConnectParam
=
commonHttpApi
.
getInitConnectParam
();
InitConnectParam
initConnectParam
=
commonHttpApi
.
getInitConnectParam
();
if
(
StringUtil
.
isNotNull
(
initConnectParam
))
{
if
(
StringUtil
.
isNotNull
(
initConnectParam
))
{
boolean
flag
;
try
{
try
{
//TODO 商城登陆
//TODO 商城登陆
flag
=
true
;
Map
<
String
,
Object
>
request
=
new
HashMap
<>(
2
);
}
catch
(
Exception
e
)
{
request
.
put
(
"mobile"
,
initConnectParam
.
getAccount
());
flag
=
false
;
request
.
put
(
"password"
,
initConnectParam
.
getPassword
());
log
.
info
(
"商城登录失败!"
);
String
response
=
HttpUtil
.
httpPost
(
initConnectParam
.
getMallAddress
()
+
"auth/login_by_mobile"
,
JsonUtil
.
toString
(
request
)).
getBody
();
}
if
(
flag
)
{
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
response
,
String
.
class
,
Object
.
class
);
log
.
info
(
"商城登录成功!"
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
}
else
{
if
(
map
.
containsKey
(
Constants
.
CODE_NAME
)
&&
HttpStatus
.
OK
.
value
()
==
Integer
.
parseInt
(
String
.
valueOf
(
map
.
get
(
Constants
.
CODE_NAME
))))
{
Map
<
String
,
Object
>
data
=
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
map
.
get
(
Constants
.
DATE_NAME
)),
String
.
class
,
Object
.
class
);
Map
<
String
,
Object
>
header
=
new
HashMap
<>(
1
);
header
.
put
(
"Authorization"
,
data
.
get
(
"token"
));
commonHttpApi
.
setHeader
(
header
);
commonHttpApi
.
setFlag
(
true
);
log
.
info
(
"商城登录成功!"
);
}
}
else
{
commonHttpApi
.
setFlag
(
false
);
log
.
info
(
"商城登录失败!"
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
info
(
"商城登录失败!"
);
log
.
info
(
"商城登录失败!"
);
}
}
commonHttpApi
.
setFlag
(
flag
);
}
else
{
}
else
{
commonHttpApi
.
setFlag
(
false
);
commonHttpApi
.
setFlag
(
false
);
log
.
info
(
"商城登录失败!"
);
}
}
}
}
...
...
src/main/java/com/system/serivce/impl/SynchronizationServiceImpl.java
浏览文件 @
efda1d33
...
@@ -6,7 +6,6 @@ import com.system.mall.MallCommonApi;
...
@@ -6,7 +6,6 @@ import com.system.mall.MallCommonApi;
import
com.system.serivce.ISynchronizationService
;
import
com.system.serivce.ISynchronizationService
;
import
com.system.transfer.mall.MallTriggerSynchronizationInVo
;
import
com.system.transfer.mall.MallTriggerSynchronizationInVo
;
import
com.system.transfer.mall.SynchronizationRecordsListOutVoRecords
;
import
com.system.transfer.mall.SynchronizationRecordsListOutVoRecords
;
import
com.system.utils.JsonUtil
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.annotation.Transactional
;
...
@@ -61,7 +60,6 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
...
@@ -61,7 +60,6 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
synchronization
(
List
<
Integer
>
request
)
{
public
void
synchronization
(
List
<
Integer
>
request
)
{
System
.
out
.
println
(
"----->"
+
JsonUtil
.
toString
(
request
));
List
<
Map
<
String
,
Object
>>
tempList
=
mallCommonApi
.
getSynchronizationRecords
(
request
);
List
<
Map
<
String
,
Object
>>
tempList
=
mallCommonApi
.
getSynchronizationRecords
(
request
);
if
(!
CollectionUtils
.
isEmpty
(
tempList
))
{
if
(!
CollectionUtils
.
isEmpty
(
tempList
))
{
...
...
src/main/java/com/system/transfer/configure/InitConnectParamC
reate
InVo.java
→
src/main/java/com/system/transfer/configure/InitConnectParamC
heck
InVo.java
浏览文件 @
efda1d33
...
@@ -2,34 +2,33 @@ package com.system.transfer.configure;
...
@@ -2,34 +2,33 @@ package com.system.transfer.configure;
import
lombok.Data
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
/**
/**
* @author Inori
* @author Inori
*/
*/
@Data
@Data
public
class
InitConnectParamC
reate
InVo
{
public
class
InitConnectParamC
heck
InVo
{
/**
/**
* 商城地址
* 商城地址
*/
*/
@NotBlank
(
message
=
"参数mallAddress缺失"
)
private
String
mallAddress
;
private
String
mallAddress
;
/**
/**
* 用户名
* 用户名
*/
*/
@NotBlank
(
message
=
"参数account缺失"
)
private
String
account
;
private
String
account
;
/**
/**
* 密码
* 密码
*/
*/
@NotBlank
(
message
=
"参数password缺失"
)
private
String
password
;
private
String
password
;
/**
* 任务时长/分钟
*/
private
Integer
duration
;
}
}
src/main/java/com/system/transfer/configure/InitConnectParamRefreshInVo.java
0 → 100644
浏览文件 @
efda1d33
package
com
.
system
.
transfer
.
configure
;
import
lombok.Data
;
import
javax.validation.constraints.NotBlank
;
import
javax.validation.constraints.NotNull
;
/**
* @author Inori
*/
@Data
public
class
InitConnectParamRefreshInVo
{
/**
* 商城地址
*/
@NotBlank
(
message
=
"参数mallAddress缺失"
)
private
String
mallAddress
;
/**
* 用户名
*/
@NotBlank
(
message
=
"参数account缺失"
)
private
String
account
;
/**
* 密码
*/
@NotBlank
(
message
=
"参数password缺失"
)
private
String
password
;
/**
* 任务时长/分钟
*/
@NotNull
(
message
=
"参数duration缺失"
)
private
Integer
duration
;
/**
* 接收地址
*/
private
String
receiveAddress
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论