基于javaweb+mysql的ssm实现进销存系统(java+ssm+bootstrap+jsp+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM实现进销存系统(java+ssm+bootstrap+jsp+mysql)
项目介绍
进销存库存管理系统源码,采用了ssm框架,功能结构非常简单明了,界面也比较清爽大气,非常适合学生和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.是否Maven项目: 否;
6.数据库:MySql 5.7版本;
技术栈
-
后端:Spring SpringMVC MyBatis
-
前端:JSP+css+javascript+bootstrap+jQuery
return jsonObject.toString();
} else {
if(user2.getT2() == 1){ // 状态不可用
Map reMap = new HashMap();
reMap.put("succ", "no_auth");
JSONObject jsonObject = JSONObject.fromObject(reMap);
return jsonObject.toString();
}
session.setAttribute("t2", user2.getT2());
session.setAttribute("id", user2.getId());
System.out.println("user2" + user2);
session.setAttribute("name", user2.getName());
session.setAttribute("user", user2);
session.setAttribute("t1", user2.getT1());
Map reMap = new HashMap();
reMap.put("succ", "true");
JSONObject jsonObject = JSONObject.fromObject(reMap);
return jsonObject.toString();
}
}
@RequestMapping("sy")
public String denglu(HttpSession session, String t2, Model model, String name, User user) {
int qx = (int) session.getAttribute("t1"); // 角色
// model.addAttribute("list", u.findall());
if (qx == 0) { // 管理员
model.addAttribute("list", u.findall(user));
return "gly/yh";
} else if (qx == 1) { // 管理员
model.addAttribute("list", u.findall(user));
return "gly/yh";
} else if (qx == 2) { // 销售
return "redirect:tzckxs";
} else if (qx == 3) { // 采购员
return "redirect:tzkccg";
}
return "redirect:/";
}
@RequestMapping("touser")
public String touser(User user) throws ParseException {
// SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
// String time = df.format(System.currentTimeMillis());
user.setDate(new Date(System.currentTimeMillis()));
user.setT1(2);
user.setT2(0);
u.touser(user);
return "redirect:tzlogin";
}
</dd>
<dd>
<a href="tjyh">用户添加</a>
</dd>
</dl>
</li>
<li>
<dl>
<dt>货物信息管理</dt>
<dd>
<a href="tzhw">货物查询</a>
</dd>
<dd>
<a href="tzkc">库存查询</a>
</dd>
</dl>
</li>
<li>
<dl>
<dt>入库单信息管理</dt>
<dd>
<a href="tzrk" class="active">入库单新建</a>
</dd>
<dd>
<a href="tzrksh">入库单审核</a>
</dd>
</dl>
</li>
<li>
<dl>
<dt>出库信息管理</dt>
<dd>
<a href="tzck" >出库单新建</a>
</dd>
<dd>
<a href="tzcksh">出库单审核</a>
</dd>
</dl>
</li>
<!-- <li>
<dl>
<dt>报表管理</dt>
<dd>
<a href="tzbb">生成报表</a>
}
.section input {
margin-left: 5px;
width: 70px;
}
</style>
</head>
<body>
<div class="section">
<span><var id="lang_tdBkColor"></var></span>
<input type="text" id="J_tone"/>
</div>
<script type="text/javascript">
var tone = $G("J_tone"),
colorPiker = new UE.ui.ColorPicker({
editor:editor
}),
colorPop = new UE.ui.Popup({
editor:editor,
content:colorPiker
});
domUtils.on(tone, "click", function () {
colorPop.showAnchor(tone);
});
domUtils.on(document, 'mousedown', function () {
colorPop.hide();
});
colorPiker.addListener("pickcolor", function () {
tone.value = arguments[1];
colorPop.hide();
});
colorPiker.addListener("picknocolor", function () {
tone.value="";
colorPop.hide();
});
dialog.onok=function(){
editor.execCommand("edittd",tone.value);
};
var start = editor.selection.getStart(),
cell = start && domUtils.findParentByTagName(start, ["td", "th"], true);
if(cell){
var color = domUtils.getComputedStyle(cell,'background-color');
if(/^#/.test(color)){
tone.value = color
}
int jj(int id);
Hw dy(int id);
int ckkk(Hw hw);
Hw dys(String name);
int updateHw(Hw hw);
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>营销系统登录</title>
<link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath}/moban/css/index.css" />
<link rel="stylesheet" type="text/css"
href="${pageContext.request.contextPath}/moban/css/animate-custom.css" />
<script type="text/javascript">
//设置此处的原因是每次进入界面展示一个随机的验证码,不设置则为空
$().ready(function() {
//createCode();
});
//设置一个全局的变量,便于保存验证码
var code;
function createCode() {
//首先默认code为空字符串
code = '';
//设置长度,这里看需求,我这里设置了4
var codeLength = 4;
var codeV = document.getElementById('code');
//设置随机字符
var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C',
'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
//循环codeLength 我设置的4就是循环4次
for (var i = 0; i < codeLength; i++) {
//设置随机数范围,这设置为0 ~ 36
var index = Math.floor(Math.random() * 36);
//字符串拼接 将每次随机的字符 进行拼接
code += random[index];
}
//将拼接好的字符串赋值给展示的Value
codeV.value = code;
}
//下面就是判断是否== 的代码,无需解释
function validate() {
var name = $("#username").val();
var password = $("#password").val();
$().ready(function() {
//createCode();
});
//设置一个全局的变量,便于保存验证码
var code;
function createCode() {
//首先默认code为空字符串
code = '';
//设置长度,这里看需求,我这里设置了4
var codeLength = 4;
var codeV = document.getElementById('code');
//设置随机字符
var random = new Array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'A', 'B', 'C',
'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O',
'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
//循环codeLength 我设置的4就是循环4次
for (var i = 0; i < codeLength; i++) {
//设置随机数范围,这设置为0 ~ 36
var index = Math.floor(Math.random() * 36);
//字符串拼接 将每次随机的字符 进行拼接
code += random[index];
}
//将拼接好的字符串赋值给展示的Value
codeV.value = code;
}
//下面就是判断是否== 的代码,无需解释
function validate() {
var name = $("#username").val();
var password = $("#password").val();
var requestDate = {};
requestDate["name"] = name;
requestDate["password"] = password;
var str = JSON.stringify(requestDate);
if (name == "") {
alert("请填写登录名");
return;
}
if (password == "") {
alert("请填写密码");
return;
}
$.ajax({
type : "get",
dataType : 'json',//默认转化对象
$(this).attr("href"));
});
});
})(jQuery);
</script>
</head>
<body>
<!--header-->
<header>
<h1>
<%-- <img
src="${pageContext.request.contextPath}/assets/images/admin_logo.png" /> --%>
</h1>
<ul class="rt_nav">
<li><a href="tzzup" class="set_icon">账号设置</a></li>
<li><a href="tzlogin" class="quit_icon">安全退出</a></li>
</ul>
</header>
<!--aside nav-->
<!--aside nav-->
<aside class="lt_aside_nav content mCustomScrollbar">
<ul>
<li>
<dl>
<dt>用户信息管理</dt>
<!--当前链接则添加class:active-->
<dd>
<a href="sy" >用户查询</a>
</dd>
<dd>
<a href="tjyh">用户添加</a>
</dd>
</dl>
</li>
<li>
<dl>
<dt>货物信息管理</dt>
<dd>
<a href="tzhw">货物查询</a>
</dd>
<dd>
<a href="tzkc">库存查询</a>
</dd>
</dl>
</li>
<li>
<!--SpringMVC的配置,包含网站跳转逻辑的控制配置-->
<context:component-scan base-package="org.shop" use-default-filters="false">
<!--只扫描控制器-->
<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"></context:include-filter>
</context:component-scan>
<!--配置视图解析器,方便页面返回-->
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"></property>
<property name="suffix" value=".jsp"></property>
</bean>
<!--两个标准配置-->
<!--将springmvc不能处理的请求交给tomcat-->
<mvc:default-servlet-handler />
<!--能支持springMVC的更高级的一些功能,JSP303校验,快捷的ajax。。映射动态请求-->
<mvc:annotation-driven />
<!-- 文件上传配置 -->
<bean name="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 默认编码 -->
<property name="defaultEncoding" value="UTF-8"/>
<!-- 上传文件大小限制为31M,31*1024*1024 -->
<property name="maxUploadSize" value="32505856"/>
<!-- 内存中的最大值 -->
<property name="maxInMemorySize" value="4096"/>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.shop.dao.HwDao">
<!-- 商品列表 -->
<select id="sp" parameterType="org.shop.pojo.Hw" resultType="map">
select * from hw where sj=#{sj} and sh=#{sh}
<if test="name != null">
and name like "%"#{name}"%"
</if>
</select>
<!-- 商品上下架信息 -->
<update id="spxj" parameterType="org.shop.pojo.Hw" >
update hw set date=#{date},sj=#{sj},sh=#{sh} where id=#{id}
</update>
$(function() {
$(".icon-save").click(function() {
var name = $("#username").val();
var password = $("#password").val();
var requestDate = {};
requestDate["name"] = name;
requestDate["password"] = password;
var str = JSON.stringify(requestDate);
if (name == "") {
alert("请填写登录名");
return;
}
if (password == "") {
alert("请填写密码");
return;
}
$.ajax({
type : "get",
dataType : 'json',//默认转化对象
async : true,
url : "login", //提交到一般处理程序请求数据
data : {
"requestDate" : str
},
error : function() {
alert("登录失败,请与管理员联系")
},
success : function(data) {
var suc = data.succ;
if (suc == "false") {
alert("登录失败,请确认用户名与密码");
} else {
alert("登录成功")
window.location.href = "sy.do";
}
}
})
})
})
</script>
</body>
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
String time = df.format(System.currentTimeMillis());
hw.setDate(df.parse(time));
h.spxj(hw);
return "redirect:tzkc";
}
@RequestMapping("tzrk")
public String tzrk() {
return "gly/rkd";
}
@RequestMapping("rk")
public String zjrk(Hw hw, HttpSession session) throws ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
String time = df.format(System.currentTimeMillis());
hw.setDate(df.parse(time));
hw.setSj(0);
hw.setSh(0);
String zrr = (String) session.getAttribute("name");
hw.setZrr(zrr);
h.xjrk(hw);
return "redirect:tzrk";
}
@RequestMapping("tzrksh")
public String tzrush(Model model, Hw hw) {
hw.setSh(0);
hw.setSj(0);
model.addAttribute("list", h.sp(hw));
return "gly/rksh";
}
@RequestMapping("rks")
public String rk(int id, Hw hw) throws ParseException {
hw.setSj(0);
hw.setSh(1);
hw.setId(id);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
String time = df.format(System.currentTimeMillis());
hw.setDate(df.parse(time));
h.spxj(hw);
return "redirect:tzrksh";
}
@RequestMapping("tzck")
public String tzck(Model model, Hw hw) {
hw.setSh(1);
hw.setSj(1);
List list = h.sp(hw);
<property name="user" value="${jdbc.user}"></property>
<property name="password" value="${jdbc.password}"></property>
</bean>
<!--配置和MyBatis的整合-->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--指定MyBatis的全局配置文件-->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
<property name="dataSource" ref="pooledDataSource"></property>
<!--指定mybatis的mapper配置文件-->
<property name="mapperLocations" value="classpath:mapper/*.xml"></property>
</bean>
<!--配置扫描器,将MyBatis接口的实现加入到ioc容器中-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!--扫描所有dao接口的实现,加入到ioc容器中-->
<property name="basePackage" value="org.shop.dao"></property>
</bean>
<!-- -->
<!--事务控制的配置-->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!--控制住数据源-->
<property name="dataSource" ref="pooledDataSource"></property>
</bean>
<!--开启基于注解的事务,使用xml配置形式的事务(必要主要的都是使用配置式)-->
<aop:config>
<!--切入点表达式-->
<aop:pointcut expression="execution(* org.shop.service..*(..))" id="txPoint" />
<!--配置事务增强-->
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint" />
</aop:config>
<!--配置事务增强,事务如何切入-->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<!--所有方法都是事务方法-->
<tx:method name="*"/>
<!--以get开始的所有方法-->
<tx:method name="get" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- -->
<!--Spring配置文件的核心点(数据源、与MyBatis的整合、事务控制-->
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<span><var id="lang_color"></var></span>
<input type="text" class="tone" id="J_tone" readonly='readonly' />
</li>
</ul>
<div class="clear"></div>
</div>
</div>
<div class="right">
<div class="section">
<h3><var id="lang_example"></var></h3>
<div class="preview" id="J_preview">
</div>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.section {
text-align: center;
margin-top: 10px;
}
.section input {
margin-left: 5px;
width: 70px;
}
</style>
</head>
<body>
<div class="section">
<span><var id="lang_tdBkColor"></var></span>
<input type="text" id="J_tone"/>
</div>
<script type="text/javascript">
var tone = $G("J_tone"),
colorPiker = new UE.ui.ColorPicker({
editor:editor
}),
colorPop = new UE.ui.Popup({
editor:editor,
content:colorPiker
});
domUtils.on(tone, "click", function () {
colorPop.showAnchor(tone);
int cksh(Sh sh);
int jj(int id);
List cc(int sh);
List bb();
List hws(String hw);
Sh hwss(int id);
List bbs();
}
public interface ShDao {
int ck(Sh sh);
int cksh(Sh sh);
int jj(int id);
List cc(int sh);
List bb();
List hws(String hw);
Sh hwss(int id);
List bbs();
}
public interface HwService {
int jj(int id);
List sp(Hw hw);
int spxj(Hw hw);
int xjrk(Hw hw);
Hw dy(int id);
int ckkk(Hw hw);
Hw dys(String name);
int updateHw(Hw hw);
}
public interface HwDao {
List sp(Hw hw);
int spxj(Hw hw);
int xjrk(Hw hw);
int jj(int id);
model.addAttribute("hw",h.dy(id));
return "gly/updateHw";
}
@RequestMapping("update_hw_act")
public String updateHwAct(Model model,Hw hw){
hw.setDate(new Date(System.currentTimeMillis()));
h.updateHw(hw);
return "redirect:tzkc";
}
}
public class Hw {
private int id;// 编号
private String name;// 货物名称
private int number;// 数量
private String money;// 价格
private String gy;// 供应商
private String phone;// 联系电话
private Date date;// 更新时间
private int sj;// 上架-入库
private int sh;// 审核
private String zrr;// 责任人
private String t5;//
private String t6;//
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
<aside class="lt_aside_nav content mCustomScrollbar">
<ul>
<li>
<dl>
<dt>用户信息管理</dt>
<!--当前链接则添加class:active-->
<dd>
<a href="sy">用户查询</a>
</dd>
<dd>
<a href="tjyh" class="active">用户添加</a>
</dd>
</dl>
</li>
<li>
<dl>
<dt>货物信息管理</dt>
<dd>
<a href="tzhw">货物查询</a>
</dd>
<dd>
<a href="tzkc">库存查询</a>
</dd>
</dl>
</li>
<li>
<dl>
<dt>入库单信息管理</dt>
<dd>
<a href="tzrk">入库单新建</a>
</dd>
<dd>
<a href="tzrksh">入库单审核</a>
</dd>
</dl>
</li>
<li>
<dl>
<dt>出库信息管理</dt>
<dd>
<a href="tzck">出库单新建</a>
</dd>
<dd>
<a href="tzcksh">出库单审核</a>
</dd>
</dl>
</li>
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
String time = df.format(System.currentTimeMillis());
hw.setDate(df.parse(time));
h.spxj(hw);
return "redirect:tzhw";
}
@RequestMapping("tzkc")
public String tzkc(Model model, Hw hw) {
hw.setSj(0);
hw.setSh(1);
model.addAttribute("list", h.sp(hw));
return "gly/kc";
}
@RequestMapping("sj")
public String spsj(int id, Hw hw) throws ParseException {
hw.setSh(1);
hw.setSj(1);
hw.setId(id);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
String time = df.format(System.currentTimeMillis());
hw.setDate(df.parse(time));
h.spxj(hw);
return "redirect:tzkc";
}
@RequestMapping("tzrk")
public String tzrk() {
return "gly/rkd";
}
@RequestMapping("rk")
public String zjrk(Hw hw, HttpSession session) throws ParseException {
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH");
String time = df.format(System.currentTimeMillis());
hw.setDate(df.parse(time));
hw.setSj(0);
hw.setSh(0);
String zrr = (String) session.getAttribute("name");
hw.setZrr(zrr);
h.xjrk(hw);
<property name="suffix" value=".jsp"></property>
</bean>
<!--两个标准配置-->
<!--将springmvc不能处理的请求交给tomcat-->
<mvc:default-servlet-handler />
<!--能支持springMVC的更高级的一些功能,JSP303校验,快捷的ajax。。映射动态请求-->
<mvc:annotation-driven />
<!-- 文件上传配置 -->
<bean name="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- 默认编码 -->
<property name="defaultEncoding" value="UTF-8"/>
<!-- 上传文件大小限制为31M,31*1024*1024 -->
<property name="maxUploadSize" value="32505856"/>
<!-- 内存中的最大值 -->
<property name="maxInMemorySize" value="4096"/>
</bean>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.shop.dao.HwDao">
<!-- 商品列表 -->
<select id="sp" parameterType="org.shop.pojo.Hw" resultType="map">
select * from hw where sj=#{sj} and sh=#{sh}
<if test="name != null">
and name like "%"#{name}"%"
</if>
</select>
<!-- 商品上下架信息 -->
<update id="spxj" parameterType="org.shop.pojo.Hw" >
update hw set date=#{date},sj=#{sj},sh=#{sh} where id=#{id}
</update>
<!-- 入库单新建 -->
<insert id="xjrk" parameterType="org.shop.pojo.Hw">
insert into hw(name,number,money,phone,gy,date,sj,sh,zrr) value(#{name},#{number},#{money},#{phone},#{gy},#{date},#{sj},#{sh},#{zrr})
</div>
<div class="right">
<div class="section">
<h3><var id="lang_example"></var></h3>
<div class="preview" id="J_preview">
</div>
</div>
</div>
</div>
</body>
</html>
<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
.section {
text-align: center;
margin-top: 10px;
}
.section input {
margin-left: 5px;
width: 70px;
}
</style>
</head>
<body>
<div class="section">
<span><var id="lang_tdBkColor"></var></span>
<input type="text" id="J_tone"/>
</div>
<script type="text/javascript">
var tone = $G("J_tone"),
colorPiker = new UE.ui.ColorPicker({
editor:editor
}),
colorPop = new UE.ui.Popup({
editor:editor,
content:colorPiker
});
domUtils.on(tone, "click", function () {
colorPop.showAnchor(tone);
});
domUtils.on(document, 'mousedown', function () {
colorPop.hide();