Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
H
hphy
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
向怀芳
hphy
Commits
9164cbc6
Commit
9164cbc6
authored
Jan 29, 2021
by
向怀芳
🎱
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master'
parents
fedf2d0d
bcf08111
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
13 deletions
+72
-13
RefreshJob.java
...n/java/cn/sh/stc/sict/theme/hphy/schedule/RefreshJob.java
+72
-13
No files found.
smart-health-modules/theme-schema/src/main/java/cn/sh/stc/sict/theme/hphy/schedule/RefreshJob.java
View file @
9164cbc6
...
...
@@ -11,6 +11,7 @@ import cn.sh.stc.sict.theme.hphy.wd.DeptInfo;
import
cn.sh.stc.sict.theme.hphy.wd.DoctInfo
;
import
cn.sh.stc.sict.theme.hphy.wd.HosInfo
;
import
cn.sh.stc.sict.theme.hphy.wd.WanDaHttpUtil
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
lombok.AllArgsConstructor
;
import
lombok.extern.slf4j.Slf4j
;
import
ma.glasnost.orika.MapperFactory
;
...
...
@@ -40,7 +41,10 @@ public class RefreshJob {
private
static
final
byte
TOP_DEPT
=
1
;
private
static
final
byte
TWO_DEPT
=
2
;
@Scheduled
(
cron
=
"0 44 13 * * ?"
)
/**
* 每月一日0点 更新医院信息
*/
@Scheduled
(
cron
=
"0 0 0 1 * ?"
)
public
void
updateHosp
(){
HosInfo
hosInfo
=
new
HosInfo
();
List
<
HosInfo
>
list
=
WanDaHttpUtil
.
getHospitalInfo
(
hosInfo
);
...
...
@@ -70,42 +74,96 @@ public class RefreshJob {
}
}
// @Scheduled(cron = "")
/**
* 每周一1点 同步科室信息
*/
@Scheduled
(
cron
=
"0 0 1 ? * 1"
)
public
void
updateDept
(){
List
<
HpHosInfo
>
hospitals
=
hpHosInfoService
.
list
();
if
(
CollectionUtil
.
isEmpty
(
hospitals
)){
return
;
}
// TODO 获取一级科室
MapperFactory
factory
=
new
DefaultMapperFactory
.
Builder
().
build
();
for
(
HpHosInfo
hospital
:
hospitals
)
{
saveOrUpdateTopDept
(
hospital
.
getHosOrgCode
(),
factory
);
// 获取一级科室
saveOrUpdateTopDept
(
hospital
.
getHosOrgCode
());
// 获取二级科室
saveOrUpdateTwoDept
(
hospital
.
getHosOrgCode
(),
factory
);
}
// TODO 获取二级科室
}
private
void
saveOrUpdateTopDept
(
String
hosOrgCode
,
MapperFactory
factory
){
private
void
saveOrUpdateTopDept
(
String
hosOrgCode
){
List
<
DeptInfo
>
deptInfos
=
WanDaHttpUtil
.
getDeptInfoTop
(
new
HosInfo
(
hosOrgCode
));
if
(
CollectionUtil
.
isEmpty
(
deptInfos
)){
return
;
}
List
<
HpDeptInfo
>
hpDeptInfos
=
cloneTopDept
(
deptInfos
);
for
(
HpDeptInfo
hpDeptInfo
:
hpDeptInfos
)
{
saveOrUpdateTopDept
(
hpDeptInfo
);
}
}
private
void
saveOrUpdateTopDept
(
HpDeptInfo
hpDeptInfo
){
try
{
HpDeptInfo
deptInfo
=
deptInfoService
.
getOne
(
new
LambdaQueryWrapper
<
HpDeptInfo
>()
.
eq
(
HpDeptInfo:
:
getHosOrgCode
,
hpDeptInfo
.
getHosOrgCode
())
.
eq
(
HpDeptInfo:
:
getOneDeptCode
,
hpDeptInfo
.
getOneDeptCode
())
.
eq
(
HpDeptInfo:
:
getDeptLevel
,
TOP_DEPT
)
);
if
(
deptInfo
!=
null
){
hpDeptInfo
.
setId
(
deptInfo
.
getId
());
deptInfoService
.
updateById
(
hpDeptInfo
);
}
else
{
deptInfoService
.
save
(
hpDeptInfo
);
}
}
catch
(
Exception
e
){
log
.
error
(
"一级科室保存失败:{}"
,
hpDeptInfo
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
private
void
saveOrUpdateTwoDept
(
String
hosOrgCode
,
MapperFactory
factory
)
{
List
<
DeptInfo
>
deptInfos
=
WanDaHttpUtil
.
getDeptInfoTwo
(
new
DeptInfo
(
hosOrgCode
));
if
(
CollectionUtil
.
isEmpty
(
deptInfos
)){
return
;
}
// @Scheduled(cron = "")
public
void
updateDeptTwo
(){
List
<
HpDeptInfo
>
hpDeptInfos
=
factory
.
getMapperFacade
().
mapAsList
(
deptInfos
,
HpDeptInfo
.
class
);
for
(
HpDeptInfo
hpDeptInfo
:
hpDeptInfos
)
{
hpDeptInfo
.
setDeptLevel
(
TWO_DEPT
);
saveOrUpdateTwoDept
(
hpDeptInfo
);
}
}
private
void
saveOrUpdateTwoDept
(
HpDeptInfo
hpDeptInfo
){
try
{
HpDeptInfo
deptInfo
=
deptInfoService
.
getOne
(
new
LambdaQueryWrapper
<
HpDeptInfo
>()
.
eq
(
HpDeptInfo:
:
getHosOrgCode
,
hpDeptInfo
.
getHosOrgCode
())
.
eq
(
HpDeptInfo:
:
getDeptCode
,
hpDeptInfo
.
getDeptCode
())
.
eq
(
HpDeptInfo:
:
getDeptLevel
,
TWO_DEPT
)
);
if
(
deptInfo
!=
null
){
hpDeptInfo
.
setId
(
deptInfo
.
getId
());
deptInfoService
.
updateById
(
hpDeptInfo
);
}
else
{
deptInfoService
.
save
(
hpDeptInfo
);
}
}
catch
(
Exception
e
){
log
.
error
(
"二级科室保存失败:{}"
,
hpDeptInfo
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
@Scheduled
(
cron
=
"0 42 14 * * ?"
)
/**
* 每周一 2点 更新医生信息
*/
@Scheduled
(
cron
=
"0 0 2 ? * 1"
)
public
void
updateDocInfo
(){
List
<
HpHosInfo
>
list
=
hpHosInfoService
.
list
();
...
...
@@ -143,6 +201,7 @@ public class RefreshJob {
}
}
catch
(
Exception
e
){
log
.
error
(
"医生信息保存出错:{}"
,
docInfo
);
log
.
error
(
e
.
getMessage
(),
e
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment