Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
别团等shy哥发育
Yygh Parent
提交
11619fea
Y
Yygh Parent
项目概览
别团等shy哥发育
/
Yygh Parent
8 个月 前同步成功
通知
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 搜索 >>
提交
11619fea
编写于
1月 04, 2022
作者:
别团等shy哥发育
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
根据医院编号和科室编号查询排版规则
上级
c79bb95c
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
155 addition
and
0 deletion
+155
-0
common/pom.xml
common/pom.xml
+5
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/controller/ScheduleController.java
.../com/atguigu/yygu/hosp/controller/ScheduleController.java
+29
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/HospitalService.java
...n/java/com/atguigu/yygu/hosp/service/HospitalService.java
+3
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/ScheduleService.java
...n/java/com/atguigu/yygu/hosp/service/ScheduleService.java
+3
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/impl/HospitalServiceImpl.java
...m/atguigu/yygu/hosp/service/impl/HospitalServiceImpl.java
+10
-0
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/impl/ScheduleServiceImpl.java
...m/atguigu/yygu/hosp/service/impl/ScheduleServiceImpl.java
+105
-0
未找到文件。
common/pom.xml
浏览文件 @
11619fea
...
...
@@ -50,6 +50,11 @@
<groupId>
com.alibaba
</groupId>
<artifactId>
fastjson
</artifactId>
</dependency>
<!--日期时间工具-->
<dependency>
<groupId>
joda-time
</groupId>
<artifactId>
joda-time
</artifactId>
</dependency>
</dependencies>
...
...
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/controller/ScheduleController.java
0 → 100644
浏览文件 @
11619fea
package
com.atguigu.yygu.hosp.controller
;
import
com.atguigu.yygu.common.result.Result
;
import
com.atguigu.yygu.hosp.service.ScheduleService
;
import
io.swagger.annotations.ApiOperation
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.Map
;
@RestController
@RequestMapping
(
"/admin/hosp/Schedule"
)
@CrossOrigin
public
class
ScheduleController
{
@Autowired
private
ScheduleService
scheduleService
;
//根据医院编号和科室编号查询排版规则
@ApiOperation
(
value
=
"根据医院编号和科室编号查询排版规则"
)
@GetMapping
(
"getScheduleRule/{page}/{limit}/{hoscode}/{depcode}"
)
public
Result
getScheduleRule
(
@PathVariable
long
page
,
@PathVariable
long
limit
,
@PathVariable
String
hoscode
,
@PathVariable
String
depcode
){
Map
<
String
,
Object
>
map
=
scheduleService
.
getRuleSchedule
(
page
,
limit
,
hoscode
,
depcode
);
return
Result
.
ok
(
map
);
}
}
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/HospitalService.java
浏览文件 @
11619fea
...
...
@@ -21,4 +21,7 @@ public interface HospitalService {
//医院详情信息
Map
<
String
,
Object
>
getHospById
(
String
id
);
//根据医院编号获取医院名称
String
getHospName
(
String
hoscode
);
}
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/ScheduleService.java
浏览文件 @
11619fea
...
...
@@ -15,4 +15,7 @@ public interface ScheduleService {
//删除排班接口
void
remove
(
String
hoscode
,
String
hosScheduleId
);
//根据医院编号和科室编号查询排版规则
Map
<
String
,
Object
>
getRuleSchedule
(
long
page
,
long
limit
,
String
hoscode
,
String
depcode
);
}
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/impl/HospitalServiceImpl.java
浏览文件 @
11619fea
...
...
@@ -106,6 +106,16 @@ public class HospitalServiceImpl implements HospitalService {
return
result
;
}
//根据医院编号获取医院名称
@Override
public
String
getHospName
(
String
hoscode
)
{
Hospital
hospital
=
hospitalRepository
.
getHospitalByHoscode
(
hoscode
);
if
(
hospital
!=
null
){
return
hospital
.
getHosname
();
}
return
null
;
}
//获取查询list集合,遍历进行医院等级封装
private
Hospital
setHospitalHosType
(
Hospital
hospital
)
{
//根据dictCode和value获取医院等级名称
...
...
service/service_hosp/src/main/java/com/atguigu/yygu/hosp/service/impl/ScheduleServiceImpl.java
浏览文件 @
11619fea
...
...
@@ -2,15 +2,25 @@ package com.atguigu.yygu.hosp.service.impl;
import
com.alibaba.fastjson.JSONObject
;
import
com.atguigu.yygh.model.hosp.Schedule
;
import
com.atguigu.yygh.vo.hosp.BookingScheduleRuleVo
;
import
com.atguigu.yygh.vo.hosp.ScheduleQueryVo
;
import
com.atguigu.yygu.hosp.repository.ScheduleRepository
;
import
com.atguigu.yygu.hosp.service.HospitalService
;
import
com.atguigu.yygu.hosp.service.ScheduleService
;
import
org.joda.time.DateTime
;
import
org.joda.time.DateTimeConstants
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.*
;
import
org.springframework.data.mongodb.core.MongoTemplate
;
import
org.springframework.data.mongodb.core.aggregation.Aggregation
;
import
org.springframework.data.mongodb.core.aggregation.AggregationResults
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.stereotype.Service
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
@Service
...
...
@@ -19,6 +29,12 @@ public class ScheduleServiceImpl implements ScheduleService {
@Autowired
private
ScheduleRepository
scheduleRepository
;
@Autowired
private
MongoTemplate
mongoTemplate
;
@Autowired
private
HospitalService
hospitalService
;
//上传排班接口
@Override
public
void
save
(
Map
<
String
,
Object
>
paramMap
)
{
...
...
@@ -77,4 +93,93 @@ public class ScheduleServiceImpl implements ScheduleService {
}
//根据医院编号和科室编号查询排版规则
@Override
public
Map
<
String
,
Object
>
getRuleSchedule
(
long
page
,
long
limit
,
String
hoscode
,
String
depcode
)
{
//1、根据医院编号和科室编号查询
Criteria
criteria
=
Criteria
.
where
(
"hoscode"
).
is
(
hoscode
).
and
(
"depcode"
).
is
(
depcode
);
//2、根据工作日期workDate进行分组
Aggregation
agg
=
Aggregation
.
newAggregation
(
Aggregation
.
match
(
criteria
),
//匹配条件
Aggregation
.
group
(
"workDate"
)
//分组字段
.
first
(
"workDate"
).
as
(
"workDate"
)
//3、统计号源数量
.
count
().
as
(
"docCount"
)
.
sum
(
"reservedNumber"
).
as
(
"reservedNumber"
)
.
sum
(
"availableNumber"
).
as
(
"availableNumber"
),
//排序
Aggregation
.
sort
(
Sort
.
Direction
.
DESC
,
"workDate"
),
//4、实现分页
Aggregation
.
skip
((
page
-
1
)*
limit
),
Aggregation
.
limit
(
limit
)
);
//调用方法,最终执行
AggregationResults
<
BookingScheduleRuleVo
>
aggResults
=
mongoTemplate
.
aggregate
(
agg
,
Schedule
.
class
,
BookingScheduleRuleVo
.
class
);
List
<
BookingScheduleRuleVo
>
bookingScheduleRuleVoList
=
aggResults
.
getMappedResults
();
//分组查询的总记录数
Aggregation
totalAgg
=
Aggregation
.
newAggregation
(
Aggregation
.
match
(
criteria
),
Aggregation
.
group
(
"workDate"
)
);
AggregationResults
<
BookingScheduleRuleVo
>
totalAggResults
=
mongoTemplate
.
aggregate
(
totalAgg
,
Schedule
.
class
,
BookingScheduleRuleVo
.
class
);
int
total
=
totalAggResults
.
getMappedResults
().
size
();
//把日期对应星期获取出来
bookingScheduleRuleVoList
.
forEach
(
bookingScheduleRuleVo
->
{
Date
workDate
=
bookingScheduleRuleVo
.
getWorkDate
();
String
dayOfWeek
=
this
.
getDayOfWeek
(
new
DateTime
(
workDate
));
bookingScheduleRuleVo
.
setDayOfWeek
(
dayOfWeek
);
});
//设置最终数据,进行返回
Map
<
String
,
Object
>
result
=
new
HashMap
<>();
result
.
put
(
"bookingScheduleRuleList"
,
bookingScheduleRuleVoList
);
result
.
put
(
"total"
,
total
);
//获取医院名称
String
hosName
=
hospitalService
.
getHospName
(
hoscode
);
//其他基础数据
Map
<
String
,
String
>
baseMap
=
new
HashMap
<>();
baseMap
.
put
(
"hosName"
,
hosName
);
result
.
put
(
"baseMap"
,
baseMap
);
return
result
;
}
/**
* 根据日期获取周几数据
* @param dateTime
* @return
*/
private
String
getDayOfWeek
(
DateTime
dateTime
)
{
String
dayOfWeek
=
""
;
switch
(
dateTime
.
getDayOfWeek
())
{
case
DateTimeConstants
.
SUNDAY
:
dayOfWeek
=
"周日"
;
break
;
case
DateTimeConstants
.
MONDAY
:
dayOfWeek
=
"周一"
;
break
;
case
DateTimeConstants
.
TUESDAY
:
dayOfWeek
=
"周二"
;
break
;
case
DateTimeConstants
.
WEDNESDAY
:
dayOfWeek
=
"周三"
;
break
;
case
DateTimeConstants
.
THURSDAY
:
dayOfWeek
=
"周四"
;
break
;
case
DateTimeConstants
.
FRIDAY
:
dayOfWeek
=
"周五"
;
break
;
case
DateTimeConstants
.
SATURDAY
:
dayOfWeek
=
"周六"
;
default
:
break
;
}
return
dayOfWeek
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录