基于javaweb+mysql的springboot体检管理系统(java+springboot+thymeleaf+layui+html+mysql)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot体检管理系统(java+springboot+thymeleaf+layui+html+mysql)
分为:管理员、医生、体检人
体检人预约-管理员审核-医生问诊
项目介绍:
登录、注册、用户管理、角色管理、体检人管理、体检健康史、体检人档案、体检中心管理
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目:是;
技术栈
JSP +SpringBoot + MyBatis + html+ css + JavaScript + JQuery + Ajax + layui+ maven等等
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中springmvc-servlet.xml配置文件中的数据库配置改为自己的配置; 4. 运行项目
return diagnosisService.getAllByLimit(diagnosis);
}
/**
* 删除记录
*/
@RequestMapping(value = "/del")
@ResponseBody
@Transactional
public String del(Long id) {
try {
diagnosisService.deleteById(id);
return "SUCCESS";
} catch (Exception e) {
logger.error("删除异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
* 增加页面user/diagnosisAdd.html
*/
@RequestMapping(value = "/add")
public String add(Long id, Model model) {
Appointment byId = appointmentService.getById(id);
model.addAttribute("userId", byId.getUserId());
model.addAttribute("petId", byId.getPetId());
return "user/diagnosisAdd";
}
/**
* 插入数据库
*/
@RequestMapping(value = "/doAdd")
@ResponseBody
@Transactional
public String doAdd(Diagnosis diagnosis) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
try {
// 医生登录id
diagnosis.setDoctorId(user.getId());
diagnosis.setCreateTime(new Date());
// 状态:1申请中,2申请通过,3不通过,4已完成
diagnosis.setStatus(1);
diagnosisService.add(diagnosis);
return "SUCCESS";
} catch (Exception e) {
logger.error("添加异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
for (Standard s : ssRows){
tsMin+=s.getTempMin();
tsMax+=s.getTempMax();
wsMin+=s.getWeightMin();
wsMax+=s.getWeightMax();
hsMin+=s.getHeightMin();
hsMax+=s.getHeightMax();
asMin+=s.getAppetiteMin();
asMax+=s.getAppetiteMax();
}
tsMin = tsMin / ssRows.size();
tsMax = tsMax / ssRows.size();
wsMin = wsMin / ssRows.size();
wsMax = wsMax / ssRows.size();
hsMin = hsMin / ssRows.size();
hsMax = hsMax / ssRows.size();
asMin = asMin / ssRows.size();
asMax = asMax / ssRows.size();
mt.add(tsMax);
mw.add(wsMax);
mh.add(hsMax);
ma.add(asMax);
if (t>=tsMin && t<=tsMax){
tsCount.add(" 体温正常");
}else if (t<tsMin){
tsCount.add( " 体温偏低");
}else if (t>tsMax){
tsCount.add( " 体温偏高");
}
if (w>=wsMin && w<=wsMax){
wsCount.add( " 体重正常");
}else if (w<wsMin){
wsCount.add(" 体重偏低");
}else if (w>wsMax){
wsCount.add(" 体重偏高");
}
if (h>=hsMin && h<=hsMax){
hsCount.add(" 身高正常");
}else if (h<hsMin){
hsCount.add( " 身高偏低");
}else if (h>hsMax){
hsCount.add(" 身高偏高");
}
model.addAttribute("mw", mw);
model.addAttribute("ma", ma);
return "tj/assess";
}
/**
* 普通用户预约统计
*/
@RequestMapping("/tjApply")
public String tjApply(Model model) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
Appointment appointment = new Appointment();
appointment.setUserId(user.getId());
appointment.setPage(1);
appointment.setLimit(99999);
MMGridPageVoBean<Appointment> voBean = (MMGridPageVoBean<Appointment>) appointmentService.getAllByLimit(appointment);
List<Appointment> rows = voBean.getRows();
Integer a1 = 0;
Integer a2 = 0;
Integer a3 = 0;
Integer a4 = 0;
for (Appointment a: rows){
switch (a.getStatus()){
case 1: a1++;break;
case 2: a2++;break;
case 3: a3++;break;
case 4: a4++;break;
}
}
model.addAttribute("a1", a1);
model.addAttribute("a2", a2);
model.addAttribute("a3", a3);
model.addAttribute("a4", a4);
return "tj/tjApply";
}
/**
/**
* Method name: updateRole <BR>
* Description: 根据权限id修改权限信息 <BR>
*
* @param id
* @param name
* @return String<BR>
*/
@RequestMapping("/updateRole")
@ResponseBody
public String updateRole(Integer id, String name) {
int n = roleService.updateRoleById(id, name);
if (n != 0) {
return "SUCCESS";
}
return "ERROR";
}
/**
* Method name: addPageRoleByRoleId <BR>
* Description: 增加某个角色的权限页面 <BR>
*
* @param roleId
* @param pageIds
* @return String<BR>
*/
@RequestMapping("/addPageRoleByRoleId")
@ResponseBody
public String addPageRoleByRoleId(Integer roleId, Integer[] pageIds) {
if (null == roleId) {
return "ERROR";
}
// 先删除老的权限
boolean flag1 = pageRoleService.delPageRoleByRoleId(roleId);
boolean flag2 = pageRoleService.addPageRoles(roleId, pageIds);
if (flag1 && flag2) {
return "SUCCESS";
}
return "ERROR";
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
}
/**
* 体检日志
*/
@Controller("UserPetDailyController")
@RequestMapping("/user/petDaily")
public class UserPetDailyController {
@Autowired
private PetDailyService petDailyService;
@Autowired
private PetService petService;
private final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
* 医生体检日志页面user/petDailyListDoctor.html
*/
@RequestMapping("/petDailyListDoctor")
public String petListDoctor(Long petId, Model model) {
if (petId!=null){
model.addAttribute("petId", petId);
}else {
model.addAttribute("petId", "petId");
}
return "user/petDailyListDoctor";
/**
* 管理员权限控制类
*/
@Controller("Admin")
@RequestMapping("/admin")
public class Adminontroller {
@Autowired
private PageService pageService;
@Autowired
private RoleService roleService;
@Autowired
private PageRoleService pageRoleService;
@Autowired
private UserRoleService userRoleService;
@Autowired
private UserService userService;
private final Logger logger = LoggerFactory.getLogger(Adminontroller.class);
/**
* Method name: page <BR>
* Description: 跳转到页面设置页面 <BR>
*
* @param model
* @return String<BR>
*/
@RequestMapping("/page")
public String page(Model model) {
List<Page> pageList = pageService.getAllPage();
model.addAttribute("pageList", pageList);
return "sa/page";
}
/**
case 4:dsCount.add(p.getName() + " 很抱歉体检已无法治疗!");break;
default:dsCount.add(p.getName() + " 体检基本健康,请继续保持");break;
}
// 获取体检日志
PetDaily petDaily = new PetDaily();
petDaily.setPetId(p.getId());
petDaily.setPage(1);
petDaily.setLimit(10);
MMGridPageVoBean<PetDaily> ps = (MMGridPageVoBean<PetDaily>) petDailyService.getAllByLimit(petDaily);
List<PetDaily> psRows = ps.getRows();
double t = 0;
double w = 0;
double h = 0;
double a = 0;
for (PetDaily petDaily1 : psRows){
t+=petDaily1.getTemperature();
w+=petDaily1.getWeight();
h+=petDaily1.getHeight();
a+=petDaily1.getAppetite();
}
t = t/psRows.size();
w = w/psRows.size();
h = h/psRows.size();
a = a/psRows.size();
pt.add(t);
pw.add(w);
ph.add(h);
pa.add(a);
// 获取标准
Standard standard = new Standard();
// 对应体检类型
standard.setType(p.getType());
// 健康标准
standard.setStatus(1);
int petAge = MyUtils.get2DateDay(MyUtils.getDate2String(p.getBirthday(), "yyyy-MM-dd"), MyUtils.getDate2String(new Date(), "yyyy-MM-dd"));
petAge = (petAge<0? -petAge : petAge)/365;
// 年龄
standard.setAgeMax(petAge);
standard.setPage(1);
standard.setLimit(100);
MMGridPageVoBean<Standard> ss = (MMGridPageVoBean<Standard>) standardService.getAllByLimit(standard);
*/
@RequestMapping("/getAllByLimit")
@ResponseBody
public Object getAllByLimit(Pet pojo) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
pojo.setUserId(user.getId());
return petService.getAllByLimit(pojo);
}
/**
* 医生返回查询数据
*/
@RequestMapping("/getAllByLimitDoctor")
@ResponseBody
public Object getAllByLimitDoctor(Pet pojo) {
return petService.getAllByLimit(pojo);
}
/**
* 删除体检
*/
@RequestMapping(value = "/del")
@ResponseBody
@Transactional
public String del(Long id, Long type) {
if (type!=null && type ==2){
return "app";
}
try {
petService.deleteById(id);
return "SUCCESS";
} catch (Exception e) {
logger.error("删除异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
* 添加体检页面user/petAdd.html
*/
@RequestMapping(value = "/add")
}
/**演示页面**/
/**
* Method name: logout <BR>
* Description: 退出登录 <BR>
* @return String<BR>
*/
@RequestMapping(value = "/logout", method = RequestMethod.GET)
public String logout() {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
if (null != user) {
logger.info("{}---退出登录!", user.getName());
}
subject.logout();
return "login";
}
/**
* Method name: login <BR>
* Description: 登录验证 <BR>
* Remark: <BR>
*
* @param username 用户名
* @param password 密码
* @return ResultMap<BR>
*/
@RequestMapping(value = "/login")
@ResponseBody
public ResultMap login(String username, String password) {
return userService.login(username, password);
}
/**
* Method name: login <BR>
* Description: 登录页面 <BR>
*
* @return String login.html<BR>
*/
@RequestMapping(value = "/index")
public String login() {
return "login";
}
/**
* 注册页面 regist.html
*/
@RequestMapping(value = "/regist")
public String regist() {
@ResponseBody
public Object getAllByLimit(Diagnosis diagnosis) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
diagnosis.setUserId(user.getId());
return diagnosisService.getAllByLimit(diagnosis);
}
/**
* 医生返回查询数据
*/
@RequestMapping("/getAllByLimitDoctor")
@ResponseBody
public Object getAllByLimitBaoJie(Diagnosis diagnosis) {
return diagnosisService.getAllByLimit(diagnosis);
}
/**
* 删除记录
*/
@RequestMapping(value = "/del")
@ResponseBody
@Transactional
public String del(Long id) {
try {
diagnosisService.deleteById(id);
return "SUCCESS";
} catch (Exception e) {
logger.error("删除异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
* 增加页面user/diagnosisAdd.html
*/
@RequestMapping(value = "/add")
public String add(Long id, Model model) {
Appointment byId = appointmentService.getById(id);
model.addAttribute("userId", byId.getUserId());
model.addAttribute("petId", byId.getPetId());
return "user/diagnosisAdd";
}
/**
* 插入数据库
* @param user
* @return String<BR>
*/
@ResponseBody
@RequestMapping("/updateUser")
public String updateUser(User user, Long oldId) {
return userService.updateUser(oldId, user);
}
/**
* Method name: delUserPage <BR>
* Description: 已删除用户列表 <BR>
*
* @return String<BR>
*/
@RequestMapping("/delUserPage")
public String delUserPage() {
return "sa/userDelPage";
}
}
/**
* 登录控制类
*/
@Controller("OpenLogin")
@RequestMapping()
public class LoginController {
@Autowired
private ResultMap resultMap;
@Autowired
private UserService userService;
}else {
model.addAttribute("petId", "petId");
}
return "user/diagnosisList";
}
/**
* 普通用户返回查询数据
*/
@RequestMapping("/getAllByLimit")
@ResponseBody
public Object getAllByLimit(Diagnosis diagnosis) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
diagnosis.setUserId(user.getId());
return diagnosisService.getAllByLimit(diagnosis);
}
/**
* 医生返回查询数据
*/
@RequestMapping("/getAllByLimitDoctor")
@ResponseBody
public Object getAllByLimitBaoJie(Diagnosis diagnosis) {
return diagnosisService.getAllByLimit(diagnosis);
}
/**
* 删除记录
*/
@RequestMapping(value = "/del")
@ResponseBody
@Transactional
public String del(Long id) {
try {
diagnosisService.deleteById(id);
return "SUCCESS";
} catch (Exception e) {
logger.error("删除异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
* 增加页面user/diagnosisAdd.html
public String logout() {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
if (null != user) {
logger.info("{}---退出登录!", user.getName());
}
subject.logout();
return "login";
}
/**
* Method name: login <BR>
* Description: 登录验证 <BR>
* Remark: <BR>
*
* @param username 用户名
* @param password 密码
* @return ResultMap<BR>
*/
@RequestMapping(value = "/login")
@ResponseBody
public ResultMap login(String username, String password) {
return userService.login(username, password);
}
/**
* Method name: login <BR>
* Description: 登录页面 <BR>
*
* @return String login.html<BR>
*/
@RequestMapping(value = "/index")
public String login() {
return "login";
}
/**
* 注册页面 regist.html
*/
@RequestMapping(value = "/regist")
public String regist() {
return "regist";
}
/**
* 注册
*/
@RequestMapping(value = "/doRegist")
@ResponseBody
String suffixName = fileName.substring(fileName.lastIndexOf(".")); // 后缀名
String filePath = "D://upload//"; // 上传后的路径
fileName = UUID.randomUUID() + suffixName; // 新文件名
FileResponse fileResponse = new FileResponse();
File dest = new File(filePath + fileName);
if (!dest.getParentFile().exists()) {
dest.getParentFile().mkdirs();
}
try {
file.transferTo(dest);
out = response.getWriter();
String filename = "/file/" + fileName;
String s = fileResponse.success(1, fileName, filename, null);
// 返回"图像"选项卡并显示图片 request.getContextPath()为web项目名
out.println(s);
} catch (IOException e) {
String s = fileResponse.error(0, "上传失败!");
// 返回"图像"选项卡并显示图片 request.getContextPath()为web项目名
out.println(s);
}
}
@RequestMapping(value = "/layuiUpload", method = RequestMethod.POST)
@ResponseBody
public void layuiUpload(MultipartFile file,
HttpServletRequest request, HttpServletResponse response){
if (file.isEmpty()) {
System.out.println("文件为空空");
}
PrintWriter out=null;
// CKEditor提交的很重要的一个参数 ,回调函数的序号
String callback = request.getParameter("CKEditorFuncNum");
String fileName = file.getOriginalFilename(); // 文件名
String suffixName = fileName.substring(fileName.lastIndexOf(".")); // 后缀名
String filePath = "D://upload//"; // 上传后的路径
fileName = UUID.randomUUID() + suffixName; // 新文件名
FileResponse fileResponse = new FileResponse();
File dest = new File(filePath + fileName);
if (!dest.getParentFile().exists()) {
dest.getParentFile().mkdirs();
}
try {
file.transferTo(dest);
out = response.getWriter();
String filename = "/file/" + fileName;
String s = fileResponse.success(1, fileName, filename, null);
// 返回"图像"选项卡并显示图片 request.getContextPath()为web项目名
return "SUCCESS";
} catch (Exception e) {
e.printStackTrace();
return "ERR";
}
}
/**
* 获取所有指南数据
*/
@RequestMapping("/getAllWordByLimit")
@ResponseBody
public Object getAllWordByLimit(Notice word) {
return noticeService.getAllByLimit(word);
}
/**
* 删除指南
*/
@ResponseBody
@RequestMapping("/delWord")
public String delWord(String[] ids) {
try {
for (String id : ids){
noticeService.deleteById(Long.parseLong(id));
}
return "SUCCESS";
} catch (Exception e) {
e.printStackTrace();
return "ERR";
}
}
}
/**
* 用户控制
*/
@Controller("User")
@RequestMapping("/user")
return userService.selectByPrimaryKey(userId);
}
/**
* Method name: addUser <BR>
* Description: 用户添加 <BR>
*
* @param user
* @return String<BR>
*/
@ResponseBody
@RequestMapping("/addUser")
public String addUser(User user) {
try {
user.setPassword(MD5.md5(user.getPassword()));
user.setCreateTime(new Date());
userService.addUser(user);
User u = userService.getUserByPhoneAndName(user.getPhone(), user.getName());
String[] ids = new String[1];
ids[0] = u.getId()+"";
// 医生角色
userRoleService.addUserRole(3, ids);
return "SUCCESS";
} catch (Exception e) {
return "ERR";
}
}
/**
* Method name: updateUser <BR>
* Description: 更新用户 <BR>
*
* @param user
* @return String<BR>
*/
@ResponseBody
@RequestMapping("/updateUser")
public String updateUser(User user, Long oldId) {
return userService.updateUser(oldId, user);
}
/**
* Method name: delUserPage <BR>
*/
@RequestMapping("/tjDailyDoctor")
public String tjDailyDoctor(Model model) {
Pet pet = new Pet();
pet.setPage(1);
pet.setLimit(99999);
MMGridPageVoBean<Pet> voBean = (MMGridPageVoBean<Pet>) petService.getAllByLimit(pet);
List<Pet> rows = voBean.getRows();
model.addAttribute("pets", rows);
if (rows.size()>0){
pet = rows.get(0);
PetDaily daily = new PetDaily();
daily.setPetId(pet.getId());
daily.setPage(1);
daily.setLimit(99999);
MMGridPageVoBean<PetDaily> ppp = (MMGridPageVoBean<PetDaily>) petDailyService.getAllByLimit(daily);
List<PetDaily> list = ppp.getRows();
for (PetDaily p : list){
p.setDateTime(MyUtils.getDate2String(p.getCreateTime(), "yyyy-MM-dd"));
}
model.addAttribute("dailys", list);
}
return "tj/tjDailyDoctor";
}
/**
* 普通用户查询条件数据返回体检日志
*/
@RequestMapping("/tjDailyData")
@ResponseBody
public Object tjDailyData(Long id){
PetDaily daily = new PetDaily();
daily.setPetId(id);
daily.setPage(1);
daily.setLimit(99999);
MMGridPageVoBean<PetDaily> ppp = (MMGridPageVoBean<PetDaily>) petDailyService.getAllByLimit(daily);
List<PetDaily> list = ppp.getRows();
for (PetDaily p : list){
p.setDateTime(MyUtils.getDate2String(p.getCreateTime(), "yyyy-MM-dd"));
}
return list;
}
/**
* 医生查询条件数据返回体检日志
*/
@RequestMapping("/tjDailyDataDoctor")
@ResponseBody
public Object tjDailyDataDoctor(Long id){