基于javaweb+mysql的springboot宠物医院预约管理系统设计和实现(java+springboot+mysql+ssm)
运行环境
Java≥8、MySQL≥5.7
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SpringBoot宠物医院预约管理系统设计和实现(java+springboot+mysql+ssm)
项目使用java SpringMVC、springboot mybatis、layui为核心技术编写
首页登录有可爱的小猫咪:
系统主页主要功能有会员信息、宠物管理、预约管理和统计分析等:
预约列表:
医院管理:
宠物档案管理:
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);
List<Standard> ssRows = ss.getRows();
double tsMin = 0;
double tsMax = 0;
double wsMin = 0;
double wsMax = 0;
double hsMin = 0;
double hsMax = 0;
double asMin = 0;
double asMax = 0;
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();
// 删除角色
boolean flag1 = roleService.delRoleById(id);
// 删除角色_权限表
boolean flag2 = pageRoleService.delPageRoleByRoleId(id);
// 删除某个角色的所有用户
boolean flag3 = userRoleService.delUserRoleByRoleId(id);
if (flag1 && flag2 && flag3) {
return "SUCCESS";
}
return "ERROR";
}
/**
* 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")
logger.error("删除异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
* 添加预约页面 user/applyAdd.html
*/
@RequestMapping(value = "/add")
public String addUserPage(Long id, Model model) {
model.addAttribute("petId", id);
return "user/applyAdd";
}
/**
* 预约信息插入数据库
*/
@RequestMapping(value = "/doAdd")
@ResponseBody
@Transactional
public String doAdd(Appointment appointment) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
if (appointment.getPetId() == null){
return "noPetId";
}
try {
// 当前预约人的id
appointment.setUserId(user.getId());
appointment.setCreateTime(new Date());
// 状态:1申请中,2申请通过,3不通过,4已完成
appointment.setStatus(1);
appointmentService.add(appointment);
return "SUCCESS";
} catch (Exception e) {
logger.error("添加异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
* 改变预约状态
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);
List<Standard> ssRows = ss.getRows();
double tsMin = 0;
double tsMax = 0;
double wsMin = 0;
double wsMax = 0;
double hsMin = 0;
double hsMax = 0;
double asMin = 0;
double asMax = 0;
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);
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";
}
/**
* 医生预约统计
*/
@RequestMapping("/tjApplyDoctor")
public String tjApplyDoctor(Model model) {
Appointment appointment = new Appointment();
appointment.setPage(1);
appointment.setLimit(99999);
MMGridPageVoBean<Appointment> voBean = (MMGridPageVoBean<Appointment>) appointmentService.getAllByLimit(appointment);
List<Appointment> rows = voBean.getRows();
Integer a1 = 0;
return "tj/tjDaily";
}
/**
* 医生宠物日志统计
*/
@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);
notice.setCreateTime(new Date());
notice.setViewCount(0L);
noticeService.add(notice);
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";
}
}
}
public Object getPageByRole(Integer roleId) {
return pageService.getAllPageByRoleId(roleId);
}
/**
* Method name: updatePageById <BR>
* Description: 根据页面id更新页面 <BR>
*
* @param page
* @return ResultMap<BR>
*/
@RequestMapping("/updatePageById")
@ResponseBody
public ResultMap updatePageById(Page page) {
return pageService.updatePageById(page);
}
/**
* Method name: addPage <BR>
* Description: 添加页面 <BR>
*
* @param page
* @return Page<BR>
*/
@RequestMapping("/addPage")
@ResponseBody
public Page addPage(Page page) {
return pageService.addPage(page);
}
/**
* Method name: delPageById <BR>
* Description: 根据页面id删除页面 <BR>
*
* @param id
* @return ResultMap<BR>
*/
@RequestMapping("/delPageById")
@ResponseBody
public ResultMap delPageById(Integer id) {
if (null == id) {
return new ResultMap().fail().message("参数错误");
}
}
/**
* 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;
@Autowired
private PageService pageService;
@Autowired
* 普通用户宠物健康史页面user/diagnosisList.html
*/
@RequestMapping("/diagnosisList")
public String diagnosisList(Long petId, Model model) {
if (petId!=null){
model.addAttribute("petId", petId);
}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";
}
}
}
/**
* 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>
* Description: 已删除用户列表 <BR>
*
* @return String<BR>
*/
@RequestMapping("/delUserPage")
public String delUserPage() {
return "sa/userDelPage";
}
}
switch (sw){
case 1:dsCount.add(p.getName() + " 宠物健康,请继续保持");break;
case 2:dsCount.add(p.getName() + " 宠物异常请及时就诊!");break;
case 3:dsCount.add(p.getName() + " 宠物病情比较严重,请及时就医!");break;
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);
List<Standard> ssRows = ss.getRows();
double tsMin = 0;
@RequestMapping("/applyList")
public String applyList(Long petId, Model model) {
if (petId!=null){
model.addAttribute("petId", petId);
}
return "user/applyList";
}
/**
* 普通用户返回查询数据渲染表格
*/
@RequestMapping("/getAllByLimit")
@ResponseBody
public Object getAllByLimit(Appointment appointment) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
appointment.setUserId(user.getId());
return appointmentService.getAllByLimit(appointment);
}
/**
* 医生角色返回查询数据渲染表格
*/
@RequestMapping("/getAllByLimitDoctor")
@ResponseBody
public Object getAllByLimitBaoJie(Appointment appointment) {
return appointmentService.getAllByLimit(appointment);
}
/**
* 根据id删除预约
*/
@RequestMapping(value = "/del")
@ResponseBody
@Transactional
public String delUser(Long id) {
try {
appointmentService.deleteById(id);
return "SUCCESS";
} catch (Exception e) {
logger.error("删除异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
private StandardService standardService;
/**
* 分析页面
*/
@RequestMapping("/assess")
public String applyListDoctor(Model model) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
Pet pet = new Pet();
pet.setUserId(user.getId());
pet.setPage(1);
pet.setLimit(100);
MMGridPageVoBean<Pet> voBean = (MMGridPageVoBean<Pet>) petService.getAllByLimit(pet);
List<Pet> rows = voBean.getRows();
// 获取到该用户下所有的宠物
model.addAttribute("pets", rows);
List<Long> applyCount = new ArrayList<>();
List<String> dsCount = new ArrayList<>();
List<String> tsCount = new ArrayList<>();
List<String> wsCount = new ArrayList<>();
List<String> hsCount = new ArrayList<>();
List<String> asCount = new ArrayList<>();
List<Double> pt = new ArrayList<>();
List<Double> pw = new ArrayList<>();
List<Double> ph = new ArrayList<>();
List<Double> pa = new ArrayList<>();
List<Double> mt = new ArrayList<>();
List<Double> mw = new ArrayList<>();
List<Double> mh = new ArrayList<>();
List<Double> ma = new ArrayList<>();
for(Pet p: rows){
// 获取预约次数
Appointment appointment = new Appointment();
appointment.setPetId(p.getId());
appointment.setPage(1);
appointment.setLimit(1000);
MMGridPageVoBean<Appointment> as = (MMGridPageVoBean<Appointment>) appointmentService.getAllByLimit(appointment);
applyCount.add(as==null? 0L : as.getTotal());
// 获取就诊记录
Diagnosis diagnosis = new Diagnosis();
diagnosis.setPetId(p.getId());
diagnosis.setPage(1);
diagnosis.setLimit(10);
MMGridPageVoBean<Diagnosis> ds = (MMGridPageVoBean<Diagnosis>) diagnosisService.getAllByLimit(diagnosis);
List<Diagnosis> dsRows = ds.getRows();
}
}
/**
* Method name: main <BR>
* Description: 进入主页面 <BR>
* index.html
*/
@RequestMapping(value = "/main")
public String main(Model model) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
if (null != user) {
model.addAttribute("user", user);
} else {
return "login";
}
List<Page> pageList = pageService.getAllRolePageByUserId(user.getId()+"");
model.addAttribute("pageList", pageList);
return "index";
}
/**
* Method name: checkUserPassword <BR>
* Description: 检测旧密码是否正确 <BR>
*
* @param password 旧密码
* @return boolean 是否正确<BR>
*/
@RequestMapping(value = "/user/checkUserPassword")
@ResponseBody
public boolean checkUserPassword(String password) {
return userService.checkUserPassword(password);
}
/**
* Method name: updatePassword <BR>
* Description: 更新密码 <BR>
*
* @param password 旧密码
* @return String 是否成功<BR>
*/
@RequestMapping(value = "/user/updatePassword")
@ResponseBody
public String updatePassword(String password) {
List<PetDaily> list = ppp.getRows();
for (PetDaily p : list){
p.setDateTime(MyUtils.getDate2String(p.getCreateTime(), "yyyy-MM-dd"));
}
return list;
}
/**
* 用户查看医生空闲时间
*/
@RequestMapping(value = "/freeTime")
public String freeTime(Model model) {
List<User> doctors = userService.listDoctor();
model.addAttribute("doctors", doctors);
Long docId = doctors.get(0).getId();
model.addAttribute("docName", doctors.get(0).getName());
String nowDateYMD = MyUtils.getNowDateYMD();
List<Map<String, Object>> map = appointmentService.getFreeTimeById(docId, nowDateYMD+MyUtils.START_HOUR);
List<String> time = new ArrayList<>();
List<Long> value = new ArrayList<>();
for (Map<String, Object> m : map){
String df = (String) m.get("df");
time.add(df);
Long v = (Long) m.get("c");
if (v == null) {
value.add(0L);
}else {
value.add(v);
}
}
model.addAttribute("time", time);
model.addAttribute("value", value);
return "tj/freeTime";
}
@RequestMapping(value = "/getFreeTime")
@ResponseBody
public Object getFreeTime(Long id, String date) {
User doctors = userService.selectByPrimaryKey(id);
Map<String, Object> result = new HashMap<>();
result.put("n", doctors.getName());
List<Map<String, Object>> map = appointmentService.getFreeTimeById(id, date+MyUtils.START_HOUR);
List<String> time = new ArrayList<>();
* Method name: checkUserPassword <BR>
* Description: 检测旧密码是否正确 <BR>
*
* @param password 旧密码
* @return boolean 是否正确<BR>
*/
@RequestMapping(value = "/user/checkUserPassword")
@ResponseBody
public boolean checkUserPassword(String password) {
return userService.checkUserPassword(password);
}
/**
* Method name: updatePassword <BR>
* Description: 更新密码 <BR>
*
* @param password 旧密码
* @return String 是否成功<BR>
*/
@RequestMapping(value = "/user/updatePassword")
@ResponseBody
public String updatePassword(String password) {
return userService.updatePassword(password);
}
}
} catch (Exception e) {
logger.error("删除异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}
/**
* 添加页面user/petDailyAdd.html
*/
@RequestMapping(value = "/add")
public String add(Model model) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
Pet pet = new Pet();
pet.setUserId(user.getId());
pet.setPage(1);
pet.setLimit(100);
MMGridPageVoBean<Pet> voBean = (MMGridPageVoBean<Pet>) petService.getAllByLimit(pet);
List<Pet> rows = voBean.getRows();
// 获取到该用户下所有的宠物
model.addAttribute("pets", rows);
return "user/petDailyAdd";
}
/**
* 插入数据库
*/
@RequestMapping(value = "/doAdd")
@ResponseBody
@Transactional
public String doAdd(PetDaily pojo) {
Subject subject = SecurityUtils.getSubject();
User user = (User) subject.getPrincipal();
try {
pojo.setUserId(user.getId());
pojo.setCreateTime(new Date());
petDailyService.add(pojo);
return "SUCCESS";
} catch (Exception e) {
logger.error("添加异常", e);
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return "ERROR";
}
}