package com.mzy.dao;
import java.sql.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import com.mzy.bean.Express;
import com.mzy.db.DruidUtil;
public class ExpressDaoImp implements BaseExpressDao {
private static final String SQL_CREATE_TABLE = "CREATE TABLE web_express(id INT PRIMARY KEY AUTO_INCREMENT,enumber VARCHAR(64) UNIQUE,username VARCHAR(64),userphone VARCHAR(64),company VARCHAR(64),CODE VARCHAR(64) UNIQUE,intime DATETIME,outtime DATETIME,STATUS INT,sysPhone VARCHAR(64))";
private static final String SQL_FIND_ALL = "SELECT * FROM WEB_EXPRESS";
private static final String SQL_FIND_BY_CODE = "SELECT * FROM WEB_EXPRESS WHERE CODE=?";
private static final String SQL_FIND_BY_ENUMBER = "SELECT * FROM WEB_EXPRESS WHERE ENUMBER=?";
private static final String SQL_FIND_BY_USERPHONE = "SELECT * FROM WEB_EXPRESS WHERE USERPHONE=?";
private static final String SQL_INSERT = "INSERT INTO WEB_EXPRESS (ENUMBER,COMPANY,USERNAME,USERPHONE,CODE,SYSPHONE,INTIME,STATUS) VALUES(?,?,?,?,?,?,now(),0)";
private static final String SQL_DELETE_BY_ID_OR_ENUMBER = "DELETE FROM WEB_EXPRESS WHERE ID=? OR ENUMBER=?";
private static final String SQL_UPDATE_BY_ID_OR_ENUMBER = "UPDATE WEB_EXPRESS SET ENUMBER=?,COMPANY=?,USERNAME=?,USERPHONE=? WHERE ID=? OR ENUMBER=?";
private static final String SQL_UPDATE_STATUS_BY_CODE = "UPDATE WEB_EXPRESS SET OUTTIME=now(),CODE=?,STATUS=1 WHERE CODE=?";
private static final String SQL_FIND_SIZE = "SELECT COUNT(ID) ecount FROM WEB_EXPRESS";
private static final String SQL_FIND_STATUS_SIZE = "SELECT COUNT(ID) ecount FROM WEB_EXPRESS WHERE STATUS=?";
static{
//1. 获取连接
Connection conn = DruidUtil.getConnection();
Statement state = null;
try {
state = conn.createStatement();
state.execute(SQL_CREATE_TABLE);
} catch (SQLException e) {
//e.printStackTrace();
}
}
@Override
public List<Express> findAll() {
ArrayList<Express> data = new ArrayList<>();
//1. 获取连接
Connection conn = DruidUtil.getConnection();
//2. 预编译SQL执行环境
PreparedStatement state = null;
ResultSet result = null;
try {
state = conn.prepareStatement(SQL_FIND_ALL);
//3. 执行sql语句 并得到结果集
result = state.executeQuery();
//4. 遍历结果集 , 并将每一行数据 存储到对象中 , 将对象存储到集合中
while(result.next()) {
int id = result.getInt("ID");
String eNumber = result.getString("ENUMBER");
String username = result.getString("USERNAME");
String userphone = result.getString("USERPHONE");
String company = result.getString("COMPANY");
String code = result.getString("CODE");
Timestamp inTime = result.getTimestamp("INTIME");
Timestamp outTime = result.getTimestamp("OUTTIME");
int status = result.getInt("STATUS");
String sysPhone = result.getString("SYSPHONE");
Express e = new Express(id, eNumber, username, userphone, company, code, inTime, outTime, status, sysPhone);
data.add(e);
}
//5. 查询完毕, 返回集合
} catch (SQLException e) {
e.printStackTrace();
}
return data;
}
/**
* 通过取件码查询快递
*
* @param code
* @return 快递对象
*/
@Override
public Express findByCode(String code) {
//1. 获取连接
Connection conn = DruidUtil.getConnection();
//2. 预编译SQL执行环境
PreparedStatement state = null;
ResultSet result = null;
try {
state = conn.prepareStatement(SQL_FIND_BY_CODE);
state.setString(1, code);
//3. 执行sql语句 并得到结果集
result = state.executeQuery();
//4. 遍历结果集 , 并将每一行数据 存储到对象中 , 将对象存储到集合中
if(result.next()) {
int id = result.getInt("ID");
String username = result.getString("USERNAME");
String userphone = result.getString("USERPHONE");
String company = result.getString("COMPANY");
String eNumber = result.getString("ENUMBER");
Timestamp inTime = result.getTimestamp("INTIME");
Timestamp outTime = result.getTimestamp("OUTTIME");
int status = result.getInt("STATUS");
String sysPhone = result.getString("SYSPHONE");
Express e = new Express(id, eNumber, username, userphone, company, code, inTime, outTime, status, sysPhone);
return e;
}
//5. 查询完毕, 返回集合
} catch (SQLException e) {
e.printStackTrace();
}finally {
DruidUtil.close(conn,state,result);
}
return null;
}
@Override
public int size() {
//1. 获取连接
Connection conn = DruidUtil.getConnection();
//2. 预编译SQL执行环境
PreparedStatement state = null;
ResultSet result = null;
int ecount = 0 ;
try {
state = conn.prepareStatement(SQL_FIND_SIZE);
//3. 执行sql语句 并得到结果集
result = state.executeQuery();
//4. 遍历结果集 , 并将每一行数据 存储到对象中 , 将对象存储到集合中
while(result.next()) {
ecount = result.getInt("ecount");
}
//5. 查询完毕, 返回集合
} catch (SQLException e) {
e.printStackTrace();
}finally {
DruidUtil.close(conn,state,result);
}
return ecount;
}
/**
* 根据快递状态查询所有快递数量
*
* @param status
* @return
*/
@Override
public int statusSize(int status) {
//1. 获取连接
Connection conn = DruidUtil.getConnection();
//2. 预编译SQL执行环境
PreparedStatement state = null;
ResultSet result = null;
int ecount = 0 ;
try {
state = conn.prepareStatement(SQL_FIND_STATUS_SIZE);
state.setInt(1,status);
//3. 执行sql语句 并得到结果集
result = state.executeQuery();
//4. 遍历结果集 , 并将每一行数据 存储到对象中 , 将对象存储到集合中
while(result.next()) {
ecount = result.getInt("ecount");
}
//5. 查询完毕, 返回集合
} catch (SQLException e) {
e.printStackTrace();
}finally {
DruidUtil.close(conn,state,result);
}
return ecount;
}
@Override
public Express findByENumber(String eNumber) {
//1. 获取连接
Connection conn = DruidUtil.getConnection();
//2. 预编译SQL执行环境
PreparedStatement state = null;
ResultSet result = null;
try {
state = conn.prepareStatement(SQL_FIND_BY_ENUMBER);
state.setString(1, eNumber);
//3. 执行sql语句 并得到结果集
result = state.executeQuery();
//4. 遍历结果集 , 并将每一行数据 存储到对象中 , 将对象存储到集合中
if(result.next()) {
int id = result.getInt("ID");
String username = result.getString("USERNAME");
String userphone = result.getString("USERPHONE");
String company = result.getString("COMPANY");
String code = result.getString("CODE");
Timestamp inTime = result.getTimestamp("INTIME");
Timestamp outTime = result.getTimestamp("OUTTIME");
int status = result.getInt("STATUS");
String sysPhone = result.getString("SYSPHONE");
Express e = new Express(id, eNumber, username, userphone, company, code, inTime, outTime, status, sysPhone);
return e;
}
//5. 查询完毕, 返回集合
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
@Override
public List<Express> findByUserPhone(String userPhone) {
ArrayList<Express> data = new ArrayList<>();
//1. 获取连接
Connection conn = DruidUtil.getConnection();
//2. 预编译SQL执行环境
PreparedStatement state = null;
ResultSet result = null;
try {
state = conn.prepareStatement(SQL_FIND_BY_USERPHONE);
state.setString(1, userPhone);
//3. 执行sql语句 并得到结果集
result = state.executeQuery();
//4. 遍历结果集 , 并将每一行数据 存储到对象中 , 将对象存储到集合中
while(result.next()) {
int id = result.getInt("ID");
String eNumber = result.getString("ENUMBER");
String username = result.getString("USERNAME");
String company = result.getString
没有合适的资源?快使用搜索试试~ 我知道了~
基于SSM快递系统(含百度地图,移动端扫一扫功能).zip
共775个文件
png:230个
gif:160个
class:74个
0 下载量 157 浏览量
2024-11-06
09:22:09
上传
评论
收藏 12.07MB ZIP 举报
温馨提示
计算机系毕业设计
资源推荐
资源详情
资源评论
收起资源包目录
基于SSM快递系统(含百度地图,移动端扫一扫功能).zip (775个子文件)
ExpressDaoImp.class 8KB
ExpressDaoImp.class 8KB
UserDaoImp.class 8KB
UserDaoImp.class 8KB
Express.class 5KB
Express.class 5KB
SignatureUtil.class 5KB
SignatureUtil.class 5KB
User.class 4KB
User.class 4KB
SendSms.class 3KB
SendSms.class 3KB
ExpressUpdateServlet.class 2KB
ExpressUpdateServlet.class 2KB
TicketUtil.class 2KB
TicketUtil.class 2KB
TokenUtil.class 2KB
TokenUtil.class 2KB
LoginServlet.class 2KB
LoginServlet.class 2KB
ExpressServiceImp.class 2KB
ExpressServiceImp.class 2KB
UserUpdateServlet.class 2KB
UserUpdateServlet.class 2KB
UserAddServlet.class 2KB
UserAddServlet.class 2KB
FindExpressServlet.class 2KB
FindExpressServlet.class 2KB
ExpressAddServlet.class 2KB
ExpressAddServlet.class 2KB
UserSelectServlet.class 2KB
UserSelectServlet.class 2KB
UserServiceImp.class 2KB
UserServiceImp.class 2KB
ExpressSelectServlet.class 2KB
ExpressSelectServlet.class 2KB
SignatureUtil$Config.class 2KB
SignatureUtil$Config.class 2KB
DruidUtil.class 2KB
DruidUtil.class 2KB
RegServlet.class 2KB
RegServlet.class 2KB
WXConfig.class 2KB
WXConfig.class 2KB
UserDeleteServlet.class 2KB
UserDeleteServlet.class 2KB
UpdateStatusServlet.class 2KB
UpdateStatusServlet.class 2KB
ExpressDeleteServlet.class 2KB
ExpressDeleteServlet.class 2KB
LoginServlet.class 2KB
LoginServlet.class 2KB
SignatureUtil$1.class 1KB
SignatureUtil$1.class 1KB
Message.class 1KB
Message.class 1KB
LogoutServlet.class 1KB
LogoutServlet.class 1KB
MyTest.class 1KB
MyTest.class 1KB
SessionUtil.class 919B
SessionUtil.class 919B
BaseExpressDao.class 747B
BaseExpressDao.class 747B
BaseExpressService.class 705B
BaseExpressService.class 705B
BaseUserDao.class 697B
BaseUserDao.class 697B
DateFormatUtil.class 651B
DateFormatUtil.class 651B
BaseUserService.class 630B
BaseUserService.class 630B
DBTest.class 387B
DBTest.class 387B
layui.css 59KB
layui.css 59KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
layer.css 14KB
admin.css 10KB
admin.css 10KB
layui.mobile.css 10KB
layui.mobile.css 10KB
normalize.css 8KB
normalize.css 8KB
laydate.css 7KB
laydate.css 7KB
common.css 6KB
common.css 6KB
login.css 6KB
login.css 6KB
layer.css 5KB
layer.css 5KB
main.css 4KB
main.css 4KB
view.css 3KB
view.css 3KB
code.css 1KB
code.css 1KB
共 775 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
学术菜鸟小晨
- 粉丝: 1w+
- 资源: 5424
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功