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

📄 inputfload.java

📁 办公自动化项目
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
package com.t60.oa.doc.service;
import com.t60.oa.doc.struts.InputDoucumentForm;
import org.hibernate.Criteria;
import java.util.List;
import org.hibernate.criterion.Restrictions;
import com.t60.oa.po.*;
import org.hibernate.Session;
import hong.javanet.dao.HibernateUtil;
import java.util.Iterator;
import org.hibernate.criterion.Projections;
import java.util.Date;
import java.util.*;

public class InputFload {
    private InputDoucumentForm form;
    private String folderId;
    private String message;
    private int userId;
    private Session session = HibernateUtil.currentSession();
    public void Input() throws Exception
   {
          Criteria crifile = session.createCriteria(DoucumentFolder.class);
          DoucumentFolder file =new DoucumentFolder();
          Floadpurview fload = new Floadpurview();
          String[] Possible=form.getPossible();
          String[] chosen = form.getChosen();
          if(folderId==null)
          {
              folderId="";
          }
          crifile.add(Restrictions.like("id",folderId+"____"));
          if(crifile.list().size()>0)
          {
              Iterator iter=crifile.list().iterator();
              while(iter.hasNext()){
                  DoucumentFolder circomfile=new DoucumentFolder();
                  circomfile = (DoucumentFolder) iter.next();
                  if (circomfile.getName().toLowerCase().equals(form.
                          getFilename().toLowerCase()))
                  {
                      message="文件名已存在";
                      return;
                  }
              }
          }
          if(Possible!=null){
            for (int i = 0; i < Possible.length; i++) {
                if (Possible[i].charAt(0) == 'y' || Possible[i].charAt(0) == 'Y') {
                    String empid = Possible[i].substring(1, Possible[i].length());
                    int emp = 0;
                    for (int j = 0; j < Possible.length; j++) {
                        if (Possible[j].charAt(0) == 'y' ||
                            Possible[j].charAt(0) == 'Y') {
                            empmass:if (empid.equals(Possible[j].substring(1,
                                    Possible[j].length()))) {
                                if (emp == 0) {
                                    emp++;
                                    break empmass;
                                }
                                if (emp == 1) {
                                    emp = 0;
                                    message = "只读权限出现相同的员工";
                                    return;
                                }
                            }
                        }
                    }
                } else {
                    int dep = 0;
                    for (int j = 0; j < Possible.length; j++) {
                        depmass:if (Possible[j].charAt(0) == 'y' ||
                                    Possible[j].charAt(0) == 'Y') {
                            Integer userid = new Integer(Possible[j]
                                                         .substring(1,
                                    Possible[j].length()));
                            List deplist = this.depemplist(userid, "");
                            Iterator iter = deplist.iterator();
                            while (iter.hasNext()) {
                                DepEmp item = (DepEmp) iter.next();
                                if (item.getDep().getId().equals(Possible[i])) {
                                    message = "只读权限的员工所在的部门已在只读权限上";
                                    return;
                                }
                            }
                        } else if (Possible[j].equals(Possible[i])) {
                            if (dep == 0) {
                                dep++;
                                break depmass;
                            }
                            message = "只读权限出现相同的部门";
                            return;
                        }
                    }
                }
            }
        }
        if(chosen!=null){
            for (int i = 0; i < chosen.length; i++) {
                if (chosen[i].charAt(0) == 'y' || chosen[i].charAt(0) == 'Y') {
                    int emp = 0;
                    String empid = chosen[i].substring(1, chosen[i].length());
                    if (Possible != null) {
                        for (int j = 0; j < Possible.length; j++) {
                            if (Possible[j].charAt(0) == 'y' ||
                                Possible[j].charAt(0) == 'Y') {
                                if (empid.equals(Possible[j].substring(1,
                                        Possible[j].length()))) {
                                    message = "编辑权限的员工和只读权限的员工相同";
                                    return;
                                }
                            }
                        }
                    }
                    for (int j = 0; j < chosen.length; j++) {
                        if (chosen[j].charAt(0) == 'y' ||
                            chosen[j].charAt(0) == 'Y') {
                            empmass:if (empid.equals(chosen[j].substring(
                                    1, chosen[j].length()))) {
                                if (emp == 0) {
                                    emp++;
                                    break empmass;
                                }
                                if (emp == 1) {
                                    message = "编辑权限出现相同的员工";
                                    return;
                                }
                            }
                        }
                    }
                } else {
                    int dep = 0;
                    if (Possible != null) {
                        for (int j = 0; j < Possible.length; j++) {
                            if (Possible[j].charAt(0) == 'y' ||
                                Possible[j].charAt(0) == 'Y') {
                                Integer userid = new Integer(Possible[j]
                                        .substring(1, Possible[j].length()));
                                List deplist = this.depemplist(userid, "");
                                Iterator iter = deplist.iterator();
                                while (iter.hasNext()) {
                                    DepEmp item = (DepEmp) iter.next();
                                    if (item.getDep().getId().equals(chosen[i])) {
                                        message = "只读权限的员工所在的部门已在编辑权限上";
                                        return;
                                    }
                                }
                            } else if (Possible[j].equals(chosen[i])) {
                                message = "只读权限的部门已在编辑权限上";
                                return;
                            }
                        }
                    }
                    for (int j = 0; j < chosen.length; j++) {
                        depmass:if (chosen[j].charAt(0) == 'y' ||
                                    chosen[j].charAt(0) == 'Y') {
                            Integer userid = new Integer(chosen[j]
                                    .substring(1, chosen[j].length()));
                            List deplist = this.depemplist(userid, "");
                            Iterator iter = deplist.iterator();
                            while (iter.hasNext()) {
                                DepEmp item = (DepEmp) iter.next();
                                if (item.getDep().getId().equals(chosen[i])) {
                                    message = "编辑权限的员工所在的部门已在编辑权限上";
                                    return;
                                }
                            }
                        } else if (chosen[j].equals(chosen[i])) {
                            if (dep == 0) {
                                dep++;
                                break depmass;
                            }
                            message = "编辑权限出现相同的部门";
                            return;
                        }
                    }
                }
            }
        }
          crifile.setProjection(Projections.max("id"));
          String id=folderId+"0001";
          if(crifile.uniqueResult()!=null){
              id = (String) crifile.uniqueResult();
              String idtwo = id;
              if (id.length() > 5) {
                  idtwo = id.substring(id.length() - 4, id.length());
              }
              idtwo = new Integer(new Integer(idtwo).intValue() + 1).toString();
              if (idtwo.length() == 1) {
                  id = id.substring(0, id.length() - 4) + "000" + idtwo;
              } else if (idtwo.length() == 2) {
                  id = id.substring(0, id.length() - 4) + "00" + idtwo;
              } else if (idtwo.length() == 3) {
                  id = id.substring(0, id.length() - 4) + "0" + idtwo;
              }
          }
          file.setId(id);
          file.setName(form.getFilename());
          file.setCreateDate(new Date());
          file.setTypeDocument(true);
          file.setState(false);
          Employee emp= (Employee)session.load(Employee.class,new Integer(userId));
          file.setOwner(emp);
          file.setEdite(emp);
          session.save(file);
          file=(DoucumentFolder)session.load(DoucumentFolder.class,id);
          fload.setDoucumentFile(file);
          fload.setUser(emp);
          fload.setType(new Byte("1"));
          session.save(fload);
          Integer empnull=null;
          List fplist=this.fioadlist(folderId,empnull,"");
          if(fplist.size()>0){
              Iterator iter = fplist.iterator();
              while (iter.hasNext()) {
                  Floadpurview item = (Floadpurview) iter.next();
                  if(item.getDepartment()!=null)
                  {
                      this.inputfioad(file,empnull,item.getDepartment()
                                      .getId(),item.getType().toString());
                  }else if(item.getUser()!=null&&
                           !item.getType().toString().equals("1"))
                  {
                      this.inputfioad(file,item.getUser().getId(),"",
                                      item.getType().toString());
                  }
              }
          }else{
              if(Possible!=null){
                  for(int i=0;i<Possible.length;i++){
                      if(Possible[i].charAt(0)=='y'||
                          Possible[i].charAt(0)=='Y'){
                          Integer empid = new Integer(Possible[i].substring(1,
                              Possible[i].length()));
                          this.inputfioad(file,empid,"","3");
                      }else{
                          this.inputfioad(file,empnull,Possible[i],"3");
                      }
                  }
              }

⌨️ 快捷键说明

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