尚医通9:医院列表功能+GateWay网关

news2024/9/30 11:22:16
内容介绍

1、医院列表功能(接口)

4、医院列表功能(前端)

5、更新医院上线状态功能

6、医院详情

7、GateWay网关

8、医院排班管理需求分析

9、查看医院所有科室接口、前端

医院列表功能(接口)
  1. 接口初步实现
  2. 跨模块接口
  3. 改造hosp实现跨模块调用

1)在service下添加依赖

2)在hosp下添加依赖

<dependency>

    <groupId>com.atguigu</groupId>

    <artifactId>service_cmn_client</artifactId>

    <version>0.0.1-SNAPSHOT</version>

  </dependency>

3)启动类添加注解

@EnableFeignClients(basePackages = "com.atguigu")

5)实现跨模块翻译

@Autowired

  private DictFeignClient dictFeignClient;

//带条件带分页查询医院列表

  @Override

  public Page<Hospital> selectPage(Integer page, Integer limit,

                                 HospitalQueryVo hospitalQueryVo) {

    //1创建分页对象

    //1.1创建排序对象

    Sort sort = Sort.by(Sort.Direction.ASC,"hoscode");

    //1.2创建分页对象

    Pageable pageable = PageRequest.of((page-1),limit,sort);

    //2创建条件模板

    //2.1封装查询条件

    Hospital hospital = new Hospital();

    BeanUtils.copyProperties(hospitalQueryVo,hospital);

    //2.2模板构造器

    ExampleMatcher matcher = ExampleMatcher.matching()

            .withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)

            .withIgnoreCase(true);

    //2.3创建模板

    Example<Hospital> example = Example.of(hospital,matcher);

    //3实现带条件带分页查询

    Page<Hospital> pageModel = hospitalRepository.findAll(example, pageable);

  

    //4 遍历集合翻译字段

    pageModel.getContent().forEach(item->{

        this.packHospital(item);

    });

  

    return pageModel;

  }

  

  //翻译医院信息

  private Hospital packHospital(Hospital hospital) {

    //1翻译医院等级

    String hostypeString = dictFeignClient.getName(DictEnum.HOSTYPE.getDictCode(), hospital.getHostype());

    //2翻译地址信息

    String provinceString = dictFeignClient.getName(hospital.getProvinceCode());

    String cityString = dictFeignClient.getName(hospital.getCityCode());

    String districtString = dictFeignClient.getName(hospital.getDistrictCode());

    //3封装数据返回

    hospital.getParam().put("hostypeString", hostypeString);

    hospital.getParam().put("fullAddress", provinceString + cityString + districtString + hospital.getAddress());

    return hospital;

  }

6)测试

4、创建cmn接口

1)分析接口

*参数:dictCode

*返回值:RList<Dict>

2)实现controller

@ApiOperation(value = "根据dictCode获取下级节点")

  @GetMapping(value = "/findByDictCode/{dictCode}")

  public R findByDictCode(

        @PathVariable String dictCode) {

    List<Dict> list = dictService.findByDictCode(dictCode);

    return R.ok().data("list",list);

  }

3)实现service

//根据dictCode获取下级节点

  @Override

  public List<Dict> findByDictCode(String dictCode) {

    //1 根据dictCode查询字典信息

    Dict parentDict = this.getByDictCode(dictCode);

    //2  根据父id查询子数据

    LambdaQueryWrapper<Dict> wrapper = new LambdaQueryWrapper<>();

    wrapper.eq(Dict::getParentId,parentDict.getId());

    List<Dict> list = baseMapper.selectList(wrapper);

    return list;

  }

4)测试

医院列表功能(前端)

1、添加路由

{

        path: 'hospital/list',

        name: '医院列表',

        component: () => import('@/views/yygh/hosp/list'),

        meta: { title: '医院列表', icon: 'table' }

      }

2、添加页面保存路由

3、添加api接口方法

(1)在api/yygh目录下创建hosp.js文件

import request from '@/utils/request'



const api_name = '/admin/hosp/hospital'



export default {

    //带条件带分页查询医院列表

    getHospPage(page, limit, searchObj) {

        return request({

            url: `${api_name}/getHospPage/${page}/${limit}`,

            method: 'get',

            params: searchObj

        })

    }

}

(2)在dict.js下添加新方法

import request from '@/utils/request'



const api_name = '/admin/cmn/dict'



export default {

    dictList(id) {//数据字典列表

      return request ({

        url: `${api_name}/findChildData/${id}`,

        method: 'get'

      })

    },

    //根据dictCode获取下级节点

    findByDictCode(dictCode) {

      return request ({

        url: `${api_name}/findByDictCode/${dictCode}`,

        method: 'get'

      })

    }

}

4、添加页面元素

<template>

  <div class="app-container">

    <el-form :inline="true" class="demo-form-inline">

      <el-form-item>

        <el-select v-model="searchObj.provinceCode" placeholder="请选择省" @change="provinceChanged">

          <el-option

            v-for="item in provinceList"

            :key="item.id"

            :label="item.name"

            :value="item.id"

          />

        </el-select>

      </el-form-item>



      <el-form-item>

        <el-select v-model="searchObj.cityCode" placeholder="请选择市">

          <el-option v-for="item in cityList" :key="item.id" :label="item.name" :value="item.id"/>

        </el-select>

      </el-form-item>



      <el-form-item>

        <el-input v-model="searchObj.hosname" placeholder="医院名称"/>

      </el-form-item>



      <el-button type="primary" icon="el-icon-search" @click="fetchData()">查询</el-button>

      <el-button type="default" @click="resetData()">清空</el-button>

    </el-form>



    <!-- banner列表 -->

    <el-table v-loading="listLoading" :data="list" border fit highlight-current-row>

      <el-table-column label="序号" width="60" align="center">

        <template slot-scope="scope">{{ (page - 1) * limit + scope.$index + 1 }}</template>

      </el-table-column>



      <el-table-column label="医院logo">

        <template slot-scope="scope">

          <img :src="'data:image/jpeg;base64,'+scope.row.logoData" width="80">

        </template>

      </el-table-column>



      <el-table-column prop="hosname" label="医院名称"/>

      <el-table-column prop="param.hostypeString" label="等级" width="90"/>

      <el-table-column prop="param.fullAddress" label="详情地址"/>

      <el-table-column label="状态" width="80">

        <template slot-scope="scope">{{ scope.row.status === 0 ? '未上线' : '已上线' }}</template>

      </el-table-column>

      <el-table-column prop="createTime" label="创建时间"/>



      <el-table-column label="操作" width="230" align="center">

        <template slot-scope="scope">

          <router-link :to="'/hospSet/hospital/show/'+scope.row.id">

            <el-button type="primary" size="mini">查看</el-button>

          </router-link>

          <router-link :to="'/hospSet/hospital/schedule/'+scope.row.hoscode">

            <el-button type="primary" size="mini">排班</el-button>

          </router-link>



          <el-button

            v-if="scope.row.status == 1"

            type="primary"

            size="mini"

            @click="updateStatus(scope.row.id, 0)"

          >下线</el-button>

          <el-button

            v-if="scope.row.status == 0"

            type="danger"

            size="mini"

            @click="updateStatus(scope.row.id, 1)"

          >上线</el-button>

        </template>

      </el-table-column>

    </el-table>



    <!-- 分页组件 -->

    <el-pagination

      :current-page="page"

      :total="total"

      :page-size="limit"

      :page-sizes="[5, 10, 20, 30, 40, 50, 100]"

      style="padding: 30px 0; text-align: center;"

      layout="sizes, prev, pager, next, jumper, ->, total, slot"

      @current-change="fetchData"

      @size-change="changeSize"

    />

  </div>

</template>

5、实现js

<script>

import hospApi from "@/api/yygh/hosp";

import dictApi from "@/api/yygh/dict";

export default {

  data() {

    return {

      listLoading: true, // 数据是否正在加载

      list: null, // 医院列表数据集合

      total: 0, // 数据库中的总记录数

      page: 1, // 默认页码

      limit: 10, // 每页记录数

      searchObj: {

        provinceCode: "",

        cityCode: ""

      }, // 查询表单对象

      provinceList: [], //所有省集合

      cityList: [] //所有市集合

    };

  },

  created() {

    //初始化查询医院列表

    this.fetchData();

    //初始化查询省信息

    this.getProvinceList();

  },

  methods: {

    //查询医院列表

    fetchData(page = 1) {

      this.page = page;

      hospApi

        .getHospPage(this.page, this.limit, this.searchObj)

        .then(response => {

          this.list = response.data.pageModel.content;

          this.total = response.data.pageModel.totalElements;

          this.listLoading = false;

        });

    },

    //查询省信息

    getProvinceList() {

      dictApi.findByDictCode("Province").then(response => {

        this.provinceList = response.data.list;

      });

    },

    //选择省加载市信息

    provinceChanged() {

      //1清空市信息

      this.searchObj.cityCode = "";

      this.cityList = [];

      //2调用接口初始化市信息

      dictApi.dictList(this.searchObj.provinceCode).then(response => {

        this.cityList = response.data.list;

      });

    },

    //清空

    resetData() {

      this.searchObj = {

        provinceCode: "",

        cityCode: ""

      }

      this.fetchData();

    },

    //切换每页记录数

    changeSize(size){

        this.limit = size

        this.fetchData();

    }

  }

};
</script>

6、测试

更新医院上线状态功能

1、分析需求

医院排班管理需求分析

1、分析需求

 

  1. 用树形结构展现科室信息
  2. 根据条件筛选带分页带排序统计分析(聚合查询)号源信息,推算周几

3)根据医院、科室、排班日期查询排班集合

2、实现方案

1)使用el-tree展现树形科室信息

2)根据hoscodedepcode筛选数据,根据排班日期进行带分页带排序的聚合查询。使用工具推算周几

3)根据医院、科室、排班日期查询排班集合

3、实现步骤

虽然是一个页面展示所有内容,但是页面相对复杂,我们分步骤实现

第一,先实现左侧科室树形展示;

第二,其次排班日期分页展示

第三,最后根据排班日期获取排班详情数据

查看医院所有科室接口、前端

1、分析需求

 

2、实现接口

1)分析接口

*参数:hoscode

*返回值:R(树形结构展示科室集合List<DepartmentVo>

 

2)创建controller

@Api(tags = "科室管理")

  @RestController

@RequestMapping("/admin/hosp/department")

  public class DepartmentController {

    @Autowired

    private DepartmentService departmentService;

  

    //根据医院编号,查询医院所有科室列表

    @ApiOperation(value = "查询医院所有科室列表")

    @GetMapping("getDeptList/{hoscode}")

    public R getDeptList(@PathVariable String hoscode) {

        List<DepartmentVo> list = departmentService.getDeptListTree(hoscode);

        return R.ok().data("list",list);

    }

  }

3)如果是mysql如何实现

#查询大科室集合

SELECT d.bigcode ,d.bigname,COUNT(d.id)

 FROM Department d

GROUP BY d.bigcode ,d.bigname;

#遍历大科室集合,根据bigcode查询小科室集合

SELECT * FROM Department d

WHERE d.bigcode = '大科室编码';

4)梳理实现步骤

//根据医院编号,查询医院所有科室列表

  @Override

  public List<DepartmentVo> getDeptListTree(String hoscode) {

    //1创建最终返回对象

    //2根据hoscode查询所有科室信息List<Department>

    //3根据集合数据进行分组

    //List<Department>=>Map( k:bigcode  v: List<Department>)

    //4遍历map,封装大科室信息DepartmentVo

    //5封装小科室信息List<DepartmentVo>

    //6小科室集合存入大科室vo

    //7大科室vo存入最终返回对象

    return null;

  }
(5)实现service

//根据医院编号,查询医院所有科室列表

  @Override

  public List<DepartmentVo> getDeptListTree(String hoscode) {

    //1创建最终返回对象

    List<DepartmentVo> result = new ArrayList<>();

    //2根据hoscode查询所有科室信息List<Department>

    List<Department> departmentList = departmentRepository.getByHoscode(hoscode);

    //3根据集合数据进行分组

    //List<Department>=>Map( k:bigcode  v: List<Department>)

    Map<String,List<Department>> departmentMap = 

            departmentList.stream().collect(Collectors.groupingBy(Department::getBigcode));

    

    //4遍历map,封装大科室信息DepartmentVo

    for (Map.Entry<String, List<Department>> entry : departmentMap.entrySet()) {

        DepartmentVo deptBigVo = new DepartmentVo();

        deptBigVo.setDepcode(entry.getKey());

        List<Department> deptList = entry.getValue();

        deptBigVo.setDepname(deptList.get(0).getBigname());

        //5封装小科室信息List<DepartmentVo>

        List<DepartmentVo> children = new ArrayList<>();

        for (Department dept : deptList) {

            DepartmentVo departmentVo = new DepartmentVo();

            departmentVo.setDepcode(dept.getDepcode());

            departmentVo.setDepname(dept.getDepname());

            children.add(departmentVo);

        }

        //6小科室集合存入大科室vo

        deptBigVo.setChildren(children);

        //7大科室vo存入最终返回对象

        result.add(deptBigVo);

        

    }

    return result;

  }

6)测试

 

3、对接前端

1)确认入口

 

<router-link :to="'/yygh/hospSet/hospital/schedule/'+scope.row.hoscode">

            <el-button type="primary" size="mini">排班</el-button>

          </router-link>

(2)创建隐藏路由

{

        path: 'hospital/schedule/:hoscode',

        name: '排班',

        component: () => import('@/views/yygh/hosp/schedule'),

        meta: { title: '排班', noCache: true },

        hidden: true

      }

(3)创建页面

 

(4)创建api

在hosp.js中添加api方法

//查看医院科室

    getDeptByHoscode(hoscode) {

        return request({

            url: `/admin/hosp/department/getDeptList/${hoscode}`,

            method: 'get'

        })

    }



(5)添加页面元素

<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"

          :default-expand-all="true"

          @node-click="handleNodeClick"

        ></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>

(6)实现js

<script>

import hospApi from "@/api/yygh/hosp";



export default {

  data() {

    return {

      data: [], //科室集合

      defaultProps: {//默认支柱属性

        children: "children",

        label: "depname"

      },

      hoscode: ""//医院编码

    };

  },

  created() {

      this.hoscode = this.$route.params.hoscode

      this.fetchData()

  },

  methods: {

      //查询科室数据

      fetchData(){

         hospApi.getDeptByHoscode(this.hoscode).then(response=>{

             this.data = response.data.list

         })

      }



  }

};

</script>

7)测试

 

2、实现接口

1)分析接口

*参数:idstatus

*返回值:R.ok()

2)实现controller

@ApiOperation(value = "更新上线状态")

  @GetMapping("updateStatus/{id}/{status}")

  public R updateStatus(

        @PathVariable("id") String id,

        @PathVariable("status") Integer status){

    hospitalService.updateStatus(id,status);

    return R.ok();

  }
(3)实现service

//更新上线状态

  @Override

  public void updateStatus(String id, Integer status) {

    if(status.intValue()==0||status.intValue()==1){

        Hospital hospital = hospitalRepository.findById(id).get();

        hospital.setStatus(status);

        hospitalRepository.save(hospital);

    }

  }

3、对接前端

1)确认入口

2)添加api

//上下线

    updateStatus(id, status) {

        return request({

            url: `${api_name}/updateStatus/${id}/${status}`,

            method: 'get'

        })

    }

3)确认页面

4)实现js

//上下线

    updateStatus(id, status) {

      hospApi.updateStatus(id, status).then(response => {

        this.$message({

          type: "success",

          message: "操作成功!"

        });

        this.fetchData();

      });

    }

5)测试

医院详情查询实现

1、实现接口

1)分析接口

*参数:id

*返回值:Rmap(医院基本信息、预约规则))

(2)实现controller

@ApiOperation(value = "获取医院详情")

  @GetMapping("show/{id}")

  public R show(

        @PathVariable String id) {

    Map<String,Object> map = hospitalService.show(id);

    return R.ok().data(map);

  }

3)实现service

//获取医院详情

  @Override

  public Map<String, Object> show(String id) {

    Hospital hospital = this.packHospital(hospitalRepository.findById(id).get()) ;

    BookingRule bookingRule = hospital.getBookingRule();

    hospital.setBookingRule(null);

    Map<String, Object> result = new HashMap<>();

    result.put("hospital",hospital);

    result.put("bookingRule",bookingRule);

    return result;

  }

4)测试

2、对接前端

1)确认入口

<router-link :to="'/yygh/hospset/hospital/show/'+scope.row.id">

            <el-button type="primary" size="mini">查看</el-button>

          </router-link>

(2)添加隐藏路由

{

        path: 'hospital/show/:id',

        name: '查看',

        component: () => import('@/views/yygh/hosp/show'),

        meta: { title: '查看', noCache: true },

        hidden: true

      }

3)创建页面,保存路由

(4)添加api接口方法

//查看医院详情

    getHospById(id) {

        return request({

            url: `${api_name}/show/${id}`,

            method: 'get'

        })

    }

(5)添加页面元素

<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%">医院logo</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%">{{ bookingRule.cycle }}天</td>

          <th width="15%">放号时间</th>

          <td width="35%">{{ bookingRule.releaseTime }}</td>

        </tr>

        <tr>

          <th>停挂时间</th>

          <td>{{ bookingRule.stopTime }}</td>

          <th>退号时间</th>

          <td>{{ bookingRule.quitDay == -1 ? '就诊前一工作日' : '就诊当日' }}{{ bookingRule.quitTime }} 前取消</td>

        </tr>

        <tr>

          <th>预约规则</th>

          <td colspan="3">

            <ol>

              <li v-for="item in bookingRule.rule" :key="item">{{ item }}</li>

            </ol>

          </td>

        </tr>

        <br>

        <el-row>

          <el-button @click="back">返回</el-button>

        </el-row>

      </tbody>

    </table>

  </div>

</template>

(6)实现js

<script>

import hospApi from "@/api/yygh/hosp";

export default {

    data () {

        return {

            hospital:{},//医院基本信息

            bookingRule:{}//预约规则

        }

    },

    created () {

        let id = this.$route.params.id

        this.init(id)

    },

    methods: {

        init(id){

            hospApi.getHospById(id).then(response=>{

                this.hospital = response.data.hospital

                this.bookingRule = response.data.bookingRule

            })

        },

        back(){

            this.$router.push({path:"/yygh/hospset/hospital/list"})

        }

    }

}

</script>

7)添加css

第一、将show.css文件复制到src/styles目录

第二、在src/main.js文件添加引用

import '@/styles/show.css'

Spring Cloud GateWay网关搭建

1、是什么

2 Spring Cloud Gateway

1)架构图

2)核心概念

路由。路由是网关最基础的部分,路由信息有一个ID、一个目的URL、一组断言和一组Filter组成。如果断言路由为真,则说明请求的URL和配置匹配

断言。Java8中的断言函数。Spring Cloud Gateway中的断言函数输入类型是Spring5.0框架中的ServerWebExchange。Spring Cloud Gateway中的断言函数允许开发者去定义匹配来自于http request中的任何信息,比如请求头和参数等。

过滤器。一个标准的Spring webFilter。Spring cloud gateway中的filter分为两种类型的Filter,分别是Gateway Filter和Global Filter。过滤器Filter将会对请求和响应进行修改处理

3、创建service_gateway模块(网关服务)

1)创建模块

2)导入依赖

<dependencies>

    <dependency>

        <groupId>com.atguigu</groupId>

        <artifactId>common_utils</artifactId>

        <version>0.0.1-SNAPSHOT</version>

    </dependency>

    <dependency>

        <groupId>org.springframework.cloud</groupId>

        <artifactId>spring-cloud-starter-gateway</artifactId>

    </dependency>

  

    <!-- 服务注册 -->

    <dependency>

        <groupId>com.alibaba.cloud</groupId>

        <artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>

    </dependency>

  </dependencies>

3)编写application.properties配置文件

# 服务端口

  server.port=8200

  # 服务名

  spring.application.name=service-gateway

  

  # nacos服务地址

  spring.cloud.nacos.discovery.server-addr=127.0.0.1:8848

  

  #使用服务发现路由

  spring.cloud.gateway.discovery.locator.enabled=true

  

  #设置路由id

  spring.cloud.gateway.routes[0].id=service-hosp

  #设置路由的uri

  spring.cloud.gateway.routes[0].uri=lb://service-hosp

  #设置路由断言,代理servicerIdauth-service/auth/路径

  spring.cloud.gateway.routes[0].predicates= Path=/*/hosp/**

  

  #设置路由id

  spring.cloud.gateway.routes[1].id=service-cmn

  #设置路由的uri

  spring.cloud.gateway.routes[1].uri=lb://service-cmn

  #设置路由断言,代理servicerIdauth-service/auth/路径

  spring.cloud.gateway.routes[1].predicates= Path=/*/cmn/**

4)添加主目录、启动类

@SpringBootApplication

  public class ApiGatewayApplication {

    public static void main(String[] args) {

        SpringApplication.run(ApiGatewayApplication.class, args);

    }

  }

5)启动模块测试

6)改造前端配置

重启生效

4、扩展功能

实现跨域功能

1)添加配置类

@Configuration

  public class CorsConfig {

  

    @Bean

    public CorsWebFilter corsFilter() {

        CorsConfiguration config = new CorsConfiguration();

        config.addAllowedMethod("*");

        config.addAllowedOrigin("*");

        config.addAllowedHeader("*");

  

        UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource(new PathPatternParser());

        source.registerCorsConfiguration("/**", config);

  

        return new CorsWebFilter(source);

    }

  

  }

2)测试

医院排班管理需求分析

1、分析需求

  1. 用树形结构展现科室信息
  2. 根据条件筛选带分页带排序统计分析(聚合查询)号源信息,推算周几

3)根据医院、科室、排班日期查询排班集合

2、实现方案

1)使用el-tree展现树形科室信息

2)根据hoscodedepcode筛选数据,根据排班日期进行带分页带排序的聚合查询。使用工具推算周几

3)根据医院、科室、排班日期查询排班集合

3、实现步骤

虽然是一个页面展示所有内容,但是页面相对复杂,我们分步骤实现

第一,先实现左侧科室树形展示;

第二,其次排班日期分页展示

第三,最后根据排班日期获取排班详情数据

查看医院所有科室接口、前端

1、分析需求

2、实现接口

1)分析接口

*参数:hoscode

*返回值:R(树形结构展示科室集合List<DepartmentVo>

2)创建controller

@Api(tags = "科室管理")

  @RestController

@RequestMapping("/admin/hosp/department")

  public class DepartmentController {

    @Autowired

    private DepartmentService departmentService;

  

    //根据医院编号,查询医院所有科室列表

    @ApiOperation(value = "查询医院所有科室列表")

    @GetMapping("getDeptList/{hoscode}")

    public R getDeptList(@PathVariable String hoscode) {

        List<DepartmentVo> list = departmentService.getDeptListTree(hoscode);

        return R.ok().data("list",list);

    }

  }

3)如果是mysql如何实现

#查询大科室集合

SELECT d.bigcode ,d.bigname,COUNT(d.id)

 FROM Department d

GROUP BY d.bigcode ,d.bigname;

#遍历大科室集合,根据bigcode查询小科室集合

SELECT * FROM Department d

WHERE d.bigcode = '大科室编码';

4)梳理实现步骤

//根据医院编号,查询医院所有科室列表

  @Override

  public List<DepartmentVo> getDeptListTree(String hoscode) {

    //1创建最终返回对象

    //2根据hoscode查询所有科室信息List<Department>

    //3根据集合数据进行分组

    //List<Department>=>Map( k:bigcode  v: List<Department>)

    //4遍历map,封装大科室信息DepartmentVo

    //5封装小科室信息List<DepartmentVo>

    //6小科室集合存入大科室vo

    //7大科室vo存入最终返回对象

    return null;

  }
(5)实现service

//根据医院编号,查询医院所有科室列表

  @Override

  public List<DepartmentVo> getDeptListTree(String hoscode) {

    //1创建最终返回对象

    List<DepartmentVo> result = new ArrayList<>();

    //2根据hoscode查询所有科室信息List<Department>

    List<Department> departmentList = departmentRepository.getByHoscode(hoscode);

    //3根据集合数据进行分组

    //List<Department>=>Map( k:bigcode  v: List<Department>)

    Map<String,List<Department>> departmentMap = 

            departmentList.stream().collect(Collectors.groupingBy(Department::getBigcode));

    

    //4遍历map,封装大科室信息DepartmentVo

    for (Map.Entry<String, List<Department>> entry : departmentMap.entrySet()) {

        DepartmentVo deptBigVo = new DepartmentVo();

        deptBigVo.setDepcode(entry.getKey());

        List<Department> deptList = entry.getValue();

        deptBigVo.setDepname(deptList.get(0).getBigname());

        //5封装小科室信息List<DepartmentVo>

        List<DepartmentVo> children = new ArrayList<>();

        for (Department dept : deptList) {

            DepartmentVo departmentVo = new DepartmentVo();

            departmentVo.setDepcode(dept.getDepcode());

            departmentVo.setDepname(dept.getDepname());

            children.add(departmentVo);

        }

        //6小科室集合存入大科室vo

        deptBigVo.setChildren(children);

        //7大科室vo存入最终返回对象

        result.add(deptBigVo);

        

    }

    return result;

  }

6)测试

3、对接前端

1)确认入口

<router-link :to="'/yygh/hospSet/hospital/schedule/'+scope.row.hoscode">

            <el-button type="primary" size="mini">排班</el-button>

          </router-link>

(2)创建隐藏路由

{

        path: 'hospital/schedule/:hoscode',

        name: '排班',

        component: () => import('@/views/yygh/hosp/schedule'),

        meta: { title: '排班', noCache: true },

        hidden: true

      }

3)创建页面

(4)创建api

在hosp.js中添加api方法

//查看医院科室

    getDeptByHoscode(hoscode) {

        return request({

            url: `/admin/hosp/department/getDeptList/${hoscode}`,

            method: 'get'

        })

    }



(5)添加页面元素

<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"

          :default-expand-all="true"

          @node-click="handleNodeClick"

        ></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>

(6)实现js

<script>

import hospApi from "@/api/yygh/hosp";



export default {

  data() {

    return {

      data: [], //科室集合

      defaultProps: {//默认支柱属性

        children: "children",

        label: "depname"

      },

      hoscode: ""//医院编码

    };

  },

  created() {

      this.hoscode = this.$route.params.hoscode

      this.fetchData()

  },

  methods: {

      //查询科室数据

      fetchData(){

         hospApi.getDeptByHoscode(this.hoscode).then(response=>{

             this.data = response.data.list

         })

      }



  }

};

</script>

7)测试

排班日期统计列表

1确认需求

1)根据医院、科室、日期带分页聚合查询

2)根据排班日期推算周几

2、实现接口

1)分析接口

*参数:pagelimithoscodedepcode

*返回值:RMaptotalList<BookingScheduleRuleVo>。。。))

2)创建controller

@Api(tags = "排班管理")

  @RestController

@RequestMapping("/admin/hosp/schedule")

  public class ScheduleController {

    @Autowired

    private ScheduleService scheduleService;

    

    //根据医院编号  科室编号 ,查询排班规则数据

    @ApiOperation(value ="查询排班规则统计数据")

    @GetMapping("getScheduleRule/{page}/{limit}/{hoscode}/{depcode}")

    public R getScheduleRule(@PathVariable long page,

                             @PathVariable long limit,

                             @PathVariable String hoscode,

                             @PathVariable String depcode) {

        Map<String,Object> map = scheduleService.getScheduleRule(page,limit,hoscode,depcode);

        return R.ok().data(map);

    }

  }

3)如果是mysql如何实现

#根据医院编号 科室编号 ,查询排班规则统计数据,带分页带排序

SELECT s.workDate,COUNT(id) AS docCount,

SUM(s.reservedNumber) AS reservedNumber,

SUM(s.availableNumber) AS availableNumber

 FROM SCHEDULE s

WHERE  s.hoscode = '医院编号' AND s.depcode = '科室编号'

GROUP BY s.workDate

ORDER BY s.workDate

LIMIT XXXX;

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/807812.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

代码随想录算法训练营day15 | 102. 二叉树的层序遍历,226. 翻转二叉树,101. 对称二叉树

目录 102. 二叉树的层序遍历 226. 翻转二叉树 101. 对称二叉树 100. 相同的树 100是101的衍生题目。572也为101的衍生题目。 102. 二叉树的层序遍历 思路&#xff1a; 以前的笔记 代码&#xff1a; class Solution {public List<List<Integer>> levelOrder(T…

web自动化测试-PageObject 设计模式

为 UI 页面写测试用例时&#xff08;比如 web 页面&#xff0c;移动端页面&#xff09;&#xff0c;测试用例会存在大量元素和操作细节。当 UI 变化时&#xff0c;测试用例也要跟着变化&#xff0c; PageObject 很好的解决了这个问题。 使用 UI 自动化测试工具时&#xff08;包…

Reinforcement Learning with Code 【Chapter 9. Policy Gradient Methods】

Reinforcement Learning with Code This note records how the author begin to learn RL. Both theoretical understanding and code practice are presented. Many material are referenced such as ZhaoShiyu’s Mathematical Foundation of Reinforcement Learning, . 文章…

C++之实例化对象总结(一百七十)

简介&#xff1a; CSDN博客专家&#xff0c;专注Android/Linux系统&#xff0c;分享多mic语音方案、音视频、编解码等技术&#xff0c;与大家一起成长&#xff01; 优质专栏&#xff1a;Audio工程师进阶系列【原创干货持续更新中……】&#x1f680; 人生格言&#xff1a; 人生…

13 亿美金买个寂寞?No!AI 时代的数据行业蓄势待发

6月底&#xff0c;全球数据分析领域彻底炸锅了。 两大数据分析企业Databricks和Snowflake纷纷将目光瞄准了AI大模型。要知道&#xff0c;这两位对手平时没少对台戏&#xff0c;为性能、产品和技术经常开撕。但在今年的自家大会上&#xff0c;两家企业却出奇的一致&#xff0c;…

opencv+ffmpeg环境(ubuntu)搭建全面详解

一.先讲讲opencv和ffmpeg之间的关系 1.1它们之间的联系 我们知道opencv主要是用来做图像处理的&#xff0c;但也包含视频解码的功能&#xff0c;而在视频解码部分的功能opencv是使用了ffmpeg。所以它们都是可以处理图像和视频的编解码&#xff0c;我个人感觉两个的侧重点不一…

【博客684】Multi-regional高可用模式部署VictoriaMetrics

Multi-regional模式部署VictoriaMetrics 整体架构图 每个工作负载区域&#xff08;地球、火星、金星&#xff09;都有一个 vmagent&#xff0c;通过监控设置将数据发送到多个区域。监控设置&#xff08;地面控制 1,2&#xff09;包含 VictoriaMetrics 时间序列数据库 (TSDB) 集…

四姑娘山三日游

趁着小孩放暑假&#xff0c;从昆明回来之后&#xff0c;直接自驾到四姑娘山。 第一天 成都-四川省阿坝藏族羌族自治州小金县日隆镇(20230711) 大概9:30从成都市郫都区出发&#xff0c;路线如下&#xff1a;郫都—都江堰–映秀—耿达—卧龙—四姑娘山&#xff0c;中途翻过巴朗…

Notepad++工具通过正则表达式批量替换内容

1.每行末尾新增特定字符串 CtrlH弹出小窗口&#xff1b;查找目标输入$&#xff0c;替换为输入特定字符串&#xff1b;选中循环查找&#xff0c;查找模式选正则表达式&#xff1b;最后点击全部替换 2.每行行首新增特定字符串 CtrlH弹出小窗口&#xff1b;查找目标输入^&…

会议OA之我的会议(会议排座送审)

目录 前言&#xff1a; 2.我的会议&#xff1a; 2.1实现的特色功能&#xff1a; 2.2思路&#xff1a; 2.3功能实现&#xff1a; 我的会议页面&#xff1a;myMeeting.jsp myMeeting.js Dao方法 在mvc中配置info信息 Meeting InfoAction 2.4会议排座的思路&#xff1a; …

第四代SHARC® ADSP-21479KBCZ-2A、ADSP-21479BSWZ-2A、ADSP-21479KSWZ-2A高性能DSP(数字信号处理器)

第四代SHARC Processors 现在内置低功耗浮点DSP产品&#xff08;ADSP-21478和ADSP-21479&#xff09;&#xff0c;可提供改进的性能、基于硬件的滤波器加速器、面向音频与应用的外设以及能够支持单芯片解决方案的新型存储器配置。所有器件都彼此引脚兼容&#xff0c;而且与以往…

【Android知识笔记】UI体系(二)

什么是UI线程? 常说的UI线程到底是哪个线程?UI线程一定是主线程吗? 下面先给出两条确定的结论: UI线程就是刷新UI所在的线程UI是单线程刷新的关于第二条为什么UI只能是单线程刷新的呢?道理很简单,因为多线程访问的话需要加锁,太卡,所以一般系统的UI框架都是采用单线程…

《重构的时机和方法》,值得程序员仔细研读的一本书

现有代码结构及框架沿用的比较久&#xff0c;持续在其上新增功能&#xff0c;可维护性与可扩展性变得越来越差&#xff0c;随着需求不断增加&#xff0c;现有代码变得越来越臃肿复杂&#xff0c;变得很难维护&#xff0c;甚至出现较严重的性能瓶颈&#xff0c;一般这个时候我们…

Thymeleaf入门

Thymeleaf是前端开发模板&#xff0c;springboot默认支持。前端模板用法大多数是类似的jsp、thymeleaf、vue.js都有while\for\if\switch等使用&#xff0c;页面组件化等。 1.前端模板区别 jsp是前后端完全不分离的&#xff0c;jsp页面写一堆Java逻辑。 thymeleaf好处是html改…

域名解析优先级

浏览器访问过程解析 访问网址——>首先在本地电脑看看hosts里面是否有域名对应IP地址&#xff0c;如何有直接访问对应IP&#xff0c; 如果没有&#xff0c;则联网询问DNS服务器&#xff08;一般网卡那边都配置了DNS服务器IP&#xff09; linux hosts 路径&#xff1a; w…

苍穹外卖-day07

苍穹外卖-day07 本项目学自黑马程序员的《苍穹外卖》项目&#xff0c;是瑞吉外卖的Plus版本 功能更多&#xff0c;更加丰富。 结合资料&#xff0c;和自己对学习过程中的一些看法和问题解决情况上传课件笔记 视频&#xff1a;https://www.bilibili.com/video/BV1TP411v7v6/?sp…

中国气象局:到2030年,人工智能在气象应用领域取得世界领先地位

最近&#xff0c;中国气象局发布了《2023-2030年人工智能气象应用工作方案》&#xff0c;旨在加快推进国内人工智能气象应用技术体系建设&#xff0c;提升基础支撑能力&#xff0c;构建健全的人工智能气象应用政策环境&#xff0c;促进人工智能技术在气象观测、预报和服务领域的…

华为H12-821更新了32题,大家注意了

&#xff08;多选题&#xff09;使用堆叠和集群技术构建园区网的优势包括以下哪些项&#xff1f; A、业务中断时间大大减少 B、简化网络管理&#xff0c;降低网络部署规划的复杂度 C、可有效减少网络功耗 D、提高网络设备和链路的利用率 正确答案是…

教雅川学缠论02-K线

传统行情上的K线是下图中这样子的 而在缠论中K线是下面这样子的&#xff0c;它没有上影线和下影线 下图是武汉控股2023年7月的日K线 接下来我们将它转换成缠论K线&#xff08;画图累死我了&#xff09; K线理解了我们才能进行下一步&#xff0c;目前位置应该很好理解的

C++笔记之vector的resize()和clear()用法

C笔记之vector的resize()和clear()用法 code review! 文章目录 C笔记之vector的resize()和clear()用法1.resize()2.clear() 1.resize() 运行 2.clear() 运行