Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
Yygh Parent
提交
3b9923f7
Y
Yygh Parent
项目概览
别团等shy哥发育
/
Yygh Parent
9 个月 前同步成功
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Y
Yygh Parent
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
3b9923f7
编写于
1月 09, 2022
作者:
别团等shy哥发育
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
前台用户系统-预约挂号详情
上级
54ed42cd
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
205 addition
and
4 deletion
+205
-4
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/controller/api/HospApiController.java
...m/atguigu/yygu/hosp/controller/api/HospApiController.java
+31
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/DepartmentService.java
...java/com/atguigu/yygu/hosp/service/DepartmentService.java
+2
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/ScheduleService.java
...n/java/com/atguigu/yygu/hosp/service/ScheduleService.java
+12
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/impl/DepartmentServiceImpl.java
...atguigu/yygu/hosp/service/impl/DepartmentServiceImpl.java
+6
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/impl/ScheduleServiceImpl.java
...m/atguigu/yygu/hosp/service/impl/ScheduleServiceImpl.java
+154
-4
未找到文件。
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/controller/api/HospApiController.java
浏览文件 @
3b9923f7
...
@@ -6,7 +6,9 @@ import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
...
@@ -6,7 +6,9 @@ import com.atguigu.yygh.vo.hosp.HospitalQueryVo;
import
com.atguigu.yygu.common.result.Result
;
import
com.atguigu.yygu.common.result.Result
;
import
com.atguigu.yygu.hosp.service.DepartmentService
;
import
com.atguigu.yygu.hosp.service.DepartmentService
;
import
com.atguigu.yygu.hosp.service.HospitalService
;
import
com.atguigu.yygu.hosp.service.HospitalService
;
import
com.atguigu.yygu.hosp.service.ScheduleService
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiOperation
;
import
io.swagger.annotations.ApiParam
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.web.bind.annotation.GetMapping
;
import
org.springframework.web.bind.annotation.GetMapping
;
...
@@ -25,6 +27,8 @@ public class HospApiController {
...
@@ -25,6 +27,8 @@ public class HospApiController {
private
HospitalService
hospitalService
;
private
HospitalService
hospitalService
;
@Autowired
@Autowired
private
DepartmentService
departmentService
;
private
DepartmentService
departmentService
;
@Autowired
private
ScheduleService
scheduleService
;
@ApiOperation
(
value
=
"查询医院列表"
)
@ApiOperation
(
value
=
"查询医院列表"
)
@GetMapping
(
"findHospitalList/{page}/{limit}"
)
@GetMapping
(
"findHospitalList/{page}/{limit}"
)
...
@@ -56,4 +60,31 @@ public class HospApiController {
...
@@ -56,4 +60,31 @@ public class HospApiController {
return
Result
.
ok
(
map
);
return
Result
.
ok
(
map
);
}
}
@ApiOperation
(
value
=
"获取可预约排班数据"
)
@GetMapping
(
"auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}"
)
public
Result
getBookingSchedule
(
@ApiParam
(
name
=
"page"
,
value
=
"当前页码"
,
required
=
true
)
@PathVariable
Integer
page
,
@ApiParam
(
name
=
"limit"
,
value
=
"每页记录数"
,
required
=
true
)
@PathVariable
Integer
limit
,
@ApiParam
(
name
=
"hoscode"
,
value
=
"医院code"
,
required
=
true
)
@PathVariable
String
hoscode
,
@ApiParam
(
name
=
"depcode"
,
value
=
"科室code"
,
required
=
true
)
@PathVariable
String
depcode
)
{
return
Result
.
ok
(
scheduleService
.
getBookingScheduleRule
(
page
,
limit
,
hoscode
,
depcode
));
}
@ApiOperation
(
value
=
"获取排班数据"
)
@GetMapping
(
"auth/findScheduleList/{hoscode}/{depcode}/{workDate}"
)
public
Result
findScheduleList
(
@ApiParam
(
name
=
"hoscode"
,
value
=
"医院code"
,
required
=
true
)
@PathVariable
String
hoscode
,
@ApiParam
(
name
=
"depcode"
,
value
=
"科室code"
,
required
=
true
)
@PathVariable
String
depcode
,
@ApiParam
(
name
=
"workDate"
,
value
=
"排班日期"
,
required
=
true
)
@PathVariable
String
workDate
)
{
return
Result
.
ok
(
scheduleService
.
getScheduleDetail
(
hoscode
,
depcode
,
workDate
));
}
}
}
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/DepartmentService.java
浏览文件 @
3b9923f7
...
@@ -24,4 +24,6 @@ public interface DepartmentService {
...
@@ -24,4 +24,6 @@ public interface DepartmentService {
//根据医院编号和科室编号查询科室名称
//根据医院编号和科室编号查询科室名称
String
getDepName
(
String
hoscode
,
String
depcode
);
String
getDepName
(
String
hoscode
,
String
depcode
);
//根据医院编号和科室编号查询科室对象
Department
getDepartment
(
String
hoscode
,
String
depcode
);
}
}
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/ScheduleService.java
浏览文件 @
3b9923f7
...
@@ -22,4 +22,16 @@ public interface ScheduleService {
...
@@ -22,4 +22,16 @@ public interface ScheduleService {
//根据医院编号、科室编号、工作日期查询排班详细信息
//根据医院编号、科室编号、工作日期查询排班详细信息
List
<
Schedule
>
getScheduleDetail
(
String
hoscode
,
String
depcode
,
String
workDate
);
List
<
Schedule
>
getScheduleDetail
(
String
hoscode
,
String
depcode
,
String
workDate
);
//获取可预约排班数据
/**
*
* @param page 当前页
* @param limit 每页记录数
* @param hoscode 医院编号
* @param depcode 科室编号
* @return 封装之后的数据
*/
Map
<
String
,
Object
>
getBookingScheduleRule
(
Integer
page
,
Integer
limit
,
String
hoscode
,
String
depcode
);
}
}
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/impl/DepartmentServiceImpl.java
浏览文件 @
3b9923f7
...
@@ -132,4 +132,10 @@ public class DepartmentServiceImpl implements DepartmentService {
...
@@ -132,4 +132,10 @@ public class DepartmentServiceImpl implements DepartmentService {
}
}
return
null
;
return
null
;
}
}
@Override
public
Department
getDepartment
(
String
hoscode
,
String
depcode
)
{
Department
department
=
departmentRepository
.
getDepartmentByHoscodeAndDepcode
(
hoscode
,
depcode
);
return
department
;
}
}
}
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/impl/ScheduleServiceImpl.java
浏览文件 @
3b9923f7
package
com.atguigu.yygu.hosp.service.impl
;
package
com.atguigu.yygu.hosp.service.impl
;
import
com.alibaba.fastjson.JSONObject
;
import
com.alibaba.fastjson.JSONObject
;
import
com.atguigu.yygh.model.hosp.BookingRule
;
import
com.atguigu.yygh.model.hosp.Department
;
import
com.atguigu.yygh.model.hosp.Hospital
;
import
com.atguigu.yygh.model.hosp.Schedule
;
import
com.atguigu.yygh.model.hosp.Schedule
;
import
com.atguigu.yygh.vo.hosp.BookingScheduleRuleVo
;
import
com.atguigu.yygh.vo.hosp.BookingScheduleRuleVo
;
import
com.atguigu.yygh.vo.hosp.ScheduleQueryVo
;
import
com.atguigu.yygh.vo.hosp.ScheduleQueryVo
;
import
com.atguigu.yygu.common.exception.YyghException
;
import
com.atguigu.yygu.common.result.ResultCodeEnum
;
import
com.atguigu.yygu.hosp.repository.ScheduleRepository
;
import
com.atguigu.yygu.hosp.repository.ScheduleRepository
;
import
com.atguigu.yygu.hosp.service.DepartmentService
;
import
com.atguigu.yygu.hosp.service.DepartmentService
;
import
com.atguigu.yygu.hosp.service.HospitalService
;
import
com.atguigu.yygu.hosp.service.HospitalService
;
import
com.atguigu.yygu.hosp.service.ScheduleService
;
import
com.atguigu.yygu.hosp.service.ScheduleService
;
import
com.baomidou.mybatisplus.core.metadata.IPage
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTimeConstants
;
import
org.joda.time.DateTimeConstants
;
import
org.joda.time.format.DateTimeFormat
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.domain.*
;
...
@@ -18,11 +25,11 @@ import org.springframework.data.mongodb.core.aggregation.Aggregation;
...
@@ -18,11 +25,11 @@ import org.springframework.data.mongodb.core.aggregation.Aggregation;
import
org.springframework.data.mongodb.core.aggregation.AggregationResults
;
import
org.springframework.data.mongodb.core.aggregation.AggregationResults
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
org.springframework.util.CollectionUtils
;
import
sun.security.util.Length
;
import
java.util.Date
;
import
java.util.*
;
import
java.util.HashMap
;
import
java.util.stream.Collectors
;
import
java.util.List
;
import
java.util.Map
;
@Service
@Service
public
class
ScheduleServiceImpl
implements
ScheduleService
{
public
class
ScheduleServiceImpl
implements
ScheduleService
{
...
@@ -166,6 +173,148 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -166,6 +173,148 @@ public class ScheduleServiceImpl implements ScheduleService {
return
scheduleList
;
return
scheduleList
;
}
}
//获取可预约排班数据
@Override
public
Map
<
String
,
Object
>
getBookingScheduleRule
(
Integer
page
,
Integer
limit
,
String
hoscode
,
String
depcode
)
{
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
//获取预约规则
//根据医院编号获取预约规则
Hospital
hospital
=
hospitalService
.
getByHoscode
(
hoscode
);
if
(
hospital
==
null
){
throw
new
YyghException
(
ResultCodeEnum
.
DATA_ERROR
);
}
BookingRule
bookingRule
=
hospital
.
getBookingRule
();
//获取可预约日期的数据(分页)
IPage
<
Date
>
iPage
=
this
.
getListDate
(
page
,
limit
,
bookingRule
);
//当前可预约的日期
List
<
Date
>
dateList
=
iPage
.
getRecords
();
//获取可预约日期里面科室的剩余预约数
Criteria
criteria
=
Criteria
.
where
(
"hoscode"
).
is
(
hoscode
).
and
(
"depcode"
).
is
(
depcode
)
.
and
(
"workDate"
).
in
(
dateList
);
Aggregation
agg
=
Aggregation
.
newAggregation
(
Aggregation
.
match
(
criteria
),
Aggregation
.
group
(
"workDate"
).
first
(
"workDate"
).
as
(
"workDate"
)
.
count
().
as
(
"docCount"
)
.
sum
(
"availableNumber"
).
as
(
"availableNumber"
)
.
sum
(
"reservedNumber"
).
as
(
"reservedNumber"
)
);
AggregationResults
<
BookingScheduleRuleVo
>
aggregate
=
mongoTemplate
.
aggregate
(
agg
,
Schedule
.
class
,
BookingScheduleRuleVo
.
class
);
List
<
BookingScheduleRuleVo
>
scheduleVoList
=
aggregate
.
getMappedResults
();
//合并数据 将统计数据ScheduleVo根据“安排日期”合并到BookingRuleVo
Map
<
Date
,
BookingScheduleRuleVo
>
scheduleVoMap
=
new
HashMap
<>();
if
(!
CollectionUtils
.
isEmpty
(
scheduleVoList
))
{
scheduleVoMap
=
scheduleVoList
.
stream
()
.
collect
(
Collectors
.
toMap
(
BookingScheduleRuleVo:
:
getWorkDate
,
BookingScheduleRuleVo
->
BookingScheduleRuleVo
)
);
}
//获取可预约的排版规则
List
<
BookingScheduleRuleVo
>
bookingScheduleRuleVoList
=
new
ArrayList
<>();
for
(
int
i
=
0
,
len
=
dateList
.
size
();
i
<
len
;
i
++){
Date
date
=
dateList
.
get
(
i
);
//从map集合中根据key日期获取value值
BookingScheduleRuleVo
bookingScheduleRuleVo
=
scheduleVoMap
.
get
(
date
);
//如果当天没有排班医生
if
(
bookingScheduleRuleVo
==
null
){
bookingScheduleRuleVo
=
new
BookingScheduleRuleVo
();
//就诊医生人数
bookingScheduleRuleVo
.
setDocCount
(
0
);
//科室剩余预约数 -1表示无号
bookingScheduleRuleVo
.
setAvailableNumber
(-
1
);
}
bookingScheduleRuleVo
.
setWorkDate
(
date
);
bookingScheduleRuleVo
.
setWorkDateMd
(
date
);
//计算当前预约日期对应星期
String
dayOfWeek
=
this
.
getDayOfWeek
(
new
DateTime
(
date
));
bookingScheduleRuleVo
.
setDayOfWeek
(
dayOfWeek
);
//最后一页最后一条记录为即将预约 状态 0:正常 1:即将放号 -1:当天已停止挂号
if
(
i
==
len
-
1
&&
page
==
iPage
.
getPages
())
{
bookingScheduleRuleVo
.
setStatus
(
1
);
}
else
{
bookingScheduleRuleVo
.
setStatus
(
0
);
}
//当天预约如果过了停号时间, 不能预约
if
(
i
==
0
&&
page
==
1
)
{
DateTime
stopTime
=
this
.
getDateTime
(
new
Date
(),
bookingRule
.
getStopTime
());
if
(
stopTime
.
isBeforeNow
())
{
//停止预约
bookingScheduleRuleVo
.
setStatus
(-
1
);
}
}
bookingScheduleRuleVoList
.
add
(
bookingScheduleRuleVo
);
}
//可预约日期规则数据
result
.
put
(
"bookingScheduleList"
,
bookingScheduleRuleVoList
);
result
.
put
(
"total"
,
iPage
.
getTotal
());
//其他基础数据
Map
<
String
,
String
>
baseMap
=
new
HashMap
<>();
//医院名称
baseMap
.
put
(
"hosname"
,
hospitalService
.
getHospName
(
hoscode
));
//科室
Department
department
=
departmentService
.
getDepartment
(
hoscode
,
depcode
);
//大科室名称
baseMap
.
put
(
"bigname"
,
department
.
getBigname
());
//科室名称
baseMap
.
put
(
"depname"
,
department
.
getDepname
());
//月
baseMap
.
put
(
"workDateString"
,
new
DateTime
().
toString
(
"yyyy年MM月"
));
//放号时间
baseMap
.
put
(
"releaseTime"
,
bookingRule
.
getReleaseTime
());
//停号时间
baseMap
.
put
(
"stopTime"
,
bookingRule
.
getStopTime
());
result
.
put
(
"baseMap"
,
baseMap
);
return
result
;
}
//获取可预约日期的数据(分页)
private
IPage
<
Date
>
getListDate
(
Integer
page
,
Integer
limit
,
BookingRule
bookingRule
)
{
//获取当天的放号时间 年月日 小时 分钟
DateTime
releaseTime
=
this
.
getDateTime
(
new
Date
(),
bookingRule
.
getReleaseTime
());
//获取预约周期
Integer
cycle
=
bookingRule
.
getCycle
();
//如果当天放号时间已经过去了,预约周期从后一天开始计算,周期+1
if
(
releaseTime
.
isBeforeNow
())
{
cycle
+=
1
;
}
//获取可预约所有日期,最后一天显示即将放号
List
<
Date
>
dateList
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
cycle
;
i
++){
DateTime
currentDateTime
=
new
DateTime
().
plusDays
(
i
);
String
dateString
=
currentDateTime
.
toString
(
"yyyy-MM-dd"
);
dateList
.
add
(
new
DateTime
(
dateString
).
toDate
());
}
//因为预约周期不同的,每页显示日期最多7天数据,超过7天分页
List
<
Date
>
pageDateList
=
new
ArrayList
<>();
int
start
=(
page
-
1
)*
limit
;
int
end
=(
page
-
1
)*
limit
+
limit
;
//如果可以显示数据小于7,直接显示
if
(
end
>
dateList
.
size
()){
end
=
dateList
.
size
();
}
for
(
int
i
=
start
;
i
<
end
;
i
++){
pageDateList
.
add
(
dateList
.
get
(
i
));
}
//如果可以显示数据大于7,进行分页
IPage
<
Date
>
iPage
=
new
com
.
baomidou
.
mybatisplus
.
extension
.
plugins
.
pagination
.
Page
<>(
page
,
7
,
dateList
.
size
());
iPage
.
setRecords
(
pageDateList
);
return
iPage
;
}
/**
* 将Date日期(yyyy-MM-dd HH:mm)转换为DateTime
*/
private
DateTime
getDateTime
(
Date
date
,
String
timeString
)
{
String
dateTimeString
=
new
DateTime
(
date
).
toString
(
"yyyy-MM-dd"
)
+
" "
+
timeString
;
DateTime
dateTime
=
DateTimeFormat
.
forPattern
(
"yyyy-MM-dd HH:mm"
).
parseDateTime
(
dateTimeString
);
return
dateTime
;
}
//封装排班详情其他值 医院名称、科室名称、日期对应星期
//封装排班详情其他值 医院名称、科室名称、日期对应星期
private
void
packageSchedule
(
Schedule
schedule
)
{
private
void
packageSchedule
(
Schedule
schedule
)
{
//设置医院名称
//设置医院名称
...
@@ -176,6 +325,7 @@ public class ScheduleServiceImpl implements ScheduleService {
...
@@ -176,6 +325,7 @@ public class ScheduleServiceImpl implements ScheduleService {
schedule
.
getParam
().
put
(
"dayOfWeek"
,
this
.
getDayOfWeek
(
new
DateTime
(
schedule
.
getWorkDate
())));
schedule
.
getParam
().
put
(
"dayOfWeek"
,
this
.
getDayOfWeek
(
new
DateTime
(
schedule
.
getWorkDate
())));
}
}
/**
/**
* 根据日期获取周几数据
* 根据日期获取周几数据
* @param dateTime
* @param dateTime
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录