1、接口分析
(1)根据预约周期,展示可预约日期数据,按分页展示
(2)选择日期展示当天可预约列表(该接口后台已经实现过)
2、页面展示分析
(1)分页展示可预约日期,根据有号、无号、约满等状态展示不同颜色,以示区分
(2)可预约最后一个日期为即将放号日期,根据放号时间页面展示倒计时
最后效果如图
涉及到两个接口,这两个接口我没具体写,比较复杂
//获取可预约排班数据
@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.getDetailSchedule(hoscode, depcode, workDate));
}
Service
//根据医院编号、科室编号、工作日期,查询排版详细信息
@Override
public List<Schedule> getScheduleDetail(String hoscode, String depcode, String workDate) {
//根据参数,查询mongodb
List<Schedule> scheduleList = scheduleRepository.findScheduleByHoscodeAndDepcodeAndWorkDate(hoscode, depcode, new DateTime(workDate).toDate());
//遍历list集合,设置每个元素对应的属性
//使用stream流遍历
scheduleList.stream().forEach(item -> {
this.packageSchedule(item);
});
return scheduleList;
}
@Override
public Map<String, Object> getBookingScheduleRule(Integer page, Integer limit, String hoscode, String depcode) {
Map<String, Object> result = new HashMap<>();
//根据医院编号获取预约规则
// 从 mongo 中取
Hospital hospital = hospitalService.getByHoscode(hoscode);
if (hospital == null) {
throw new HospitalException(ResultCodeEnum.DATA_ERROR);
}
BookingRule bookingRule = hospital.getBookingRule();
// 获取可预约日期的数据(分页)
IPage 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> aggregateResult =
mongoTemplate.aggregate(agg, Schedule.class, BookingScheduleRuleVo.class);
List<BookingScheduleRuleVo> scheduleVoList = aggregateResult.getMappedResults();
//合并数据 map集合 key:日期 value:预约规则和剩余数量等
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;
}
跳转路径需要修改
需要手动修改数据,我改的是 邵迎红 这位医生的排班信息,修改 work_date 为当前时间以后几天就可以看到数据了
1、根据排班id获取排班信息,在页面展示
2、选择就诊人
3、预约下单
有一个查询排版信息详情的接口
//根据医院编号、科室编号、工作日期,查询排版详细信息
@GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
public Result getScheduleDetail(@PathVariable String hoscode,
@PathVariable String depcode,
@PathVariable String workDate){
List<Schedule> list = scheduleService.getScheduleDetail(hoscode,depcode,workDate);
return Result.ok(list);
}
//根据医院编号、科室编号、工作日期,查询排版详细信息
@Override
public List<Schedule> getScheduleDetail(String hoscode, String depcode, String workDate) {
//根据参数,查询mongodb
List<Schedule> scheduleList = scheduleRepository.findScheduleByHoscodeAndDepcodeAndWorkDate(hoscode, depcode, new DateTime(workDate).toDate());
//遍历list集合,设置每个元素对应的属性
//使用stream流遍历
scheduleList.stream().forEach(item -> {
this.packageSchedule(item);
});
return scheduleList;
}
这块就是 booking 这个页面
这块放到了后面