servlet+mysql实现的旅游汽车公司车辆管理系统

servlet+mysql实现的旅游汽车公司车辆管理系统,第1张

博客目录
  • servlet+mysql实现的旅游汽车公司车辆管理系统
    • 实现功能截图
    • 使用技术
  • 实现的功能
    • 代码
    • 写在最后

servlet+mysql实现的旅游汽车公司车辆管理系统

本系统解决了旅游公司各个角色对于车辆的管理,财务员、司机、调度员、领导等。实现了反馈管理、费用管理、报表管理、维修管理、角色管理、车辆管理、登录管理、公司客户查询、录入管理等。

实现功能截图

司机:

司机反馈

调度员
查询公司客户

车辆报表

车辆管理

登录管理

维修管理

添加客户

调度员录入

财务员费用管理

财务员报表管理

领导角色费用管理

领导客户管理

领导车辆管理

使用技术

数据库:mysql
开发工具:Eclipse(Myeclispe、Idea也可以)
知识点:servlet/jsp

本系统采用将MVC的思想:将项目包分为pojo、dao/service/controller,代码结构清晰

实现的功能

一共分为四个角色
财务员、司机、调度员、领导

财务员:
费用管理
报表管理
车辆管理
维修管理
登录管理

司机
反馈管理
车辆管理
维修管理
登录管理

调度员
反馈管理
车辆报表管理
维修管理
登录管理

领导
客户管理
角色管理
登录管理

代码

dao

package che.dao.impl;

import che.data.*;
import che.dbc.*;
import java.util.* ;

public class chaxunDAOImpl {
	DbUtile db=new DbUtile();
	//查询未派出车辆信息
	public Vector<cheliang> query1() throws Exception {
		   Vector<cheliang> all = new Vector<cheliang>() ;
		//String sql = "SELECT * FROM cheliangbiao WHERE Cheliangzhuangtai='未派出' order by paicheshijian desc" ;
		   String sql = "SELECT * FROM cheliangbiao  order by paicheshijian desc" ;
	//	System.out.println(sql);
		db.rs = db.executeQuery(sql) ;
		while(db.rs.next()) {
			cheliang stu = new cheliang() ;
			stu.setId(db.rs.getInt(1));
			stu.setCheliangbianhao(db.rs.getInt(2)) ;
			stu.setChepaihao(db.rs.getString(3)) ;
			stu.setChexing(db.rs.getString(4)) ;
			stu.setYanse(db.rs.getString(5)) ;
			stu.setSiji(db.rs.getString(6)) ;
			stu.setZuoweishu(db.rs.getInt(7));
			stu.setQishilicheng(db.rs.getString(8));
			stu.setWanchenglicheng(db.rs.getString(9));
			stu.setCheliangsuoyou(db.rs.getString(10));
			stu.setCheliangzhuangtai(db.rs.getString(11));
			stu.setCheliangshuxing(db.rs.getString(12));
			all.add(stu) ;
		}			
		db.close() ;
		return all ;
	}
	public Vector<cheliang> newquery1(String a,String b) throws Exception {
		   Vector<cheliang> all = new Vector<cheliang>() ;
		//String sql = "SELECT * FROM cheliangbiao WHERE "+a+"='"+b+"' and Cheliangzhuangtai='未派出' order by paicheshijian desc" ;
		String sql = "SELECT * FROM cheliangbiao WHERE "+a+" like '%"+b+"%'  order by paicheshijian desc" ;
	//	System.out.println(sql);
		db.rs = db.executeQuery(sql) ;
			while(db.rs.next()) {
				cheliang stu = new cheliang() ;
				stu.setId(db.rs.getInt(1));
				stu.setCheliangbianhao(db.rs.getInt(2)) ;
				stu.setChepaihao(db.rs.getString(3)) ;
				stu.setChexing(db.rs.getString(4)) ;
				stu.setYanse(db.rs.getString(5));
				stu.setSiji(db.rs.getString(6));
				stu.setZuoweishu(db.rs.getInt(7));
				stu.setQishilicheng(db.rs.getString(8));
				stu.setWanchenglicheng(db.rs.getString(9));
				stu.setCheliangsuoyou(db.rs.getString(10));
				stu.setCheliangzhuangtai(db.rs.getString(11));
				stu.setCheliangshuxing(db.rs.getString(12));
				all.add(stu) ;
			}			
			db.close() ;
			return all ;
	}
	public Vector<chengbenfei> query1101() throws Exception {
		   Vector<chengbenfei> all = new Vector<chengbenfei>() ;
		String sql = "SELECT distinct chepaihao FROM chengbenfeibiao" ;
	//	System.out.println(sql);
		db.rs = db.executeQuery(sql) ;
			while(db.rs.next()) {
				chengbenfei stu = new chengbenfei() ;
			    stu.setChepaihao(db.rs.getString(1)) ;
				all.add(stu) ;
			}			
			db.close() ;
			return all ;
	}
	public Vector<chengbenfei> query11011() throws Exception {
		   Vector<chengbenfei> all = new Vector<chengbenfei>() ;
		String sql = "SELECT pingzhenghao FROM chengbenfeibiao" ;
	//	System.out.println(sql);
		db.rs = db.executeQuery(sql) ;
			while(db.rs.next()) {
				chengbenfei stu = new chengbenfei() ;
			    stu.setPingzhenghao(db.rs.getInt(1)) ;
				all.add(stu) ;
			}			
			db.close() ;
			return all ;
	}

loginDAOImpl.java

package che.dao.impl;
import che.data.*;
import che.dbc.*;
import java.util.* ;
public class loginDAOImpl {
	DbUtile db=new DbUtile();
	public boolean login(String a) throws Exception
	 {
		boolean flag = false ;
		String sql = "SELECT * FROM denglu WHERE yonghuming='"+a+"'";
		db.rs = db.executeQuery(sql) ;			
			if (db.rs.next()) {
				flag = true ;
			}
			//db.close() ;		
		return flag ;
	  }
	public denglu login1(String a) throws Exception
	 {
		denglu stu=null;
		String sql = "SELECT * FROM denglu WHERE yonghuming='"+a+"'" ;
		db.rs = db.executeQuery(sql) ;			
			if (db.rs.next()) {
				stu=new denglu();
				stu.setId(db.rs.getInt(1));
				stu.setYonghuming(db.rs.getString(2));
				stu.setMima(db.rs.getString(3));
				stu.setQuanli(db.rs.getString(4));
			}
			//db.close() ;		
			return stu ;
	  }
	public boolean login2(String a) throws Exception
	 {
		boolean flag = false ;
		String sql = "SELECT * FROM denglu WHERE yonghuming='"+a+"'";
		db.rs = db.executeQuery(sql) ;			
			if (db.rs.next()) {
				flag = true ;
			}
			//db.close() ;		
		return flag ;
	  }
	public boolean login3(String a,String b) throws Exception
	 {
		boolean flag = false ;
		String sql = "SELECT * FROM danchehesuanbiao WHERE chepaihao='"+a+"' AND yuefen='"+b+"'";
		db.rs = db.executeQuery(sql) ;			
			if (db.rs.next()) {
				flag = true ;
			}
			//db.close() ;		
		return flag ;
	  }
	public Vector<denglu> query() throws Exception
	 {
		Vector<denglu> all = new Vector<denglu>() ;
		String sql = "SELECT * FROM denglu ";
		db.rs = db.executeQuery(sql) ;			
			while (db.rs.next()) {
				denglu stu=new denglu();
				stu.setId(db.rs.getInt(1));
				stu.setYonghuming(db.rs.getString(2));
				stu.setMima(db.rs.getString(3));
				stu.setQuanli(db.rs.getString(4));
				all.add(stu);
			}
			db.close() ;		
			return all ;
	  }
	public Vector<denglu> query1(String a,String b) throws Exception
	 {
		Vector<denglu> all = new Vector<denglu>() ;
		String sql = "SELECT * FROM denglu WHERE "+a+" LIKE '%"+b+"%'";
		db.rs = db.executeQuery(sql) ;			
		while (db.rs.next()) {
				denglu stu=new denglu();
				stu.setId(db.rs.getInt(1));
				stu.setYonghuming(db.rs.getString(2));
				stu.setMima(db.rs.getString(3));
				stu.setQuanli(db.rs.getString(4));
				all.add(stu);
			}
			db.close() ;		
			return all ;
	  }
	public denglu queryById(int a) throws Exception
	 {
		denglu stu=null;
		String sql = "SELECT * FROM denglu WHERE id='"+a+"'" ;
		db.rs = db.executeQuery(sql) ;			
			if (db.rs.next()) {
				stu=new denglu();
				stu.setId(db.rs.getInt(1));
				stu.setYonghuming(db.rs.getString(2));
				stu.setMima(db.rs.getString(3));
				stu.setQuanli(db.rs.getString(4));
			}
			db.close() ;		
			return stu ;
	  }
	public static String getMD5(String password) {
		byte[] source = password.getBytes();
		String s = null;
		char hexDigits[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D','E','F'};
		try {
			java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5");
			md.update(source);
			byte tmp[] = md.digest(); 
			
			char str[] = new char[16 * 2]; 
			
			int k = 0; 
			for (int i = 0; i < 16; i++) { 
				
				byte byte0 = tmp[i]; 
				str[k++] = hexDigits[byte0 >>> 4 & 0xf]; 
				
				str[k++] = hexDigits[byte0 & 0xf];
			}
			s = new String(str); 

		} catch (Exception e) {
			e.printStackTrace();
		}
		return s;
	}
	public static void main(String args[]){
		System.out.println(getMD5("123456"));
	}

}

实体类
bumen.java

package che.data;

public class bumen {
	private int id;
	private String bumen  ;
	public void setId(int id){
		this.id =id;
	}
	public void setBumen(String bumen) {
		this.bumen = bumen ;
	}
	public int getId(){
		return this.id;
	}
    public String getBumen() {
		return this.bumen ;
	}
};

cheliang.java

package che.data;
public class cheliang  {
	private int id;
	private int cheliangbianhao  ;
	private String chepaihao ;
	private String chexing ;
	private String yanse;
	private int zuoweishu;
	private String cheliangsuoyou ;
	private String cheliangzhuangtai ;
	private String cheliangshuxing ;
	private String paicheshijian ;
	private String siji ;
	private String qishilicheng;
	private String wanchenglicheng;
	public void setId(int id){
		this.id =id;
	}
	public void setCheliangbianhao(int cheliangbianhao) {
		this.cheliangbianhao = cheliangbianhao ;
	}
	public void setChepaihao(String chepaihao) {
		this.chepaihao = chepaihao;
	}
	public void setChexing(String chexing) {
		this.chexing = chexing;
	}
	public void setYanse(String yanse) {
		this.yanse = yanse;
	}
	public void setZuoweishu(int zuoweishu){
		this.zuoweishu =zuoweishu;
	}
	public void setSiji(String siji){
		this.siji =siji;
	}
	public void setCheliangsuoyou(String cheliangsuoyou) {
		this.cheliangsuoyou = cheliangsuoyou;
	}
	public void setCheliangzhuangtai(String cheliangzhuangtai) {
		this.cheliangzhuangtai = cheliangzhuangtai;
	}
	public void setQishilicheng(String qishilicheng){
		this.qishilicheng =qishilicheng;
	}
	public void setWanchenglicheng(String wanchenglicheng){
		this.wanchenglicheng =wanchenglicheng;
	}
	public void setCheliangshuxing(String cheliangshuxing) {
		this.cheliangshuxing = cheliangshuxing;
	}
	public void setPaicheshijian(String paicheshijian) {
		this.paicheshijian = paicheshijian;
	}
	public int getId(){
		return this.id;
	}
    public int getCheliangbianhao() {
		return this.cheliangbianhao ;
	}
    public String getChepaihao() {
    	return this.chepaihao;
	}
	public String getChexing() {
		return this.chexing;
	}
	public String getSiji(){
		return this.siji;
	}
	public String getYanse() {
		return this.yanse;
	}
	public int getZuoweishu(){
		return this.zuoweishu;
	}
	public String getCheliangsuoyou() {
		return this.cheliangsuoyou;
	}
	public String getCheliangzhuangtai() {
		return this.cheliangzhuangtai;
	}
	public String getCheliangshuxing() {
		return this.cheliangshuxing;
	}  
	public String getQishilicheng(){
		return this.qishilicheng;
	}
	public String getWanchenglicheng(){
		return this.wanchenglicheng;
	}
	public String getPaicheshijian() {
		return this.paicheshijian;
	}   
};

servlet
cheliangluruservlet.java

package servlet;

import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import che.dao.impl.chaxunDAOImpl;
import che.data.paiche;
import che.data.yingjiaokuan;
import java.util.*;
import java.text.*;

public class cheliangluruservlet extends HttpServlet {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public cheliangluruservlet() {
		super();
	}
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException 
			{
		           doPost(request,response);
	        }
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		
		     request.setCharacterEncoding("utf-8");

		     SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
 
		     int hao =Integer.parseInt(request.getParameter("id"));
		     String ha=request.getParameter("chepaihao");
		     String hh=request.getParameter("cheliangsuoyou");
		     //String hao1=request.getParameter("siji");
		     String hao2=request.getParameter("chucheriqi");
		     String hao3=request.getParameter("wanchengriqi");
		     String hao4=request.getParameter("xingcheng");
		     String hao5=request.getParameter("xianshou");
		     String hao51=request.getParameter("beizhu");
		     String hhhh=request.getParameter("page");
		     
		     String haotime=formatter.format(new Date());
		     
//		     System.out.println(haotime); 
		     double a,b;
		     if(hao5!=""){
		    	 a=Double.parseDouble(hao5);
		     }else{
		    	 a=0;
		     }
		     
		     String hao55=request.getParameter("sheqian");
		     if(hao55!=""){
		    	 b=Double.parseDouble(hao55);
		     }else{
		    	 b=0;
		     }
		     String hao6=request.getParameter("qishilicheng");
		     //System.out.println(hao6);
		     double hhh=a+b;
		     String hao7=request.getParameter("wanchenglicheng");
		     String hao8=request.getParameter("zuchedanwei");
		  //   String hao9=request.getParameter("kehulianxifangshi");
		       	//派车表
		        paiche sa=new paiche();
		       // sa.setSiji(hao1) ;
				sa.setChucheriqi(hao2) ;
				sa.setWanchengriqi(hao3) ;
				sa.setXingcheng(hao4) ;
				sa.setXianshou(a);
				sa.setSheqian(b);
				sa.setQishilicheng(hao6);
			    sa.setWanchenglicheng(hao7);
				sa.setZuchedanwei(hao8);
			//	sa.setKehulianxifangshi(hao9);
				sa.setBeizhu(hao51);
				sa.setLrtime(haotime);
				System.out.println(haotime);
				
				//应交表
				yingjiaokuan aa=new yingjiaokuan();
				aa.setChepaihao(ha);
				aa.setChucheriqi(hao2);
				aa.setCheliangsuoyou(hh);
				aa.setZuchedanwei(hao8);
			//	aa.setKehulianxifangshi(hao9);
				aa.setYingshoukuan(hhh);
				aa.setXianshoukuan(a);
				aa.setSheqiankuan(b);
				aa.setXingcheng(hao4);
				aa.setWanchengriqi(hao3) ;
				aa.setBeizhu(hao51);
				
				chaxunDAOImpl ch=new chaxunDAOImpl();
				response.setContentType( "text/html;charset=utf-8 ");
				PrintWriter out = response.getWriter();
				try{				
				 if(ch.login(aa)){
					 response.setContentType( "text/html;charset=utf-8 "); 
				     out.print("");
					out.close();
					return;
				 }else{
					 ch.insertyingshou(aa);
					 ch.updatepaiche(sa,ha);
					 response.setContentType( "text/html;charset=utf-8 "); 
					 out.print("");
											out.close();
											return;}

				
		}catch(Exception e){response.setContentType("text/html; charset=UTF-8");
			out.print("");
				out.close();return;
		
		}
	}
	public void init() throws ServletException {
		// Put your code here
	}

}

InsertbumenServlet.java

package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import che.dao.impl.chaxunDAOImpl;
import che.data.bumen;

public class InsertbumenServlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public InsertbumenServlet() {
		super();
	}
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request,response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		 request.setCharacterEncoding("UTF-8");
		   response.setContentType("text/html; charset=UTF-8");
		   String hao0 =(String)request.getParameter("bumen");
		   bumen sa=new bumen();
	        sa.setBumen(hao0) ;
			chaxunDAOImpl cha=new chaxunDAOImpl();
			 response.setContentType( "text/html;charset=utf-8 ");
			try{
			    cha.insertbumen(sa);
			    PrintWriter out = response.getWriter();
			    out.print("");
			   						out.close();
			   						return;
		      
	}catch(Exception e){
	     System.out.println(e.getMessage()); 
	     PrintWriter out = response.getWriter();
    out.print("");
		   						out.close();
		   						return;
	}

	}
	public void init() throws ServletException {
		// Put your code here
	}

}

tianjiagongsikehuservlet.java

package servlet;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import che.dao.impl.chaxunDAOImpl;
import che.data.kehu;

public class tianjiagongsikehuservlet extends HttpServlet {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public tianjiagongsikehuservlet() {
		super();
	}
	public void destroy() {
		super.destroy(); // Just puts "destroy" string in log
		// Put your code here
	}
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doPost(request,response);
	}
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		 request.setCharacterEncoding("UTF-8");
		   response.setContentType("text/html; charset=UTF-8");
		   String hao0 =(String)request.getParameter("gongsimingcheng");
		   String hao1 =(String)request.getParameter("lianxifangshi");
           String hao2 =(String)request.getParameter("lianxiren");
           String hao3 =(String)request.getParameter("dizhi");
		   kehu sa=new kehu();
	        sa.setGongsimingcheng(hao0) ;
			sa.setLianxifangshi(hao1) ;
			sa.setLianxiren(hao2) ;
	        sa.setDizhi(hao3);
		    chaxunDAOImpl cha=new chaxunDAOImpl();
		    response.setContentType( "text/html;charset=utf-8 ");
			try{
			    cha.insert3(sa);
			    //JOptionPane.showMessageDialog(null,"添加成功!");
			    //response.sendRedirect("../tianjiagongsikehu.jsp?chaxun=1&xinxi=1");
			    //this.getServletConfig().getServletContext().getRequestDispatcher("/tianjiagongsikehu.jsp").forward(request,response);
			    PrintWriter out = response.getWriter();

			       out.print("");
			      				   						out.close();
			      				   						return;
	       }catch(Exception e){
		     //JOptionPane.showMessageDialog(null,"添加失败!");
		    // response.sendRedirect("../tianjiagongsikehu.jsp?chaxun=1&xinxi=1");
		     //this.getServletConfig().getServletContext().getRequestDispatcher("/tianjiagongsikehu.jsp").forward(request,response);
	         System.out.println(e.getMessage()); 
	         PrintWriter out = response.getWriter();

		       out.print("");
		      				   						out.close();
		      				   						return;
	
	}

	}
	public void init() throws ServletException {
		// Put your code here
	}

}

写在最后

如果运行代码中遇到问题,或者需要完整源码和报告,可以加博主V交流:Code2Life2

觉得有用,别忘了一键三连哈!

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/872171.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-13
下一篇 2022-05-13

发表评论

登录后才能评论

评论列表(0条)

保存