Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
N
nzwz
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
inroi
nzwz
Commits
7fca0686
提交
7fca0686
authored
6月 24, 2022
作者:
inroi
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
微调
上级
dcca2149
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
119 行增加
和
26 行删除
+119
-26
Constants.java
...em/src/main/java/com/nzwz/common/constants/Constants.java
+7
-0
SynchronizationController.java
...n/java/com/nzwz/controller/SynchronizationController.java
+2
-2
SynchronizationServiceImpl.java
...ava/com/nzwz/serivce/impl/SynchronizationServiceImpl.java
+61
-24
KingDeeUtil.java
starbos-system/src/main/java/com/nzwz/utils/KingDeeUtil.java
+49
-0
没有找到文件。
starbos-system/src/main/java/com/nzwz/common/constants/Constants.java
浏览文件 @
7fca0686
...
...
@@ -13,4 +13,10 @@ public interface Constants {
String
ROOT_MENU_CODE
=
"-1"
;
String
SYN_SUCCESS_CODE
=
"1"
;
String
SYN_ERROR_CODE
=
"0"
;
}
\ No newline at end of file
starbos-system/src/main/java/com/nzwz/controller/SynchronizationController.java
浏览文件 @
7fca0686
...
...
@@ -35,14 +35,14 @@ public class SynchronizationController {
}
@ApiOperation
(
"查询金蝶参数"
)
@GetMapping
(
"init/connect/parm"
)
@GetMapping
(
"
/
init/connect/parm"
)
public
RestResponse
initConnectParm
()
{
InitConnectParmOutVo
outVo
=
synchronizationService
.
initConnectParm
();
return
RestResponse
.
success
(
outVo
);
}
@ApiOperation
(
"保存金蝶参数"
)
@PostMapping
(
"init/connect/parm/create"
)
@PostMapping
(
"
/
init/connect/parm/create"
)
public
RestResponse
initConnectParmCreate
(
@RequestBody
@Validated
InitConnectParmCreateInVo
inVo
)
{
return
synchronizationService
.
initConnectParmCreate
(
inVo
);
}
...
...
starbos-system/src/main/java/com/nzwz/serivce/impl/SynchronizationServiceImpl.java
浏览文件 @
7fca0686
package
com
.
nzwz
.
serivce
.
impl
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.nzwz.common.constants.Constants
;
import
com.nzwz.common.response.RestResponse
;
import
com.nzwz.quartz.model.QuartzJob
;
import
com.nzwz.quartz.transfer.QuartzJobPauseInVo
;
...
...
@@ -7,6 +9,7 @@ import com.nzwz.quartz.transfer.QuartzJobResumeInVo;
import
com.nzwz.transfer.synchronization.InitConnectParmCreateInVo
;
import
com.nzwz.transfer.synchronization.InitConnectParmOutVo
;
import
com.nzwz.utils.JsonUtil
;
import
com.nzwz.utils.KingDeeUtil
;
import
com.nzwz.utils.StringUtil
;
import
com.nzwz.api.KingDeeApi
;
import
com.nzwz.api.KingDeeK3CloudApi
;
...
...
@@ -108,7 +111,7 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
initConnectParmMapper
.
updateById
(
initConnectParm
);
KingDeeK3CloudApi
kingDeeK3CloudApi
=
new
KingDeeK3CloudApi
(
inVo
.
getK3CloudUrl
());
Boolean
flag
=
null
;
Boolean
flag
;
try
{
flag
=
kingDeeK3CloudApi
.
login
(
inVo
.
getDbid
(),
inVo
.
getUid
(),
inVo
.
getPwd
(),
inVo
.
getLang
());
}
catch
(
Exception
e
)
{
...
...
@@ -128,20 +131,51 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
@Override
public
void
synchronization
()
{
List
<
TableRelation
>
tableRelationList
=
tableRelationMapper
.
selectList
(
n
ull
);
List
<
TableRelation
>
tableRelationList
=
tableRelationMapper
.
selectList
(
n
ew
QueryWrapper
<>()
);
List
<
TableRelation
>
temp01List
=
tableRelationList
.
stream
().
filter
(
m
->
StringUtil
.
isNotBlank
(
m
.
getTableDate
())).
collect
(
Collectors
.
toList
());
for
(
TableRelation
tableRelation
:
temp01List
)
{
this
.
reload
(
tableRelation
);
List
<
TableRelation
>
tempList
=
tableRelationList
.
stream
().
filter
(
m
->
StringUtil
.
isNotBlank
(
m
.
getTableDate
())).
collect
(
Collectors
.
toList
());
for
(
TableRelation
tableRelation
:
tempList
)
{
Map
<
String
,
Object
>
data
=
this
.
assemblyMap
(
tableRelation
);
Log
log
=
new
Log
(
tableRelation
.
getTableName
(),
tableRelation
.
getTableHeader
(),
JsonUtil
.
toString
(
Collections
.
singletonList
(
data
)));
logMapper
.
insert
(
log
);
String
result
=
this
.
reload
(
data
,
log
);
List
<
TableRelation
>
subTableRelationList
=
new
ArrayList
<>();
this
.
getTableRelationTree
(
subTableRelationList
,
tableRelation
.
getTableHeader
(),
tableRelationList
);
if
(!
CollectionUtils
.
isEmpty
(
subTableRelationList
))
{
for
(
TableRelation
subTableRelation
:
subTableRelationList
)
{
Map
<
String
,
Object
>
dataMap
=
this
.
assemblyMap
(
subTableRelation
);
dataMap
.
put
(
"DATE_FORM"
,
data
.
get
(
"DATE_FORM"
));
dataMap
.
put
(
"DATE_TO"
,
data
.
get
(
"DATE_TO"
));
Log
tempLog
=
new
Log
(
subTableRelation
.
getTableName
(),
subTableRelation
.
getTableHeader
(),
JsonUtil
.
toString
(
Collections
.
singletonList
(
dataMap
)));
logMapper
.
insert
(
tempLog
);
Map
<
String
,
Object
>
tempMap
=
JsonUtil
.
toMap
(
result
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
tempMap
))
{
String
flagName
=
"DNResult"
;
if
(
tempMap
.
containsKey
(
flagName
))
{
if
(
Constants
.
ROOT_MENU_CODE
.
equals
(
tempMap
.
get
(
flagName
)))
{
logMapper
.
updateById
(
new
Log
(
tempLog
.
getId
(),
0
,
"未查询到数据"
,
0
));
continue
;
}
}
}
this
.
reload
(
dataMap
,
tempLog
);
}
}
}
}
List
<
TableRelation
>
temp02List
=
tableRelationList
.
stream
().
filter
(
m
->
!
"-1"
.
equals
(
m
.
getSubTableHeader
())
&&
StringUtil
.
isBlank
(
m
.
getTableDate
())).
collect
(
Collectors
.
toList
());
for
(
TableRelation
tableRelation
:
temp02List
)
{
this
.
reload
(
tableRelation
);
private
void
getTableRelationTree
(
List
<
TableRelation
>
result
,
String
tableHeader
,
List
<
TableRelation
>
tableRelationList
)
{
List
<
TableRelation
>
tempList
=
tableRelationList
.
stream
().
filter
(
m
->
tableHeader
.
equals
(
m
.
getSubTableHeader
())).
collect
(
Collectors
.
toList
());
for
(
TableRelation
tableRelation
:
tempList
)
{
result
.
add
(
tableRelation
);
this
.
getTableRelationTree
(
result
,
tableRelation
.
getTableHeader
(),
tableRelationList
);
}
}
private
void
reload
(
TableRelation
tableRelation
)
{
private
Map
<
String
,
Object
>
assemblyMap
(
TableRelation
tableRelation
)
{
Map
<
String
,
Object
>
data
=
new
HashMap
<>(
6
);
data
.
put
(
"TABLE_HEADER"
,
tableRelation
.
getTableHeader
());
data
.
put
(
"TABLE_DATE"
,
tableRelation
.
getTableDate
());
...
...
@@ -154,19 +188,12 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
String
dateForm
=
logMapper
.
slectOrderCreateTimeByContent
(
tableRelation
.
getTableHeader
());
if
(
StringUtil
.
isNotBlank
(
dateForm
))
{
data
.
put
(
"DATE_FORM"
,
dateForm
);
data
.
put
(
"DATE_TO"
,
DateFormatUtils
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
}
else
{
}
else
{
data
.
put
(
"DATE_FORM"
,
"2020-01-01 00:00:00"
);
data
.
put
(
"DATE_TO"
,
DateFormatUtils
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
}
data
.
put
(
"DATE_TO"
,
DateFormatUtils
.
format
(
new
Date
(),
"yyyy-MM-dd HH:mm:ss"
));
}
//记录日志
Log
log
=
new
Log
(
tableRelation
.
getTableName
(),
tableRelation
.
getTableHeader
(),
JsonUtil
.
toString
(
Collections
.
singletonList
(
data
)));
logMapper
.
insert
(
log
);
//发送请求并修改日志
loadResult
(
data
,
log
);
return
data
;
}
@Override
...
...
@@ -175,33 +202,43 @@ public class SynchronizationServiceImpl implements ISynchronizationService {
for
(
Log
log
:
logList
)
{
Map
<
String
,
Object
>
data
=
JsonUtil
.
toMap
(
log
.
getData
(),
String
.
class
,
Object
.
class
);
loadResult
(
data
,
log
);
this
.
reload
(
data
,
log
);
}
}
private
void
loadResult
(
Map
<
String
,
Object
>
data
,
Log
log
)
{
private
String
reload
(
Map
<
String
,
Object
>
data
,
Log
log
)
{
System
.
out
.
println
(
"金蝶请求参数: "
+
data
);
String
result
=
this
.
send
(
Collections
.
singletonList
(
data
),
3
);
System
.
out
.
println
(
"金蝶返回值: "
+
result
);
String
flagName
=
"DNResult"
;
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
result
,
String
.
class
,
Object
.
class
);
if
(!
CollectionUtils
.
isEmpty
(
map
))
{
Map
<
String
,
Object
>
tempMap
=
ThreadLocalConfig
.
get
();
int
costime
=
StringUtil
.
isNotNull
(
tempMap
.
get
(
"costime"
))
?
Integer
.
parseInt
(
tempMap
.
get
(
"costime"
).
toString
())
:
0
;
if
(
map
.
containsKey
(
"DNResult"
))
{
if
(
"1"
.
equals
(
map
.
get
(
"DNResult"
)))
{
if
(
KingDeeUtil
.
isError
(
result
))
{
logMapper
.
updateById
(
new
Log
(
log
.
getId
(),
0
,
result
,
costime
));
}
else
{
if
(
map
.
containsKey
(
flagName
))
{
if
(
Constants
.
SYN_SUCCESS_CODE
.
equals
(
map
.
get
(
flagName
)))
{
logMapper
.
updateById
(
new
Log
(
log
.
getId
(),
1
,
result
,
costime
));
}
else
if
(
Constants
.
ROOT_MENU_CODE
.
equals
(
map
.
get
(
flagName
)))
{
logMapper
.
updateById
(
new
Log
(
log
.
getId
(),
0
,
"未查询到数据"
,
0
));
}
else
{
logMapper
.
updateById
(
new
Log
(
log
.
getId
(),
0
,
result
,
costime
));
}
}
else
{
logMapper
.
updateById
(
new
Log
(
log
.
getId
(),
0
,
result
,
costime
));
}
}
}
return
result
;
}
private
String
send
(
List
<
Map
<
String
,
Object
>>
data
,
Integer
index
)
{
String
result
=
""
;
String
result
;
try
{
result
=
kingDeeApi
.
synchronization
(
data
);
}
catch
(
Exception
e
)
{
...
...
starbos-system/src/main/java/com/nzwz/utils/KingDeeUtil.java
0 → 100644
浏览文件 @
7fca0686
package
com
.
nzwz
.
utils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.springframework.util.CollectionUtils
;
import
java.util.List
;
import
java.util.Map
;
/**
* @author Inori
*/
public
class
KingDeeUtil
{
public
static
boolean
isError
(
String
json
)
{
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
json
,
String
.
class
,
Object
.
class
);
Map
<
String
,
Object
>
tempMap
=
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
map
.
get
(
"Result"
)),
String
.
class
,
Object
.
class
);
Map
<
String
,
Object
>
responseMap
=
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
tempMap
.
get
(
"ResponseStatus"
)),
String
.
class
,
Object
.
class
);
List
<
Object
>
errorList
=
JsonUtil
.
toList
(
JsonUtil
.
toString
(
responseMap
.
get
(
"Errors"
)),
Object
.
class
);
return
!
CollectionUtils
.
isEmpty
(
errorList
);
}
public
static
String
getMessage
(
Object
object
)
{
Map
<
String
,
Object
>
map
=
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
object
),
String
.
class
,
Object
.
class
);
String
result
=
JsonUtil
.
toString
(
map
.
get
(
"Result"
));
Map
<
String
,
Object
>
toMap
=
JsonUtil
.
toMap
(
result
,
String
.
class
,
Object
.
class
);
String
responseStatus
=
JsonUtil
.
toString
(
toMap
.
get
(
"ResponseStatus"
));
Map
<
String
,
Object
>
objectMap
=
JsonUtil
.
toMap
(
responseStatus
,
String
.
class
,
Object
.
class
);
List
<
Object
>
errorList
=
JsonUtil
.
toList
(
JsonUtil
.
toString
(
objectMap
.
get
(
"Errors"
)),
Object
.
class
);
StringBuilder
message
=
new
StringBuilder
();
for
(
Object
obj
:
errorList
)
{
Map
<
String
,
Object
>
messageMap
=
JsonUtil
.
toMap
(
JsonUtil
.
toString
(
obj
),
String
.
class
,
Object
.
class
);
if
(
StringUtils
.
isBlank
(
message
))
{
message
.
append
(
messageMap
.
get
(
"Message"
).
toString
());
}
else
{
message
.
append
(
","
).
append
(
messageMap
.
get
(
"Message"
).
toString
());
}
}
return
message
.
toString
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论