基于javaweb+mysql的springboot药品管理系统(java+springboot+html+layui+bootstrap+echarts+mysql)

基于javaweb+mysql的springboot药品管理系统(java+springboot+html+layui+bootstrap+echarts+mysql)

运行环境

Java≥8、MySQL≥5.7

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SpringBoot药品管理系统(java+springboot+html+layui+bootstrap+echarts+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项目:是

技术栈

  1. 后端:SpringBoot

  2. 前端:html+layui+jquery+bootstrap+echarts

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,后端输入localhost:8081/
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/insertStorage")
    public AjaxInfo insertStroage(@RequestBody Instorage instorage, HttpSession session) {
        System.out.println(instorage);
        AjaxInfo ajaxInfo = new AjaxInfo();
        Instorage in = new Instorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(instorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            Date date = new Date();
            in.setMedId(instorage.getMedId());
            in.setBuyerId(instorage.getBuyerId());
            in.setInDate(time.format(date));
            in.setInStorageNum(instorage.getInStorageNum());
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("入库失败,该药品不存在!");
            } else {
                adminService.insertInstorage(in);
                adminService.updateMedStorage(instorage.getMedId(), instorage.getInStorageNum()+med.getMedStorage());
                ajaxInfo.setMsg("入库成功~");
                ajaxInfo.setCode(0);
            }

            return ajaxInfo;

        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;

    }

    @RequestMapping("/insertMedicine")
    public AjaxInfo insertMedicine(@RequestBody Medicine medicine, HttpSession session) {
        System.out.println(medicine);
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(medicine.getMedId());
            if (med == null) {
                adminService.insertMedicine(medicine);
                ajaxInfo.setMsg("插入信息成功~");
                ajaxInfo.setCode(0);
            } else {
                ajaxInfo.setMsg("该药品已存在~");
                ajaxInfo.setCode(-1);
            }
            return ajaxInfo;
        return ajaxInfo;
    }

    @RequestMapping("/queryFactory")
    public AjaxInfo queryFactory(HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            List<Factory> factories = queryService.queryFactory();
            ajaxInfo.setCode(0);
            ajaxInfo.setData(factories);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/queryBuyer")
    public AjaxInfo queryBuyer1(HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            List<Buyer> buyers = queryService.queryBuyer();
            ajaxInfo.setCode(0);
            ajaxInfo.setData(buyers);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/showInRecord")
    public AjaxInfo showInRecord(MedicineTable medicineTable,HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<ShowInRecord> inRecord = queryService.getInRecord(medicineTable);
            ajaxInfo.setCount(queryService.getInRecordCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(inRecord);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/showOutRecord")
    public AjaxInfo queryBuyer(MedicineTable medicineTable,HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {

/**
 **/
@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/insertStorage")
    public AjaxInfo insertStroage(@RequestBody Instorage instorage, HttpSession session) {
        System.out.println(instorage);
        AjaxInfo ajaxInfo = new AjaxInfo();
        Instorage in = new Instorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(instorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            Date date = new Date();
            in.setMedId(instorage.getMedId());
            in.setBuyerId(instorage.getBuyerId());
            in.setInDate(time.format(date));
            in.setInStorageNum(instorage.getInStorageNum());
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("入库失败,该药品不存在!");
            } else {
                adminService.insertInstorage(in);
                adminService.updateMedStorage(instorage.getMedId(), instorage.getInStorageNum()+med.getMedStorage());
                ajaxInfo.setMsg("入库成功~");
                ajaxInfo.setCode(0);
            }

            return ajaxInfo;

        } else {
            ajaxInfo.setCode(-2);
            Factory fId = adminService.getFactoryByfactoryId(factory.getFactoryId());
            if (fId == null) {
                adminService.insertFactory(factory);
                ajaxInfo.setMsg("插入信息成功~");
                ajaxInfo.setCode(0);
            } else {
                ajaxInfo.setMsg("该药厂已存在~");
                ajaxInfo.setCode(-1);
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryFactory")
    public AjaxInfo queryFactory(@RequestBody Factory factory, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            Factory fId = adminService.getFactoryByfactoryId(factory.getFactoryId());
            if (fId == null) {
                ajaxInfo.setMsg("该药厂不存在,请重新输入!");
                ajaxInfo.setCode(-1);
            } else {
                ajaxInfo.setMsg("查询成功!");
                ajaxInfo.setData(fId);
                ajaxInfo.setCode(0);
                System.out.println(fId);
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
            ajaxInfo.setCode(-2);
        }
        return ajaxInfo;
    }
    @RequestMapping("/updateFactory")
    public AjaxInfo updateFactory(@RequestBody Factory factory, HttpSession session) {
        System.out.println(factory);
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
        if (session.getAttribute("userName") != null) {
            User userByAcc = userService.getUserByAcc(user.getUserAcc());
            if (userByAcc == null||userByAcc.getUserRight()!=2) {
                ajaxInfo.setMsg("该取药员不存在,请重新输入!");
                ajaxInfo.setCode(-1);
            } else {
                ajaxInfo.setMsg("查询成功!");
                ajaxInfo.setCode(0);
                ajaxInfo.setData(userByAcc);
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/deleteUser")
    public AjaxInfo deleteUser(@RequestBody User user, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();

        if (session.getAttribute("userName") != null) {
            userService.deleteUser(user.getUserAcc());
            ajaxInfo.setMsg("删除成功!");
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/registBuyer")
    public AjaxInfo registBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println("======"+buyer);
        Buyer buyerByUserId = userService.getBuyerById(buyer.getBuyerId());
        if (session.getAttribute("userName") != null) {
            if (buyerByUserId == null) {
                userService.registBuyer(buyer);
                ajaxInfo.setMsg("注册成功!");
            } else {
                ajaxInfo.setMsg("ID已存在!");
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
            Medicine med = adminService.getMedicineBymedId(medicine.getMedId());
            if (med == null) {
                adminService.insertMedicine(medicine);
                ajaxInfo.setMsg("插入信息成功~");
                ajaxInfo.setCode(0);
            } else {
                ajaxInfo.setMsg("该药品已存在~");
                ajaxInfo.setCode(-1);
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/queryMedicine")
    public AjaxInfo queryMedicine(@RequestBody Medicine medicine, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(medicine.getMedId());
            if (med == null) {
                ajaxInfo.setMsg("该药品不存在,请重新输入!");
                ajaxInfo.setCode(-1);
            } else {
                ajaxInfo.setMsg("查询成功!");
                ajaxInfo.setData(med);
                ajaxInfo.setCode(0);
                System.out.println(med);
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
            ajaxInfo.setCode(-2);
        }

        return ajaxInfo;
    }

    @RequestMapping("/updateMedicine")
    public AjaxInfo updateMedicine(@RequestBody Medicine medicine, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            adminService.updateMedicine(medicine);
    private TakeService takeService;
    @RequestMapping("/insertStorage")
    public AjaxInfo outStroage(@RequestBody Outstorage outstorage, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        Outstorage o1 = new Outstorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(outstorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("出库失败,该药品不存在!");
            } else {
                if (med.getMedStorage()>=outstorage.getOutStorageNum()) {
                    o1.setMedId(outstorage.getMedId());
                    o1.setPatientId(outstorage.getPatientId());
                    o1.setOutStorageNum(outstorage.getOutStorageNum());
                    o1.setOutDate(time.format(new Date()));
                    adminService.updateMedStorage(med.getMedId(), med.getMedStorage()-outstorage.getOutStorageNum());
                    ajaxInfo.setMsg("取药成功");
                    ajaxInfo.setCode(0);
                    takeService.insertOutStorage(o1);
                }else{
                    ajaxInfo.setCode(-1);
                    ajaxInfo.setMsg("取药数量大于库存量,请重新输入!该药品当前库存量为:"+med.getMedStorage());
                }
                return ajaxInfo;
            }
            return ajaxInfo;

        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
}
package com.jx.medical.filter;

@WebFilter
public class CrosFilter  implements Filter{

	@Override
	public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
            ajaxInfo.setCode(0);
            ajaxInfo.setData(medicines);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryFactoryByName")
    public AjaxInfo queryFactoryByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Factory> factories = queryService.queryFactoryByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryFactoryByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(factories);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryBuyerByName")
    public AjaxInfo queryBuyerByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Buyer> buyers = queryService.queryBuyerByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryBuyerByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(buyers);
        } else {
            ajaxInfo.setCode(-2);
        }
        return ajaxInfo;
    }

}
package com.jx.medical.controller;

/**
 **/

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/login")
    public AjaxInfo login(@RequestBody User user, HttpSession session) {

        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(session.getId());
        User user1 = userService.findUser(user);
        if (user1 != null) {
            ajaxInfo.setCode(user1.getUserRight());
            ajaxInfo.setMsg("登陆成功!");
            ajaxInfo.setData(user1.getUserName());
            session.setAttribute("userName", user1.getUserName());
            System.out.println(session.getAttribute("userName"));
        } else {
            ajaxInfo.setCode(-1);
            ajaxInfo.setMsg("账号或密码错误!");
        }
        return ajaxInfo;
    }

    @RequestMapping("/logout")
    public String login(HttpSession session) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<ShowInRecord> inRecord = queryService.getInRecord(medicineTable);
            ajaxInfo.setCount(queryService.getInRecordCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(inRecord);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/showOutRecord")
    public AjaxInfo queryBuyer(MedicineTable medicineTable,HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<ShowOutRecord> outRecord = queryService.getOutRecord(medicineTable);
            ajaxInfo.setCount(queryService.getOutRecordCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(outRecord);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryMedicineByName")
    public AjaxInfo queryMedicineByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Medicine> medicines = queryService.queryMedicineByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryMedicineByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(medicines);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryFactoryByName")
    public AjaxInfo queryFactoryByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
    }

    @RequestMapping("/queryFactory")
    public AjaxInfo queryFactory(HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            List<Factory> factories = queryService.queryFactory();
            ajaxInfo.setCode(0);
            ajaxInfo.setData(factories);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/queryBuyer")
    public AjaxInfo queryBuyer1(HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            List<Buyer> buyers = queryService.queryBuyer();
            ajaxInfo.setCode(0);
            ajaxInfo.setData(buyers);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/showInRecord")
    public AjaxInfo showInRecord(MedicineTable medicineTable,HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<ShowInRecord> inRecord = queryService.getInRecord(medicineTable);
            ajaxInfo.setCount(queryService.getInRecordCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(inRecord);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/showOutRecord")
 **/
@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/insertStorage")
    public AjaxInfo insertStroage(@RequestBody Instorage instorage, HttpSession session) {
        System.out.println(instorage);
        AjaxInfo ajaxInfo = new AjaxInfo();
        Instorage in = new Instorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(instorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            Date date = new Date();
            in.setMedId(instorage.getMedId());
            in.setBuyerId(instorage.getBuyerId());
            in.setInDate(time.format(date));
            in.setInStorageNum(instorage.getInStorageNum());
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("入库失败,该药品不存在!");
            } else {
                adminService.insertInstorage(in);
                adminService.updateMedStorage(instorage.getMedId(), instorage.getInStorageNum()+med.getMedStorage());
                ajaxInfo.setMsg("入库成功~");
                ajaxInfo.setCode(0);
            }

            return ajaxInfo;

        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;

    }

                ajaxInfo.setMsg("查询成功!");
                ajaxInfo.setCode(0);
                ajaxInfo.setData(userByAcc);
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/deleteUser")
    public AjaxInfo deleteUser(@RequestBody User user, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();

        if (session.getAttribute("userName") != null) {
            userService.deleteUser(user.getUserAcc());
            ajaxInfo.setMsg("删除成功!");
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/registBuyer")
    public AjaxInfo registBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println("======"+buyer);
        Buyer buyerByUserId = userService.getBuyerById(buyer.getBuyerId());
        if (session.getAttribute("userName") != null) {
            if (buyerByUserId == null) {
                userService.registBuyer(buyer);
                ajaxInfo.setMsg("注册成功!");
            } else {
                ajaxInfo.setMsg("ID已存在!");
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

        if (session.getAttribute("userName") != null) {
            List<Medicine> medicines = queryService.queryMedicine();
            ajaxInfo.setCode(0);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setData(medicines);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/queryFactory")
    public AjaxInfo queryFactory(HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            List<Factory> factories = queryService.queryFactory();
            ajaxInfo.setCode(0);
            ajaxInfo.setData(factories);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/queryBuyer")
    public AjaxInfo queryBuyer1(HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            List<Buyer> buyers = queryService.queryBuyer();
            ajaxInfo.setCode(0);
            ajaxInfo.setData(buyers);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/showInRecord")
    public AjaxInfo showInRecord(MedicineTable medicineTable,HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<ShowInRecord> inRecord = queryService.getInRecord(medicineTable);
            ajaxInfo.setCount(queryService.getInRecordCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(inRecord);
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryFactoryByName")
    public AjaxInfo queryFactoryByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Factory> factories = queryService.queryFactoryByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryFactoryByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(factories);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryBuyerByName")
    public AjaxInfo queryBuyerByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Buyer> buyers = queryService.queryBuyerByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryBuyerByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(buyers);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryUserByName")
    public AjaxInfo queryUserByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<User> users = queryService.queryUserByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryUserByNameCount(medicineTable));

/**
 **/
@RestController
@CrossOrigin
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private AdminService adminService;

    @RequestMapping("/insertStorage")
    public AjaxInfo insertStroage(@RequestBody Instorage instorage, HttpSession session) {
        System.out.println(instorage);
        AjaxInfo ajaxInfo = new AjaxInfo();
        Instorage in = new Instorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(instorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            Date date = new Date();
            in.setMedId(instorage.getMedId());
            in.setBuyerId(instorage.getBuyerId());
            in.setInDate(time.format(date));
            in.setInStorageNum(instorage.getInStorageNum());
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("入库失败,该药品不存在!");
            } else {
                adminService.insertInstorage(in);
                adminService.updateMedStorage(instorage.getMedId(), instorage.getInStorageNum()+med.getMedStorage());
                ajaxInfo.setMsg("入库成功~");
                ajaxInfo.setCode(0);
            }

            return ajaxInfo;


/**
 **/
@RestController
@CrossOrigin
@RequestMapping("/take")
public class TakeController {

    @Autowired
    private AdminService adminService;

    @Autowired
    private TakeService takeService;
    @RequestMapping("/insertStorage")
    public AjaxInfo outStroage(@RequestBody Outstorage outstorage, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        Outstorage o1 = new Outstorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(outstorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("出库失败,该药品不存在!");
            } else {
                if (med.getMedStorage()>=outstorage.getOutStorageNum()) {
                    o1.setMedId(outstorage.getMedId());
                    o1.setPatientId(outstorage.getPatientId());

/**
 **/
@RestController
@CrossOrigin
@RequestMapping("/take")
public class TakeController {

    @Autowired
    private AdminService adminService;

    @Autowired
    private TakeService takeService;
    @RequestMapping("/insertStorage")
    public AjaxInfo outStroage(@RequestBody Outstorage outstorage, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        Outstorage o1 = new Outstorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(outstorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("出库失败,该药品不存在!");
            } else {
                if (med.getMedStorage()>=outstorage.getOutStorageNum()) {
                    o1.setMedId(outstorage.getMedId());
                    o1.setPatientId(outstorage.getPatientId());
                    o1.setOutStorageNum(outstorage.getOutStorageNum());
                    o1.setOutDate(time.format(new Date()));
                    adminService.updateMedStorage(med.getMedId(), med.getMedStorage()-outstorage.getOutStorageNum());
                    ajaxInfo.setMsg("取药成功");
                    ajaxInfo.setCode(0);
    public AjaxInfo queryFactoryByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Factory> factories = queryService.queryFactoryByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryFactoryByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(factories);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryBuyerByName")
    public AjaxInfo queryBuyerByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Buyer> buyers = queryService.queryBuyerByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryBuyerByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(buyers);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryUserByName")
    public AjaxInfo queryUserByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<User> users = queryService.queryUserByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryUserByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(users);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Factory> factories = queryService.queryFactoryByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryFactoryByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(factories);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryBuyerByName")
    public AjaxInfo queryBuyerByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<Buyer> buyers = queryService.queryBuyerByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryBuyerByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(buyers);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryUserByName")
    public AjaxInfo queryUserByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<User> users = queryService.queryUserByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryUserByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(users);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
            ajaxInfo.setCount(queryService.queryBuyerByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(buyers);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
    @RequestMapping("/queryUserByName")
    public AjaxInfo queryUserByName(MedicineTable medicineTable, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(medicineTable);
        if (session.getAttribute("userName") != null) {
            int page=(medicineTable.getPage()-1)*medicineTable.getLimit();
            medicineTable.setPage(page);
            List<User> users = queryService.queryUserByName(medicineTable);
            ajaxInfo.setMsg("查询成功");
            ajaxInfo.setCount(queryService.queryUserByNameCount(medicineTable));
            ajaxInfo.setCode(0);
            ajaxInfo.setData(users);
        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

}
package com.jx.medical.controller;

/**
 **/

@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {
    @RequestMapping("/queryBuyer")
    public AjaxInfo queryBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(buyer);

        if (session.getAttribute("userName") != null) {
            Buyer buyer1 = userService.getBuyerById(buyer.getBuyerId());
            if (buyer1 == null) {
                ajaxInfo.setMsg("该采购员不存在,请重新输入!");
                ajaxInfo.setCode(-1);
            } else {
                ajaxInfo.setMsg("查询成功!");
                ajaxInfo.setData(buyer1);
                ajaxInfo.setCode(0);
            }

        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        System.out.println("================="+ajaxInfo.getCode());
        return ajaxInfo;
    }

    @RequestMapping("/deleteBuyer")
    public AjaxInfo deleteBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            userService.deleteBuyer(buyer.getBuyerId());
            ajaxInfo.setMsg("删除成功!");
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/updateBuyer")
    public AjaxInfo updateBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        if (session.getAttribute("userName") != null) {
            userService.updateBuyer(buyer);
            ajaxInfo.setMsg("更新成功!");
        } else {

/**
 **/
@RestController
@CrossOrigin
@RequestMapping("/take")
public class TakeController {

    @Autowired
    private AdminService adminService;

    @Autowired
    private TakeService takeService;
    @RequestMapping("/insertStorage")
    public AjaxInfo outStroage(@RequestBody Outstorage outstorage, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        Outstorage o1 = new Outstorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(outstorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("出库失败,该药品不存在!");
            } else {
                if (med.getMedStorage()>=outstorage.getOutStorageNum()) {
                    o1.setMedId(outstorage.getMedId());
                    o1.setPatientId(outstorage.getPatientId());
                    o1.setOutStorageNum(outstorage.getOutStorageNum());
                    o1.setOutDate(time.format(new Date()));
                    adminService.updateMedStorage(med.getMedId(), med.getMedStorage()-outstorage.getOutStorageNum());
                    ajaxInfo.setMsg("取药成功");
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/registBuyer")
    public AjaxInfo registBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println("======"+buyer);
        Buyer buyerByUserId = userService.getBuyerById(buyer.getBuyerId());
        if (session.getAttribute("userName") != null) {
            if (buyerByUserId == null) {
                userService.registBuyer(buyer);
                ajaxInfo.setMsg("注册成功!");
            } else {
                ajaxInfo.setMsg("ID已存在!");
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/queryBuyer")
    public AjaxInfo queryBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(buyer);

        if (session.getAttribute("userName") != null) {
            Buyer buyer1 = userService.getBuyerById(buyer.getBuyerId());
            if (buyer1 == null) {
                ajaxInfo.setMsg("该采购员不存在,请重新输入!");
                ajaxInfo.setCode(-1);
            } else {
                ajaxInfo.setMsg("查询成功!");
                ajaxInfo.setData(buyer1);
                ajaxInfo.setCode(0);
            }

        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        System.out.println("================="+ajaxInfo.getCode());
        return ajaxInfo;
    }

    @RequestMapping("/deleteBuyer")
    public AjaxInfo deleteBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();

    @Autowired
    private TakeService takeService;
    @RequestMapping("/insertStorage")
    public AjaxInfo outStroage(@RequestBody Outstorage outstorage, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        Outstorage o1 = new Outstorage();
        if (session.getAttribute("userName") != null) {
            Medicine med = adminService.getMedicineBymedId(outstorage.getMedId());
            SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd HH:mm");
            if (med == null) {
                ajaxInfo.setCode(-1);
                ajaxInfo.setMsg("出库失败,该药品不存在!");
            } else {
                if (med.getMedStorage()>=outstorage.getOutStorageNum()) {
                    o1.setMedId(outstorage.getMedId());
                    o1.setPatientId(outstorage.getPatientId());
                    o1.setOutStorageNum(outstorage.getOutStorageNum());
                    o1.setOutDate(time.format(new Date()));
                    adminService.updateMedStorage(med.getMedId(), med.getMedStorage()-outstorage.getOutStorageNum());
                    ajaxInfo.setMsg("取药成功");
                    ajaxInfo.setCode(0);
                    takeService.insertOutStorage(o1);
                }else{
                    ajaxInfo.setCode(-1);
                    ajaxInfo.setMsg("取药数量大于库存量,请重新输入!该药品当前库存量为:"+med.getMedStorage());
                }
                return ajaxInfo;
            }
            return ajaxInfo;

        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }
}
package com.jx.medical.filter;

        } else {
            ajaxInfo.setCode(-2);
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/deleteUser")
    public AjaxInfo deleteUser(@RequestBody User user, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();

        if (session.getAttribute("userName") != null) {
            userService.deleteUser(user.getUserAcc());
            ajaxInfo.setMsg("删除成功!");
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/registBuyer")
    public AjaxInfo registBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println("======"+buyer);
        Buyer buyerByUserId = userService.getBuyerById(buyer.getBuyerId());
        if (session.getAttribute("userName") != null) {
            if (buyerByUserId == null) {
                userService.registBuyer(buyer);
                ajaxInfo.setMsg("注册成功!");
            } else {
                ajaxInfo.setMsg("ID已存在!");
            }
            return ajaxInfo;
        } else {
            ajaxInfo.setMsg("权限不足!请先登录~");
        }
        return ajaxInfo;
    }

    @RequestMapping("/queryBuyer")
    public AjaxInfo queryBuyer(@RequestBody Buyer buyer, HttpSession session) {
        AjaxInfo ajaxInfo = new AjaxInfo();
        System.out.println(buyer);

        if (session.getAttribute("userName") != null) {
            Buyer buyer1 = userService.getBuyerById(buyer.getBuyerId());

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值