Java项目:JSP大学实验室设备管理系统

133 篇文章 9 订阅

作者主页:源码空间站2022

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

文末获取源码

项目介绍

本项目为后台管理系统,主要功能如下:

管理员登录,管理数据字典,设备信息管理,进购管理,报损管理,查看库存,账号管理等功能。

环境需要

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项目:否;

技术栈

HTML+CSS+JavaScript+JSP+jquery+easyui+mysql

使用说明

1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;
2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;
若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行;
3. 将项目中dbpool.properties配置文件中的数据库配置改为自己的配置;
4. 运行项目,输入http://localhost:8080/jsp_dxsys_sys/  登录

管理员账号密码:admin/admin

运行截图

相关代码 

ChuhuoAction

package com.wbstar.jxc.action;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import com.wbstar.jxc.model.Chuhuo;
import com.wbstar.jxc.model.Kucun;
import com.wbstar.jxc.model.PageBean;
import com.wbstar.jxc.service.ChuhuoService;
import com.wbstar.jxc.service.KucunService;
import com.wbstar.jxc.util.DBUtil;
import com.wbstar.jxc.util.JsonUtil;
import com.wbstar.jxc.util.ResponseUtil;
import com.wbstar.jxc.util.StringUtil;

public class ChuhuoAction {

	private String page; // 第几页
	private String rows; // 每页记录数
	private Chuhuo chuhuo; // 出货单
	private String id; // 出货单ID
	
	private String s_goodsid; // 搜索商品ID
	private String s_outtime; // 下单日期
	
	DBUtil dbUtil = new DBUtil();
	ResultSet rs = null;
	ChuhuoService chuhuoService = new ChuhuoService();
	KucunService kucunService = new KucunService();
	
	public String execute() throws SQLException {
		Connection conn = dbUtil.getConnection();
		PageBean pageBean = new PageBean (Integer.parseInt(page), Integer.parseInt(rows));
		JSONObject result = new JSONObject();
		JSONArray jsonArray;
		try {
			if(chuhuo == null){
				chuhuo = new Chuhuo();
			}
			if(StringUtil.isNotEmpty(s_goodsid)){
				chuhuo.setGoodsid(Integer.parseInt(s_goodsid));
			}
			jsonArray = JsonUtil.formatRsToJsonArray(chuhuoService.chuhuoList(conn, pageBean, chuhuo, s_outtime));
			int total = chuhuoService.chuhuoListTotal(conn, chuhuo, s_outtime);
			result.put("rows", jsonArray);
			result.put("total", total);
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}
	
	public String save() throws Exception {
		Connection conn = dbUtil.getConnection();
		int saveNums = 0;
		JSONObject result = new JSONObject();
		Kucun currentkucun = null;
		try {
			currentkucun = kucunService.queryKucunByGoodsid(conn, chuhuo.getGoodsid());
			if(currentkucun == null){ // 库存中没有该商品时
				result.put("success", "true");
				result.put("errorMsg", "保存失败,该商品暂无库存");
			//	return null;
			}
			if(currentkucun.getInventory() < chuhuo.getQuantity()){ // 库存量小于出货量
				result.put("success", "true"); 
				result.put("errorMsg", "保存失败,该商品的库存量小于出货量,请查看库存");
			//	return null;
			} else {
				currentkucun.setEndDate(chuhuo.getOuttime());
				currentkucun.setInventory(currentkucun.getInventory()-chuhuo.getQuantity());
				kucunService.kucunModify(conn, currentkucun);
				saveNums = chuhuoService.chuhuoAdd(conn, chuhuo);
			}
			if (saveNums > 0) {
				result.put("success", "true");
				result.put("errorMsg", "保存成功");
			} else {
				result.put("success", "true");  // true是技术上的,表示返回成功
				result.put("errorMsg", "保存失败");
			}
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
			throw (e);
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}

	
	/**********************GETTER/SETTER***********************/
	public String getPage() {
		return page;
	}

	public void setPage(String page) {
		this.page = page;
	}

	public String getRows() {
		return rows;
	}

	public void setRows(String rows) {
		this.rows = rows;
	}

	public Chuhuo getChuhuo() {
		return chuhuo;
	}

	public void setChuhuo(Chuhuo chuhuo) {
		this.chuhuo = chuhuo;
	}

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getS_goodsid() {
		return s_goodsid;
	}

	public void setS_goodsid(String s_goodsid) {
		this.s_goodsid = s_goodsid;
	}

	public String getS_outtime() {
		return s_outtime;
	}

	public void setS_outtime(String s_outtime) {
		this.s_outtime = s_outtime;
	}
	
}

DictionaryAction

package com.wbstar.jxc.action;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import org.apache.struts2.ServletActionContext;

import com.wbstar.jxc.model.Dictionary;
import com.wbstar.jxc.model.PageBean;
import com.wbstar.jxc.service.DictionaryService;
import com.wbstar.jxc.service.GoodsService;
import com.wbstar.jxc.util.DBUtil;
import com.wbstar.jxc.util.JsonUtil;
import com.wbstar.jxc.util.ResponseUtil;
import com.wbstar.jxc.util.StringUtil;

public class DictionaryAction {

	private String page; // 第几页
	private String rows; // 每页记录数
	private String s_name="";
	private String s_value="";
	private Dictionary dictionary;
	private String delIds;
	private String id;
	private String name;
	
	DBUtil dbUtil = new DBUtil();
	ResultSet rs = null;
	DictionaryService dictionaryService = new DictionaryService();
	GoodsService goodsService = new GoodsService();
	
	public String execute() throws SQLException {
		Connection conn = dbUtil.getConnection();
		PageBean pageBean = new PageBean (Integer.parseInt(page), Integer.parseInt(rows));
		try {
			if(dictionary == null) {
				dictionary = new Dictionary();
			}
			dictionary.setName(s_name);
			dictionary.setValue(s_value);
			JSONObject result = new JSONObject();
			JSONArray jsonArray = JsonUtil.formatRsToJsonArray(dictionaryService.dictionaryList(conn, pageBean, dictionary));
			int total = dictionaryService.dictionaryListTotal(conn, dictionary);
			result.put("rows", jsonArray);
			result.put("total", total);
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}
	
	public String delete () throws SQLException {
		Connection conn = dbUtil.getConnection();
		try {
			JSONObject result = new JSONObject();
			String str [] = delIds.split(",");
			for(int i = 0; i < str.length; i++) {
				boolean f = goodsService.getGoodsByDictionaryId(conn, str[i]);
				if(f) {
					result.put("errorIndex", i);
					result.put("errorMsg", "该数据下面有商品,不能删除!");
					ResponseUtil.write(ServletActionContext.getResponse(), result);
					return null;
				}
			} 
			int delNums = dictionaryService.dictionaryDelete(conn, delIds);
			if(delNums > 0 ) {
				result.put("success", "true");
				result.put("delNums", delNums);
			} else {
				result.put("errorMsg", "删除失败");
			}
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}
	
	public String save() throws SQLException {
		Connection conn = dbUtil.getConnection();
		try {
			int saveNums = 0;
			JSONObject result = new JSONObject();
			if(StringUtil.isNotEmpty(id)) {
				dictionary.setId(Integer.parseInt(id));
				saveNums = dictionaryService.dictionaryModify(conn, dictionary);
			} else {
				saveNums = dictionaryService.dictionaryAdd(conn, dictionary);
			}
			if(saveNums > 0 ) {
				result.put("success", "true");
			} else {
				result.put("success", "true");
				result.put("errorMsg", "保存失败");
			}
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}
	
	public String dictionaryComboList() throws SQLException {
		Connection conn = dbUtil.getConnection();
		try {
			JSONArray jsonArray = new JSONArray();
			JSONObject jsonObject = new JSONObject();
			jsonObject.put("id", "");
			jsonObject.put("value", "请选择...");
			jsonArray.add(jsonObject);
			Dictionary dy = new Dictionary();
			if(dictionary == null) {//name = new String(name.getBytes("UTF-8"), "GBK");
				if(name.equals("gys"))
					name = "供应商";
				else if(name.equals("type"))
					name = "类型";
				dy.setName(name);
				jsonArray.addAll(JsonUtil.formatRsToJsonArray(dictionaryService.dictionaryList(conn, null, dy)));
			} else {
				jsonArray.addAll(JsonUtil.formatRsToJsonArray(dictionaryService.dictionaryList(conn, null, dictionary)));
			}
			ResponseUtil.write(ServletActionContext.getResponse(), jsonArray);
		} catch (Exception e) {
			e.printStackTrace();
		} finally {
			dbUtil.close(conn, null, rs);
		}
		return null;
	}
	
	/*************** GETTER/SETTER ***************/
	public String getPage() {
		return page;
	}
	public void setPage(String page) {
		this.page = page;
	}
	public String getRows() {
		return rows;
	}
	public void setRows(String rows) {
		this.rows = rows;
	}
	public String getS_name() {
		return s_name;
	}
	public void setS_name(String s_name) {
		this.s_name = s_name;
	}
	public String getS_value() {
		return s_value;
	}
	public void setS_value(String s_value) {
		this.s_value = s_value;
	}
	public Dictionary getDictionary() {
		return dictionary;
	}
	public void setDictionary(Dictionary dictionary) {
		this.dictionary = dictionary;
	}
	public String getDelIds() {
		return delIds;
	}
	public void setDelIds(String delIds) {
		this.delIds = delIds;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
}

GoodsAction

package com.wbstar.jxc.action;

import net.sf.json.JSONArray;
import net.sf.json.JSONObject;

import java.sql.Connection;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;
import com.wbstar.jxc.model.Goods;
import com.wbstar.jxc.model.PageBean;
import com.wbstar.jxc.service.GoodsService;
import com.wbstar.jxc.util.DBUtil;
import com.wbstar.jxc.util.JsonUtil;
import com.wbstar.jxc.util.ResponseUtil;
import com.wbstar.jxc.util.StringUtil;

@SuppressWarnings("serial")
public class GoodsAction extends ActionSupport{
	
	private String page; // 第几页
	private String rows; // 每页记录数
	private String s_goodsname = ""; // 搜索商品名
	private String s_supplier = ""; // 搜索供应商
	private String s_type = ""; // 搜索商品类型
	private Goods goods; // 商品
	private String delIds; // 批量删除ID号
	private String goodsid; // 商品ID
	DBUtil dbUtil = new DBUtil();
	GoodsService goodsService = new GoodsService();
	
	public String execute() throws Exception{
		PageBean pageBean = new PageBean(Integer.parseInt(page), Integer.parseInt(rows));
		Connection conn = dbUtil.getConnection();
		if (goods == null) {
			goods = new Goods();
		}
		if(StringUtil.isNotEmpty(s_goodsname)){
			goods.setGoodsname(s_goodsname);
		}
		if(StringUtil.isNotEmpty(s_supplier)){
			goods.setSupplier(s_supplier);
		}
		if(StringUtil.isNotEmpty(s_type)){
			goods.setType(s_type);
		}
		
		int total = goodsService.goodsListTotal(goods,conn);
		JSONObject result = new JSONObject();
		JSONArray jsonArray = null;
		try {
			jsonArray = JsonUtil.formatRsToJsonArray(goodsService.goodsList(pageBean, goods,conn)); // 将结果集转为json数组
			result.put("rows", jsonArray);
			result.put("total", total);
			ResponseUtil.write(ServletActionContext.getResponse(), result);
			
		} catch (Exception e) {
			e.printStackTrace();
			throw e;
		}finally{
			dbUtil.close(conn, null, null);
		}
		
		
		return null;
	}
	
	public String delete() throws Exception {
		JSONObject result = new JSONObject();
		int delNums = goodsService.goodsDelete(delIds);
		if (delNums > 0) {
			result.put("success", "true");
			result.put("delNums", delNums);
		} else {
			result.put("errorMsg", "删除失败");
		}
		try {
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
			throw (e);
		}
		return null;
	}
	
	public String save() throws Exception {
		if (StringUtil.isNotEmpty(goodsid)) {
			goods.setGoodsid(Integer.parseInt(goodsid));
		}
		int saveNums = 0;
		JSONObject result = new JSONObject();
		if (StringUtil.isNotEmpty(goodsid)) {
			saveNums = goodsService.goodsModify(goods);
		} else {
			saveNums = goodsService.goodsAdd(goods);
		}
		if (saveNums > 0) {
			result.put("success", "true");
		} else {
			result.put("success", "true");
			result.put("errorMsg", "保存失败");
		}
		try {
			ResponseUtil.write(ServletActionContext.getResponse(), result);
		} catch (Exception e) {
			e.printStackTrace();
			throw (e);
		}
		return null;
	}
	
	public String goodsComboList() throws Exception{
		Connection conn = dbUtil.getConnection();
		JSONArray jsonArray = new JSONArray();
		JSONObject jsonObject = new JSONObject();
		jsonObject.put("goodsid", "");
		jsonObject.put("goodsname", "请选择...");
		jsonArray.add(jsonObject);
		try {
			jsonArray.addAll(JsonUtil.formatRsToJsonArray(goodsService.goodsList(null, null,conn)));
			ResponseUtil.write(ServletActionContext.getResponse(), jsonArray);
		} catch (Exception e) {
			e.printStackTrace();
		}finally{
			dbUtil.close(conn, null, null);
		}
		return null;
	}
	/**************** GETTER/SETTER ******************/
	
	public String getPage() {
		return page;
	}
	public void setPage(String page) {
		this.page = page;
	}
	public String getRows() {
		return rows;
	}
	public void setRows(String rows) {
		this.rows = rows;
	}
	public String getS_goodsname() {
		return s_goodsname;
	}
	public void setS_goodsname(String s_goodsname) {
		this.s_goodsname = s_goodsname;
	}
	public String getS_supplier() {
		return s_supplier;
	}
	public void setS_supplier(String s_supplier) {
		this.s_supplier = s_supplier;
	}
	public String getS_type() {
		return s_type;
	}
	public void setS_type(String s_type) {
		this.s_type = s_type;
	}
	public Goods getGoods() {
		return goods;
	}
	public void setGoods(Goods goods) {
		this.goods = goods;
	}
	public String getDelIds() {
		return delIds;
	}
	public void setDelIds(String delIds) {
		this.delIds = delIds;
	}
	public String getGoodsid() {
		return goodsid;
	}
	public void setGoodsid(String goodsid) {
		this.goodsid = goodsid;
	}
	
}

如果也想学习本系统,下面领取。关注并回复:053jsp

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值