📄 dealjob.java
字号:
package com.skyhawk.control;
import java.io.IOException;
import java.sql.Date;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.skyhawk.user.AgentList;
import com.skyhawk.user.Emplyee;
public class DealJob {
private int id1;
public void play(HttpServletRequest req,HttpServletResponse res){
HttpSession session=req.getSession();
System.out.println("-in the dealplay-");
String method=req.getParameter("method");
System.out.println(method);
//获得设置代办员工姓名
if (method.equals("getempname"))
{
Djmethod dm=new Djmethod();
List list1=dm.getEmplyee("select * from o_employee");
try {
req.setAttribute("list1",list1);
System.out.println("in the jsp");
req.getRequestDispatcher("/deal.jsp").forward(req,res);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
//添加自己的计划
if(method.equals("addself"))
{
AgentList agent=new AgentList();
System.out.println("add selfproject!");
String name=(String)session.getAttribute("name");
System.out.println("empename==="+name);
Integer id=(Integer)session.getAttribute("id");
int id1=id.intValue();
System.out.println("empid======"+id1);
String time1=(String)req.getParameter("starttime");
System.out.println(time1);
//agent.setendTime(Date.valueOf(time1));
//System.out.println(agent.getendTime());
String project=(String)req.getParameter("addproject");
String strinsert="insert into o_project values('"+id1+"',to_date('"+time1+"','yyyy-mm-dd'),'"+project+"','"+name+"')";
Djmethod dmt=new Djmethod();
int m=dmt.addAgentList(strinsert);
System.out.println(m);
if(m>0)
{
try {
req.getRequestDispatcher("/success1.jsp").forward(req,res);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}else{
try {
res.sendRedirect("/skyhawk/terror.html");
} catch (IOException e) {
e.printStackTrace();
}
}
}else if (method.equals("adddj")) {
//添加代办信息
Emplyee emp=null;
System.out.println("int the adddj");
AgentList agent=new AgentList();
String time=(String)req.getParameter("starttime");
System.out.println("tiem======"+time);
HttpSession hs=req.getSession();
Integer id= (Integer)hs.getAttribute("id");
int id1 = id.intValue();
System.out.println(id);
String name=(String) hs.getAttribute("name");
System.out.println("name+++===="+name);
String empname=req.getParameter("user");
System.out.println(empname);
//获得要添加个人代办信息
agent.setagentId(String.valueOf(id1));
agent.setagentName(name);
agent.setempName(req.getParameter("user"));
agent.setendTime(Date.valueOf(time));
agent.setTittle(req.getParameter("tittle"));
agent.setTaskwork(req.getParameter("taskwork"));
List list1=null;
Djmethod dmt=new Djmethod();
list1 =dmt.getEmplyee("select * from o_employee where empname='"+empname+"'");
emp=(Emplyee)list1.get(0);
int empid1=emp.getempId();
System.out.println("empid:"+empid1);
boolean m=dmt.getTime(agent.getendTime(),empid1);
System.out.println("判断时间冲突"+m);
if(m){
try {
res.sendRedirect("/skyhawk/web/timeclash.html");
} catch (IOException e) {
e.printStackTrace();
}
}else{
//hs.setAttribute("timeclash",new boolean(m));
//session.setAttribute("m",new Integer(m));
System.out.println("-----------"+empid1);
String strinsert="insert into o_agentlist values('"+agent.getagentId()+"','"+empid1+"',to_date('"+agent.getendTime()+"','yyyy-mm-dd'),'"+agent.getTaskwork()+"','"+agent.getTittle()+"','"+agent.getempName()+"','"+agent.getagentName()+"')";
agent.setempId(emp.getempId());
int n=dmt.addAgentList(strinsert);
if (n>0){
try {
req.getRequestDispatcher("/deal.jsp").forward(req,res);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}else{
try {
res.sendRedirect("/skyhawk/terror.html");
} catch (IOException e) {
e.printStackTrace();
}
}
}
}else if (method.equals("login")) {
HttpSession s=req.getSession();
Djmethod dmt1=new Djmethod();
//判断数据库是否为空
boolean n=dmt1.getDep();
System.out.println("数据库是否为空"+n);
String b;
if(n){
b="1";
session.setAttribute("b",b);
}else{
b="0";
session.setAttribute("b",b);
}
Emplyee emp1=null;
List list1=null;
List deplist=null;
List list2=null;
List list3=null;
String ma=(String)s.getAttribute("rand");
int id=Integer.parseInt(req.getParameter("user1"));
list2=dmt1.getEmplyee("select * from o_employee where depid in (select depid from o_employee where empid='"+id+"')");
s.setAttribute("list2",list2);
list3=dmt1.getDep1("select DISTINCT(depid) from o_employee where empid='"+id+"'");
s.setAttribute("list3",list3);
System.out.println(list2.size() );
System.out.println(list2);
System.out.println(id);
s.setAttribute("id",new Integer(id));
String nowtime=dmt1.nowTime();
System.out.println("现在时间:"+nowtime);
String timeSQL="select * from o_agentlist where endtime=to_date('"+nowtime+"','yyyy-mm-dd') and empid='"+id+"'";
s.setAttribute("timeSQL",timeSQL);
System.out.println("111111111111111111111111");
String strSQL="select * from o_agentlist where empid='"+id+"' order by(endtime) desc";
s.setAttribute("strSQL",strSQL);
String strSQL1="select * from o_agentlist where agentid='"+id+"' order by(endtime) desc";
s.setAttribute("strSQL1",strSQL1);
String strSQL2="select * from o_project where empid='"+id+"'";
s.setAttribute("strSQL2",strSQL2);
String strSQL5="select * from o_myinfo1 where empid='"+id+"'";
s.setAttribute("strSQL5",strSQL5);
System.out.println(strSQL5);
list1=dmt1.getEmplyee("select * from o_employee where empid='"+id+"'");
deplist=dmt1.getDep("select * from o_department");
//String depname1="select depname from o_department,o_employee where o_department.depid=o_employee.depid and empid='"+id+"'";
s.setAttribute("deplist",deplist);
//String depempSQL="select empname form o_employee where depid='"++"'"
String pasw=req.getParameter("pw");
String yzm=req.getParameter("yanzhengma");
System.out.println("验证码="+yzm);
//s.setAttribute("id",id);
boolean i=dmt1.getLogin(id,pasw);
System.out.println(ma);
System.out.println(yzm);
if(i && yzm.equals(ma)){
emp1=(Emplyee)list1.get(0);
String name=emp1.getempName();
s.setAttribute("name",name);
System.out.println("姓名:"+name);
int bool =emp1.getpurview();
s.setAttribute("bool",new Integer(bool));
System.out.println("yzmcw");
try {
req.getRequestDispatcher("/all.jsp").forward(req,res);
} catch (ServletException e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -