摘要
时代在飞速进步, 每个行业都在努力发展现在先进技术,通过这些先进的技术来提高自己的水平和优势,智慧养老中心管理系统当然不能排除在外。智慧养老中心管理系统是在实际应用和软件工程的开发原理之上,运用Java语言以及SpringBoot+vue框架开发的一个管理系统。在开发过程中首先要对系统进行需求分析,分析出智慧养老中心管理系统的主要功能,再对系统结构进行整体设计和详细设计。整体设计主要有系统功能、系统总体结构、系统数据结构和系统安全等设计;过程的最后再对系统进行测试,并对测试结果进行分析和总结,为今后的系统维护提供了方便,同时也为今后类似系统的开发提供了参考和帮助。这种个性化的在线系统管理特别注重相互协调和管理合作,它激发了管理者的创造力和主动性,这对智慧养老中心管理系统来说非常有益。
研究意义
智慧养老中心管理系统主要通过计算机网络,对智慧养老中心管理系统所需的信息进行统一管理,方便用户随时随地进行增添、修改、查询、删除各类信息。本系统极大的促进了系统与数据库管理系统软件之间的配合,满足了绝大部分用户的需求,给用户带来了很大的便利。以现在计算机的技术的应用,使计算机成为人们使用现代发达技术的桥梁。计算机可以有效的解决信息,十分方便的获取信息,从而提高工作的效率。全球经济在快速的发展,中国更是进步飞速,这使得国内的互联网技术进入了发展的高峰时期,这让中外资本不断转向互联网这个大市场。在这个信息高度发达的现在,利用网络进行信息管理改革已经成为了人们追捧的一种趋势。“智慧养老中心管理系统”是运用java语言和MySQL数据库为基础而发出来的。为保证我国经济的持续性发展,必须要让互联网信息时代在我国日益壮大,蓬勃发展。伴随着信息社会的飞速发展,智慧养老中心管理系统所面临的问题也一个接一个的出现,所以现在最该解决的问题就是信息的实时查询和访问需求的问题,以及如何利用快捷便利的方式让访问者在广大信息系统中进行查询、分享、储存和管理。这对我们的现实生活中具有非常重要的意义,所以智慧养老中心管理系统诞生了。
研究现状
现在还有许多人用纸质工具存储并管理信息,网络仅仅起到一般的辅助性作用。以我对人们常用软件的了解程度,大家仍然把传统的Office软件当成主要工具,智慧养老中心管理系统相比Office软件来说会更全面更专业。本系统通过标签分类等方式,使管理人员对各项功能信息实现高效的管理,可以极大的提高管理人员的工作效率。本智慧养老中心管理系统是为了提高用户查阅信息的效率和管理人员管理信息的工作效率,可以快速存储大量数据,还有信息检索功能,这大大的满足了老人信息和管理员这两者的需求。操作简单易懂,合理分析各个模块的功能,尽可能优化界面,让老人信息和管理员能使用环境更好的系统。对比要实现的功能来分析出老人的需求,可以让老人在线对其进行添加、修改、查看、删除,这不仅满足了老人的需求,还大大的节省了时间。因此,管理员的需求也应当考虑一下,尽可能提高管理员的工作效率。
功能展示
前台
后台
代码展示
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("/jiaolian")
public class JiaolianController {
private static final Logger logger = LoggerFactory.getLogger(JiaolianController.class);
@Autowired
private JiaolianService jiaolianService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private YonghuService yonghuService;
/**
* 后端列表
*/
@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("yonghuId",request.getSession().getAttribute("userId"));
else if("教练".equals(role))
params.put("jiaolianId",request.getSession().getAttribute("userId"));
params.put("jiaolianDeleteStart",1);params.put("jiaolianDeleteEnd",1);
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = jiaolianService.queryPage(params);
//字典表数据转换
List<JiaolianView> list =(List<JiaolianView>)page.getList();
for(JiaolianView 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);
JiaolianEntity jiaolian = jiaolianService.selectById(id);
if(jiaolian !=null){
//entity转view
JiaolianView view = new JiaolianView();
BeanUtils.copyProperties( jiaolian , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,jiaolian:{}",this.getClass().getName(),jiaolian.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<JiaolianEntity> queryWrapper = new EntityWrapper<JiaolianEntity>()
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.andNew()
.eq("jiaolian_delete", 1)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JiaolianEntity jiaolianEntity = jiaolianService.selectOne(queryWrapper);
if(jiaolianEntity==null){
jiaolian.setJiaolianDelete(1);
jiaolian.setCreateTime(new Date());
jiaolian.setPassword("123456");
jiaolianService.insert(jiaolian);
return R.ok();
}else {
return R.error(511,"账户或者教练手机号已经被使用");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,jiaolian:{}",this.getClass().getName(),jiaolian.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有相同数据
Wrapper<JiaolianEntity> queryWrapper = new EntityWrapper<JiaolianEntity>()
.notIn("id",jiaolian.getId())
.andNew()
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.andNew()
.eq("jiaolian_delete", 1)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JiaolianEntity jiaolianEntity = jiaolianService.selectOne(queryWrapper);
if("".equals(jiaolian.getJiaolianPhoto()) || "null".equals(jiaolian.getJiaolianPhoto())){
jiaolian.setJiaolianPhoto(null);
}
if(jiaolianEntity==null){
jiaolianService.updateById(jiaolian);//根据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());
ArrayList<JiaolianEntity> list = new ArrayList<>();
for(Integer id:ids){
JiaolianEntity jiaolianEntity = new JiaolianEntity();
jiaolianEntity.setId(id);
jiaolianEntity.setJiaolianDelete(2);
list.add(jiaolianEntity);
}
if(list != null && list.size() >0){
jiaolianService.updateBatchById(list);
}
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
try {
List<JiaolianEntity> jiaolianList = 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){
//循环
JiaolianEntity jiaolianEntity = new JiaolianEntity();
// jiaolianEntity.setUsername(data.get(0)); //账户 要改的
// //jiaolianEntity.setPassword("123456");//密码
// jiaolianEntity.setJiaolianName(data.get(0)); //教练姓名 要改的
// jiaolianEntity.setJiaolianPhoto("");//照片
// jiaolianEntity.setJiaolianPhone(data.get(0)); //教练手机号 要改的
// jiaolianEntity.setJiaolianShanchangxiangmnu(data.get(0)); //擅长项目 要改的
// jiaolianEntity.setJiaolianSuodejiangxiang(data.get(0)); //所得奖项 要改的
// jiaolianEntity.setJiaolianEmail(data.get(0)); //邮箱 要改的
// jiaolianEntity.setSexTypes(Integer.valueOf(data.get(0))); //性别 要改的
// jiaolianEntity.setJiaolianDelete(1);//逻辑删除字段
// jiaolianEntity.setCreateTime(date);//时间
jiaolianList.add(jiaolianEntity);
//把要查询是否重复的字段放入map中
//账户
if(seachFields.containsKey("username")){
List<String> username = seachFields.get("username");
username.add(data.get(0));//要改的
}else{
List<String> username = new ArrayList<>();
username.add(data.get(0));//要改的
seachFields.put("username",username);
}
//教练手机号
if(seachFields.containsKey("jiaolianPhone")){
List<String> jiaolianPhone = seachFields.get("jiaolianPhone");
jiaolianPhone.add(data.get(0));//要改的
}else{
List<String> jiaolianPhone = new ArrayList<>();
jiaolianPhone.add(data.get(0));//要改的
seachFields.put("jiaolianPhone",jiaolianPhone);
}
}
//查询是否重复
//账户
List<JiaolianEntity> jiaolianEntities_username = jiaolianService.selectList(new EntityWrapper<JiaolianEntity>().in("username", seachFields.get("username")).eq("jiaolian_delete", 1));
if(jiaolianEntities_username.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(JiaolianEntity s:jiaolianEntities_username){
repeatFields.add(s.getUsername());
}
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
}
//教练手机号
List<JiaolianEntity> jiaolianEntities_jiaolianPhone = jiaolianService.selectList(new EntityWrapper<JiaolianEntity>().in("jiaolian_phone", seachFields.get("jiaolianPhone")).eq("jiaolian_delete", 1));
if(jiaolianEntities_jiaolianPhone.size() >0 ){
ArrayList<String> repeatFields = new ArrayList<>();
for(JiaolianEntity s:jiaolianEntities_jiaolianPhone){
repeatFields.add(s.getJiaolianPhone());
}
return R.error(511,"数据库的该表中的 [教练手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
jiaolianService.insertBatch(jiaolianList);
return R.ok();
}
}
}
}catch (Exception e){
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
/**
* 登录
*/
@IgnoreAuth
@RequestMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
JiaolianEntity jiaolian = jiaolianService.selectOne(new EntityWrapper<JiaolianEntity>().eq("username", username));
if(jiaolian==null || !jiaolian.getPassword().equals(password))
return R.error("账号或密码不正确");
else if(jiaolian.getJiaolianDelete() != 1)
return R.error("账户已被删除");
// // 获取监听器中的字典表
// ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
// Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
// Map<Integer, String> role_types = dictionaryMap.get("role_types");
// role_types.get(.getRoleTypes());
String token = tokenService.generateToken(jiaolian.getId(),username, "jiaolian", "教练");
R r = R.ok();
r.put("token", token);
r.put("role","教练");
r.put("username",jiaolian.getJiaolianName());
r.put("tableName","jiaolian");
r.put("userId",jiaolian.getId());
return r;
}
/**
* 注册
*/
@IgnoreAuth
@PostMapping(value = "/register")
public R register(@RequestBody JiaolianEntity jiaolian){
// ValidatorUtils.validateEntity(user);
Wrapper<JiaolianEntity> queryWrapper = new EntityWrapper<JiaolianEntity>()
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.andNew()
.eq("jiaolian_delete", 1)
;
JiaolianEntity jiaolianEntity = jiaolianService.selectOne(queryWrapper);
if(jiaolianEntity != null)
return R.error("账户或者教练手机号已经被使用");
jiaolian.setJiaolianDelete(1);
jiaolian.setCreateTime(new Date());
jiaolianService.insert(jiaolian);
return R.ok();
}
/**
* 重置密码
*/
@GetMapping(value = "/resetPassword")
public R resetPassword(Integer id){
JiaolianEntity jiaolian = new JiaolianEntity();
jiaolian.setPassword("123456");
jiaolian.setId(id);
jiaolianService.updateById(jiaolian);
return R.ok();
}
/**
* 忘记密码
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request) {
JiaolianEntity jiaolian = jiaolianService.selectOne(new EntityWrapper<JiaolianEntity>().eq("username", username));
if(jiaolian!=null){
jiaolian.setPassword("123456");
boolean b = jiaolianService.updateById(jiaolian);
if(!b){
return R.error();
}
}else{
return R.error("账号不存在");
}
return R.ok();
}
/**
* 获取用户的session用户信息
*/
@RequestMapping("/session")
public R getCurrJiaolian(HttpServletRequest request){
Integer id = (Integer)request.getSession().getAttribute("userId");
JiaolianEntity jiaolian = jiaolianService.selectById(id);
if(jiaolian !=null){
//entity转view
JiaolianView view = new JiaolianView();
BeanUtils.copyProperties( jiaolian , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 退出
*/
@GetMapping(value = "logout")
public R logout(HttpServletRequest request) {
request.getSession().invalidate();
return R.ok("退出成功");
}
/**
* 前端列表
*/
@IgnoreAuth
@RequestMapping("/list")
public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
// 没有指定排序字段就默认id倒序
if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){
params.put("orderBy","id");
}
PageUtils page = jiaolianService.queryPage(params);
//字典表数据转换
List<JiaolianView> list =(List<JiaolianView>)page.getList();
for(JiaolianView c:list)
dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段
return R.ok().put("data", page);
}
/**
* 前端详情
*/
@RequestMapping("/detail/{id}")
public R detail(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
JiaolianEntity jiaolian = jiaolianService.selectById(id);
if(jiaolian !=null){
//entity转view
JiaolianView view = new JiaolianView();
BeanUtils.copyProperties( jiaolian , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 前端保存
*/
@RequestMapping("/add")
public R add(@RequestBody JiaolianEntity jiaolian, HttpServletRequest request){
logger.debug("add方法:,,Controller:{},,jiaolian:{}",this.getClass().getName(),jiaolian.toString());
Wrapper<JiaolianEntity> queryWrapper = new EntityWrapper<JiaolianEntity>()
.eq("username", jiaolian.getUsername())
.or()
.eq("jiaolian_phone", jiaolian.getJiaolianPhone())
.andNew()
.eq("jiaolian_delete", 1)
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
JiaolianEntity jiaolianEntity = jiaolianService.selectOne(queryWrapper);
if(jiaolianEntity==null){
jiaolian.setJiaolianDelete(1);
jiaolian.setCreateTime(new Date());
jiaolian.setPassword("123456");
jiaolianService.insert(jiaolian);
return R.ok();
}else {
return R.error(511,"账户或者教练手机号已经被使用");
}
}
}