⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sqdcx.java

📁 办公自动化项目
💻 JAVA
字号:
package com.t60.oa.service.car;

import java.util.List;


import com.t60.oa.web.car.SqdcxForm;
import hong.javanet.dao.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.criterion.Projections;
import org.hibernate.criterion.Restrictions;
import com.t60.oa.po.Apply;
import java.util.Iterator;
import com.t60.oa.po.Employee;
import java.text.SimpleDateFormat;
import java.text.*;
import org.hibernate.criterion.Order;

public class Sqdcx {

    private SqdcxForm form;
    private List result;
    private String message;

   private int pageIndex;
   private int pageSize = 10;
   private boolean needCount;

   private int rowCount;
   private int pageCount;


   public void querySqd() {
       SimpleDateFormat time = new SimpleDateFormat("yyyy-MM-dd");
       Session session = HibernateUtil.currentSession();
//       this.result= session.createQuery("from Apply where carnum like '%8%'").list();
       org.hibernate.Criteria sqdcx = session.createCriteria(Apply.class);

       if(form.getId()>0){
           sqdcx.add(Restrictions.eq("id",new Integer(form.getId())));
       }
       //车辆编号
       if (form.getCarnum()!= null &&
           form.getCarnum().trim().length() > 0) {
           String carnum = form.getCarnum().trim().toString();
           sqdcx.add(Restrictions.like("carnum.num", "%" + carnum + "%"));
       }

       //车辆类型
       if (form.getCartype() != null &&
           form.getCartype().trim().length() > 0) {
           if(!form.getCartype().trim().equals("忽略")){
               String cartype = form.getCartype().trim().toString();
           sqdcx.add(Restrictions.like("cartype", "%" + cartype + "%"));
           }
       }

       //申请单状态
       if (form.getState() != null &&
           form.getState().trim().length() > 0) {
           if (!form.getState().trim().equals("忽略")) {
               String state = form.getState().trim().toString();
               sqdcx.add(Restrictions.like("state", "%" + state + "%"));
           }
       }

       //申请人
       if (form.getAuse() != null &&
           form.getAuse().trim().length() > 0) {
           String ause = form.getAuse().trim().toString();
//           System.out.println(ause);
           sqdcx.add(Restrictions.eq("ause.id",new Integer(ause)));
       }

       //取车人
       if (form.getOuser() != null &&
           form.getOuser().trim().length() > 0) {
           String ouser = form.getOuser().trim().toString();
//           System.out.println("ouser:"+ouser);
           sqdcx.add(Restrictions.eq("ouser.id",new Integer(ouser)));
       }


       //还车人
       if (form.getBuser() != null &&
           form.getBuser().trim().length() > 0) {
           String buser = form.getBuser().trim().toString();
//           System.out.println(buser);
           sqdcx.add(Restrictions.eq("buser.id",new Integer(buser)));
       }


       //领导
       if (form.getLuse() != null &&
           form.getLuse().trim().length() > 0) {
           String luse = form.getLuse().trim().toString();
//           System.out.println(luse);
           sqdcx.add(Restrictions.eq("luse.id",new Integer(luse)));
       }


       //时间

        try {
            if(form.getGagebreakout()!=null&& form.getGagebreakout().trim().length()>0){
            sqdcx.add(Restrictions.ge("gagebreakout",
                                      time.parse(form.getGagebreakout())));
            }
            if(form.getGagegiveback()!=null&& form.getGagegiveback().trim().length()>0){
            sqdcx.add(Restrictions.le("gagegiveback",
                                      time.parse(form.getGagegiveback())));
            }


        } catch (ParseException ex) {
        }

       sqdcx.addOrder(Order.desc("gagegiveback"));

       this.result=sqdcx.list();

       Iterator iter = this.result.iterator();
       while (iter.hasNext()) {
           Apply item = (Apply) iter.next();
          // item.getJob().getJob_desc();
          org.hibernate.Hibernate.initialize(item.getAuse());
          org.hibernate.Hibernate.initialize(item.getBuser());
          org.hibernate.Hibernate.initialize(item.getOuser());
          org.hibernate.Hibernate.initialize(item.getLuse());
          org.hibernate.Hibernate.initialize(item.getCarnum());
          org.hibernate.Hibernate.initialize(item.getCartype());
       }




//分页

//       sqdcx.setMaxResults(this.pageSize);
//       sqdcx.setFirstResult((this.pageIndex - 1) * this.pageSize);
//       this.result = sqdcx.list();
//       if (this.needCount) {
//           sqdcx.setProjection(Projections.rowCount());
//           this.rowCount = ((Integer) sqdcx.uniqueResult()).intValue();
//           this.pageCount = (this.rowCount - 1) / this.pageSize + 1;
//       }



//       Iterator iter = this.result.iterator();
//       while (iter.hasNext()) {
//           Employee item = (Employee) iter.next();
//          // item.getJob().getJob_desc();
//          org.hibernate.Hibernate.initialize(item.getJob());
//       }

   }

    public SqdcxForm getForm() {
        return form;
    }

    public String getMessage() {
        return message;
    }

    public boolean isNeedCount() {
        return needCount;
    }

    public int getPageCount() {
        return pageCount;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public int getPageSize() {
        return pageSize;
    }

    public List getResult() {
        return result;
    }

    public int getRowCount() {
        return rowCount;
    }

    public void setRowCount(int rowCount) {
        this.rowCount = rowCount;
    }

    public void setResult(List result) {
        this.result = result;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public void setPageCount(int pageCount) {
        this.pageCount = pageCount;
    }

    public void setNeedCount(boolean needCount) {
        this.needCount = needCount;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public void setForm(SqdcxForm form) {
        this.form = form;
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -