基于javaweb+mysql的ssm物流快递管理系统(java+ssm+js+jsp+mysql)
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb+mysql的SSM物流快递管理系统(java+ssm+js+jsp+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版本;
技术栈
- 后端:Spring+SpringMVC+Mybatis 2. 前端:HTML+CSS+JavaScript+jsp
使用说明
- 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中application.yml配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/ 登录
<div class="demo">
<center>
<button onclick="fmsub()"
style="color: #fff; background-color: #4B95FF; border-color: #2a75fe; border-radius: 5px; height: 45px; width: 100%">查询快递</button>
</center>
</div>
<div class="demo">
<center>
<button onclick="javascript:window.location='addorder.jsp'"
style="color: #fff; background-color: #4B95FF; border-color: #2a75fe; border-radius: 5px; height: 45px; width: 100%">我要发快递</button>
</center>
</div>
</div>
<div style="text-align:center;">
<br>
<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br>
</div>
<script type="text/javascript">
function fmsub(){
var expid = $("#expid").val();
if(expid==''){
$("#msg").html("物流单号不能为空");
return;
}
$("#form0").submit();
}
</script>
</body>
</html>
<?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="com.dzx.express.mapper.ExpressMapper" >
<resultMap id="BaseResultMap" type="com.dzx.express.entity.Express" >
<id column="id" property="id" jdbcType="VARCHAR" />
<result column="fromlocation" property="fromlocation" jdbcType="VARCHAR" />
<result column="tolocation" property="tolocation" jdbcType="VARCHAR" />
<result column="phone" property="phone" jdbcType="VARCHAR" />
<result column="posttime" property="posttime" jdbcType="TIMESTAMP" />
<result column="type" property="type" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, fromlocation, tolocation, phone, posttime, type
</sql>
<select id="selectall" resultMap="BaseResultMap" parameterType="java.lang.String">
select * from express where fromlocation like concat(#{0},'%') or tolocation like concat(#{0},'%')
</select>
<select id="selectbyphone" resultMap="BaseResultMap" parameterType="java.lang.String" >
}else if(user.getType().equals("员工")){
log.setContext("已签收");
express.setType("已签收,请确认收货");
session.setAttribute("msg", "操作成功!单号"+expid+"已经完成签收");
}else {
log.setContext(user.getType()+"已入库");
express.setType("正在运输,当前位置:"+user.getType());
session.setAttribute("msg", "操作成功!单号"+expid+"已经入库");
}
expressBiz.updateByPrimaryKeySelective(express);
logBiz.insert(log);
return "orderin";
}
@RequestMapping(value="orderout")
public String orderout(String expid,HttpSession session) {
Express express = expressBiz.selectByPrimaryKey(expid);
if(express==null) {
session.setAttribute("msg", "没有此快递单号的记录,请核对后再次操作!");
return "orderin";
}
User user = (User) session.getAttribute("loginUser");
Log log = new Log();
log.setExpressid(expid);
log.setTime(new Date());
if(express.getType().equals("等待揽收")&&user.getType().equals("快递员")) {
session.setAttribute("msg", "操作有误请确认快递单号!");
}else if(user.getType()!=null&&user.getType().equals("员工")){
log.setContext("派件中,快递员:"+user.getName()+",电话:"+user.getPhone()+",请确保电话畅通!");
express.setType("派件中,快递员:"+user.getName()+"电话:"+user.getPhone());
session.setAttribute("msg", "操作成功!单号"+expid+"已经准备派件");
}else {
log.setContext(user.getType()+"已出库,发往下一目的地");
express.setType("正在运输,之前位置:"+user.getType());
session.setAttribute("msg", "操作成功!单号"+expid+"已经出库");
}
expressBiz.updateByPrimaryKeySelective(express);
logBiz.insert(log);
return "orderin";
}
@RequestMapping(value="order")
public void order(String expid,String staffid,HttpServletResponse res) throws IOException {
res.setCharacterEncoding("utf-8");
PrintWriter pw = res.getWriter();
User user = userBiz.selectByPrimaryKey(staffid);
if(user==null) {
pw.write("0");
return;
}
Log log = new Log();
log.setContext("快递员:"+user.getName()+"已出发,联系电话"+user.getPhone());
function fmsub(){
var fromlocation = $('#fromlocation').val();
var fromdetal = $("#fromdetal").val();
var fromname = $("#fromname").val();
var fromphone = $("#fromphone").val();
var tolocation = $("#tolocation").val();
var todetal = $("#todetal").val();
var toname = $("#toname").val();
var tophone = $("#tophone").val();
if(fromlocation==""||fromdetal==""){
$("#fromlabel").html("寄发地或寄发详细地址不能为空");
return;
}
$("#fromlabel").html("");
if(fromname==""||fromphone==""){
$("#fromlabel1").html("寄发人或寄发人手机号不能为空");
return;
}$("#fromlabel1").html("");
if(tolocation==""||todetal==""){
$("#tolabel").html("收货地或收货详细地址不能为空");
return;
}$("#tolabel").html("");
if(toname==""||tophone==""){
$("#tolabel1").html("收货人或收货人手机号不能为空");
return;
}$("#tolabel1").html("");
var rfromlocation = fromlocation+fromdetal+fromname;
$("#rfromlocation").val(rfromlocation);
var rtolocation = tolocation+todetal+toname+"收"+tophone;
$("#rtolocation").val(rtolocation);
$("#fm1").submit();
}
</script>
<div style="text-align: center;"></div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrapValidator.css">
<body><table class="table">
<thead>
<tr>
<th>
快递单号
</th>
<th>
寄发地
</th>
<th>
收件地
</th>
<th>
当前状态
</th>
<th>
下单时间
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password == null ? null : password.trim();
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
public String getPhone() {
return phone;
}
public void setPhone(String phone) {
this.phone = phone;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getPt() {
return pt;
}
public void setPt(String pt) {
this.pt = pt;
}
}
public class Log {
private Integer logid;
private String expressid;
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="css/bootstrapValidator.css">
<body><table class="table">
<thead>
<tr>
<th>
快递单号
</th>
<th>
寄发地
</th>
<th>
收件地
</th>
<th>
当前状态
</th>
<th>
下单时间
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
<c:forEach items="${orderList }" var="order">
<tr class="warning">
<td>
${order.id }
</td>
<td>
${order.fromlocation }
</td>
<td>
${order.tolocation }
</td>
}
public void setTime(Date time) {
this.time = time;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type == null ? null : type.trim();
}
}
public class DateUtil {
private static SimpleDateFormat sdf=new SimpleDateFormat("yyyyMMddHHmmss");
public static String getId(){
Random random=new Random();
Date date=new Date();
String resu=sdf.format(date)+(random.nextInt(1000)+1000);
return resu;
}
public static String getStaffId(){
Random random=new Random();
Date date=new Date();
String resu=sdf.format(date)+(random.nextInt(10)+10);
return resu;
}
public static void main(String args[]){
}
User user = (User) session.getAttribute("loginUser");
Log log = new Log();
log.setExpressid(expid);
log.setTime(new Date());
if(express.getType().equals("等待揽收")&&user.getType().equals("快递员")) {
session.setAttribute("msg", "操作有误请确认快递单号!");
}else if(user.getType()!=null&&user.getType().equals("员工")){
log.setContext("派件中,快递员:"+user.getName()+",电话:"+user.getPhone()+",请确保电话畅通!");
express.setType("派件中,快递员:"+user.getName()+"电话:"+user.getPhone());
session.setAttribute("msg", "操作成功!单号"+expid+"已经准备派件");
}else {
log.setContext(user.getType()+"已出库,发往下一目的地");
express.setType("正在运输,之前位置:"+user.getType());
session.setAttribute("msg", "操作成功!单号"+expid+"已经出库");
}
expressBiz.updateByPrimaryKeySelective(express);
logBiz.insert(log);
return "orderin";
}
@RequestMapping(value="order")
public void order(String expid,String staffid,HttpServletResponse res) throws IOException {
res.setCharacterEncoding("utf-8");
PrintWriter pw = res.getWriter();
User user = userBiz.selectByPrimaryKey(staffid);
if(user==null) {
pw.write("0");
return;
}
Log log = new Log();
log.setContext("快递员:"+user.getName()+"已出发,联系电话"+user.getPhone());
log.setExpressid(expid);
log.setTime(new Date());
Express express = expressBiz.selectByPrimaryKey(expid);
express.setType("正在揽收,快递员:"+user.getName()+",电话:"+user.getPhone());
logBiz.insert(log);
expressBiz.updateByPrimaryKeySelective(express);
pw.write("已发出揽收通知!");
}
@RequestMapping(value="orderremove")
public void orderremove(String expid) {
expressBiz.deleteByPrimaryKey(expid);
}
#{time,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.dzx.express.entity.Log" >
insert into log
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="logid != null" >
logid,
</if>
<if test="expressid != null" >
expressid,
</if>
<if test="context != null" >
context,
</if>
<if test="time != null" >
time,
</if>
<if test="type != null" >
type,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides="," >
<if test="logid != null" >
#{logid,jdbcType=INTEGER},
</if>
<if test="expressid != null" >
#{expressid,jdbcType=VARCHAR},
</if>
<if test="context != null" >
#{context,jdbcType=VARCHAR},
</if>
<if test="time != null" >
#{time,jdbcType=TIMESTAMP},
</if>
<if test="type != null" >
#{type,jdbcType=VARCHAR},
</if>
</trim>
</insert>
<update id="updateByPrimaryKeySelective" parameterType="com.dzx.express.entity.Log" >
update log
<set >
<if test="expressid != null" >
expressid = #{expressid,jdbcType=VARCHAR},
return "orderin";
}
@RequestMapping(value="orderout")
public String orderout(String expid,HttpSession session) {
Express express = expressBiz.selectByPrimaryKey(expid);
if(express==null) {
session.setAttribute("msg", "没有此快递单号的记录,请核对后再次操作!");
return "orderin";
}
User user = (User) session.getAttribute("loginUser");
Log log = new Log();
log.setExpressid(expid);
log.setTime(new Date());
if(express.getType().equals("等待揽收")&&user.getType().equals("快递员")) {
session.setAttribute("msg", "操作有误请确认快递单号!");
}else if(user.getType()!=null&&user.getType().equals("员工")){
log.setContext("派件中,快递员:"+user.getName()+",电话:"+user.getPhone()+",请确保电话畅通!");
express.setType("派件中,快递员:"+user.getName()+"电话:"+user.getPhone());
session.setAttribute("msg", "操作成功!单号"+expid+"已经准备派件");
}else {
log.setContext(user.getType()+"已出库,发往下一目的地");
express.setType("正在运输,之前位置:"+user.getType());
session.setAttribute("msg", "操作成功!单号"+expid+"已经出库");
}
expressBiz.updateByPrimaryKeySelective(express);
logBiz.insert(log);
return "orderin";
}
@RequestMapping(value="order")
public void order(String expid,String staffid,HttpServletResponse res) throws IOException {
res.setCharacterEncoding("utf-8");
PrintWriter pw = res.getWriter();
User user = userBiz.selectByPrimaryKey(staffid);
if(user==null) {
pw.write("0");
return;
}
Log log = new Log();
log.setContext("快递员:"+user.getName()+"已出发,联系电话"+user.getPhone());
log.setExpressid(expid);
log.setTime(new Date());
Express express = expressBiz.selectByPrimaryKey(expid);
express.setType("正在揽收,快递员:"+user.getName()+",电话:"+user.getPhone());
logBiz.insert(log);
expressBiz.updateByPrimaryKeySelective(express);
pw.write("已发出揽收通知!");
}
@RequestMapping(value="orderremove")
public void orderremove(String expid) {
alert("员工号输入有误!");
return;
}
alert(data);
location.reload(true);
},
error : function(data) {
alert("出错!请联系管理员");
}
});
}
function removeorder(id){
$.ajax({
type : "post",
url : "orderremove.do",
data : {
"expid" : id
},
async : true,
dataType : 'text',
success : function(data) {
alert("删除成功!");
location.reload(true);
},
error : function(data) {
alert("出错!请联系管理员");
}
});
}
</script>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Express物流查询</title>
<link rel="stylesheet" href="css/cityselect.css">
<style type="text/css">
.demo{width:220px;margin:50px auto;}
.demo input{padding: 12px 18px;}
</style>
</head>
alert(data);
location.reload(true);
},
error : function(data) {
alert("出错!请联系管理员");
}
});
}
function removeorder(id){
$.ajax({
type : "post",
url : "orderremove.do",
data : {
"expid" : id
},
async : true,
dataType : 'text',
success : function(data) {
alert("删除成功!");
location.reload(true);
},
error : function(data) {
alert("出错!请联系管理员");
}
});
}
</script>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Express物流查询</title>
<link rel="stylesheet" href="css/cityselect.css">
<style type="text/css">
.demo{width:220px;margin:50px auto;}
.demo input{padding: 12px 18px;}
</style>
</head>
<body style="background-image: url(image/background.jpg);-moz-background-size:100% 100%; background-size:100% 100%;">
<div style="background-color: rgba(246,246,246,0.7);" >
<div style="text-align: center;margin:200px auto auto 20px;"><h2>新闻热点</h2><br>
<a href="http://www.sohu.com/picture/274945213?_f=index_chan08focus_0" target="_blank">“复兴号”首设快递专用车厢</a><br>
<a href="new1.htm" target="_blank">“双十一”后快递激增 南京各高校“快递山”模式开启</a><br><br><br>
<h3 >在下面的输入框中输入所查询的物流单号:</h3>
</div>
<resultMap id="BaseResultMap" type="com.dzx.express.entity.Log" >
<id column="logid" property="logid" jdbcType="INTEGER" />
<result column="expressid" property="expressid" jdbcType="VARCHAR" />
<result column="context" property="context" jdbcType="VARCHAR" />
<result column="time" property="time" jdbcType="TIMESTAMP" />
<result column="type" property="type" jdbcType="VARCHAR" />
</resultMap>
<sql id="Base_Column_List" >
logid, expressid, context, time, type
</sql>
<select id="selectlog" resultMap="BaseResultMap" parameterType="String">
select * from log
where expressid = #{expressid} order by time desc
</select>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
select
<include refid="Base_Column_List" />
from log
where logid = #{logid,jdbcType=INTEGER}
</select>
<delete id="deleteByPrimaryKey" parameterType="java.lang.Integer" >
delete from log
where logid = #{logid,jdbcType=INTEGER}
</delete>
<insert id="insert" parameterType="com.dzx.express.entity.Log" >
insert into log (logid, expressid, context,
time, type)
values (#{logid,jdbcType=INTEGER}, #{expressid,jdbcType=VARCHAR}, #{context,jdbcType=VARCHAR},
#{time,jdbcType=TIMESTAMP}, #{type,jdbcType=VARCHAR})
</insert>
<insert id="insertSelective" parameterType="com.dzx.express.entity.Log" >
insert into log
<trim prefix="(" suffix=")" suffixOverrides="," >
<if test="logid != null" >
logid,
</if>
<if test="expressid != null" >
expressid,
</if>
<if test="context != null" >
context,
int insertSelective(Express record);
Express selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(Express record);
int updateByPrimaryKey(Express record);
}
public interface LogBiz {
int deleteByPrimaryKey(Integer logid);
int insert(Log record);
int insertSelective(Log record);
Log selectByPrimaryKey(Integer logid);
int updateByPrimaryKeySelective(Log record);
int updateByPrimaryKey(Log record);
List<Log> selectlog(String expressid);
}
public interface LogMapper {
List<Log> selectlog(String expressid);
int deleteByPrimaryKey(Integer logid);
int insert(Log record);
int insertSelective(Log record);
Log selectByPrimaryKey(Integer logid);
int updateByPrimaryKeySelective(Log record);
int updateByPrimaryKey(Log record);
}
int deleteByPrimaryKey(Integer logid);
int insert(Log record);
int insertSelective(Log record);
Log selectByPrimaryKey(Integer logid);
int updateByPrimaryKeySelective(Log record);
int updateByPrimaryKey(Log record);
}
public interface UserMapper {
List<User> selectbypt(String pt);
int deleteByPrimaryKey(String id);
int insert(User record);
int insertSelective(User record);
User selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(User record);
int updateByPrimaryKey(User record);
}
public interface UserBiz {
List<User> selectbypt(String pt);
int deleteByPrimaryKey(String id);
int insert(User record);
int insertSelective(User record);
User selectByPrimaryKey(String id);
int updateByPrimaryKeySelective(User record);
int updateByPrimaryKey(User record);
if(lastname.equals("仓")) {
return "cangadmin";
}
if(user.getType().equals("admin")) {
List<Express> orderList = expressBiz.selectall("");
session.setAttribute("orderList", orderList);
return "admin";
}
return "orderin";
}
@RequestMapping(value="orderin")
public String orderin(String expid,HttpSession session) {
session.removeAttribute("msg");
Express express = expressBiz.selectByPrimaryKey(expid);
if(express==null) {
session.setAttribute("msg", "没有此快递单号的记录,请核对后再次操作!");
return "orderin";
}
User user = (User) session.getAttribute("loginUser");
Log log = new Log();
log.setExpressid(expid);
log.setTime(new Date());
String type = express.getType().substring(0, 4);
//System.out.println(type);
if(type.equals("正在揽收")&&user.getType().equals("员工")) {
log.setContext("揽收成功!");
express.setType("已经揽收等待运输");
session.setAttribute("msg", "操作成功!单号"+expid+"已经揽收");
}else if(user.getType().equals("员工")){
log.setContext("已签收");
express.setType("已签收,请确认收货");
session.setAttribute("msg", "操作成功!单号"+expid+"已经完成签收");
}else {
log.setContext(user.getType()+"已入库");
express.setType("正在运输,当前位置:"+user.getType());
session.setAttribute("msg", "操作成功!单号"+expid+"已经入库");
}
expressBiz.updateByPrimaryKeySelective(express);
logBiz.insert(log);
return "orderin";
}
@RequestMapping(value="orderout")
public String orderout(String expid,HttpSession session) {
Express express = expressBiz.selectByPrimaryKey(expid);
if(express==null) {
session.setAttribute("msg", "没有此快递单号的记录,请核对后再次操作!");
return "orderin";
}
User user = (User) session.getAttribute("loginUser");
}
@Override
public int updateByPrimaryKeySelective(Express record) {
// TODO Auto-generated method stub
return expressMapper.updateByPrimaryKeySelective(record);
}
@Override
public int updateByPrimaryKey(Express record) {
// TODO Auto-generated method stub
return expressMapper.updateByPrimaryKey(record);
}
@Override
public List<Express> selectbyphone(String phone) {
// TODO Auto-generated method stub
return expressMapper.selectbyphone(phone);
}
@Override
public List<Express> selectall(String location) {
// TODO Auto-generated method stub
return expressMapper.selectall(location);
}
}
@Service(value="LogBiz")
public class LogBizImpl implements LogBiz{
@Autowired
LogMapper logMapper;
@Override