首页 > 编程语言 >尚医通-day08【排班管理详细步骤】(内附源码)

尚医通-day08【排班管理详细步骤】(内附源码)

时间:2023-06-12 19:33:51浏览次数:57  
标签:hoscode workDate return String 尚医通 day08 data 源码 depcode

页面预览

医院详情

image-20230217040332183

排班管理

image-20230217051939537

第01章-医院详情

1、后端

1.1、Controller

AdminHospitalController

@ApiOperation(value = "获取医院详情")
@ApiImplicitParam(name = "hoscode",value = "医院编码", required = true)
@GetMapping("/show/{hoscode}")
public Result<Hospital> show(@PathVariable String hoscode) {
    Hospital hospital = hospitalService.show(hoscode);
    return Result.ok(hospital);
}

1.2、Service

接口:HospitalService

/**
     * 根据医院编码获取医院详情
     * @param hoscode
     * @return
     */
Hospital show(String hoscode);

实现:HospitalServiceImpl

@Override
public Hospital show(String hoscode) {
    Hospital hospital = hospitalRepository.findByHoscode(hoscode);
    return this.packHospital(hospital);
}

2、前端

2.1、添加路由

静态路由:

src/router/index.js:在“医院管理”下添加子节点

{
  path: 'hosp/show/:hoscode',
  name: 'hospShow',
  component: () => import('@/views/syt/hosp/show'),
  meta: { title: '查看', noCache: true },
  hidden: true
}

动态路由:

医院列表下添加按钮

image-20230317104455506

2.2、api

src/api/syt/hosp.js

//查看医院详情
getHospByCode(hoscode){
  return request ({
    url: `${apiName}/show/${hoscode}`,
    method: 'get'
  })
},

2.3、组件渲染

创建 src/views/syt/hosp/show.vue

<template>
  <div class="app-container">
    <h4>基本信息</h4>
    <table
      class="table table-striped table-condenseda table-bordered"
      width="100%"
    >
      <tbody>
        <tr>
          <th width="15%">医院名称</th>
          <td width="35%">
            <b style="font-size: 14px">{{ hospital.hosname }}</b> |
            {{ hospital.param.hostypeString }}
          </td>
          <th width="15%"></th>
          <td width="35%">
            <img
              :src="'data:image/jpeg;base64,' + hospital.logoData"
              width="80"
            />
          </td>
        </tr>
        <tr>
          <th>医院编码</th>
          <td>{{ hospital.hoscode }}</td>
          <th>地址</th>
          <td>{{ hospital.param.fullAddress }}</td>
        </tr>
        <tr>
          <th>坐车路线</th>
          <td colspan="3">{{ hospital.route }}</td>
        </tr>
        <tr>
          <th>医院简介</th>
          <td colspan="3">{{ hospital.intro }}</td>
        </tr>
      </tbody>
    </table>
    <h4>预约规则信息</h4>
    <table
      class="table table-striped table-condenseda table-bordered"
      width="100%"
    >
      <tbody>
        <tr>
          <th width="15%">预约周期</th>
          <td width="35%">{{ hospital.bookingRule.cycle }}天</td>
          <th width="15%">放号时间</th>
          <td width="35%">{{ hospital.bookingRule.releaseTime }}</td>
        </tr>
        <tr>
          <th>停挂时间</th>
          <td>{{ hospital.bookingRule.stopTime }}</td>
          <th>退号时间</th>
          <td>
            {{ hospital.bookingRule.quitDay == -1 ? '就诊前一工作日' : '就诊当日'
            }}{{ hospital.bookingRule.quitTime }} 前取消
          </td>
        </tr>
        <tr>
          <th>预约规则</th>
          <td colspan="3">
            <ol>
              <li v-for="item in hospital.bookingRule.rule" :key="item">{{ item }}</li>
            </ol>
          </td>
        </tr>
      </tbody>
    </table>
    <p style="text-align:center;"><el-button @click="back">返回</el-button></p>
    
  </div>
</template>

<script>
import hospApi from '@/api/syt/hosp'
import '@/styles/show.css'

export default {
  data() {
    return {
      hospital: null, //医院信息
    }
  },

  created () {
    
    this.fetchHospByHoscode(this.$route.params.hoscode)

  },

  methods: {
    //获取医院详情
    fetchHospByHoscode(hoscode){
      hospApi.getHospByCode(hoscode).then(response => {
        this.hospital = response.data
      })
    },

    //返回到医院列表
    back(){
        this.$router.push({path: '/syt/hospset/hosp/list'})
    }
  }
}
</script>

第02章-科室列表

1、后端

1.1、Controller

创建 AdminDepartmentController

package com.atguigu.syt.hosp.controller.admin;

@Api(tags = "科室管理")
@RestController
@RequestMapping("/admin/hosp/department")
public class AdminDepartmentController {

    @Resource
    private DepartmentService departmentService;

    @ApiOperation(value = "查询医院所有科室列表")
    @ApiImplicitParam(name = "hoscode",value = "医院编码", required = true)
    @GetMapping("/getDeptList/{hoscode}")
    public Result<List<DepartmentVo>> getDeptList(@PathVariable String hoscode) {
        List<DepartmentVo> list = departmentService.findDeptTree(hoscode);
        return Result.ok(list);
    }
}

1.2、Service

接口:DepartmentService

/**
     * 根据医院编码获取部门嵌套列表
     * @param hoscode
     * @return
     */
List<DepartmentVo> findDeptTree(String hoscode);

实现:DepartmentServiceImpl

@Override
public List<DepartmentVo> findDeptTree(String hoscode) {

    //创建list集合,用于最终数据封装
    List<DepartmentVo> result = new ArrayList<>();
    //根据医院编号,查询医院所有科室信息
    List<Department> departmentList = departmentRepository.findByHoscode(hoscode);
    //根据大科室编号  bigcode 分组,获取每个大科室里面下级子科室
    //collect:将流转换为其他形式。接收一个 Collector接口的实现,用于给Stream中元素做汇总的方法
    Map<String, List<Department>> deparmentMap =
        departmentList.stream().collect(Collectors.groupingBy(Department::getBigcode));
    //遍历map集合 deparmentMap   (iter)
    for(Map.Entry<String,List<Department>> entry : deparmentMap.entrySet()) {
        //大科室编号
        String bigcode = entry.getKey();
        //大科室编号对应的全部数据
        List<Department> subList = entry.getValue();
        //封装大科室
        DepartmentVo departmentVo = new DepartmentVo();
        departmentVo.setDepcode(bigcode);
        departmentVo.setDepname(subList.get(0).getBigname());
        //封装小科室
        List<DepartmentVo> children = new ArrayList<>();
        for(Department subDepartment: subList) {
            DepartmentVo subDepartmentVo =  new DepartmentVo();
            subDepartmentVo.setDepcode(subDepartment.getDepcode());
            subDepartmentVo.setDepname(subDepartment.getDepname());
            //封装到list集合
            children.add(subDepartmentVo);
        }
        //把小科室list集合放到大科室children里面
        departmentVo.setChildren(children);
        //放到最终result里面
        result.add(departmentVo);
    }
    //返回
    return result;
}

1.3、Repository

/**
 * 根据医院编号查询科室列表
 * @param hoscode
 * @return
 */
List<Department> findByHoscode(String hoscode);

2、前端

2.1、添加路由

静态路由:

src/router/index.js:在“医院管理”下添加子节点

{
  path: 'hosp/schedule/:hoscode',
  name: 'hospSchedule',
  component: () => import('@/views/syt/hosp/schedule'),
  meta: { title: '排班', noCache: true },
  hidden: true
} 

动态路由:

医院列表下添加按钮

image-20230611004523358

image-20230317105009222

2.2、api

创建src/api/syt/dept.js

import request from '@/utils/request'
const apiName = '/admin/hosp/department'
export default {
  //查看医院科室
  getDeptByHoscode(hoscode) {
    return request ({
        url: `${apiName}/getDeptList/${hoscode}`,
        method: 'get'
    })
  },
}

2.3、组件渲染

src/views/syt/hosp/schedule.vue

<template>
  <div class="app-container">
    <div style="margin-bottom: 10px; font-size: 10px">选择:</div>
    <el-container style="height: 100%">
      <el-aside width="200px" style="border: 1px silver solid">
        <!-- 部门 -->
        <el-tree
          :data="data"
          :props="defaultProps"
          @node-click="selectDept"
        >
        </el-tree>
      </el-aside>
      <el-main style="padding: 0 0 0 20px">
        <el-row style="width: 100%">
          <!-- 排班日期 分页 -->
        </el-row>
        <el-row style="margin-top: 20px">
          <!-- 排班日期对应的排班医生 -->
        </el-row>
      </el-main>
    </el-container>
  </div>
</template>
<script>
import deptApi from '@/api/syt/dept'
export default {
  data() {
    return {
      data: [], //部门列表
      defaultProps: {
        children: 'children',
        label: 'depname',
      },
      
      hoscode: null, //医院编号
      depcode: null, //科室编号
      workDate: null, //选中的排班日期
      activeIndex: -1, //选中的排班日期的索引

      bookingScheduleList: [], //当前选中的科室下所显示的排班日期数据
      page: 1, // 当前页
      limit: 6, // 每页个数
      total: 0, // 总页码

      scheduleDetailList:[] //某一个日期下排班详情列表
    }
  },

  created() {
    this.hoscode = this.$route.params.hoscode
    this.fetchData()
  },

  methods: {
    fetchData() {
      deptApi.getDeptByHoscode(this.hoscode).then((response) => {
        this.data = response.data
      })
    },

        //选择部门
    selectDept(data) {
      // 科室大类直接返回,
      if (data.children != null) return

      this.depcode = data.depcode
      this.getScheduleRule()
    },
  },
}
</script>

第03章-日期统计列表

1、后端

1.1、引入工具类

在service-hosp中引入joda-time依赖

<!--时间日期工具-->
<dependency>
    <groupId>joda-time</groupId>
    <artifactId>joda-time</artifactId>
</dependency>

资料:资料>DateUtil工具

将DateUtil复制到service-hosp的utils包

1.2、Controller

创建AdminScheduleController

package com.atguigu.syt.hosp.controller.admin;

@Api(tags = "排班接口")
@RestController
@RequestMapping("/admin/hosp/schedule")
public class AdminScheduleController {

    @Resource
    private ScheduleService scheduleService;

    @ApiOperation(value ="查询排班规则数据")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "page",value = "页码",required = true),
            @ApiImplicitParam(name = "limit",value = "每页记录数",required = true),
            @ApiImplicitParam(name = "hoscode",value = "医院编码",required = true),
            @ApiImplicitParam(name = "depcode",value = "部门编码",required = true)
    })
    @GetMapping("/getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")
    public Result<Map<String, Object>> getScheduleRule(@PathVariable Long page,
                                                       @PathVariable Long limit,
                                                       @PathVariable String hoscode,
                                                       @PathVariable String depcode) {
        Map<String,Object> map = scheduleService.getScheduleRule(page,limit,hoscode,depcode);
        return Result.ok(map);
    }
}

1.3、Service

接口:ScheduleService

/**
     * 根据医院编号 和 科室编号 ,查询排班规则(按日期展示)
     * @param page
     * @param limit
     * @param hoscode
     * @param depcode
     * @return
     */
Map<String, Object> getScheduleRule(Long page, Long limit, String hoscode, String depcode);

实现:ScheduleServiceImpl

@Resource
private MongoTemplate mongoTemplate;

@Override
public Map<String, Object> getScheduleRule(Long page, Long limit, String hoscode, String depcode) {

    //获取查询结果
    //List<Schedule> list = mongoTemplate.findAll(Schedule.class);
    //查询条件:根据医院编号和科室编号查询
    Criteria criteria = Criteria.where("hoscode").is(hoscode).and("depcode").is(depcode);
    //根据工作日workDate期进行分组
    Aggregation agg = Aggregation.newAggregation(
        //1 查询条件
        Aggregation.match(criteria),
        Aggregation
        //2 按照日期分组 select workDate as workDate from schedule group by workDate
        .group("workDate").first("workDate").as("workDate")
        //3 可预约数
        .sum("reservedNumber").as("reservedNumber")
        //4 剩余预约数
        .sum("availableNumber").as("availableNumber"),
        //5 排序
        Aggregation.sort(Sort.Direction.ASC,"workDate"),
        //6 分页
        Aggregation.skip((page-1)*limit),
        Aggregation.limit(limit)
    );
    //执行查询,查询Schedule集合,将文档中的同名字段数据存入BookingScheduleRuleVo类
    AggregationResults<ScheduleRuleVo> aggResults = mongoTemplate.aggregate(agg, Schedule.class, ScheduleRuleVo.class);
    //获取查询结果
    List<ScheduleRuleVo> list = aggResults.getMappedResults();


    //分组查询后的总记录数
    Aggregation totalAgg = Aggregation.newAggregation(
        Aggregation.match(criteria),
        Aggregation.group("workDate")
    );
    AggregationResults<ScheduleRuleVo> totalAggResults = mongoTemplate.aggregate(totalAgg, Schedule.class, ScheduleRuleVo.class);
    int total = totalAggResults.getMappedResults().size();
    //根据日期计算对应星期获取 (iter)
    for (ScheduleRuleVo scheduleRuleVo : list) {
        Date workDate = scheduleRuleVo.getWorkDate();
        String dayOfWeek = DateUtil.getDayOfWeek(new DateTime(workDate));
        scheduleRuleVo.setDayOfWeek(dayOfWeek);
    }
    //设置最终数据,进行返回
    Map<String, Object> result = new HashMap<>();
    result.put("list",list);
    result.put("total",total);
    return result;
}

2、前端

2.1、api

创建src/api/syt/schedule.js

import request from '@/utils/request'
const apiName = '/admin/hosp/schedule'
export default {
  //查看排班
  getScheduleRule(page, limit, hoscode, depcode) {
    return request ({
        url: `${apiName}/getScheduleRule/${page}/${limit}/${hoscode}/${depcode}`,
        method: 'get'
    })
  },
}

2.2、组件渲染

完善src/views/syt/hosp/schedule.vue

html:

<!-- 排班日期 -->
<el-tag
        v-for="(item, index) in bookingScheduleList"
        :key="item.id"
        @click="selectDate(item.workDate, index)"
        :type="index == activeIndex ? '' : 'info'"
        style="height: 60px; margin-right: 15px; cursor: pointer"
        >
    {{ item.workDate }} {{ item.dayOfWeek }}<br />
    余号{{ item.availableNumber }} / 共{{ item.reservedNumber }}
</el-tag>
<!-- 分页 -->
<el-pagination
               v-if="total > 0"
               :current-page="page"
               :total="total"
               :page-size="limit"
               class="pagination"
               layout="prev, pager, next"
               align="center"
               style="margin-top: 20px"
               @current-change="changePage"
               >
</el-pagination>

js

import scheduleApi from '@/api/syt/schedule'

methods

 fetchData() {
      deptApi.getDeptByHoscode(this.hoscode).then(response => {
        this.data = response.data;
        //默认加载日期统计列表
        //如果this.data有数据,默认选中第一个
        if (this.data.length > 0) {
          this.depcode = this.data[0].children[0].depcode;
          this.getScheduleRule();
        }
      });
    },
//获取排班日期列表
getScheduleRule() {
  this.workDate = null
  this.activeIndex = -1
  this.scheduleDetailList = []
    
  //调用api查询
  scheduleApi
    .getScheduleRule(this.page, this.limit, this.hoscode, this.depcode)
    .then((response) => {
      this.bookingScheduleList = response.data.list
      this.total = response.data.total
    })
},

//日期翻页
changePage(page) {
  this.page = page
  this.getScheduleRule()
},
//选择日期
selectDate(workDate, index) {
  this.workDate = workDate
  this.activeIndex = index
},

第04章-排班详情

1、后端

1.1、Controller

在AdminScheduleController中添加方法

@ApiOperation(value = "查询排班详细信息")
@ApiImplicitParams({
    @ApiImplicitParam(name = "hoscode",value = "医院编码",required = true),
    @ApiImplicitParam(name = "depcode",value = "部门编码",required = true),
    @ApiImplicitParam(name = "workDate",value = "选择日期",required = true)
})
@GetMapping("/getScheduleDetail/{hoscode}/{depcode}/{workDate}")
public Result<List<Schedule>> getScheduleDetail( @PathVariable String hoscode,
                                                @PathVariable String depcode,
                                                @PathVariable String workDate) {
    List<Schedule> list = scheduleService.getScheduleList(hoscode,depcode,workDate);
    return Result.ok(list);
}

1.2、service

接口:ScheduleService

/**
     * 据医院编号 、科室编号和工作日期,查询排班详细信息
     * @param hoscode
     * @param depcode
     * @param workDate
     * @return
     */
List<Schedule> getScheduleList(String hoscode, String depcode, String workDate);

实现:ScheduleServiceImpl

@Override
public List<Schedule> getScheduleList(String hoscode, String depcode, String workDate) {

    //注意:最后一个参数需要进行数据类型的转换
    return scheduleRepository.findByHoscodeAndDepcodeAndWorkDate(
        hoscode,
        depcode,
        new DateTime(workDate).toDate());  //数据类型的转换
}

1.3、Repository

在ScheduleRepository中添加接口方法

/**
     * 据医院编号 、科室编号和工作日期,查询排班详细信息
     * @param hoscode
     * @param depcode
     * @param date
     * @return
     */
List<Schedule> findByHoscodeAndDepcodeAndWorkDate(String hoscode, String depcode, Date date);

2、前端

2.1、api

src/api/syt/schedule.js添加方法

//查询排班详情
getScheduleDetail(hoscode, depcode, workDate) {
    return request({
        url: `${apiName}/getScheduleDetail/${hoscode}/${depcode}/${workDate}`,
        method: 'get'
    })
}

2.2、组件渲染

src/views/yygh/hosp/schedule.vue

html:

<!-- 排班日期对应的排班医生 -->
<el-table
          v-if="scheduleDetailList.length > 0"
          :data="scheduleDetailList"
          border
          fit
          highlight-current-row
          >
    <el-table-column label="序号" width="60" align="center">
        <template slot-scope="scope">
            {{ scope.$index + 1 }}
        </template>
    </el-table-column>
    <el-table-column label="职称" width="150">
        <template slot-scope="scope">
            {{ scope.row.title }} | {{ scope.row.docname }}
        </template>
    </el-table-column>
    <el-table-column label="号源时间" width="80">
        <template slot-scope="scope">
            {{ scope.row.workTime == 0 ? '上午' : '下午' }}
        </template>
    </el-table-column>
    <el-table-column
                     prop="reservedNumber"
                     label="可预约数"
                     width="80"
                     />
    <el-table-column
                     prop="availableNumber"
                     label="剩余预约数"
                     width="100"
                     />
    <el-table-column prop="amount" label="挂号费(元)" width="90" />
    <el-table-column prop="skill" label="擅长技能" />
</el-table>

methods:完善之前的selectDate()方法,添加getDetailSchedule()方法


//查询日期统计数据
    getScheduleRule() {
      //数据初始化
      this.workDate = null;
      this.activeIndex = -1;
      this.scheduleDetailList = [];
      //调用接口获取数据
      scheduleApi
        .getScheduleRule(this.page, this.limit, this.hoscode, this.depcode)
        .then(response => {
          this.bookingScheduleList = response.data.list;
          this.total = response.data.total;
          //默认选中workdate、activeIndex赋值,调用方法加载排班数据
          this.workDate = this.bookingScheduleList[0].workDate;
          this.activeIndex = 0;
          this.getDetailSchedule();
        });
    },

//选择日期(完善此方法,添加最后一行代码)
selectDate(workDate, index) {
  this.workDate = workDate
  this.activeIndex = index
  this.getDetailSchedule()
},

//查询排班详情
getDetailSchedule() {
  scheduleApi
    .getScheduleDetail(this.hoscode, this.depcode, this.workDate)
    .then((response) => {
      this.scheduleDetailList = response.data
    })
},

源码:https://gitee.com/dengyaojava/guigu-syt-parent

标签:hoscode,workDate,return,String,尚医通,day08,data,源码,depcode
From: https://www.cnblogs.com/deyo/p/17475903.html

相关文章

  • 尚医通day01-【项目环境搭建和医院设置详细步骤】(内附源码)
    第01章-项目介绍1、课程介绍项目名称:尚医通预约挂号统一平台项目原型:https://www.114yygh.com北京市预约挂号统一平台项目技术栈:前后端分离后端技术:SpringBoot+SpringCloud+MyBatisPlus+MySQL+MongoDB+Redis+RabbitMQ+Docker+EasyExcel+API远程接口调......
  • 尚医通-day02【医院设置前端详细步骤】(内附源码)
    页面预览列表页面新增页面编辑页面第01章-项目中的路由1、引入路由1.1、路由模块中定义路由src/router/index.js关键代码importVuefrom'vue'//引入vue模块importRouterfrom'vue-router'//引入路由模块Vue.use(Router)//挂载路由功能到vue框架中exportc......
  • 尚医通day09-【用户平台搭建详细步骤】(内附源码)
    页面预览首页医院详情第01章-服务器端渲染和客户端渲染1、搜索引擎优化1.1、什么是搜索引擎优化SEO是网站为了获得更多的流量,对网站的结构及内容进行调整和优化,以便搜索引擎(百度,google等)更好抓取到网站的内容,提高自已的网站排名。1.2、搜索引擎工作流程1.3、简单的S......
  • 社交app源码技术屏幕的两大实用功能
    在这个大部分人都是独生子的时代,很多人都会因为没有朋友或是在外地、亲人不在身边而孤独,这时候,很多人就会去选择去社交app软件,这也促使了社交app源码搭建平台的火爆,但是要想搭建出一个令用户满意的社交app平台,就要去了解用户需要什么样的社交app源码技术功能,今天我要讲的也是用户需......
  • 视频直播网站源码,vue tabs标签页 点击才加载
    视频直播网站源码,vuetabs标签页点击才加载tabs标签页,默认加载显示第1个tab; <el-tabsv-model="tTab"type="card"style="height:100%"@tab-click="tTabClick">  <el-tab-panelabel="Jupyter"name="Jupyter">   ......
  • std::string源码探秘和性能分析
    std::string源码探秘和性能分析2016年05月05日22:15:15std::string源码探秘和性能分析本文主要讲c++标准库的string的内部实现,以及对象拷贝的性能分析。文中采用的源码版本为gcc-4.9,测试环境为centos7,x86_64,涉及到指针等数据类型的大小也假定是在64环境位下。stl源码可以在......
  • dubbo源码深度分析:62个文档+中文注释+流程图+思维导图
    你好,我是田哥为满足群里大部分同学的需求,国庆期间,我重新对Dubbo源码进行梳理,一共7个内容:1、Dubbo核心知识总结2、Dubbo源码分析指南3、Dubbo服务发布流程4、Dubbo服务调用流程5、Dubbo中文版注释6、共62节Dubbo文档7、看Dubbo源码必备的知识点咱们话不多说,直接看内容。Dubbo核心知......
  • springboot+vue留守儿童爱心网站,附源码+数据库+论文+PPT,远程包安装运行
    1、项目介绍留守儿童爱心网站采用了B/S结构,JAVA作为开发语言,数据库采用了B/S结构,Mysql数据库进行开发。该系统包括前台操作,后台由管理员和用户两个部分,一方面,为用户提供首页、宣传新闻、志愿活动、爱心捐赠、个人中心、后台管理等功能;另一方面,为管理员提供首页、个人中心、用户管......
  • 家居购买管理系统(含源码)
    家居购买管理系统源码地址:https://pan.baidu.com/s/1UWQTntNOIiJ5xlaby6R60Q?pwd=cwq6提取码:cwq6开发工具:IDEA2021负责模块:主要负责管理员的订单管理、商品管理和用户的订单管理、购物车管理、首页、登录功能、后端的接口设计和实现。技术选型:java+jsp+MySQL+servlet1.模拟......
  • 从JDK源码级深入剖析main方法的运行机制
    如果你是一名Java应用开发工程师,你应该对“publicstaticvoidmain(String[]args)”这段代码再熟悉不过了,然而你是否了解main方法是如何调用的,为什么我们运行java.exe,就能启动应用程序?下面,让我们来一探究竟吧!首先,聊一聊,java.exe文件是怎么来的如果你下载了OpenJDK源码,在源码目......