作者主页:编程千纸鹤
作者简介:Java、前端、Pythone开发多年,做过高程,项目经理,架构师
主要内容:Java项目开发、毕业设计开发、面试技术整理、最新技术分享
项目编号:BS-XCX-007
中国人口众多,医疗资源匮乏,人们就医难从建国开始就一直存在,如何使医疗资源能惠及大众,让老百姓们享受医疗资源更加的公平,也是政府管理者一直在思考解决的问题。解决公平问题,一是要靠制度,二是要靠技术。目前在医疗领域普遍应用的信息化技术手段,就可有效的辅助解决医疗资源有效利用的问题。比如目前医院一号难求的局面,如何更加公平的解决,从而遏制黄牛倒号党的产生,并且更加有利于群众挂号治病。在线预约挂号系统可以在这方面起到非常积极的作用,通过患者注册账号,一个身份证只能挂一个号,人证对照,接诊时必须是本人就诊才可以实现看病就医,一是方便群众在家就可以远程挂号预约时间,二是也可有效的解决就医公平问题。
本项目基本UNI-APP前端框架开发,后台基于Springboot+Vue开发实现,完成了一个在线预约挂号系统,系统的使用角色有三个:管理员、患者、医生。
患者的主要功能:
医生的主要功能:
管理员的主要功能:
语言环境:Java: jdk1.8
数据库:Mysql: mysql5.7
应用服务器:Tomcat: tomcat8.5.31
开发工具:IDEA、HbuilderX、微信开发者工具
开发技术:后台开发Springboot+Mybatis
前台开发:UNI-APP和微信小程序
前端用户注册登陆
前台首页面
资读列表
文章详情
文章评论
个人中心
挂号大厅
预约挂号
我的预约
我的收藏
微信小程序
后台管理界面
基本统计
轮播图管理
公告栏管理
用户管理
资讯管理
资读分类管理
挂号大厅:发布预约挂号信息
挂号信息管理
己取消的挂号信息
package com.project.demo.service.base;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.project.demo.constant.FindConfig;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.*;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.ParameterizedType;
import java.net.URLDecoder;
import java.security.MessageDigest;
import java.util.*;
/**
*/
@Slf4j
public class BaseService {
@Autowired
@PersistenceContext
private EntityManager entityManager;
Class eClass = (Class)((ParameterizedType)getClass().getGenericSuperclass()).getActualTypeArguments()[0];
private final String table = humpToLine(eClass.getSimpleName());
public Query runEntitySql(String sql){
return entityManager.createNativeQuery(sql, eClass);
}
public Query runCountSql(String sql){
return entityManager.createNativeQuery(sql);
}
public void insert(Map body){
StringBuffer sql = new StringBuffer("INSERT INTO ");
sql.append("`").append(table).append("`").append(" (");
for (Map.Entry entry:body.entrySet()){
sql.append("`"+humpToLine(entry.getKey())+"`").append(",");
}
sql.deleteCharAt(sql.length()-1);
sql.append(") VALUES (");
for (Map.Entry entry:body.entrySet()){
Object value = entry.getValue();
if (value instanceof String){
sql.append("'").append(entry.getValue()).append("'").append(",");
}else {
sql.append(entry.getValue()).append(",");
}
}
sql.deleteCharAt(sql.length() - 1);
sql.append(")");
log.info("[{}] - 插入操作:{}",table,sql);
Query query = runCountSql(sql.toString());
query.executeUpdate();
}
@Transactional
public void update(Map query,Map config,Map body){
StringBuffer sql = new StringBuffer("UPDATE ").append("`").append(table).append("`").append(" SET ");
for (Map.Entry entry:body.entrySet()){
Object value = entry.getValue();
if (value instanceof String){
sql.append("`"+humpToLine(entry.getKey())+"`").append("=").append("'").append(value).append("'").append(",");
}else {
sql.append("`"+humpToLine(entry.getKey())+"`").append("=").append(value).append(",");
}
}
sql.deleteCharAt(sql.length()-1);
sql.append(toWhereSql(query,"0".equals(config.get(FindConfig.LIKE))));
// sql.append(";");
log.info("[{}] - 更新操作:{}",table,sql);
Query query1 = runCountSql(sql.toString());
query1.executeUpdate();
}
public Map selectToPage(Map query,Map config){
Query select = select(query, config);
Map map = new HashMap<>();
map.put("list",select.getResultList());
map.put("count",count(query,config).getSingleResult());
return map;
}
public Map selectToList(Map query,Map config){
Query select = selectGroupCount(query, config);
Map map = new HashMap<>();
map.put("list",select.getResultList());
return map;
}
public Map selectBarGroup(Map query,Map config){
Query select = barGroup(query, config);
Map map = new HashMap<>();
map.put("list",select.getResultList());
return map;
}
public Query barGroup(Map query,Map config){
StringBuffer sql = new StringBuffer(" SELECT ");
if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
sql.append(config.get(FindConfig.GROUP_BY));
if (config.get(FindConfig.FIELD) != null && !"".equals(config.get(FindConfig.FIELD))){
String[] fieldList = config.get(FindConfig.FIELD).split(",");
for (int i=0;i query,Map config){
StringBuffer sql = new StringBuffer("select COUNT(*) AS count_value, ");
sql.append(config.get(FindConfig.GROUP_BY)).append(" ");
sql.append("from ").append("`").append(table).append("` ");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
sql.append("group by ").append(config.get(FindConfig.GROUP_BY)).append(" ");
}
log.info("[{}] - 查询操作,sql: {}",table,sql);
return runCountSql(sql.toString());
}
public Query select(Map query,Map config){
StringBuffer sql = new StringBuffer("select ");
sql.append(config.get(FindConfig.FIELD) == null || "".equals(config.get(FindConfig.FIELD)) ? "*" : config.get(FindConfig.FIELD)).append(" ");
sql.append("from ").append("`").append(table).append("`").append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
sql.append("group by ").append(config.get(FindConfig.GROUP_BY)).append(" ");
}
if (config.get(FindConfig.ORDER_BY) != null && !"".equals(config.get(FindConfig.ORDER_BY))){
sql.append("order by ").append(config.get(FindConfig.ORDER_BY)).append(" ");
}
if (config.get(FindConfig.PAGE) != null && !"".equals(config.get(FindConfig.PAGE))){
int page = config.get(FindConfig.PAGE) != null && !"".equals(config.get(FindConfig.PAGE)) ? Integer.parseInt(config.get(FindConfig.PAGE)) : 1;
int limit = config.get(FindConfig.SIZE) != null && !"".equals(config.get(FindConfig.SIZE)) ? Integer.parseInt(config.get(FindConfig.SIZE)) : 10;
sql.append(" limit ").append( (page-1)*limit ).append(" , ").append(limit);
}
log.info("[{}] - 查询操作,sql: {}",table,sql);
return runEntitySql(sql.toString());
}
@Transactional
public void delete(Map query,Map config){
StringBuffer sql = new StringBuffer("DELETE FROM ").append("`").append(table).append("`").append(" ");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.GROUP_BY))));
log.info("[{}] - 删除操作:{}",table,sql);
Query query1 = runCountSql(sql.toString());
query1.executeUpdate();
}
public Query count(Map query,Map config){
StringBuffer sql = new StringBuffer("SELECT ");
// log.info("拼接统计函数前");
if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
sql.append(config.get(FindConfig.GROUP_BY)).append(" ,COUNT(").append(config.get(FindConfig.GROUP_BY)).append(") FROM ").append("`").append(table).append("`");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
// sql.append(" ").append("GROUP BY ").append(config.get(FindConfig.GROUP_BY));
}else {
sql.append("COUNT(*) FROM ").append("`").append(table).append("`");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
}
log.info("[{}] - 统计操作,sql: {}",table,sql);
return runCountSql(sql.toString());
}
public Query sum(Map query,Map config){
StringBuffer sql = new StringBuffer(" SELECT ");
if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
sql.append(config.get(FindConfig.GROUP_BY)).append(" ,SUM(").append(config.get(FindConfig.FIELD)).append(") FROM ").append("`").append(table).append("`");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
sql.append(" ").append("GROUP BY ").append(config.get(FindConfig.GROUP_BY));
}else {
sql.append(" SUM(").append(config.get(FindConfig.FIELD)).append(") FROM ").append("`").append(table).append("`");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
}
log.info("[{}] - 查询操作,sql: {}",table,sql);
return runCountSql(sql.toString());
}
public Query avg(Map query,Map config){
StringBuffer sql = new StringBuffer(" SELECT ");
if (config.get(FindConfig.GROUP_BY) != null && !"".equals(config.get(FindConfig.GROUP_BY))){
sql.append(config.get(FindConfig.GROUP_BY)).append(" ,AVG(").append(config.get(FindConfig.FIELD)).append(") FROM ").append("`").append(table).append("`");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
sql.append(" ").append("GROUP BY ").append(config.get(FindConfig.GROUP_BY));
}else {
sql.append(" AVG(").append(config.get(FindConfig.FIELD)).append(") FROM ").append("`").append(table).append("`");
sql.append(toWhereSql(query, "0".equals(config.get(FindConfig.LIKE))));
}
log.info("[{}] - 查询操作,sql: {}",table,sql);
return runCountSql(sql.toString());
}
public String toWhereSql(Map query, Boolean like) {
if (query.size() > 0) {
try {
StringBuilder sql = new StringBuilder(" WHERE ");
for (Map.Entry entry : query.entrySet()) {
if (entry.getKey().contains(FindConfig.MIN_)) {
String min = humpToLine(entry.getKey()).replace("_min", "");
sql.append("`"+min+"`").append(" >= '").append(URLDecoder.decode(entry.getValue(), "UTF-8")).append("' and ");
continue;
}
if (entry.getKey().contains(FindConfig.MAX_)) {
String max = humpToLine(entry.getKey()).replace("_max", "");
sql.append("`"+max+"`").append(" <= '").append(URLDecoder.decode(entry.getValue(), "UTF-8")).append("' and ");
continue;
}
if (like == true) {
sql.append("`"+humpToLine(entry.getKey())+"`").append(" LIKE '%").append(URLDecoder.decode(entry.getValue(), "UTF-8")).append("%'").append(" and ");
} else {
sql.append("`"+humpToLine(entry.getKey())+"`").append(" = '").append(URLDecoder.decode(entry.getValue(), "UTF-8")).append("'").append(" and ");
}
}
sql.delete(sql.length() - 4, sql.length());
sql.append(" ");
return sql.toString();
} catch (UnsupportedEncodingException e) {
log.info("拼接sql 失败:{}", e.getMessage());
}
}
return "";
}
public Map readBody(BufferedReader reader){
BufferedReader br = null;
StringBuilder sb = new StringBuilder("");
try{
br = reader;
String str;
while ((str = br.readLine()) != null){
sb.append(str);
}
br.close();
String json = sb.toString();
return JSONObject.parseObject(json, Map.class);
}catch (IOException e){
e.printStackTrace();
}finally{
if (null != br){
try{
br.close();
}catch (IOException e){
e.printStackTrace();
}
}
}
return null;
}
public Map readQuery(HttpServletRequest request){
String queryString = request.getQueryString();
if (queryString != null && !"".equals(queryString)) {
String[] querys = queryString.split("&");
Map map = new HashMap<>();
for (String query : querys) {
String[] q = query.split("=");
map.put(q[0], q[1]);
}
map.remove(FindConfig.PAGE);
map.remove(FindConfig.SIZE);
map.remove(FindConfig.LIKE);
map.remove(FindConfig.ORDER_BY);
map.remove(FindConfig.FIELD);
map.remove(FindConfig.GROUP_BY);
map.remove(FindConfig.MAX_);
map.remove(FindConfig.MIN_);
return map;
}else {
return new HashMap<>();
}
}
public Map readConfig(HttpServletRequest request){
Map map = new HashMap<>();
map.put(FindConfig.PAGE,request.getParameter(FindConfig.PAGE));
map.put(FindConfig.SIZE,request.getParameter(FindConfig.SIZE));
map.put(FindConfig.LIKE,request.getParameter(FindConfig.LIKE));
map.put(FindConfig.ORDER_BY,request.getParameter(FindConfig.ORDER_BY));
map.put(FindConfig.FIELD,request.getParameter(FindConfig.FIELD));
map.put(FindConfig.GROUP_BY,request.getParameter(FindConfig.GROUP_BY));
map.put(FindConfig.MAX_,request.getParameter(FindConfig.MAX_));
map.put(FindConfig.MIN_,request.getParameter(FindConfig.MIN_));
return map;
}
public void importDb(MultipartFile file) throws IOException {
if (file.isEmpty()) {
return;
}
List
package com.project.demo.controller.base;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.project.demo.service.base.BaseService;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import javax.persistence.Query;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
*/
@Slf4j
public class BaseController> {
@Setter
protected S service;
@PostMapping("/add")
@Transactional
public Map add(HttpServletRequest request) throws IOException {
service.insert(service.readBody(request.getReader()));
return success(1);
}
@Transactional
public Map addMap(Map map){
service.insert(map);
return success(1);
}
@PostMapping("/set")
@Transactional
public Map set(HttpServletRequest request) throws IOException {
service.update(service.readQuery(request), service.readConfig(request), service.readBody(request.getReader()));
return success(1);
}
@RequestMapping(value = "/del")
@Transactional
public Map del(HttpServletRequest request) {
service.delete(service.readQuery(request), service.readConfig(request));
return success(1);
}
@RequestMapping("/get_obj")
public Map obj(HttpServletRequest request) {
Query select = service.select(service.readQuery(request), service.readConfig(request));
List resultList = select.getResultList();
if (resultList.size() > 0) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("obj",resultList.get(0));
return success(jsonObject);
} else {
return success(null);
}
}
@RequestMapping("/get_list")
public Map getList(HttpServletRequest request) {
Map map = service.selectToPage(service.readQuery(request), service.readConfig(request));
return success(map);
}
@RequestMapping("/list_group")
public Map listGroup(HttpServletRequest request) {
Map map = service.selectToList(service.readQuery(request), service.readConfig(request));
return success(map);
}
@RequestMapping("/bar_group")
public Map barGroup(HttpServletRequest request) {
Map map = service.selectBarGroup(service.readQuery(request), service.readConfig(request));
return success(map);
}
@RequestMapping(value = {"/count_group", "/count"})
public Map count(HttpServletRequest request) {
Query count = service.count(service.readQuery(request), service.readConfig(request));
return success(count.getResultList());
}
@RequestMapping(value = {"/sum_group", "/sum"})
public Map sum(HttpServletRequest request) {
Query count = service.sum(service.readQuery(request), service.readConfig(request));
return success(count.getResultList());
}
@RequestMapping(value = {"/avg_group", "/avg"})
public Map avg(HttpServletRequest request) {
Query count = service.avg(service.readQuery(request), service.readConfig(request));
return success(count.getResultList());
}
@PostMapping("/upload")
public Map upload(@RequestParam("file") MultipartFile file) {
log.info("进入方法");
if (file.isEmpty()) {
return error(30000, "没有选择文件");
}
try {
//判断有没路径,没有则创建
String filePath = System.getProperty("user.dir") + "\\target\\classes\\static\\upload\\";
File targetDir = new File(filePath);
if (!targetDir.exists() && !targetDir.isDirectory()) {
if (targetDir.mkdirs()) {
log.info("创建目录成功");
} else {
log.error("创建目录失败");
}
}
// String path = ResourceUtils.getURL("classpath:").getPath() + "static/upload/";
// String filePath = path.replace('/', '\\').substring(1, path.length());
String fileName = file.getOriginalFilename();
File dest = new File(filePath + fileName);
log.info("文件路径:{}", dest.getPath());
log.info("文件名:{}", dest.getName());
file.transferTo(dest);
JSONObject jsonObject = new JSONObject();
jsonObject.put("url", "/api/upload/" + fileName);
return success(jsonObject);
} catch (IOException e) {
log.info("上传失败:{}", e.getMessage());
}
return error(30000, "上传失败");
}
@PostMapping("/import_db")
public Map importDb(@RequestParam("file") MultipartFile file) throws IOException {
service.importDb(file);
return success(1);
}
@RequestMapping("/export_db")
public void exportDb(HttpServletRequest request, HttpServletResponse response) throws IOException {
HSSFWorkbook sheets = service.exportDb(service.readQuery(request), service.readConfig(request));
response.setContentType("application/octet-stream");
response.setHeader("Content-disposition", "attachment;filename=employee.xls");
response.flushBuffer();
sheets.write(response.getOutputStream());
sheets.close();
}
public Map success(Object o) {
Map map = new HashMap<>();
if (o == null) {
map.put("result", null);
return map;
}
if (o instanceof List) {
if (((List) o).size() == 1) {
o = ((List) o).get(0);
map.put("result", o);
}else {
String jsonString = JSONObject.toJSONString(o);
JSONArray objects = service.covertArray(JSONObject.parseArray(jsonString));
map.put("result", objects);
}
} else if (o instanceof Integer || o instanceof String) {
map.put("result", o);
} else {
String jsonString = JSONObject.toJSONString(o);
JSONObject jsonObject = JSONObject.parseObject(jsonString);
JSONObject j = service.covertObject(jsonObject);
map.put("result", j);
}
return map;
}
public Map error(Integer code, String message) {
Map map = new HashMap<>();
map.put("error", new HashMap(4) {{
put("code", code);
put("message", message);
}});
return map;
}
}
现在人们的生活节奏随着生活压力的增大越来越高,人们变得十分焦虑,不再有耐心等待。而计算机信息化技术有效应用,有效的解决人们对时空效率的要求,它的应用不断地渗入到各个邻域,比如像在医疗领域、教育方面等,信息化技术的使用确实给我们的生活带来很大的改变。比如就医疗领域方面来讲,以前我们很多医院就医生挂号大多都采用的是人工排队挂号的方式,这种方式不难浪费了患者的时间,也降低了就诊的效率,本就资源匮乏的医疗领域,则变的更加紧张,这不仅造成医院拥挤秩序混乱,更是拉动人力物力成本高。在线预约挂号系统则可以有效的解决这一问题,患者只需在家通过电脑访问挂号系统网站即可实现在线挂号,即方便患者,又节省医院资源,提高就诊效率,增加医院收入。