Implementation of pet hospital comprehensive management system based on Springboot

Posted by TRI0N on Tue, 18 Jan 2022 15:00:30 +0100

Project No.: BS-098-XX

The front desk of the system is for customers. Customers can make an appointment, browse the articles published by the hospital, enter the hospital mall to shop for pets, leave a message to the official if in doubt, and view all their record information, such as medical treatment records, appointment records, vaccine injection records, etc. The users in the background are hospital personnel. The system administrator has the highest authority and can manage all data, assign permissions to all roles and create roles; The business administrator's authority is mainly to maintain some common data; Doctors can accept the appointment orders issued by customers, process their own appointment orders, and answer customers' inquiries; Beauticians can accept the appointment form issued by customers and process their own appointment form.

The core technology of the project adopts Spring Boot+Mybatis; Development tool idea; Database mysql 5 6; The template engine adopts Thymeleaf; The security framework adopts Shiro to realize the complete permission system, and the Controller method adopts Shiro annotation to realize effective permission control; The foreground interface adopts Bootstrap technology; The background interface adopts EasyUI technology;

####Unregistered user



When non registered users (i.e. tourists) enter the homepage of the hospital's official website, they can browse the publicity about the hospital and the articles published by the hospital, enter the hospital mall, browse the goods on sale, search the published articles and goods, register and log in.



####Registered user



Registered users can modify their personal information and pet information, issue appointment forms (appointment doctors and beauticians), shop in the mall of the hospital, collect goods, leave official messages, view their own relevant record information, such as case records, appointment records, consultation records, order records, etc., log out of the system.



####Doctor



Doctors can view and accept the unprocessed doctor's appointment form issued by customers, end their own appointment form, reply to customers' online consultation and view their own consultation records, modify their personal password and exit the system safely.



####Beautician



Beauticians can view and accept the unprocessed appointment orders issued by customers, and end their own appointment orders.



####Business Administrator



The business administrator has purchase management (including purchase receipt, return issue, purchase document query, return document query and current inventory query), sales management (including sales issue, customer return receipt, sales document query and return document query), inventory management (including commodity loss reporting, commodity overflow reporting, inventory alarm and loss and overflow reporting record query) View statistics (supplier purchase and return doc statistics, customer purchase and return doc statistics, daily sales profit statistics, monthly sales profit Statistics), supplier management, customer management, commodity management, opening inventory management, foreground rotation chart management, equipment type management, equipment management, equipment use management, equipment use record management, article type management, article management Customer message management, hospital supplies management, hospital supplies warehousing management, hospital supplies warehousing record management, customer message management, customer order processing, customer reservation form management, customer consultation record management, medical record management, laboratory record management, vaccine injection record management, customer return visit record management, foster care record management, password modification Exit the system safely.



####System administrator



In addition to all the permissions of the business administrator, the system administrator also has the function of creating roles and giving role permissions, and can view the system operation log.

####System itself



At 0:00 every day, the system automatically creates tomorrow's empty appointment forms (appointment forms not accepted by customers) belonging to each doctor or beautician in each time period, automatically filters out the empty appointment forms that expire after 5 minutes every minute and deletes them from the database, automatically filters and cancels the unpaid orders submitted by customers for more than one day every minute and releases the inventory At 1 a.m. every day, the "new product" label of goods with a release date of more than 3 months will be automatically removed. After the hospital goes to work (8 a.m.), the system will automatically send a reminder message to customers with an appointment on the same day

The following shows the overall functions of the system:

Front end home page

Mall home page

Front end user login registration

Personal Center

Individual order

Appointment doctor

Customer service function

Add to cart

place order

Payment order

News articles

Background management function

Purchase management

Sales management

Inventory management

Statistical report

Basic data management

Reservation management

Medical service module

System management module

The specific roles are no longer displayed one by one. Different users can set different operation permissions according to the background. The function of the overall system is very powerful, including almost all functional modules of pet mall, pet medical treatment, pet purchase, sales and inventory management. You can select some functions according to your own needs!

For example, after the doctor logs in:

System engineering structure:

Some core codes:

package com.ledao.controller;

import com.ledao.entity.Article;
import com.ledao.service.ArticleService;
import com.ledao.service.ArticleTypeService;
import com.ledao.util.PageUtil;
import com.ledao.util.StringUtil;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author compass
 * @company
 * @create 2022-01-27 19:04
 */
@Controller
@RequestMapping("/article")
public class ArticleController {

    @Resource
    private ArticleService articleService;

    @Resource
    private ArticleTypeService articleTypeService;

    @RequestMapping("/search")
    public ModelAndView search(@Valid Article searchArticle, BindingResult bindingResult) {
        ModelAndView mav = new ModelAndView();
        if (bindingResult.hasErrors()) {
            mav.addObject("error", bindingResult.getFieldError().getDefaultMessage());
            mav.addObject("title", "home page");
            mav.addObject("mainPage", "page/indexFirst");
        } else {
            Map<String, Object> map = new HashMap<>(16);
            map.put("title", StringUtil.formatLike(searchArticle.getTitle()));
            List<Article> articleList = articleService.list(map);
            mav.addObject("articleList", articleList);
            mav.addObject("title", "about(" + searchArticle.getTitle() + ")Articles");
            mav.addObject("mainPage", "page/article/articleResult");
            mav.addObject("mainPageKey", "#b");
            mav.addObject("searchArticle", searchArticle);
            mav.addObject("total", articleList.size());
        }
        mav.setViewName("index");
        return mav;
    }

    /**
     * Paging classification query article information
     *
     * @param page
     * @param typeId
     * @return
     */
    @RequestMapping("/list/{id}")
    public ModelAndView list(@PathVariable(value = "id", required = false) Integer page, @RequestParam(value = "typeId", required = false) Integer typeId) {
        ModelAndView mav = new ModelAndView();
        Map<String, Object> map = new HashMap<>(16);
        String typeName = articleTypeService.findById(typeId).getName();
        map.put("typeId", typeId);
        int pageSize = 7;
        map.put("start", (page - 1) * pageSize);
        map.put("size", pageSize);
        List<Article> articleList = articleService.list(map);
        Long total = articleService.getCount(map);
        mav.addObject("typeName", typeName);
        mav.addObject("title", "Article list(" + typeName + ")");
        mav.addObject("articleList", articleList);
        mav.addObject("total", total);
        mav.addObject("pageCode", PageUtil.genPagination("/article/list", total, page, pageSize, typeId));
        mav.addObject("mainPage", "page/article/articleList");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Get article details by id
     *
     * @param id
     * @return
     */
    @RequestMapping("/{id}")
    public ModelAndView view(@PathVariable(value = "id", required = false) Integer id) {
        ModelAndView mav = new ModelAndView();
        Article article = articleService.findById(id);
        article.setClick(article.getClick()+1);
        articleService.update(article);
        mav.addObject("typeName", articleTypeService.findById(article.getTypeId()).getName());
        mav.addObject("article", article);
        mav.addObject("title", article.getTitle());
        mav.addObject("pageCode", this.getLastAndNextArticle(articleService.getLast(id), articleService.getNext(id)));
        mav.addObject("mainPage", "page/article/articleView");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Get previous and next articles
     *
     * @param lastArticle
     * @param nextArticle
     * @return
     */
    private String getLastAndNextArticle(Article lastArticle, Article nextArticle) {
        StringBuffer pageCode = new StringBuffer();
        if (lastArticle == null || lastArticle.getId() == null) {
            pageCode.append("<p>Last:period</p>");
        } else {
            pageCode.append("<p>Last:<a href='/article/" + lastArticle.getId() + "'>" + lastArticle.getTitle() + "</a></p>");
        }
        if (nextArticle == null || nextArticle.getId() == null) {
            pageCode.append("<p>Next:period</p>");
        } else {
            pageCode.append("<p>Next:<a href='/article/" + nextArticle.getId() + "'>" + nextArticle.getTitle() + "</a></p>");
        }
        return pageCode.toString();
    }
}

package com.ledao.controller;

import com.ledao.entity.*;
import com.ledao.service.*;
import com.ledao.util.PageUtil;
import com.ledao.util.StringUtil;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Front desk customer product review layer
 *
 * @author compass
 * @company
 * @create 2022-05-27 23:04
 */
@Controller
@RequestMapping("/comment")
public class CommentController {

    @Resource
    private CommentService commentService;

    @Resource
    private GoodsService goodsService;

    @Resource
    private SaleListGoodsService saleListGoodsService;

    @Resource
    private ReturnListGoodsService returnListGoodsService;

    @Resource
    private GoodsTypeService goodsTypeService;

    @Resource
    private CustomerService customerService;

    @Resource
    private FavoriteService favoriteService;

    /**
     * My test records
     *
     * @param page
     * @param session
     * @return
     */
    @RequestMapping("/myComment/list/{id}")
    public ModelAndView myComment(@PathVariable(value = "id", required = false) Integer page, HttpSession session) {
        ModelAndView mav = new ModelAndView();
        Map<String, Object> map = new HashMap<>(16);
        int pageSize = 4;
        map.put("start", (page - 1) * pageSize);
        map.put("size", pageSize);
        Customer currentCustomer = (Customer) session.getAttribute("currentCustomer");
        map.put("customerId", currentCustomer.getId());
        List<Comment> commentList = commentService.list(map);
        for (Comment comment : commentList) {
            comment.setGoods(goodsService.findById(comment.getGoodsId()));
            comment.setSaleListGoods(saleListGoodsService.findById(comment.getSaleListGoodsId()));
            comment.setSaleList(comment.getSaleListGoods().getSaleList());
        }
        Long total = commentService.getCount(map);
        mav.addObject("commentList", commentList);
        mav.addObject("total", total);
        mav.addObject("pageCode", PageUtil.genPagination2("/comment/myComment/list", total, page, pageSize));
        mav.addObject("title", "My comments");
        mav.addObject("mainPage", "page/comment/myComment");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Jump to the customer evaluation product interface
     *
     * @param saleListGoodsId
     * @return
     */
    @RequestMapping("/commentPage")
    public ModelAndView commentPage(Integer saleListGoodsId) {
        ModelAndView mav = new ModelAndView();
        SaleListGoods saleListGoods = saleListGoodsService.findById(saleListGoodsId);
        Goods goods = goodsService.findById(saleListGoods.getGoodsId());
        mav.addObject("saleListGoods", saleListGoods);
        mav.addObject("goods", goods);
        mav.addObject("title", "Evaluation commodity");
        mav.addObject("mainPage", "page/comment/commentPage");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Add product reviews
     *
     * @param comment
     * @return
     */
    @RequestMapping("/save")
    public String save(Comment comment, HttpSession session) {
        Customer currentCustomer = (Customer) session.getAttribute("currentCustomer");
        comment.setCustomerId(currentCustomer.getId());
        commentService.add(comment);
        SaleListGoods saleListGoods = saleListGoodsService.findById(comment.getSaleListGoodsId());
        saleListGoods.setStatus(1);
        saleListGoodsService.update(saleListGoods);
        return "redirect:/comment/myComment/list/1";
    }

    /**
     * View evaluation details
     *
     * @param commentId
     * @return
     */
    @RequestMapping("/commentDetails")
    public ModelAndView commentDetails(Integer commentId) {
        Comment comment = commentService.findById(commentId);
        comment.setGoods(goodsService.findById(comment.getGoodsId()));
        ModelAndView mav = new ModelAndView();
        mav.addObject("comment", comment);
        mav.addObject("title", "View evaluation details");
        mav.addObject("mainPage", "page/comment/commentDetails");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    @RequestMapping("/customerComment/list/{id}")
    public ModelAndView customerComment(@PathVariable(value = "id", required = false) Integer page, Integer goodsId, HttpSession session) {
        ModelAndView mav = new ModelAndView();
        Map<String, Object> map = new HashMap<>(16);
        int pageSize = 4;
        map.put("start", (page - 1) * pageSize);
        map.put("size", pageSize);
        map.put("goodsId", goodsId);
        List<Comment> commentList = commentService.list(map);
        for (Comment comment : commentList) {
            comment.setCustomer(customerService.findById(comment.getCustomerId()));
        }
        Long total = commentService.getCount(map);
        List<GoodsType> goodsTypeList = goodsTypeService.findByParentId(1);
        for (GoodsType goodsType : goodsTypeList) {
            goodsType.setSmallGoodsTypeList(goodsTypeService.findByParentId(goodsType.getId()));
        }
        Map<String, Object> map2 = new HashMap<>(16);
        map.put("typeId", goodsService.findById(goodsId).getType().getId());
        List<Goods> goodsList = goodsService.list(map2);
        Collections.shuffle(goodsList);
        goodsList.remove(goodsService.findById(goodsId));
        Goods goods = goodsService.findById(goodsId);
        this.setGoodsFavorite(goods,session);
        mav.addObject("allSaleTotal", saleListGoodsService.getSaleCount(goods.getId()) - returnListGoodsService.getReturnCount(goods.getId()));
        mav.addObject("goodsTypeList", goodsTypeList);
        mav.addObject("goods", goods);
        mav.addObject("commentList", commentList);
        mav.addObject("recommendGoodsList", goodsList);
        mav.addObject("total", total);
        mav.addObject("pageCode", PageUtil.genPagination3("/comment/customerComment/list", total, page, pageSize,goodsId));
        mav.addObject("title", "Customer evaluation");
        mav.addObject("mainPage", "page/comment/customerComment");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Set favorite label for item (0 No, 1 yes)
     *
     * @param goods
     */
    private void setGoodsFavorite(Goods goods, HttpSession session) {
        Map<String, Object> map = new HashMap<>(16);
        map.put("customer", session.getAttribute("currentCustomer"));
        List<Favorite> favoriteList = favoriteService.list(map);
        for (Favorite favorite : favoriteList) {
            if (goods.getId().equals(favorite.getGoods().getId())) {
                goods.setIsFavorite(1);
            }
        }
    }
}

package com.ledao.controller;

import com.ledao.entity.Customer;
import com.ledao.entity.Log;
import com.ledao.entity.Pet;
import com.ledao.service.CustomerService;
import com.ledao.service.LogService;
import com.ledao.service.PetService;
import com.ledao.util.DateUtil;
import com.ledao.util.PageUtil;
import org.apache.commons.io.FileUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import javax.validation.Valid;
import java.io.File;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Front office customer Controller layer
 *
 * @author compass
 * @company
 * @create 2022-01-30 14:57
 */
@Controller
@RequestMapping("/customer")
public class CustomerController {

    @Value("${customerImageFilePath}")
    private String customerImageFilePath;

    @Resource
    private CustomerService customerService;

    @Resource
    private PetService petService;

    /**
     * Add or modify customer information
     *
     * @param customer
     * @return
     */
    @RequestMapping("/save")
    public ModelAndView save(Customer customer, @RequestParam("customerImage") MultipartFile file, HttpSession session) throws Exception {
        if (!file.isEmpty()) {
            if (customer.getId() != null) {
                FileUtils.deleteQuietly(new File(customerImageFilePath + customerService.findById(customer.getId()).getImageName()));
            }
            // Get the uploaded file name
            String fileName = file.getOriginalFilename();
            // Gets the suffix of the file
            String suffixName = fileName.substring(fileName.lastIndexOf("."));
            String newFileName = DateUtil.getCurrentDateStr2() + suffixName;
            FileUtils.copyInputStreamToFile(file.getInputStream(), new File(customerImageFilePath + newFileName));
            customer.setImageName(newFileName);
        }
        if (customer.getId() == null) {
            customerService.add(customer);
            ModelAndView mav = new ModelAndView("redirect:/login");
            mav.addObject("successRegister", true);
            mav.addObject("title", "User login");
            mav.addObject("mainPage", "page/login");
            mav.addObject("mainPageKey", "#b");
            return mav;
        } else {
            customerService.update(customer);
            ModelAndView mav = new ModelAndView("redirect:/customer/personalCenter");
            mav.addObject("successModify", true);
            mav.addObject("title", "Personal Center");
            mav.addObject("mainPage", "page/customer/personalCenterFirst");
            customer.setImageName(customerService.findById(customer.getId()).getImageName());
            session.setAttribute("currentCustomer", customer);
            mav.addObject("mainPageKey", "#b");
            return mav;
        }
    }

    /**
     * Customer login
     *
     * @param customer
     * @param bindingResult
     * @param session
     * @return
     */
    @RequestMapping("/login")
    public ModelAndView login(@Valid Customer customer, BindingResult bindingResult, HttpSession session) {
        ModelAndView mav = new ModelAndView();
        if (bindingResult.hasErrors()) {
            mav.addObject("customer", customer);
            mav.addObject("error", bindingResult.getFieldError().getDefaultMessage());
            mav.addObject("title", "User login");
            mav.addObject("mainPage", "page/login");
        } else {
            List<Customer> customerList = customerService.findByUserName(customer.getUserName());
            if (customerList.size() != 0) {
                Customer currentCustomer = customerService.findByUserName(customer.getUserName()).get(0);
                if (currentCustomer.getPassword().equals(customer.getPassword())) {
                    session.setAttribute("currentCustomer", currentCustomer);
                    mav.addObject("successLogin", true);
                    mav.addObject("title", "home page");
                    mav.addObject("mainPage", "page/indexFirst");
                } else {
                    mav.addObject("successLogin", false);
                    mav.addObject("title", "User login");
                    mav.addObject("mainPage", "page/login");
                }
            } else {
                mav.addObject("successLogin", false);
                mav.addObject("title", "User login");
                mav.addObject("mainPage", "page/login");
            }
        }
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Exit the page returned by login
     *
     * @param session
     * @return
     */
    @RequestMapping("/logout")
    public ModelAndView logout(HttpSession session) {
        session.invalidate();
        ModelAndView mav = new ModelAndView("");
        mav.addObject("title", "User login");
        mav.addObject("mainPage", "page/indexFirst");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Jump to modify personal center page
     *
     * @return
     */
    @RequestMapping("/personalCenter")
    public ModelAndView personalCenter() {
        ModelAndView mav = new ModelAndView();
        mav.addObject("title", "Personal Center");
        mav.addObject("mainPage", "page/customer/personalCenterFirst");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Jump to modify personal information page
     *
     * @return
     */
    @RequestMapping("/personalCenter/ModifyMessage")
    public ModelAndView personalCenterModifyMessage() {
        ModelAndView mav = new ModelAndView();
        mav.addObject("title", "Modify personal information");
        mav.addObject("mainPage", "page/customer/personalCenterModifyMessage");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Judge whether the user name already exists during customer registration
     *
     * @param userName
     * @return
     */
    @ResponseBody
    @RequestMapping("/existUserWithUserName")
    public Map<String, Object> existUserWithUserName(String userName) {
        Map<String, Object> resultMap = new HashMap<>(16);
        Long count = customerService.getCountByUserName(userName);
        if (count != 0) {
            resultMap.put("success", true);
        } else {
            resultMap.put("success", false);
        }
        return resultMap;
    }

    /**
     * View my pets
     *
     * @return
     */
    @RequestMapping("/myPet/list/{id}")
    public ModelAndView myPet(@PathVariable(value = "id", required = false) Integer page, HttpSession session) {
        ModelAndView mav = new ModelAndView();
        Map<String, Object> map = new HashMap<>(16);
        int pageSize = 3;
        map.put("start", (page - 1) * pageSize);
        map.put("size", pageSize);
        map.put("customer", session.getAttribute("currentCustomer"));
        List<Pet> petList = petService.list(map);
        Long total = petService.getCount(map);
        mav.addObject("petList", petList);
        mav.addObject("total", total);
        mav.addObject("pageCode", PageUtil.genPagination2("/customer/myPet/list", total, page, pageSize));
        mav.addObject("title", "My pet");
        mav.addObject("mainPage", "page/customer/myPet");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Add pet information page
     *
     * @return
     */
    @RequestMapping("/petAdd")
    public ModelAndView petAdd() {
        ModelAndView mav = new ModelAndView();
        mav.addObject("title", "Add pet info");
        mav.addObject("mainPage", "page/customer/petAdd");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * Modify pet information page
     *
     * @param petId
     * @return
     */
    @RequestMapping("/petModify")
    public ModelAndView petModify(Integer petId) {
        Pet pet = petService.findById(petId);
        ModelAndView mav = new ModelAndView();
        mav.addObject("pet", pet);
        mav.addObject("title", "Modify pet information");
        mav.addObject("mainPage", "page/customer/petModify");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }

    /**
     * View pet information page
     *
     * @param petId
     * @return
     */
    @RequestMapping("/petDetails")
    public ModelAndView petDetails(Integer petId) {
        Pet pet = petService.findById(petId);
        ModelAndView mav = new ModelAndView();
        mav.addObject("pet", pet);
        mav.addObject("title", "View pet information");
        mav.addObject("mainPage", "page/customer/petDetails");
        mav.addObject("mainPageKey", "#b");
        mav.setViewName("index");
        return mav;
    }
}

Topics: Spring Boot