后端-医院管理之医院列表实现
后端-医院管理实现
- 1、医院列表
- 1.1、 医院列表api接口
- 1.1.1、添加controller方法
- 1.1.2、service层方法
- 1.2、service-cmn模块提供接口
- 1.2.1、接口编写的背景
- 1.2.2、编写接口
- 1.3、服务调用--案例
- 1.3.1、需求背景:在service_hosp中调用service_cmn中的接口
- 1.3.2、在service_client模块下创建模块service_client_cmn
- 1.3.3、在service_hosp导入service_cmn_client模块坐标
- 1.3.4、在service_hosp的hospitalServiceImpl中注入DictFeignClient
- 1.3.5、在service_hosp的hospitalServiceImpl编写代码实现服务远程调用
- 1.4、 添加数据字典显示接口,查询出省份信息,一级省份下边的市
- 1.4.1、 编写controller
- 1.4.2、业务层
1、医院列表
1.1、 医院列表api接口
1.1.1、添加controller方法
@RestController
@RequestMapping("/admin/hosp/hospital")
@CrossOrigin
public class HospitalController {@Autowiredprivate HospitalService hospitalService;//医院信息列表@GetMapping("limit/{page}/{limit}")public Result listHospital(@PathVariable Integer page,@PathVariable Integer limit,HospitalQueryVo hospitalQueryVo){//调用业务层方法Page<Hospital> pageModel = hospitalService.selectHospPage(page,limit,hospitalQueryVo);return Result.ok(pageModel);}}
1.1.2、service层方法
接口:
//医院信息列表
Page<Hospital> selectHospPage(Integer page, Integer limit, HospitalQueryVo hospitalQueryVo);
实现类:
//医院信息列表(分页带模糊查询)
@Override
public Page<Hospital> selectHospPage(Integer page, Integer limit, HospitalQueryVo hospitalQueryVo) {//创建pageable,用于设置分页信息Pageable pageable = PageRequest.of(page,limit);//设置条件匹配规则ExampleMatcher matcher = ExampleMatcher.matching().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)//改变默认字符串匹配为:模糊查询.withIgnoreCase(true);//查询时忽略大小写//将hospitalQueryVo对象转换成Hospital对象Hospital hospital = new Hospital();BeanUtils.copyProperties(hospitalQueryVo,hospital);//创建Example对象,用于设置查询条件Example<Hospital> example = Example.of(hospital,matcher);Page<Hospital> all = hospitalRepository.findAll(example, pageable);return all;
}
1.2、service-cmn模块提供接口
由于有关医院的信息查询的接口都在service_cmn微服务中,因此我们要在service-cmn模块中编写需要的接口,供service_hosp模块调用使用。
1.2.1、接口编写的背景
- 由于我们的医院等级、省市区地址都是取的数据字典value值,因此我们在列表显示医院等级与医院地址时要根据数据字典value值获取数据字典名称。
- 通过学习数据字典我们知道,根据上级编码与value值可以获取对应的数据字典名称,如果value值能够保持唯一(不一定唯一),我们也可以直接通过value值获取数据字典名称,目前省市区三级数据我们使用的是国家统计局的数据,数据编码我们就是数据字典的id与value,所以value能够唯一确定一条数据字典,如图:
1.2.2、编写接口
在service_cmn中编写接口,返回getName值,供service_hosp模块调用。
控制层:
//根据dictCode和value查询
@GetMapping("getName/{dictCode}/{value}")
public String getName(@PathVariable String dictCode,@PathVariable String value){String dictName = dictService.getName(dictCode,value);return dictName;
}//根据value查询
@GetMapping("getName/{value}")
public String getName(@PathVariable String value){String dictName = dictService.getName("",value);return dictName;
}
业务层接口:
//查询getName
String getName(String dictCode, String value);
业务层实现类:;
//查询getName
@Override
public String getName(String dictCode, String value) {//如果dictCode为空,根据value查询if(StringUtils.isEmpty(dictCode)){QueryWrapper<Dict> wrapper = new QueryWrapper<>();wrapper.eq("value",value);Dict dict = baseMapper.selectOne(wrapper);return dict.getName();}else {//如果value为空,首先根据dictCode查询出Dict对象Dict Dict = getDictByDictCode(dictCode);Long parentId = Dict.getId();//在根据查询出来的parent_id和value查询Dict finalDict = baseMapper.selectOne(new QueryWrapper<Dict>().eq("parent_id", parentId).eq("value", value));return finalDict.getName();}
private Dict getDictByDictCode(String dictCode){QueryWrapper<Dict> wrapper = new QueryWrapper<>();wrapper.eq("dict_code", dictCode);Dict codeDict = baseMapper.selectOne(wrapper);return codeDict;}
1.3、服务调用–案例
1.3.1、需求背景:在service_hosp中调用service_cmn中的接口
因为医院的所有信息都在mysql数据库中的yygh_cmn数据库的dict表中存放。该数据是service_cmn模块下的数据库。
医院平台端系统的数据在mongoDB中存放,在mongoDB中存放的医院部分信息都是编号,没有真实的名字。该数据是service_hosp模块中的数据:
因此要在service_hosp中调用service_cmn的接口,查询医院相关数据,并最终在浏览器上显示医院的真实名字,而不是显示其编号。
创建service_client模块,在该模块下在创建子模块做远程调用使用。
在service_client的pom.xml文件中引入依赖:
<dependencies><dependency><groupId>com.study</groupId><artifactId>common_util</artifactId></dependency><dependency><groupId>com.study</groupId><artifactId>model</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><scope>provided </scope></dependency><!-- 服务调用feign --><!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-openfeign --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId><version>2.2.6.RELEASE</version></dependency>
</dependencies>
1.3.2、在service_client模块下创建模块service_client_cmn
把被调用的service_cmn的接口在service_client_cmn中做声明:
@FeignClient("service-cmn")
public interface DictFeignClient {@GetMapping("/admin/cmn/dict/getName/{dictCode}/{value}")public String getName(@PathVariable("dictCode") String dictCode,@PathVariable("value") String value);@GetMapping("/admin/cmn/dict/getName/{value}")public String getName(@PathVariable("value") String value);
}
1.3.3、在service_hosp导入service_cmn_client模块坐标
因为服务调用的代码是在service_cmn_client中编写的,而最终是service_hosp调用service_cmn中的接口。所以要在service_hosp中引入service_cmn_client依赖。
1.3.4、在service_hosp的hospitalServiceImpl中注入DictFeignClient
1.3.5、在service_hosp的hospitalServiceImpl编写代码实现服务远程调用
主要是远程调用service_cmn中的接口,查询出来医院的等级信息。封装到hospital中供平台显示。
//医院信息列表(分页带模糊查询)@Overridepublic Page<Hospital> selectHospPage(Integer page, Integer limit, HospitalQueryVo hospitalQueryVo) {//创建pageable,用于设置分页信息Pageable pageable = PageRequest.of(page,limit);//设置条件匹配规则ExampleMatcher matcher = ExampleMatcher.matching().withStringMatcher(ExampleMatcher.StringMatcher.CONTAINING)//改变默认字符串匹配为:模糊查询.withIgnoreCase(true);//查询时忽略大小写//将hospitalQueryVo对象转换成Hospital对象Hospital hospital = new Hospital();BeanUtils.copyProperties(hospitalQueryVo,hospital);//创建Example对象,用于设置查询条件Example<Hospital> example = Example.of(hospital,matcher);//调用方法实现查询,返回查询到底所有的医院的信息(list集合)Page<Hospital> pages = hospitalRepository.findAll(example, pageable);//获取查询的list集合,遍历及进行医院等级的封装pages.getContent().stream().forEach(item->{this.getHospitalHosType(item);});return pages;}//远程调用服务,获取医院等级private Hospital getHospitalHosType(Hospital hospital){String hosTypeString = dictFeignClient.getName("HosType", hospital.getHostype());//查询 省 市 区信息String provinceString = dictFeignClient.getName(hospital.getProvinceCode());String cityString = dictFeignClient.getName(hospital.getCityCode());String districtString = dictFeignClient.getName(hospital.getDistrictCode());//将查询出来的细腻些存放到hospital中hospital.getParam().put("fullAddress",provinceString+cityString+districtString);hospital.getParam().put("hosTypeString",hosTypeString);return hospital;}
1.4、 添加数据字典显示接口,查询出省份信息,一级省份下边的市
1.4.1、 编写controller
//根据dictCode获取其下级节点(例如根据省份的dictCode的值获取其下级节点(北京市,上海市))
@ApiModelProperty(value = "根据dictCode获取其下级节点")
@GetMapping("findByDictCode/{dictCode}")
public Result findByDictCode(@PathVariable String dictCode){List<Dict> list = dictService.findByDictCode(dictCode);return Result.ok(list);
}
1.4.2、业务层
接口:
//根据dictCode获取其下级节点(例如根据省份的dictCode的值获取其下级节点(北京市,上海市))List<Dict> findByDictCode(String dictCode);
实现类:
//根据dictCode获取其下级节点(例如根据省份的dictCode的值获取其下级节点(北京市,上海市))
@Override
public List<Dict> findByDictCode(String dictCode) {//根据传递过来的dictCode查询dict对象Dict dict = this.getDictByDictCode(dictCode);//获取该对象的id,调用方法已写好的方法,查询其下级节点List<Dict> childData = findChildData(dict.getId());return childData;
}private Dict getDictByDictCode(String dictCode){QueryWrapper<Dict> wrapper = new QueryWrapper<>();wrapper.eq("dict_code", dictCode);Dict codeDict = baseMapper.selectOne(wrapper);return codeDict;
}//根据数据id查询子数据列表
@Override
@Cacheable(value = "dict", keyGenerator = "keyGenerator")//作用是将该方法返回的值放到缓存中
public List<Dict> findChildData(Long id) {QueryWrapper<Dict> query = new QueryWrapper<>();query.eq("parent_id", id);List<Dict> dictList = baseMapper.selectList(query);//查询父节点为id的所有子数据对象//遍历集合中的每一个对象,并调用方法,判断该对象是否有子数据for (Dict dict : dictList) {Long dictId = dict.getId();boolean flag = this.isChildren(dictId);//如果对象是否有子数据,返回truedict.setHasChildren(flag);//将hasChildren属性设置为flag的值}return dictList;
}
后端-医院管理之医院列表实现相关推荐
- 医院管理软件 医院收费软件 pacs系统源码his系统源码
医院管理软件 医院收费软件 电子病历 电子处方 pacs系统 lis系统 体检系统: his医院管理软件,his医院收费软件的开发和销售,及合疗医保接口的开发. [软件功能]全国专业 医院信息化整体解 ...
- 医院管理php,医院管理系统接入php短信接口的应用
现在大大小小的医院都已经有了自己的医院管理系统,更有不少医院系统对接了php短信接口,实现了在很多场景下的短信发送功能,大大提升了患者的使用体验.那么医院管理系统接入php短信接口的应用都有哪些呢? ...
- 医院管理信息系统 HIS EMR PACS LIS
主要功能模块: 系统设置 数据字典 业务数据 权限管理医疗卡 门诊挂号 大屏叫号 分诊 急诊管理 门诊医院站 门诊护士站 门诊收费 药库 药房 住院管理 住院结算 住院医生 住院护士 医技执行 手术室 ...
- 企业医疗服务后台管理/互联网医疗/远程会诊/统计分析/医生管理/处方管理/药品管理/运营管理/挂号单管理/预约管理/结算转账管理/问诊管理/药店管理/科室管理/医院管理/电子处方/后台管理原型/rp
企业医疗服务后台管理/互联网医疗/远程会诊/统计分析/医生管理/处方管理/药品管理/运营管理/挂号单管理/预约管理/结算转账管理/问诊管理/药店管理/科室管理/医院管理/电子处方/后台管理原型/rp源 ...
- SpringBoot+Vue实现前后端分离的宠物医院管理系统
文末获取源码 开发语言:Java 使用框架:spring boot 前端技术:JavaScript.Vue.js .css3 开发工具:IDEA/MyEclipse/Eclipse.Visual St ...
- 国家卫健委医院管理研究所 电子病历系统应用水平分级评价4级实证材料--基础项
国家卫健委医院管理研究所 电子病历系统应用水平分级评价4级实证材料 (基本项) 2021年 6 月 目录 1.病房医师 01.01.4 病房医嘱处理 (1) 医嘱中的药品.检验.检查等信息可传 ...
- Day109.尚医通:集成Nacos、翻译字段、医院列表分页条件、下拉列表查询、医院状态、医院详情
目录 一.搭建Nacos服务 二.医院需求分析 三.医院列表功能(接口) 1.医院列表接口初步实现 2.cmn模块 实现翻译字段接口服务 3.实现跨模块远程调用 4.在 hosp 实现跨模块调用 四. ...
- 医院管理住院系统的研究与实现(论文+PPT+源码)
医院管理住院系统的研究与实现 摘要 医院管理住院系统是一项集多类学科为一体的系统,其中包含医学.信息.计算机等学科,广泛的应用在当今欧美等发达国家,给治疗患者们提供了很大的便利.假如全面实现了这一系统 ...
- 基于javaweb的宠物医院管理系统设计和实现(java+springboot+ssm+mysql+jsp)
基于javaweb的宠物医院管理系统设计和实现(java+springboot+ssm+mysql+jsp) 运行环境 Java≥8.MySQL≥5.7 开发工具 eclipse/idea/myecl ...
最新文章
- qt与python互联_PYQT5 vscode联合操作qtdesigner的方法
- WebApplication和WebSite有什么区别?我该选择哪个?
- OpenCV 加载图像、转换图像和保存图像
- 二:SpringAOP
- java 调用服务器文档,JAVA远程调用服务器端方法
- linux实验报告用户管理,Linux实验报告-用命令实现用户和组的管理
- vb 绘制图形/蝴蝶动画
- java md5.computehash_c# – ObjectDisposedException使用MD5 ComputeHash时
- Duilib学习笔记《04》— 窗体显示
- 计算机知识竞赛决赛流程,计算机知识竞赛决赛圆满结束!还不快戳?!
- python3中maketrans()方法的使用
- 计算机视觉开源代码集合(转载)
- linux 进程崩溃log,Linux系统日志及日志分析
- like roofs shell white_高二英语新教材Unit 3同步练习
- argis怎么关掉对象捕捉_ArcGIS ArcMap编辑捕捉教程
- 搭建私有云=我使用的是开源的可道云,服务器是win service 2019+公网ip+动态域名解析
- DOS获取注册表键值
- SAXReader解析器
- 基于Esp8266的远程开机棒设计和实现
- 青春散场,初心不忘【致毕业季理想主义的你】