当前位置:   article > 正文

Java项目:springboot私人牙医管理系统_java springboot docor

java springboot docor

作者主页:源码空间站2022

 简介:Java领域优质创作者、Java项目、学习资料、技术互助

文末获取源码

项目介绍

私人牙医管理系统。该项目分为前后台,共三种角色:管理员、医生、客户;

前台主要功能包括:首页、医生介绍、新闻资讯、关于我们、联系我们等功能;
后台管理员主要功能包括:
客户管理:客户信息统计、客户列表、添加客户;
医生管理:医生列表、病例列表、新增病例、添加医生;
药品管理:药品信息统计、药品列表、药品添加;
文章管理:文章列表、添加文章;

医生登录主要功能包括:
病例管理:在诊病历、历史病例、新增病例;
客户管理:客户列表、新增客户、预约信息;

普通客户登录主要功能包括:
基本信息、修改密码、预约信息、病例查看;

共10张表;

环境需要

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.是否Maven项目: 是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 

6.数据库:MySql 8.0版本;

技术栈

1. 后端:SpringBoot

2. 前端:html+jQuery+layui+echarts

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 将项目中db.properties配置文件中的数据库配置改为自己的配置

3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;

若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行;

4. 运行项目,
前台网站运行地址:http://localhost:8087/user/toCusWel
普通用户登录地址:http://localhost:8087/login/toUserLogin

后台运行地址:管理员及医生登录:http://localhost:8087/login/toDocLogin

运行截图

 

后台界面

代码相关

登录拦截器

  1. @Component
  2. public class UserLoginInterceptor implements HandlerInterceptor {
  3. @Override
  4. public boolean preHandle(HttpServletRequest request, HttpServletResponse response,
  5. Object handler) throws Exception {
  6. HttpSession session = request.getSession(true);
  7. Object username = session.getAttribute("userName");
  8. String userId = (String) session.getAttribute("userId");
  9. if(username != null && userId != null){
  10. return true;
  11. }else {
  12. response.sendRedirect(request.getContextPath()+"/login/toDocLogin");
  13. return false;
  14. }
  15. }
  16. }

 客户管理控制器

  1. @Controller
  2. @RequestMapping("/admin")
  3. public class AdminHandler {
  4. @Resource
  5. private CustomerService customerService;
  6. @RequestMapping("/toCusList")
  7. public String toList(){
  8. return "admin/customer/cus_list";
  9. }
  10. @RequestMapping("/toCaseList")
  11. public String toCaseList(){
  12. return "admin/doctor/case_list";
  13. }
  14. @RequestMapping("/toAdminRePass")
  15. public String toRePass(){
  16. return "admin/admin_mess";
  17. }
  18. @RequestMapping("/toIndex")
  19. public String toIndex(){
  20. return "admin/customer/cus_index";
  21. }
  22. @RequestMapping("/toAdminWel")
  23. public String toWel(HttpSession session){
  24. String userId = (String) session.getAttribute("userId");
  25. if(userId.equals("admin")){
  26. return "admin/admin_wel";
  27. }else {
  28. return "redirect:/login/toDocLogin";
  29. }
  30. }
  31. @RequestMapping("/toAddCus")
  32. public String toAddCus(){
  33. return "admin/customer/cus_add";
  34. }
  35. // 按ID搜索客户信息
  36. @ResponseBody
  37. @GetMapping("/findById")
  38. public LayData findById(String customerId){
  39. LayData layData = customerService.layFindById(customerId);
  40. return layData;
  41. }
  42. // 按Name搜索客户信息
  43. @ResponseBody
  44. @GetMapping("/findByName")
  45. public LayData findByName(String customerName){
  46. LayData layData = customerService.layFindByName(customerName);
  47. return layData;
  48. }
  49. // 按ID删除客户信息
  50. @ResponseBody
  51. @GetMapping("/deleteById")
  52. public Integer deleteById(String customerId){
  53. Integer index = customerService.deleteById(customerId);
  54. return index;
  55. }
  56. // 执行弹出窗的操作
  57. @RequestMapping("/toCusInfo")
  58. public ModelAndView toCusInfo(String customerId){
  59. ModelAndView model = new ModelAndView();
  60. model.setViewName("admin/customer/cus_info");
  61. Customer customer = customerService.findById(customerId);
  62. model.addObject("cus",customer);
  63. return model;
  64. }
  65. // 修改客户信息
  66. @ResponseBody
  67. @RequestMapping("/saveCus")
  68. public Integer saveCus(@RequestBody Customer customer){
  69. System.out.println("获取到的Customer信息:" + customer);
  70. int index = customerService.update(customer);
  71. return index;
  72. }
  73. // 新增客户信息
  74. @ResponseBody
  75. @RequestMapping("/insertCus")
  76. public Integer insertCus(@RequestBody Customer customer){
  77. System.out.println("insertCus中的Customer信息:" + customer);
  78. int index = customerService.save(customer);
  79. return index;
  80. }
  81. @ResponseBody
  82. @RequestMapping("/toCusIndex")
  83. private CustomerAreaData toCusIndex(){
  84. CustomerAreaData cusAreaData = customerService.findCusAreaData();
  85. return cusAreaData;
  86. }
  87. //获取客户年龄段接口
  88. @ResponseBody
  89. @RequestMapping("/toCusIndex1")
  90. private CustomerLoginData toCusIndex1(){
  91. CustomerLoginData cusLoginMes = customerService.findCusLoginMes();
  92. return cusLoginMes;
  93. }
  94. @ResponseBody
  95. @RequestMapping("/toCusIndex2")
  96. private List<CustomerSexData> toCusIndex2(){
  97. List<CustomerSexData> cusSexData = customerService.findCusSexData();
  98. return cusSexData;
  99. }
  100. }

客户逻辑

  1. @Service
  2. public class CustomerService {
  3. @Resource
  4. private CustomerRepository customerRepository;
  5. @Resource
  6. private CaseInfoRepository caseInfoRepository;
  7. @Resource
  8. private LoginInfoRepository loginInfoRepository;
  9. public int getAllCount(){
  10. return customerRepository.getAllCount();
  11. }
  12. public LayData findAllByDoc(String docId){
  13. LayData layData = new LayData();
  14. List<Customer> cusList = new ArrayList<>();
  15. List<CaseInfo> byDocId = caseInfoRepository.findByDocId(docId);
  16. Set<String> cusId = new HashSet<>();
  17. // 去除重复
  18. for (CaseInfo c:byDocId) {
  19. cusId.add(c.getCustomerId());
  20. }
  21. for(String id : cusId){
  22. Customer byId = customerRepository.findById(id);
  23. cusList.add(byId);
  24. }
  25. if(cusList.size() > 0){
  26. layData.setCode(0);
  27. layData.setData(cusList);
  28. layData.setCount(cusList.size());
  29. layData.setMsg("该医生的所有客户");
  30. }else {
  31. layData.setCode(0);
  32. }
  33. return layData;
  34. }
  35. public LayData findAll(Integer page, Integer limit) {
  36. LayData cusList = new LayData();
  37. List<Customer> all = customerRepository.findAll(((page - 1) * limit), limit);
  38. int count = customerRepository.getAllCount();
  39. if (all != null) {
  40. cusList.setCode(0);
  41. cusList.setData(all);
  42. cusList.setCount(count);
  43. cusList.setMsg("所有用户信息");
  44. } else {
  45. cusList.setCode(0);
  46. }
  47. return cusList;
  48. }
  49. // 分页展示查询
  50. public List<Customer> findAllCus() {
  51. int allCount = customerRepository.getAllCount();
  52. return customerRepository.findAll(0, allCount);
  53. }
  54. public Customer findById(String customerId) {
  55. Customer customer = customerRepository.findById(customerId);
  56. return customer;
  57. }
  58. // 用户列表界面:按ID搜索
  59. public LayData<Customer> layFindById(String customerId) {
  60. LayData cus = new LayData();
  61. Customer customer = customerRepository.findById(customerId);
  62. if(customer != null){
  63. List<Customer> cust = new ArrayList<>();
  64. cust.add(customer);
  65. cus.setData(cust);
  66. cus.setCount(1);
  67. cus.setMsg("按ID查找信息");
  68. cus.setCode(0);
  69. }else {
  70. cus.setCode(0);
  71. }
  72. return cus;
  73. }
  74. // 用户列表界面:按Name搜索
  75. public LayData layFindByName(String customerName) {
  76. LayData cus = new LayData();
  77. List<Customer> byName = customerRepository.findByName(customerName);
  78. if(byName.size() > 0){
  79. cus.setData(byName);
  80. cus.setCount(byName.size());
  81. cus.setMsg("按Name查找信息");
  82. cus.setCode(0);
  83. }else {
  84. cus.setCode(0);
  85. }
  86. return cus;
  87. }
  88. public int save(Customer customer) {
  89. customer.setCustomerId(getCustomerId());
  90. LoginInfo loginInfo = new LoginInfo();
  91. loginInfo.setUserId(customer.getCustomerId());
  92. loginInfo.setUsername(customer.getCustomerName());
  93. loginInfo.setPassword("123123");
  94. loginInfo.setUserSort(1);
  95. Integer save = loginInfoRepository.save(loginInfo);
  96. System.out.println("客户 账号信息存储状态:" + save);
  97. return customerRepository.save(customer);
  98. }
  99. public int update(Customer customer) {
  100. return customerRepository.update(customer);
  101. }
  102. public Integer getCount(String CustomerIdPrefix) {
  103. return customerRepository.getCount(CustomerIdPrefix);
  104. }
  105. public Integer deleteById(String customerId) {
  106. Integer index = loginInfoRepository.deleteById(customerId);
  107. System.out.println("客户 账号信息删除结果:" + index);
  108. return customerRepository.deleteById(customerId);
  109. }
  110. /*管理员模块*/
  111. // 获取客户的住址数据(重点)
  112. public CustomerAreaData findCusAreaData() {
  113. CustomerAreaData index = new CustomerAreaData();
  114. List<CustomerAddress> addr = new ArrayList<>();
  115. int allCount = customerRepository.getAllCount();
  116. List<Customer> all = customerRepository.findAll(0, allCount);
  117. List<CustomerAddress> addr2 = new ArrayList<>();
  118. for (Customer customer : all) {
  119. // 每次循环开始前,先清空addr2
  120. addr2.clear();
  121. // 拷贝数组
  122. for (CustomerAddress cc : addr) {
  123. try {
  124. addr2.add(cc.clone());
  125. } catch (CloneNotSupportedException e) {
  126. e.printStackTrace();
  127. }
  128. }
  129. if (customer.getAddress() == null || !customer.getAddress().contains("省")) {
  130. continue;
  131. }
  132. String area = getArea(customer.getAddress());
  133. for (CustomerAddress c1 : addr) {
  134. if (area.equals(c1.getName())) {
  135. c1.setValue(c1.getValue() + 1);
  136. break; //结束该循环
  137. }
  138. }
  139. if (null != addr && null != addr2) {
  140. if (addr.containsAll(addr2) && addr2.containsAll(addr)) {
  141. CustomerAddress aa = new CustomerAddress();
  142. aa.setValue(1);
  143. aa.setName(area);
  144. addr.add(aa);
  145. } else {
  146. continue;
  147. }
  148. }
  149. }
  150. index.setAddressCount(addr);
  151. String[] areaName = new String[addr.size()];
  152. for (int j = 0; j < addr.size(); j++) {
  153. areaName[j] = addr.get(j).getName();
  154. }
  155. index.setAreaName(areaName);
  156. return index;
  157. }
  158. // 获取客户的年龄段信息
  159. public CustomerLoginData findCusLoginMes() {
  160. CustomerLoginData cLogin = new CustomerLoginData();
  161. int allCount = customerRepository.getAllCount();
  162. List<Customer> all = customerRepository.findAll(0, allCount);
  163. List<Integer> data = new ArrayList<>();
  164. Integer a1 = 0, a2 = 0, a3 = 0, a4 = 0, a5 = 0, a6 = 0, a7 = 0, a8 = 0, a9 = 0, a10 = 0, a11 = 0, a12 = 0, a13 = 0;
  165. for (Customer cc : all) {
  166. if (cc.getAge() < 5) {
  167. a1++;
  168. } else if (cc.getAge() >= 5 && cc.getAge() < 10) {
  169. a2++;
  170. } else if (cc.getAge() >= 10 && cc.getAge() < 15) {
  171. a3++;
  172. } else if (cc.getAge() >= 15 && cc.getAge() < 20) {
  173. a4++;
  174. } else if (cc.getAge() >= 20 && cc.getAge() < 25) {
  175. a5++;
  176. } else if (cc.getAge() >= 25 && cc.getAge() < 30) {
  177. a6++;
  178. } else if (cc.getAge() >= 30 && cc.getAge() < 35) {
  179. a7++;
  180. } else if (cc.getAge() >= 35 && cc.getAge() < 40) {
  181. a8++;
  182. } else if (cc.getAge() >= 40 && cc.getAge() < 45) {
  183. a9++;
  184. } else if (cc.getAge() >= 45 && cc.getAge() < 50) {
  185. a10++;
  186. } else if (cc.getAge() >= 50 && cc.getAge() < 55) {
  187. a11++;
  188. } else if (cc.getAge() >= 55 && cc.getAge() < 60) {
  189. a12++;
  190. } else if (cc.getAge() >= 60) {
  191. a13++;
  192. }
  193. }
  194. data.add(a1);
  195. data.add(a2);
  196. data.add(a3);
  197. data.add(a4);
  198. data.add(a5);
  199. data.add(a6);
  200. data.add(a7);
  201. data.add(a8);
  202. data.add(a9);
  203. data.add(a10);
  204. data.add(a11);
  205. data.add(a12);
  206. data.add(a13);
  207. cLogin.setData(data);
  208. return cLogin;
  209. }
  210. //获取客户性别比例信息
  211. public List<CustomerSexData> findCusSexData(){
  212. List<CustomerSexData> sexData = new ArrayList<>();
  213. CustomerSexData sex1 = new CustomerSexData();
  214. CustomerSexData sex2 = new CustomerSexData();
  215. sex1.setValue(0);
  216. sex1.setName("男性");
  217. sex2.setValue(0);
  218. sex2.setName("女性");
  219. int allCount = customerRepository.getAllCount();
  220. List<Customer> all = customerRepository.findAll(0, allCount);
  221. for (Customer cc : all) {
  222. if(cc.getSex().equals("男")){
  223. sex1.setValue(sex1.getValue()+1);
  224. }else if(cc.getSex().equals("女")){
  225. sex2.setValue(sex2.getValue()+1);
  226. }
  227. }
  228. sexData.add(sex1);
  229. sexData.add(sex2);
  230. return sexData;
  231. }
  232. // 工具方法
  233. private String getArea(String address) {
  234. String s1;
  235. int index = address.indexOf("省");
  236. s1 = address.substring(0, index + 1);
  237. return s1;
  238. }
  239. // 自动生成下一客户ID
  240. private String getCustomerId() {
  241. String NextCustomerId = "";
  242. // 获取当前日期并转化为字符串
  243. SimpleDateFormat s = new SimpleDateFormat("yyyyMMdd");
  244. String s1 = s.format(new Date());
  245. // 获取该日期下已注册的客户数量
  246. Integer count = customerRepository.getCount(s1);
  247. // 改数量加1,获取下一个客户的ID尾号
  248. count++;
  249. // 若下一编号ID长度不足4位,则前面补0
  250. int length = count.toString().length();
  251. if (length < 4) {
  252. int i = 4 - length;
  253. for (int j = 0; j < i; j++) {
  254. NextCustomerId = NextCustomerId + "0";
  255. }
  256. NextCustomerId = s1 + NextCustomerId + count;
  257. }
  258. while (true){
  259. Customer byId = customerRepository.findById(NextCustomerId);
  260. if(byId == null){
  261. break;
  262. }else {
  263. String pro = NextCustomerId.substring(0, NextCustomerId.length() - length);
  264. String end = NextCustomerId.substring(NextCustomerId.length() - length);
  265. Integer num = Integer.parseInt(end);
  266. num++;
  267. NextCustomerId = pro + num;
  268. }
  269. }
  270. return NextCustomerId;
  271. }
  272. }

如果也想学习本系统,下面领取。回复:043springboot

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/599611
推荐阅读
相关标签
  

闽ICP备14008679号