基于javaweb+mysql的ssm+maven医疗药品采购系统(java+ssm+jsp+jquery+h-ui+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM+Maven医疗药品采购系统(java+ssm+jsp+jquery+h-ui+mysql)
项目介绍
ssm医疗药品采购系统。主要功能有: 用户管理:管理员列表; 采购管理:采购列表; 药品出库:药品出库; 库存管理:库存统计; 数据维护:药品列表、仓库列表、供应商列表;
环境需要
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 5.7版本;
技术栈
- 后端:Spring SpringMVC MyBatis 2. 前端:JSP+jQuery+h-ui
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 将项目中settings.properties配置文件中的数据库配置改为自己的配置 3. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 4. 运行项目,输入localhost:8080/xxx 登录
/**
*/
@Controller
public class LoginController {
@Autowired
private UserService userService;
/**
* 跳转登录页面
*/
@RequestMapping(value = "/login", method = RequestMethod.GET)
public String login() {
return "login";
}
/**
* 执行登录业务逻辑
*/
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String login(HttpServletRequest request, @RequestParam(name = "username") String username,
@RequestParam(name = "password", required = true, defaultValue = "") String password, Model model) {
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
model.addAttribute("error", "用户名或密码为空");
return "login";
}
edu.nxu.mdps.model.User user = userService.getUserByUsername(username);
if (StringUtils.isEmpty(user)) {
model.addAttribute("error", "用户名不存在");
@RequestMapping("/update")
public String update(Output output) {
try {
outputService.updateOutput(output);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
}
/**
* @title: 拦截器
* @company: 北京云知声信息技术有限公司
*/
public class LoginInterceptor implements HandlerInterceptor {
public LoginInterceptor() {
}
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
User user = (User) request.getSession().getAttribute(Constants.SESSION_LONGIN_USER);
if (!StringUtils.isEmpty(user) && user.getId() > 0) {
return true;
} else {
// 如果没登陆则重定向到登录页面
// 如果是ajax请求响应头会有,x-requested-with;
response.sendRedirect(request.getContextPath() + "/login");
return false;
}
}
@Override
public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object arg2, Exception arg3)
throws Exception {
}
model.addAttribute("user", user);
return "user/edit";
}
@ResponseBody
@RequestMapping("/update")
public String update(User user) {
try {
userService.updateUser(user);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@ResponseBody
@RequestMapping("/delete")
public String delete(Integer id) {
try {
userService.deleteUserById(id);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
}
/**
*/
@Controller
public class LoginController {
@Controller
@RequestMapping("output")
public class OutputController {
private static Logger logger = Logger.getLogger(OutputController.class);
@Autowired
private PurchaseOrderService purchaseOrderService;
@Autowired
private OutputService outputService;
@RequestMapping("/list")
public String list() {
return "output/list";
}
@SuppressWarnings("rawtypes")
@RequestMapping("/findByPage")
public String findByPage(PurchaseOrder purchaseOrder, Model model) {
PaginationVO paginationVO = purchaseOrderService.getPurchaseOrderListWithPage(purchaseOrder);
model.addAttribute("list", paginationVO.getList());
model.addAttribute("total", paginationVO.getTotal());
model.addAttribute("pageNo", paginationVO.getPageNo());
model.addAttribute("totalPageSize", paginationVO.getTotalPageSize());
return "output/page";
}
@ResponseBody
@RequestMapping("/update")
public String update(Output output) {
try {
outputService.updateOutput(output);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
}
private static Logger logger = Logger.getLogger(DrugController.class);
@Autowired
private DrugService drugService;
@RequestMapping("/list")
public String list(Model model) {
model.addAttribute("list", drugService.getDrugList());
return "drug/list";
}
@RequestMapping("/add")
public String add() {
return "drug/add";
}
@ResponseBody
@RequestMapping("/save")
public String save(Drug drug) {
try {
drugService.saveDrug(drug);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@RequestMapping("edit")
public String edit(Integer id, Model model) {
Drug drug = drugService.getDrugById(id);
model.addAttribute("drug", drug);
return "drug/edit";
}
@ResponseBody
@RequestMapping("/update")
public String update(Drug drug) {
try {
public String save(PurchaseOrder purchaseOrder) {
try {
purchaseOrderService.savePurchaseOrder(purchaseOrder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@RequestMapping("edit")
public String edit(Integer id, Model model) {
PurchaseOrder purchaseOrder = purchaseOrderService.getPurchaseOrderById(id);
model.addAttribute("obj", purchaseOrder);
model.addAttribute("drugs", drugService.getDrugList());
model.addAttribute("suppliers", supplierService.getSupplierList());
model.addAttribute("repertorys", repertoryService.getRepertoryList());
return "purchaseorder/edit";
}
@ResponseBody
@RequestMapping("/update")
public String update(PurchaseOrder purchaseOrder) {
try {
purchaseOrderService.updatePurchaseOrder(purchaseOrder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@ResponseBody
@RequestMapping("/delete")
public String delete(Integer id) {
try {
purchaseOrderService.deletePurchaseOrderById(id);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
}
@Autowired
private PurchaseOrderService purchaseOrderService;
@Autowired
private SupplierService supplierService;
@Autowired
private RepertoryService repertoryService;
@Autowired
private DrugService drugService;
@RequestMapping("/list")
public String list(Model model) {
return "purchaseorder/list";
}
@SuppressWarnings("rawtypes")
@RequestMapping("/findByPage")
public String findByPage(PurchaseOrder purchaseOrder, Model model) {
PaginationVO paginationVO = purchaseOrderService.getPurchaseOrderListWithPage(purchaseOrder);
model.addAttribute("list", paginationVO.getList());
model.addAttribute("total", paginationVO.getTotal());
model.addAttribute("pageNo", paginationVO.getPageNo());
model.addAttribute("totalPageSize", paginationVO.getTotalPageSize());
return "purchaseorder/page";
}
@RequestMapping("/add")
public String add(Model model) {
model.addAttribute("drugs", drugService.getDrugList());
model.addAttribute("suppliers", supplierService.getSupplierList());
model.addAttribute("repertorys", repertoryService.getRepertoryList());
return "purchaseorder/add";
}
@ResponseBody
@RequestMapping("/save")
public String save(PurchaseOrder purchaseOrder) {
try {
purchaseOrderService.savePurchaseOrder(purchaseOrder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@ResponseBody
@RequestMapping("/save")
public String save(PurchaseOrder purchaseOrder) {
try {
purchaseOrderService.savePurchaseOrder(purchaseOrder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@RequestMapping("edit")
public String edit(Integer id, Model model) {
PurchaseOrder purchaseOrder = purchaseOrderService.getPurchaseOrderById(id);
model.addAttribute("obj", purchaseOrder);
model.addAttribute("drugs", drugService.getDrugList());
model.addAttribute("suppliers", supplierService.getSupplierList());
model.addAttribute("repertorys", repertoryService.getRepertoryList());
return "purchaseorder/edit";
}
@ResponseBody
@RequestMapping("/update")
public String update(PurchaseOrder purchaseOrder) {
try {
purchaseOrderService.updatePurchaseOrder(purchaseOrder);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@ResponseBody
@RequestMapping("/delete")
public String delete(Integer id) {
try {
purchaseOrderService.deletePurchaseOrderById(id);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
}
}
user.setId(u.getId());
userService.updateUser(user);
map.put("msg", "密码修改成功!");
return map;
}
@RequestMapping("/list")
public String list() {
return "user/list";
}
@SuppressWarnings("rawtypes")
@RequestMapping("/findByPage")
public String findByPage(User user, Model model) {
PaginationVO paginationVO = userService.getUserListWithPage(user);
model.addAttribute("list", paginationVO.getList());
model.addAttribute("total", paginationVO.getTotal());
model.addAttribute("pageNo", paginationVO.getPageNo());
model.addAttribute("totalPageSize", paginationVO.getTotalPageSize());
return "user/page";
}
@RequestMapping("/add")
public String add() {
return "user/add";
}
@ResponseBody
@RequestMapping("/save")
public String save(User user) {
try {
userService.saveUser(user);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@RequestMapping("edit")
public String edit(Integer id, Model model) {
request.getSession().setAttribute(Constants.SESSION_LONGIN_USER, user);
return "redirect:/welcome";
}
@RequestMapping("welcome")
public String welcome() {
return "welcome";
}
@RequestMapping("desktop")
public String desktop() {
return "desktop";
}
@RequestMapping("/download")
public String download(Model model, HttpServletRequest request) {
model.addAttribute("time", new Date());
model.addAttribute("ip", PubUtil.getIpAddr(request));
return "download";
}
/**
* 退出操作
*/
@RequestMapping("logout")
public String logout(HttpServletRequest request) {
request.getSession().removeAttribute(Constants.SESSION_LONGIN_USER);
request.getSession().invalidate();
return "login";
}
}
/**
* @company: 宁夏大学
/**
* @company: 宁夏大学
*/
@Controller
@RequestMapping("repertory")
public class RepertoryController {
private static Logger logger = Logger.getLogger(RepertoryController.class);
@Autowired
private RepertoryService repertoryService;
@RequestMapping("/list")
public String list(Model model) {
model.addAttribute("list", repertoryService.getRepertoryList());
return "repertory/list";
}
@RequestMapping("/add")
public String add() {
return "repertory/add";
}
@ResponseBody
@RequestMapping("/save")
public String save(Repertory repertory) {
try {
repertoryService.saveRepertory(repertory);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@RequestMapping("edit")
public String edit(Integer id, Model model) {
Repertory repertory = repertoryService.getRepertoryById(id);
model.addAttribute("repertory", repertory);
return "repertory/edit";
}
@ResponseBody
@RequestMapping("/update")
if (StringUtils.isEmpty(u)) {
map.put("code", "0");
map.put("msg", "当前登录状态已经失效,请重新登录!");
return map;
}
user.setId(u.getId());
userService.updateUser(user);
map.put("msg", "密码修改成功!");
return map;
}
@RequestMapping("/list")
public String list() {
return "user/list";
}
@SuppressWarnings("rawtypes")
@RequestMapping("/findByPage")
public String findByPage(User user, Model model) {
PaginationVO paginationVO = userService.getUserListWithPage(user);
model.addAttribute("list", paginationVO.getList());
model.addAttribute("total", paginationVO.getTotal());
model.addAttribute("pageNo", paginationVO.getPageNo());
model.addAttribute("totalPageSize", paginationVO.getTotalPageSize());
return "user/page";
}
@RequestMapping("/add")
public String add() {
return "user/add";
}
@ResponseBody
@RequestMapping("/save")
public String save(User user) {
try {
userService.saveUser(user);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@RequestMapping("edit")
public String edit(Integer id, Model model) {
User user = userService.getUserById(id);
model.addAttribute("user", user);
return "user/edit";
return map;
}
user.setId(u.getId());
userService.updateUser(user);
map.put("msg", "密码修改成功!");
return map;
}
@RequestMapping("/list")
public String list() {
return "user/list";
}
@SuppressWarnings("rawtypes")
@RequestMapping("/findByPage")
public String findByPage(User user, Model model) {
PaginationVO paginationVO = userService.getUserListWithPage(user);
model.addAttribute("list", paginationVO.getList());
model.addAttribute("total", paginationVO.getTotal());
model.addAttribute("pageNo", paginationVO.getPageNo());
model.addAttribute("totalPageSize", paginationVO.getTotalPageSize());
return "user/page";
}
@RequestMapping("/add")
public String add() {
return "user/add";
}
@ResponseBody
@RequestMapping("/save")
public String save(User user) {
try {
userService.saveUser(user);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@RequestMapping(value = "/login", method = RequestMethod.POST)
public String login(HttpServletRequest request, @RequestParam(name = "username") String username,
@RequestParam(name = "password", required = true, defaultValue = "") String password, Model model) {
if (StringUtils.isEmpty(username) || StringUtils.isEmpty(password)) {
model.addAttribute("error", "用户名或密码为空");
return "login";
}
edu.nxu.mdps.model.User user = userService.getUserByUsername(username);
if (StringUtils.isEmpty(user)) {
model.addAttribute("error", "用户名不存在");
return "login";
}
if (!password.equals(user.getPassword())) {
model.addAttribute("error", "密码错误");
return "login";
}
if (user.getStatus() != Constants.ACCOUNT_STATUS_START) {
model.addAttribute("error", "该账号已经禁止登陆");
return "login";
}
request.getSession().setAttribute(Constants.SESSION_LONGIN_USER, user);
return "redirect:/welcome";
}
@RequestMapping("welcome")
public String welcome() {
return "welcome";
}
@RequestMapping("desktop")
public String desktop() {
return "desktop";
}
@RequestMapping("/download")
public String download(Model model, HttpServletRequest request) {
model.addAttribute("time", new Date());
model.addAttribute("ip", PubUtil.getIpAddr(request));
return "download";
}
public String download(Model model, HttpServletRequest request) {
model.addAttribute("time", new Date());
model.addAttribute("ip", PubUtil.getIpAddr(request));
return "download";
}
/**
* 退出操作
*/
@RequestMapping("logout")
public String logout(HttpServletRequest request) {
request.getSession().removeAttribute(Constants.SESSION_LONGIN_USER);
request.getSession().invalidate();
return "login";
}
}
/**
* @company: 宁夏大学
*/
@Controller
@RequestMapping("repertory")
public class RepertoryController {
private static Logger logger = Logger.getLogger(RepertoryController.class);
@Autowired
private RepertoryService repertoryService;
@RequestMapping("/list")
public String list(Model model) {
/**
*/
@Controller
@RequestMapping("output")
public class OutputController {
private static Logger logger = Logger.getLogger(OutputController.class);
@Autowired
private PurchaseOrderService purchaseOrderService;
@Autowired
private OutputService outputService;
@RequestMapping("/list")
public String list() {
return "output/list";
}
@SuppressWarnings("rawtypes")
@RequestMapping("/findByPage")
public String findByPage(PurchaseOrder purchaseOrder, Model model) {
PaginationVO paginationVO = purchaseOrderService.getPurchaseOrderListWithPage(purchaseOrder);
model.addAttribute("list", paginationVO.getList());
model.addAttribute("total", paginationVO.getTotal());
model.addAttribute("pageNo", paginationVO.getPageNo());
model.addAttribute("totalPageSize", paginationVO.getTotalPageSize());
return "output/page";
}
@ResponseBody
@RequestMapping("/update")
public String update(Output output) {
try {
outputService.updateOutput(output);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
}
/**
* @company: 宁夏大学
*/
@Controller
@RequestMapping("supplier")
public class SupplierController {
private static Logger logger = Logger.getLogger(SupplierController.class);
@Autowired
private SupplierService supplierService;
@RequestMapping("/list")
public String list(Model model) {
model.addAttribute("list", supplierService.getSupplierList());
return "supplier/list";
}
@RequestMapping("/add")
public String add() {
return "supplier/add";
}
@ResponseBody
@RequestMapping("/save")
public String save(Supplier supplier) {
try {
supplierService.saveSupplier(supplier);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return "0";
}
return "1";
}
@RequestMapping("edit")
public String edit(Integer id, Model model) {
Supplier supplier = supplierService.getSupplierById(id);
model.addAttribute("supplier", supplier);
return "supplier/edit";
}
@ResponseBody
@RequestMapping("/update")
public String update(Supplier supplier) {
try {
@Override
public void postHandle(HttpServletRequest arg0, HttpServletResponse arg1, Object arg2, ModelAndView arg3)
throws Exception {
}
}
/**
*/
@Controller
@RequestMapping("repo")
public class RepoController {
@Autowired
private PurchaseOrderService purchaseOrderService;
@RequestMapping("/list")
public String list() {
return "repo/list";
}
@SuppressWarnings("rawtypes")
@RequestMapping("/findByPage")
public String findByPage(PurchaseOrder purchaseOrder, Model model) {
PaginationVO paginationVO = purchaseOrderService.getPurchaseOrderListWithPage(purchaseOrder);
model.addAttribute("list", paginationVO.getList());
model.addAttribute("total", paginationVO.getTotal());
model.addAttribute("pageNo", paginationVO.getPageNo());
model.addAttribute("totalPageSize", paginationVO.getTotalPageSize());