servletService

原创
2013/12/22 20:57
阅读数 102

package com.luojin.service;


import java.io.File;

import java.io.IOException;

import java.lang.reflect.InvocationTargetException;

import java.text.SimpleDateFormat;

import java.util.Date;


import javax.servlet.ServletException;

import javax.servlet.http.HttpServlet;

import javax.servlet.http.HttpServletRequest;

import javax.servlet.http.HttpServletResponse;


import org.apache.commons.beanutils.BeanUtils;


import com.luojin.dao.UserBeanDao;

import com.luojin.model.Custom;

import com.luojin.model.CustomEerter;

import com.luojin.model.LandEstateImg;

import com.luojin.model.landEsatae;

import com.luojin.model.sysUser;

import com.luojin.tools.CombKey;

import com.luojin.tools.CreateFile;

import com.luojin.tools.TimeDistance;


public class AddStarts extends HttpServlet {

private static final long serialVersionUID = 1L;

protected void service(HttpServletRequest req, HttpServletResponse resp)

throws ServletException, IOException { 

req.setCharacterEncoding("utf-8");

resp.setContentType("text/html;charset=UTF-8");

//得到新建csId;是按用户名来得值的

        String csId=req.getParameter("type");

        System.out.println(csId);

        String appItem=req.getParameter("item");

        String finshday=req.getParameter("setdate");

        System.out.println("预计日期是:"+finshday);

        Date endTime=TimeDistance.getDays(finshday);

        //uuid

        String comb=CombKey.createPrimaryKey();

        String cstname=req.getParameter("applName");

        System.out.println(cstname);

        Custom cst=new Custom();

        CustomEerter ctr=new CustomEerter();

        landEsatae ld=new landEsatae();

         try {

        //功能好强大啊表单的name 与bean要设置一样 集体设值

        BeanUtils.populate(cst, req.getParameterMap());

        BeanUtils.populate(ctr, req.getParameterMap());

        BeanUtils.populate(ld, req.getParameterMap());

} catch (IllegalAccessException e) {

e.printStackTrace();

} catch (InvocationTargetException e) {

e.printStackTrace();

}

       //得到头像路径

         String path = req.getSession().getServletContext().getRealPath("upload/1.jpg");

         String oglImg=req.getSession().getServletContext().getRealPath("upload/ogl.jpg");

         String oglImg1=req.getSession().getServletContext().getRealPath("upload/1.jpg");

         String oglImg2=req.getSession().getServletContext().getRealPath("upload/2.jpg");

         String oglImg3=req.getSession().getServletContext().getRealPath("upload/3.jpg");

         String oglImg4=req.getSession().getServletContext().getRealPath("upload/4.jpg");

         String oglImg5=req.getSession().getServletContext().getRealPath("upload/5.jpg");

         String oglImg6=req.getSession().getServletContext().getRealPath("upload/6.jpg");

         String oglImg7=req.getSession().getServletContext().getRealPath("upload/7.jpg");

         String oglImg8=req.getSession().getServletContext().getRealPath("upload/8.jpg");

         String oglImg9=req.getSession().getServletContext().getRealPath("upload/9.jpg");

         String oglImg10=req.getSession().getServletContext().getRealPath("upload/10.jpg");

         String oglImg11=req.getSession().getServletContext().getRealPath("upload/11.jpg");

  File fileImg=new File(path);

  Date statetime =new Date();

  UserBeanDao dao=new UserBeanDao();

         sysUser usere=(sysUser)req.getSession().getAttribute("user");

         String user=usere.getUserAccount();

         String parsId=req.getParameter("PersionCard");

         String Usercode=req.getParameter("paper_code");

        //DES加密

  Custom cum=new Custom(comb,appItem,cst.getApplName(),parsId,cst.getAppAddress(),

      cst.getAppTelephone(),statetime,user,csId,fileImg,endTime);

  int coutrows=dao.CommonTable(cum);

  //客户信息

  int cstUser=dao.addEerter(comb,ctr.getEtrName(),ctr.getEtrType(), ctr.getEtrsetNew(),

  ctr.getEtrBslicence(),ctr.getEtrOrgencode(),ctr.getErtJuridical(),

  ctr.getErtIdcode(),ctr.getPaper_type(),ctr.getPaper_code(),ctr.getPaper_name(),ctr.getPaper_sex(),ctr.getFund());

  //原件信息

   //得到一个数组

String [] shuzu=req.getParameterValues("checkbox");

//建立一个空数组

int[] includ=new int[12];

for (int i = 0; i < shuzu.length; i++)

{

if(Integer.parseInt(shuzu[i])==1)

{

 includ[0]=1;//把1装进数组

}else if(Integer.parseInt(shuzu[i])==2){

includ[1]=1;

}else if (Integer.parseInt(shuzu[i])==3) {

includ[2]=1;

}else if (Integer.parseInt(shuzu[i])==4) {

includ[3]=1;

}else if (Integer.parseInt(shuzu[i])==5) {

includ[4]=1;

}else if (Integer.parseInt(shuzu[i])==6) {

includ[5]=1;

}else if (Integer.parseInt(shuzu[i])==7) {

includ[6]=1;

}else if (Integer.parseInt(shuzu[i])==8) {

includ[7]=1;

}else if (Integer.parseInt(shuzu[i])==9) {

includ[8]=1;

}else if (Integer.parseInt(shuzu[i])==10) {

includ[9]=1;

}else if (Integer.parseInt(shuzu[i])==11) {

includ[10]=1;

}else if (Integer.parseInt(shuzu[i])==12) {

includ[11]=1;

}

}

landEsatae state=new landEsatae(comb,includ[0],includ[1],includ[2],includ[3],includ[4],includ[5],includ[6],includ[7],includ[8],includ[9],includ[10],includ[11]);

LandEstateImg images=new LandEstateImg(comb,oglImg,oglImg1,oglImg2,oglImg3,oglImg4,oglImg5,oglImg6,oglImg7,oglImg8,oglImg9,oglImg10,oglImg11);

    int rows= dao.addLandEstate(state);

    String strpath=req.getServletContext().getRealPath("/");

    Date date=new Date();

String year=new SimpleDateFormat("yyyy").format(date);

String moth=new SimpleDateFormat("MM").format(date);

String dates=new SimpleDateFormat("dd").format(date);

//String str=strpath+"\\"+year+"\\"+moth+dates+"\\"+csId+"\\";

String str=strpath+"\\"+year+"\\"+csId+"\\";

File filepath=new File(str); 

 if(!filepath.exists()){

 filepath.mkdirs();

 }

    int Imags=dao.addLandOglImg(images,csId,str);

         /*System.out.println("++img"+Imags);*/

    //删除文件夹里的临时图片

    CreateFile dlfile=new CreateFile();

    File zdf =new File("D:/MyWork/.metadata/.plugins/org.eclipse.wst.server.core/tmp0/wtpwebapps/AdministrationService/upload");

    dlfile.deleteFile(zdf);

 //得到新建立的文件路径 在文件夹下给一个预定义的jpg装二进制。

 //File filepaths=new File(str + "temp.jpg");

     //dao.crtApplNameIfo(comb);

     resp.getWriter().print(coutrows);

     resp.getWriter().close();

   /* resp.getWriter().print(rows);

    resp.getWriter().print(cstUser);*/

   

}

}

//-------------------------------------------------
package com.luojin.service;

import java.io.IOException;
import java.util.List;

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

import com.luojin.dao.UserBeanDao;
import com.luojin.model.CheckIn;

public class Bussmanger extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException { 
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=UTF-8");
String pNow=req.getParameter("pageNow");
int pageNows=1;
if (pNow!=null) {
pageNows=Integer.parseInt(pNow);
}
//实现分页
int pageSize=6;//显示几行记录
int pageNow=1;//显示第几页
int pageCount=0;
UserBeanDao dao=new UserBeanDao();
//统计有多少行记
int rowCount= dao.CountBuss();
if(rowCount%pageSize==0)
{
pageCount=rowCount/pageSize;
}else 
pageCount=rowCount/pageSize+1; 
}
if(pageNows<pageCount)
{
if(pageNows==0)
{
pageNow=1;
}
else
{
pageNow=pageNows;

}
}else {
pageNow=pageCount;
}
HttpSession session=req.getSession();
List<CheckIn> Item =dao.PageBussManger(pageSize, pageNow);
System.out.println("集合长度"+Item.size()+"daxiao"+pageSize+"sklhsl"+pageNow);
System.out.println("当前页数"+pageNow);
req.setAttribute("pageSize", pageSize);
req.setAttribute("pagenow", pageNow);
req.setAttribute("Pagecount", pageCount);
req.setAttribute("allItem", Item);
try {
req.getRequestDispatcher("/BussManger.jsp").forward(req, resp);
} catch (ServletException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

//------------------------------------------------
package com.luojin.service;

import java.io.IOException;
import java.util.List;

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

import com.luojin.dao.UserBeanDao;
import com.luojin.model.landAssist;

public class CallbackAssigen extends HttpServlet{
 protected void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws ServletException, IOException {
//         String czyauditor=req.getParameter("text");
//         String Hremark=req.getParameter("Hremark");
        //循环更新
    String str[]=req.getParameterValues("delid");
    if(str!=null)
     {
        for (int i = 0; i < str.length; i++) 
        {
System.out.println(str[i]);
String clstate=req.getParameter(""+str[i]+"a");
String clrmark=req.getParameter(""+str[i]+"b");
UserBeanDao dao=new UserBeanDao(); 
       int rows=  dao.updateczyauditor(clstate,clrmark,str[i]);   
}
           //循环后查询
          // UserBeanDao  dao=new UserBeanDao();
          // dao.appercl();
           UserBeanDao dao=new UserBeanDao();
           String userCount=req.getParameter("userCountion");
    List<landAssist> Item = dao.getListHouse(userCount);
       req.setAttribute("allItem", Item);
           req.getRequestDispatcher("recallInfo").forward(req, resp);
       }else{
           resp.sendRedirect("headerr.jsp");  
       }
   
  }
}

//--------------------------------------------------------
package com.luojin.service;

import java.io.IOException;
import java.lang.reflect.Type;
import java.util.List;

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

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.luojin.dao.UserBeanDao;
import com.luojin.model.CheckIn;
import com.luojin.model.landAssist;

public class CheckFCId extends HttpServlet{
private static final long serialVersionUID = 1L;
protected void service(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException { 
req.setCharacterEncoding("utf-8");
resp.setContentType("text/html;charset=UTF-8");
String busses=req.getParameter("appItem");
UserBeanDao dao=new UserBeanDao();
//得到序列号
int csId=dao.checkFcId();
//天数及信息
List<CheckIn> dayInfo=dao.getbussesDay(busses);
Gson gson=new Gson();
   Type type=new TypeToken<List<CheckIn>>(){}.getType();
   String jsonStr=gson.toJson(dayInfo,type);
 // String messageBack=gson.toJson(messageback,type);
   resp.getWriter().print(csId+"|"+jsonStr);
resp.getWriter().close();
}    
}



展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部