当前位置:网站首页>Day116. Shangyitong: Details of appointment registration ※
Day116. Shangyitong: Details of appointment registration ※
2022-08-02 01:41:00 【Firework Youth·】
一、预约挂号详情 ※
1、需求分析
(1) 根据page、limit、hoscode、depcode,Query information with pagination and conditions
(2) 根据hoscode、depcode、workDate Query the schedule details data
(3) Display the number source information according to the hospital appointment cycle(失效)
(4) If the registration time has passed on the day,预约周期+1
(5) If there is no doctor visit date(放假),也需要展示出来
(6) 根据开始、Stop registration time,判断状态
2、接口分析
1. With pagination and conditional statistics number source information
*参数:page、limit、hoscode、depcode
*返回值:map
2. Query the schedule details data
*参数:hoscode、depcode、workDate
*返回值:list
3、实现controller
HospitalApiController下新增方法
@ApiOperation(value = "获取可预约排班数据")
@GetMapping("auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
public R getBookingSchedule(
@PathVariable Integer page,
@PathVariable Integer limit,
@PathVariable String hoscode,
@PathVariable String depcode) {
Map<String, Object> map = scheduleService.getBookingSchedule(page, limit, hoscode, depcode);
return R.ok().data(map);
}
@ApiOperation(value = "获取排班数据")
@GetMapping("auth/findScheduleList/{hoscode}/{depcode}/{workDate}")
public R findScheduleList(
@PathVariable String hoscode,
@PathVariable String depcode,
@PathVariable String workDate) {
//方法复用
List<Schedule> scheduleList = scheduleService.getScheduleDetail(hoscode,depcode,workDate);
return R.ok().data("scheduleList",scheduleList);
}
4、实现Service
//获取可预约排班数据
@Override
public Map<String, Object> getBookingSchedule(
Integer page, Integer limit, String hoscode, String depcode) {
//1.根据hoscode 查询医院信息,获取预约规则
//2.According to the reservation rules,分页信息,Query the collection pagination object of available dates (Not affected by the database,Ipage<Date>苞米豆)
//3.Refer to the background interface to implement aggregate query (List<BookingScheduleRuleVo>)
//4.合并 步骤2和步骤3的数据
//5.封装数据并返回
return null;
}
//获取可预约排班数据
@Override
public Map<String, Object> getBookingSchedule(
Integer page, Integer limit, String hoscode, String depcode) {
Map<String, Object> result = new HashMap<>();
//1、根据hoscode 查询医院信息,获取预约规则
Hospital hospital = hospitalService.getHospital(hoscode);
if(hospital==null){
throw new YyghException(20001,"The hospital information is incorrect");
}
BookingRule bookingRule = hospital.getBookingRule();
//2、According to the reservation rules,分页信息,Query the collection pagination object of available dates (Not affected by the database,Ipage<Date>苞米豆)
IPage<Date> iPage = this.getDateListPage(page,limit,bookingRule);
List<Date> datePageList = iPage.getRecords();
//3、Refer to the background interface to implement aggregate query (List<BookingScheduleRuleVo>),获取可预约日期科室剩余预约数
//3.1Prepare filters
Criteria criteria = Criteria
.where("hoscode").is(hoscode)
.and("depcode").is(depcode)
.and("workDate").in(datePageList);
//3.2创建聚合查询对象
Aggregation agg = Aggregation.newAggregation(
//3.2.1设置查询条件
Aggregation.match(criteria),
//3.2.2设置聚合参数 + 聚合查询字段 (分组)
Aggregation.group("workDate")
.first("workDate").as("workDate")
.count().as("docCount")
.sum("reservedNumber").as("reservedNumber")
.sum("availableNumber").as("availableNumber")
);
//3.3执行聚合查询List<BookingScheduleRuleVo>
AggregationResults<BookingScheduleRuleVo> aggregate =
mongoTemplate.aggregate(agg, Schedule.class, BookingScheduleRuleVo.class);
List<BookingScheduleRuleVo> scheduleVoList =
aggregate.getMappedResults();
//3.4The type of conversion query result,List=>Map k:workDate v:BookingScheduleRuleVo
Map<Date,BookingScheduleRuleVo> scheduleVoMap = new HashMap<>();
if(!CollectionUtils.isEmpty(scheduleVoList)){
scheduleVoMap = scheduleVoList.stream().collect(Collectors.toMap(
BookingScheduleRuleVo::getWorkDate,
BookingScheduleRuleVo->BookingScheduleRuleVo
));
}
//4、合并 步骤2(datePageList)和步骤3(scheduleVoMap)的数据
List<BookingScheduleRuleVo> bookingScheduleRuleVoList = new ArrayList<>();
for (int i = 0, let = datePageList.size(); i < let; i++) {
//4.1 遍历 datePageList,Take out the date of each day
Date date = datePageList.get(i);
//4.2 根据日期,查询scheduleVoMap,Get the record information of shift aggregation
BookingScheduleRuleVo bookingScheduleRuleVo = scheduleVoMap.get(date);
//4.3 The records of the shift aggregation are empty,需要初始化
if(bookingScheduleRuleVo==null){
bookingScheduleRuleVo = new BookingScheduleRuleVo();
bookingScheduleRuleVo.setDocCount(0);//Current number of appointments
bookingScheduleRuleVo.setAvailableNumber(-1);//
}
//4.4 Set shift dates
bookingScheduleRuleVo.setWorkDate(date);
bookingScheduleRuleVo.setWorkDateMd(date);
//4.5 Convert the day of the week based on the date
String dayOfWeek = this.getDayOfWeek(new DateTime(date));
bookingScheduleRuleVo.setDayOfWeek(dayOfWeek);
//4.6 Status judgment based on time (状态 0:正常 1:即将放号 -1:当天已停止挂号)
//最后一页,最后一条记录,The status is about to be released
if(i==let-1 && page==iPage.getPages()){
bookingScheduleRuleVo.setStatus(1);
}else{
bookingScheduleRuleVo.setStatus(0);
}
//第一页,第一条记录,If the stop registration time has passed,状态为-1,Registration will be closed on the day
if(i==0&&page==1){
DateTime stopDateTime = this.getDateTime(new Date(), bookingRule.getStopTime());
if(stopDateTime.isBeforeNow()){
bookingScheduleRuleVo.setStatus(-1);
}
}
bookingScheduleRuleVoList.add(bookingScheduleRuleVo);
}
//5、封装数据并返回
//可预约日期规则数据
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;
}
//分支2 :According to the reservation rules,分页信息,Query the collection pagination object of available dates
private IPage<Date> getDateListPage(
Integer page, Integer limit, BookingRule bookingRule) {
//1.Get the registration start time from the appointment rule(当前系统日期+开始时间)
DateTime releaseDateTime =
this.getDateTime(new Date(),bookingRule.getReleaseTime());
// 2.Get the period from the appointment rule,Determine if the cycle is needed+1 如果当天放号时间已过,则预约周期后一天为即将放号时间,周期加1
Integer cycle = bookingRule.getCycle();
if(releaseDateTime.isBeforeNow()) cycle +=1;
//3.Calculate the date of registration according to the cycle,存入集合(list)
List<Date> dateList = new ArrayList<>();
for (int i = 0; i < cycle; i++) {
//The current date is backwardsi天
DateTime plusDays = new DateTime().plusDays(i);
String plusDaysString = plusDays.toString("yyyy-MM-dd");
dateList.add(new DateTime(plusDaysString).toDate());
}
//4.Prepare pagination parameters 日期分页,由于预约周期不一样,页面一排最多显示7天数据,多了就要分页显示
int start = (page-1)*limit;
int end = (page-1)*limit+limit;
if(end>dateList.size()) end = dateList.size();
//5.根据分页参数,Get a collection of paginated dates
List<Date> datePageList = new ArrayList<>();
for (int i = start; i < end; i++) {
datePageList.add(dateList.get(i));
}
//6.封装数据到IPage对象,返回
IPage<Date> iPage = new com.baomidou.mybatisplus.extension.plugins.pagination.Page<>(page,limit,dateList.size());
iPage.setRecords(datePageList);
return iPage;
}
//日期+开始时间
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;
}
Update shift data,测试:
边栏推荐
- Oracle data to mysql FlinkSQL CDC to achieve synchronization
- 字节给我狠狠上了一课:危机来的时候你连准备时间都没有...
- 【图像融合】基于加权和金字塔实现图像融合附matlab代码
- Day115.尚医通:后台用户管理:用户锁定解锁、详情、认证列表审批
- Pytorch seq2seq model architecture to achieve English translation tasks
- flyway的快速入门教程
- 超大规模的产业实用语义分割数据集PSSL与预训练模型开源啦!
- TKU记一次单点QPS优化(顺祝ITEYE终于回来了)
- When paying attention to the "Internet +" model, you usually only focus on the "Internet +" model itself
- Some insights from 5 years of automated testing experience: UI automation must overcome these 10 pits
猜你喜欢
随机推荐
GO开发环境配置
6-25漏洞利用-irc后门利用
H5页面调用微信授权获取code
flowable工作流所有业务概念
HSDC和独立生成树相关
Kubernetes — 核心资源对象 — 网络
6-24 exploit-vnc password cracking
电商库存系统的防超卖和高并发扣减方案
Markdown (CSDN) MD编辑器(四)- 漂亮表格(表格背景色、跨行、跨列)
【轮式里程计】
MInIO入门-03 秒传+大文件分片上传
传统企业数字化转型需要经过几个阶段?
使用百度EasyDL实现厂区工人抽烟行为识别
R语言使用table1包绘制(生成)三线表、使用单变量分列构建三线表、编写自定义三线表结构(将因子变量细粒度化重新构建三线图)、自定义修改描述性统计参数输出自定义统计量
go mode tidy出现报错go warning “all“ matched no packages
喜报 | AR 开启纺织产业新模式,ALVA Systems 再获殊荣!
云和恩墨:让商业数据库时代的价值在openGauss生态上持续繁荣
C语言实验十 函数(二)
当关注「互联网+」模式的时候,通常仅仅只是在关注「互联网+」模式本身
3.Bean的作用域与生命周期