学习指南:
https://www.zhihu.com/question/351439302/answer/2362637429?utm_id=0
一、预约挂号详情
1、需求分析
1、接口分析
(1)根据预约周期,展示可预约日期数据,按分页展示
(2)选择一个日期展示当天可预约列表(该接口后台已经实现过)
2、页面展示分析
(1)分页展示可预约日期,根据有号、无号、约满等状态展示不同颜色,以示区分
(2)可预约最后一个日期为即将放号日期,根据放号时间页面展示倒计时 (此日期是在10天预约周期额外增加的一天)
请详细看下图:
比如我们只能预约从当前09-01时间到往后十天的号,即09-10的号,则想要预约第十一天的号(09-11),只能等明天(09-02)放号时间到了才能预约。预约周期是十天(09-01—09-10)
2、api接口
2.1 、controller代码:
添加controller的两个接口方法:
第一个接口:获取可预约排班数据
第二个接口:获取排班具体数据详情
在HospitalApiController类添加方法
在以下模块中开发2个接口的编写:
代码:
/*=========预约挂号=========*/
//第一个接口:获取可预约排班数据
/**
* 获取排班可预约日期数据
* //根据医院编号和部门编号参数来获取
* @param page
* @param limit
* @param hoscode 医院编号
* @param depcode 部门编号
* @return
*/
@ApiOperation("获取可预约排班数据")
@GetMapping("auth/getBookingScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
public Result getBookingScheduleRule(
@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 = "科室编号",required = true)
@PathVariable String depcode
){
return Result.ok(scheduleService
.getBookingScheduleRule(page,limit,hoscode,depcode));
}
//第二个接口:获取排班具体数据
/**
* 获取排班可预约日期数据
* //根据医院编号和部门编号参数来获取
* @param hoscode 医院编号
* @param depcode 部门编号
* @param workDate 排班日期
* @return
*/
@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));
}
补充接口方法:
2.2 、Service类接口:
在ScheduleService类添加接口
interface ScheduleService:
/**
* 获取排班可预约日期数据
* @param page
* @param limit
* @param hoscode
* @param depcode
* @return
*/
Map<String, Object> getBookingScheduleRule
(int page, int limit, String hoscode, String depcode);
2.3 、添加service接口实现:
在ScheduleServiceImpl类实现接口
第①步:根据医院编号获取预约规则:
Hospital实体类中有预约属性:private BookingRule bookingRule
第②步:
2.1 写一个工具方法getDateTime():将Date和放号时间 拼装成DateTime
2.2 写一个方法getListDate(参数是page,limit,bookingRule): 获取可预约日期的分页数据
方法一:将DateTime格式转换为字符串:
String time = dateTime.toString(“yyyy-MM-dd hh:mm:ss.SSSa”);
方法二:将字符串转换为DateTime格式:
DateTimeFormatter format = DateTimeFormat .forPattern(“yyyy-MM-dd HH:mm:ss”);
DateTime dateTime = DateTime.parse(“2018-4-23 23:12:16”, format);
查询数据:
合并数据:
获取可预约排班规则:
//可预约日期规则数据
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;
调用的一个补充方法:
总结;