其他源码获取可以看首页:代码老y
个人简介:专注于毕业设计项目定制开发:springboot+vue系统,Java微信小程序,javaSSM系统等技术开发,并提供远程调试部署、代码讲解、文档指导、ppt制作等技术指导。源码获取,毕设定制文章末尾查看联系方式
技术范围:SpringBoot、Vue、SSM、Nodejs、小程序等设计与开发。
本人负责:系统功能设计、毕设开题报告的撰写、任务书的制定、中期检查PPT的制作、系统功能的具体实现、论文的撰写与辅导以及长期的答辩答疑辅导。大家在毕设选题,项目以及论文编写等相关问题都可以和我沟通,我会尽自己所能给大家解答。
感兴趣的同学可在文末获取联系
1、开发相关技术介绍
1.1 SpringBoot框架
SpringBoot 是由 Pivotal 团队开发的开源 Java 基础框架,旨在简化 Spring 应用的初始搭建以及开发过程。它通过提供一系列的“Starters”来自动配置 Spring 及其集成的第三方库,极大地降低了开发者的配置难度。SpringBoot 应用通常可以独立运行,通常打包成 JAR 文件,内置了如 Tomcat、Jetty 或 Undertow 等 Web 服务器,无需外部 Servlet SpringBoot 提倡使用 Java 注解 来优化配置流程,简化了设置步骤。此外,它还包含了一些高级的监控和管控工具,特别是 Actuator 模块,它让开发者能够方便地追踪应用程序的运行状况和性能表现。这些特点使得 SpringBoot 成为开发微服务和云应用的优选,同样适用于企业级应用。
1.2 Vue框架
Vue 是一款专为构建动态和响应式的用户界面而设计的渐进式前端框架。Vue 在与一些更为庞大和全面的框架相比之中以其轻量级和模块化的特性脱颖而出,它的核心专注于视图层的构建,这样降低学习曲线的同时也便于与现有的项目或库进行无缝集成。 Vue 的设计理念强调简洁性和实用性,使开发者可以逐步地将框架的功能集成到项目中,不管是构建小型的交互界面还是处理大型应用,Vue 均能提供强大的功能支持。这种灵活性和易用性使前端开发更加高效和灵活,也是 Vue 受到广泛欢迎的关键因素之一。
1.3 MySQL数据库
MySQL 数据库是一个使用 SQL 作为查询语言的开源关系型数据库管理系统。这个系统一开始是 MySQL AB 公司所开发的,之后经历了 Sun Microsystems 的收购,最终成为 Oracle 公司旗下的产品。MySQL 因其出色的性能、可靠性和用户友好的特性而受到青睐,正因如此它也被广泛地应用于网站开发、数据存储解决方案和企业级软件系统中。它不但支持多种操作系统,而且还功能丰富且配置灵活,基本上都能满足从小型应用到大型数据仓库的需求,也正因如此是众多开发者和企业第一个选择的数据库解决方案。
2、数据库实体设计
在绘制E-R图之前,先要找出数据库的实体,明确各个实体具有的属性,比如用户信息这个实体,它具备的属性包括了用户的姓名属性,用户的密码属性,用户的创建时间属性等,所以明确了用户这个实体,以及用户实体具备的属性之后,就需要根据这些信息绘制用户实体对应的实体属性图了。绘制软件选用当下认可度高,使用范围广,操作便利的微软旗下的Visio工具。各实体信息的E-R图如下图所示。
图2-1病房E-R图
图2-2病例E-R图
图2-3处方E-R图
图2-4字典E-R图
图2-5公告E-R图
图2-6患者E-R图
图2-7药品E-R图
图2-8医生E-R图
图2-9预约医生E-R图
图2-10住院E-R图
图2-11管理员E-R图
图2-12系统总体E-R图
3、数据库表设计(展示部分表)
表4-1病房表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | bingfang_name | String | 病房名称 | 是 |
3 | bingfang_address | String | 病房位置 | 是 |
4 | chuangwei_types | Integer | 床位 | 是 |
5 | bingfang_content | String | 病房介绍 | 是 |
6 | insert_time | Date | 添加时间 | 是 |
7 | create_time | Date | 创建时间 | 是 |
表4-2病例表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | huanzhe_id | Integer | 患者 | 是 |
3 | yisheng_id | Integer | 医生 | 是 |
4 | ruyuantujing_types | Integer | 入院途径 | 是 |
5 | zhusu_content | String | 主诉 | 是 |
6 | zhenduan_content | String | 诊断 | 是 |
7 | insert_time | Date | 添加时间 | 是 |
8 | create_time | Date | 创建时间 | 是 |
表4-3处方表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | huanzhe_id | Integer | 患者 | 是 |
3 | yisheng_id | Integer | 医生 | 是 |
4 | zhenduan_content | String | 处方内容 | 是 |
5 | insert_time | Date | 开方时间 | 是 |
6 | create_time | Date | 创建时间 | 是 |
表4-4字典表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | dic_code | String | 字段 | 是 |
3 | dic_name | String | 字段名 | 是 |
4 | code_index | Integer | 编码 | 是 |
5 | index_name | String | 编码名字 | 是 |
6 | super_id | Integer | 父字段id | 是 |
7 | beizhu | String | 备注 | 是 |
8 | create_time | Date | 创建时间 | 是 |
表4-5公告信息表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | gonggao_name | String | 公告名称 | 是 |
3 | gonggao_photo | String | 公告图片 | 是 |
4 | gonggao_types | Integer | 公告类型 | 是 |
5 | insert_time | Date | 公告发布时间 | 是 |
6 | gonggao_content | String | 公告详情 | 是 |
7 | create_time | Date | 创建时间 | 是 |
表4-6患者表
序号 | 列名 | 数据类型 | 说明 | 允许空 |
1 | Id | Int | id | 否 |
2 | huanzhe_name | String | 患者姓名 | 是 |
3 | huanzhe_phone | String | 患者手机号 | 是 |
4 | huanzhe_id_number | String | 患者身份证号 | 是 |
5 | huanzhe_photo | String | 患者头像 | 是 |
6 | huanzhe_email | String | 电子邮箱 | 是 |
7 | create_time | Date | 创建时间 | 是 |
4、部分关键代码实现
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
* 病房
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/bingfang")
public class BingfangController {
private static final Logger logger = LoggerFactory.getLogger(BingfangController.class);
@Autowired
private BingfangService bingfangService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private YishengService yishengService;
@Autowired
private HuanzheService huanzheService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("医生".equals(role))
params.put("yishengId",request.getSession().getAttribute("userId"));
else if("患者".equals(role))
params.put("huanzheId",request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = bingfangService.queryPage(params);
//字典表数据转换
List<BingfangView> list =(List<BingfangView>)page.getList();
for(BingfangView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
BingfangEntity bingfang = bingfangService.selectById(id);
if(bingfang !=null){
//entity转view
BingfangView view = new BingfangView();
BeanUtils.copyProperties( bingfang , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody BingfangEntity bingfang, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,bingfang:{}",this.getClass().getName(),bingfang.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<BingfangEntity> queryWrapper = new EntityWrapper<BingfangEntity>()
.eq("bingfang_name", bingfang.getBingfangName())
.eq("bingfang_address", bingfang.getBingfangAddress())
.eq("chuangwei_types", bingfang.getChuangweiTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
BingfangEntity bingfangEntity = bingfangService.selectOne(queryWrapper);
if(bingfangEntity==null){
bingfang.setInsertTime(new Date());
bingfang.setCreateTime(new Date());
bingfangService.insert(bingfang);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody BingfangEntity bingfang, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,bingfang:{}",this.getClass().getName(),bingfang.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有相同数据
Wrapper<BingfangEntity> queryWrapper = new EntityWrapper<BingfangEntity>()
.notIn("id",bingfang.getId())
.andNew()
.eq("bingfang_name", bingfang.getBingfangName())
.eq("bingfang_address", bingfang.getBingfangAddress())
.eq("chuangwei_types", bingfang.getChuangweiTypes())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
BingfangEntity bingfangEntity = bingfangService.selectOne(queryWrapper);
if(bingfangEntity==null){
bingfangService.updateById(bingfang);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
bingfangService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
try {
List<BingfangEntity> bingfangList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
BingfangEntity bingfangEntity = new BingfangEntity();
// bingfangEntity.setBingfangName(data.get(0)); //病房名称 要改的
// bingfangEntity.setBingfangAddress(data.get(0)); //病房位置 要改的
// bingfangEntity.setChuangweiTypes(Integer.valueOf(data.get(0))); //床位 要改的
// bingfangEntity.setBingfangContent("");//照片
// bingfangEntity.setInsertTime(date);//时间
// bingfangEntity.setCreateTime(date);//时间
bingfangList.add(bingfangEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
bingfangService.insertBatch(bingfangList);
return R.ok();
}
}
}
}catch (Exception e){
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
}
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
* 病例
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/bingli")
public class BingliController {
private static final Logger logger = LoggerFactory.getLogger(BingliController.class);
@Autowired
private BingliService bingliService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private HuanzheService huanzheService;
@Autowired
private YishengService yishengService;
/**
* 后端列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永不会进入");
else if("医生".equals(role))
params.put("yishengId",request.getSession().getAttribute("userId"));
else if("患者".equals(role))
params.put("huanzheId",request.getSession().getAttribute("userId"));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = bingliService.queryPage(params);
//字典表数据转换
List<BingliView> list =(List<BingliView>)page.getList();
for(BingliView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
BingliEntity bingli = bingliService.selectById(id);
if(bingli !=null){
//entity转view
BingliView view = new BingliView();
BeanUtils.copyProperties( bingli , view );//把实体数据重构到view中
//级联表
HuanzheEntity huanzhe = huanzheService.selectById(bingli.getHuanzheId());
if(huanzhe != null){
BeanUtils.copyProperties( huanzhe , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setHuanzheId(huanzhe.getId());
}
//级联表
YishengEntity yisheng = yishengService.selectById(bingli.getYishengId());
if(yisheng != null){
BeanUtils.copyProperties( yisheng , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYishengId(yisheng.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody BingliEntity bingli, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,bingli:{}",this.getClass().getName(),bingli.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("患者".equals(role))
bingli.setHuanzheId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
else if("医生".equals(role))
bingli.setYishengId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
bingli.setInsertTime(new Date());
bingli.setCreateTime(new Date());
bingliService.insert(bingli);
return R.ok();
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody BingliEntity bingli, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,bingli:{}",this.getClass().getName(),bingli.toString());
bingliService.updateById(bingli);//根据id更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
bingliService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
try {
List<BingliEntity> bingliList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
BingliEntity bingliEntity = new BingliEntity();
// bingliEntity.setHuanzheId(Integer.valueOf(data.get(0))); //患者 要改的
// bingliEntity.setYishengId(Integer.valueOf(data.get(0))); //医生 要改的
// bingliEntity.setRuyuantujingTypes(Integer.valueOf(data.get(0))); //入院途径 要改的
// bingliEntity.setZhusuContent("");//照片
// bingliEntity.setZhenduanContent("");//照片
// bingliEntity.setInsertTime(date);//时间
// bingliEntity.setCreateTime(date);//时间
bingliList.add(bingliEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
bingliService.insertBatch(bingliList);
return R.ok();
}
}
}
}catch (Exception e){
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
}
package com.controller;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
import com.alibaba.fastjson.JSON;
import com.utils.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ResourceUtils;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.annotation.IgnoreAuth;
import com.baidu.aip.face.AipFace;
import com.baidu.aip.face.MatchRequest;
import com.baidu.aip.util.Base64Util;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.ConfigEntity;
import com.service.CommonService;
import com.service.ConfigService;
import com.utils.BaiduUtil;
import com.utils.FileUtil;
import com.utils.R;
/**
* 通用接口
*/
@RestController
public class CommonController{
private static final Logger logger = LoggerFactory.getLogger(CommonController.class);
@Autowired
private CommonService commonService;
@Autowired
private ConfigService configService;
private static AipFace client = null;
private static String BAIDU_DITU_AK = null;
@RequestMapping("/location")
public R location(String lng,String lat) {
if(BAIDU_DITU_AK==null) {
BAIDU_DITU_AK = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "baidu_ditu_ak")).getValue();
if(BAIDU_DITU_AK==null) {
return R.error("请在配置管理中正确配置baidu_ditu_ak");
}
}
Map<String, String> map = BaiduUtil.getCityByLonLat(BAIDU_DITU_AK, lng, lat);
return R.ok().put("data", map);
}
/**
* 人脸比对
*
* @param face1 人脸1
* @param face2 人脸2
* @return
*/
@RequestMapping("/matchFace")
public R matchFace(String face1, String face2, HttpServletRequest request) {
if(client==null) {
/*String AppID = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "AppID")).getValue();*/
String APIKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "APIKey")).getValue();
String SecretKey = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "SecretKey")).getValue();
String token = BaiduUtil.getAuth(APIKey, SecretKey);
if(token==null) {
return R.error("请在配置管理中正确配置APIKey和SecretKey");
}
client = new AipFace(null, APIKey, SecretKey);
client.setConnectionTimeoutInMillis(2000);
client.setSocketTimeoutInMillis(60000);
}
JSONObject res = null;
try {
File file1 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face1);
File file2 = new File(request.getSession().getServletContext().getRealPath("/upload")+"/"+face2);
String img1 = Base64Util.encode(FileUtil.FileToByte(file1));
String img2 = Base64Util.encode(FileUtil.FileToByte(file2));
MatchRequest req1 = new MatchRequest(img1, "BASE64");
MatchRequest req2 = new MatchRequest(img2, "BASE64");
ArrayList<MatchRequest> requests = new ArrayList<MatchRequest>();
requests.add(req1);
requests.add(req2);
res = client.match(requests);
System.out.println(res.get("result"));
} catch (FileNotFoundException e) {
e.printStackTrace();
return R.error("文件不存在");
} catch (IOException e) {
e.printStackTrace();
}
return R.ok().put("data", com.alibaba.fastjson.JSONObject.parse(res.get("result").toString()));
}
/**
* 获取table表中的column列表(联动接口)
* @return
*/
@RequestMapping("/option/{tableName}/{columnName}")
@IgnoreAuth
public R getOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,String level,String parent) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
if(StringUtils.isNotBlank(level)) {
params.put("level", level);
}
if(StringUtils.isNotBlank(parent)) {
params.put("parent", parent);
}
List<String> data = commonService.getOption(params);
return R.ok().put("data", data);
}
/**
* 根据table中的column获取单条记录
* @return
*/
@RequestMapping("/follow/{tableName}/{columnName}")
@IgnoreAuth
public R getFollowByOption(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName, @RequestParam String columnValue) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
params.put("columnValue", columnValue);
Map<String, Object> result = commonService.getFollowByOption(params);
return R.ok().put("data", result);
}
/**
* 修改table表的sfsh状态
* @param map
* @return
*/
@RequestMapping("/sh/{tableName}")
public R sh(@PathVariable("tableName") String tableName, @RequestBody Map<String, Object> map) {
map.put("table", tableName);
commonService.sh(map);
return R.ok();
}
/**
* 获取需要提醒的记录数
* @param tableName
* @param columnName
* @param type 1:数字 2:日期
* @param map
* @return
*/
@RequestMapping("/remind/{tableName}/{columnName}/{type}")
@IgnoreAuth
public R remindCount(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName,
@PathVariable("type") String type,@RequestParam Map<String, Object> map) {
map.put("table", tableName);
map.put("column", columnName);
map.put("type", type);
if(type.equals("2")) {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Calendar c = Calendar.getInstance();
Date remindStartDate = null;
Date remindEndDate = null;
if(map.get("remindstart")!=null) {
Integer remindStart = Integer.parseInt(map.get("remindstart").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindStart);
remindStartDate = c.getTime();
map.put("remindstart", sdf.format(remindStartDate));
}
if(map.get("remindend")!=null) {
Integer remindEnd = Integer.parseInt(map.get("remindend").toString());
c.setTime(new Date());
c.add(Calendar.DAY_OF_MONTH,remindEnd);
remindEndDate = c.getTime();
map.put("remindend", sdf.format(remindEndDate));
}
}
int count = commonService.remindCount(map);
return R.ok().put("count", count);
}
/**
* 圖表统计
*/
@IgnoreAuth
@RequestMapping("/group/{tableName}")
public R group1(@PathVariable("tableName") String tableName, @RequestParam Map<String,Object> params) {
params.put("table1", tableName);
List<Map<String, Object>> result = commonService.chartBoth(params);
return R.ok().put("data", result);
}
/**
* 单列求和
*/
@RequestMapping("/cal/{tableName}/{columnName}")
@IgnoreAuth
public R cal(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
Map<String, Object> result = commonService.selectCal(params);
return R.ok().put("data", result);
}
/**
* 分组统计
*/
@RequestMapping("/group/{tableName}/{columnName}")
@IgnoreAuth
public R group(@PathVariable("tableName") String tableName, @PathVariable("columnName") String columnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("column", columnName);
List<Map<String, Object>> result = commonService.selectGroup(params);
return R.ok().put("data", result);
}
/**
* (按值统计)
*/
@RequestMapping("/value/{tableName}/{xColumnName}/{yColumnName}")
@IgnoreAuth
public R value(@PathVariable("tableName") String tableName, @PathVariable("yColumnName") String yColumnName, @PathVariable("xColumnName") String xColumnName) {
Map<String, Object> params = new HashMap<String, Object>();
params.put("table", tableName);
params.put("xColumn", xColumnName);
params.put("yColumn", yColumnName);
List<Map<String, Object>> result = commonService.selectValue(params);
return R.ok().put("data", result);
}
/**
* 下面为新加的
*
*
*
*/
/**
* 查询字典表的分组求和
* tableName 表名
* groupColumn 分组字段
* sumCloum 统计字段
* @return
*/
@RequestMapping("/newSelectGroupSum")
public R newSelectGroupSum(@RequestParam Map<String,Object> params) {
logger.debug("newSelectGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.newSelectGroupSum(params);
return R.ok().put("data", result);
}
/**
tableName 查询表
condition1 条件1
condition1Value 条件1值
condition2 条件2
condition2Value 条件2值
average 计算平均评分
取值
有值 Number(res.data.value.toFixed(1))
无值 if(res.data){}
* */
@IgnoreAuth
@RequestMapping("/queryScore")
public R queryScore(@RequestParam Map<String, Object> params) {
logger.debug("queryScore:,,Controller:{},,params:{}",this.getClass().getName(),params);
Map<String, Object> queryScore = commonService.queryScore(params);
return R.ok().put("data", queryScore);
}
/**
* 查询字典表的分组统计总条数
* tableName 表名
* groupColumn 分组字段
* @return
*/
@RequestMapping("/newSelectGroupCount")
public R newSelectGroupCount(@RequestParam Map<String,Object> params) {
logger.debug("newSelectGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params);
List<Map<String, Object>> result = commonService.newSelectGroupCount(params);
return R.ok().put("data", result);
}
/**
* 当前表的日期分组求和
* tableName 表名
* groupColumn 分组字段
* sumCloum 统计字段
* dateFormatType 日期格式化类型 1:年 2:月 3:日
* @return
*/
@RequestMapping("/newSelectDateGroupSum")
public R newSelectDateGroupSum(@RequestParam Map<String,Object> params) {
logger.debug("newSelectDateGroupSum:,,Controller:{},,params:{}",this.getClass().getName(),params);
String dateFormatType = String.valueOf(params.get("dateFormatType"));
if("1".equals(dateFormatType)){
params.put("dateFormat", "%Y");
}else if("2".equals(dateFormatType)){
params.put("dateFormat", "%Y-%m");
}else if("3".equals(dateFormatType)){
params.put("dateFormat", "%Y-%m-%d");
}else{
R.error("日期格式化不正确");
}
List<Map<String, Object>> result = commonService.newSelectDateGroupSum(params);
return R.ok().put("data", result);
}
/**
*
* 查询字典表的分组统计总条数
* tableName 表名
* groupColumn 分组字段
* dateFormatType 日期格式化类型 1:年 2:月 3:日
* @return
*/
@RequestMapping("/newSelectDateGroupCount")
public R newSelectDateGroupCount(@RequestParam Map<String,Object> params) {
logger.debug("newSelectDateGroupCount:,,Controller:{},,params:{}",this.getClass().getName(),params);
String dateFormatType = String.valueOf(params.get("dateFormatType"));
if("1".equals(dateFormatType)){
params.put("dateFormat", "%Y");
}else if("2".equals(dateFormatType)){
params.put("dateFormat", "%Y-%m");
}else if("3".equals(dateFormatType)){
params.put("dateFormat", "%Y-%m-%d");
}else{
R.error("日期格式化类型不正确");
}
List<Map<String, Object>> result = commonService.newSelectDateGroupCount(params);
return R.ok().put("data", result);
}
/**
* 饼状图
* -- 饼状图 查询当前表
-- 查询字典表【月】
-- 统计 -- 查询某个月的每个类型的订单销售数量
-- 求和 -- 查询某个月的每个类型的订单销售额
-- 查询某个字符串【月】
-- 统计 -- 查询某个月的每个员工的订单销售数量
-- 求和 -- 查询某个月的每个员工的订单销售额
-- 查询时间【年】
-- 统计 -- 查询每个月的订单销售数量
-- 求和 -- 查询每个月的订单销售额
-- 饼状图 查询级联表
-- 查询字典表
-- 统计 -- 查询某个月的每个类型的订单销售数量
-- 求和 -- 查询某个月的每个类型的订单销售额
-- 查询某个字符串
-- 统计 -- 查询某个月的每个员工的订单销售数量
-- 求和 -- 查询某个月的每个员工的订单销售额
-- 查询时间
-- 统计 -- 统计每个月的订单销售数量
-- 求和 -- 查询每个月的订单销售额
*/
/**
* 柱状图
-- 柱状图 查询当前表
-- 某个【年,月】
-- 当前表 2 级联表 1
-- 统计
-- 【日期,字符串,下拉框】
-- 求和
-- 【日期,字符串,下拉框】
-- 柱状图 查询级联表
-- 某个【年,月】
-- 统计
-- 【日期,字符串,下拉框】
-- 求和
-- 【日期,字符串,下拉框】
*/
/**
* 柱状图求和
*/
@RequestMapping("/barSum")
public R barSum(@RequestParam Map<String,Object> params) {
logger.debug("barSum方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
Boolean isJoinTableFlag = false;//是否有级联表相关
String one = "";//第一优先
String two = "";//第二优先
//处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
//当前表
Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
params.put("thisTable",thisTable);
//级联表
String joinTableString = String.valueOf(params.get("joinTable"));
if(StringUtil.isNotEmpty(joinTableString)) {
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
params.put("joinTable", joinTable);
isJoinTableFlag = true;
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期
thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));
one = "thisDate0";
}
if(isJoinTableFlag){//级联表日期
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){
joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinDate0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinDate0";
}
}
}
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串
thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));
if(StringUtil.isEmpty(one)){
one ="thisString0";
}else{
if(StringUtil.isEmpty(two)){
two ="thisString0";
}
}
}
if(isJoinTableFlag){//级联表字符串
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){
joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinString0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinString0";
}
}
}
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型
thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));
if(StringUtil.isEmpty(one)){
one ="thisTypes0";
}else{
if(StringUtil.isEmpty(two)){
two ="thisTypes0";
}
}
}
if(isJoinTableFlag){//级联表类型
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){
joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinTypes0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinTypes0";
}
}
}
}
List<Map<String, Object>> result = commonService.barSum(params);
List<String> xAxis = new ArrayList<>();//报表x轴
List<List<String>> yAxis = new ArrayList<>();//y轴
List<String> legend = new ArrayList<>();//标题
if(StringUtil.isEmpty(two)){//不包含第二列
List<String> yAxis0 = new ArrayList<>();
yAxis.add(yAxis0);
legend.add("数值");
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get(one));
String value = String.valueOf(map.get("value"));
xAxis.add(oneValue);
yAxis0.add(value);
}
}else{//包含第二列
Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
if(StringUtil.isNotEmpty(two)){
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get(one));
String twoValue = String.valueOf(map.get(two));
String value = String.valueOf(map.get("value"));
if(!legend.contains(twoValue)){
legend.add(twoValue);//添加完成后 就是最全的第二列的类型
}
if(dataMap.containsKey(oneValue)){
dataMap.get(oneValue).put(twoValue,value);
}else{
HashMap<String, String> oneData = new HashMap<>();
oneData.put(twoValue,value);
dataMap.put(oneValue,oneData);
}
}
}
for(int i =0; i<legend.size(); i++){
yAxis.add(new ArrayList<String>());
}
Set<String> keys = dataMap.keySet();
for(String key:keys){
xAxis.add(key);
HashMap<String, String> map = dataMap.get(key);
for(int i =0; i<legend.size(); i++){
List<String> data = yAxis.get(i);
if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
data.add(map.get(legend.get(i)));
}else{
data.add("0");
}
}
}
System.out.println();
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("xAxis",xAxis);
resultMap.put("yAxis",yAxis);
resultMap.put("legend",legend);
return R.ok().put("data", resultMap);
}
/**
* 柱状图统计
*/
@RequestMapping("/barCount")
public R barCount(@RequestParam Map<String,Object> params) {
logger.debug("barCount方法:,,Controller:{},,params:{}",this.getClass().getName(), com.alibaba.fastjson.JSONObject.toJSONString(params));
Boolean isJoinTableFlag = false;//是否有级联表相关
String one = "";//第一优先
String two = "";//第二优先
//处理thisTable和joinTable 处理内容是把json字符串转为Map并把带有,的切割为数组
//当前表
Map<String,Object> thisTable = JSON.parseObject(String.valueOf(params.get("thisTable")),Map.class);
params.put("thisTable",thisTable);
//级联表
String joinTableString = String.valueOf(params.get("joinTable"));
if(StringUtil.isNotEmpty(joinTableString)) {
Map<String, Object> joinTable = JSON.parseObject(joinTableString, Map.class);
params.put("joinTable", joinTable);
isJoinTableFlag = true;
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("date")))){//当前表日期
thisTable.put("date",String.valueOf(thisTable.get("date")).split(","));
one = "thisDate0";
}
if(isJoinTableFlag){//级联表日期
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("date")))){
joinTable.put("date",String.valueOf(joinTable.get("date")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinDate0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinDate0";
}
}
}
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("string")))){//当前表字符串
thisTable.put("string",String.valueOf(thisTable.get("string")).split(","));
if(StringUtil.isEmpty(one)){
one ="thisString0";
}else{
if(StringUtil.isEmpty(two)){
two ="thisString0";
}
}
}
if(isJoinTableFlag){//级联表字符串
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("string")))){
joinTable.put("string",String.valueOf(joinTable.get("string")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinString0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinString0";
}
}
}
}
if(StringUtil.isNotEmpty(String.valueOf(thisTable.get("types")))){//当前表类型
thisTable.put("types",String.valueOf(thisTable.get("types")).split(","));
if(StringUtil.isEmpty(one)){
one ="thisTypes0";
}else{
if(StringUtil.isEmpty(two)){
two ="thisTypes0";
}
}
}
if(isJoinTableFlag){//级联表类型
Map<String, Object> joinTable = (Map<String, Object>) params.get("joinTable");
if(StringUtil.isNotEmpty(String.valueOf(joinTable.get("types")))){
joinTable.put("types",String.valueOf(joinTable.get("types")).split(","));
if(StringUtil.isEmpty(one)){
one ="joinTypes0";
}else{
if(StringUtil.isEmpty(two)){
two ="joinTypes0";
}
}
}
}
List<Map<String, Object>> result = commonService.barCount(params);
List<String> xAxis = new ArrayList<>();//报表x轴
List<List<String>> yAxis = new ArrayList<>();//y轴
List<String> legend = new ArrayList<>();//标题
if(StringUtil.isEmpty(two)){//不包含第二列
List<String> yAxis0 = new ArrayList<>();
yAxis.add(yAxis0);
legend.add("数值");
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get(one));
String value = String.valueOf(map.get("value"));
xAxis.add(oneValue);
yAxis0.add(value);
}
}else{//包含第二列
Map<String, HashMap<String, String>> dataMap = new LinkedHashMap<>();
if(StringUtil.isNotEmpty(two)){
for(Map<String, Object> map :result){
String oneValue = String.valueOf(map.get(one));
String twoValue = String.valueOf(map.get(two));
String value = String.valueOf(map.get("value"));
if(!legend.contains(twoValue)){
legend.add(twoValue);//添加完成后 就是最全的第二列的类型
}
if(dataMap.containsKey(oneValue)){
dataMap.get(oneValue).put(twoValue,value);
}else{
HashMap<String, String> oneData = new HashMap<>();
oneData.put(twoValue,value);
dataMap.put(oneValue,oneData);
}
}
}
for(int i =0; i<legend.size(); i++){
yAxis.add(new ArrayList<String>());
}
Set<String> keys = dataMap.keySet();
for(String key:keys){
xAxis.add(key);
HashMap<String, String> map = dataMap.get(key);
for(int i =0; i<legend.size(); i++){
List<String> data = yAxis.get(i);
if(StringUtil.isNotEmpty(map.get(legend.get(i)))){
data.add(map.get(legend.get(i)));
}else{
data.add("0");
}
}
}
System.out.println();
}
Map<String, Object> resultMap = new HashMap<>();
resultMap.put("xAxis",xAxis);
resultMap.put("yAxis",yAxis);
resultMap.put("legend",legend);
return R.ok().put("data", resultMap);
}
}
5、系统实现
5.1.1 患者管理
5.1.2 公告信息管理
5.1.3公告类型管理
源码获取
谢谢大家点赞、收藏、关注、评论,查看主页获取联系方式或下方vx👇🏻👇🏻👇🏻
yyy100667