Exemplo n.º 1
0
  private List<HashMap<String, Object>> getQuestionAnswerData(ExamResult examResult) {
    DetachedCriteria criteria =
        DetachedCriteria.forClass(ExamResultAnswer.class, "examResultAnswer");
    criteria.createAlias("examResultAnswer.question", "question");
    criteria.createAlias("examResultAnswer.answer1", "answer1");
    criteria.createAlias("examResultAnswer.answer2", "answer2");
    criteria.createAlias("examResultAnswer.answer3", "answer3");
    criteria.createAlias("examResultAnswer.answer4", "answer4");

    ProjectionList projectionList = Projections.projectionList();
    projectionList.add(Projections.property("question.questionId"), "questionId");
    projectionList.add(Projections.property("question.questionText"), "questionText");
    projectionList.add(Projections.property("answer1.answerId"), "answer1Id");
    projectionList.add(Projections.property("answer1.answerText"), "answer1Text");
    projectionList.add(Projections.property("answer2.answerId"), "answer2Id");
    projectionList.add(Projections.property("answer2.answerText"), "answer2Text");
    projectionList.add(Projections.property("answer3.answerId"), "answer3Id");
    projectionList.add(Projections.property("answer3.answerText"), "answer3Text");
    projectionList.add(Projections.property("answer4.answerId"), "answer4Id");
    projectionList.add(Projections.property("answer4.answerText"), "answer4Text");
    projectionList.add(
        Projections.property("examResultAnswer.examResultAnswerId"), "examResultAnswerId");
    projectionList.add(Projections.property("examResultAnswer.answerId"), "answerId");
    criteria.setProjection(projectionList);
    criteria.add(Restrictions.eq("examResultAnswer.examResultId", examResult.getExamResultId()));
    criteria.addOrder(Order.asc("examResultAnswer.ordinal"));
    criteria.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);

    return basicFinderService.findByCriteria(criteria);
  }
Exemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see com.changpeng.common.action.AbstractAction#go()
   */
  @Override
  protected String go() throws Exception {

    DetachedCriteria detachedCriteria =
        DetachedCriteria.forClass(SysUser.class).add(Restrictions.eq("roleid", 1));

    // 这里要判断出登录帐号所属的group
    // 如果是admin,看所有的,如果不是admin,则根据登录人员的所属角色,判断角色对用户和对部门的可见性

    if (loginname != null && !"".equals(loginname))
      detachedCriteria.add(Restrictions.like("loginname", loginname, MatchMode.ANYWHERE));
    if (username != null && !"".equals(username))
      detachedCriteria.add(Restrictions.like("username", username, MatchMode.ANYWHERE));
    if (systemno != null && !"".equals(systemno))
      detachedCriteria.add(Restrictions.like("systemno", systemno, MatchMode.ANYWHERE));
    // 必须是没有删除的啊
    detachedCriteria.add(Restrictions.eq("delflag", false));
    // 取消掉自己的显示
    detachedCriteria.add(Restrictions.ne("userid", getLoginUser().getUserid()));
    SysUser sysUser = getLoginUser();
    SysGroup group = sysUser.getSysGroup();
    // 如果没有所属的group,则能查看所有的数据信息,否则只能看本部门和下级部门的数据
    if (group != null && group.getGroupid() != 1) { // 不是深圳律协的人上来的话
      int groupid = group.getGroupid();
      GroupTree tree = new GroupTree();
      List groupidlist = tree.getChildGroupIds(groupid);
      detachedCriteria
          .createAlias("sysGroup", "sysGroup")
          .add(Restrictions.in("sysGroup.groupid", groupidlist));
      if (groupname != null && !"".equals(groupname)) {
        detachedCriteria.add(
            Restrictions.like("sysGroup.groupname", groupname, MatchMode.ANYWHERE));
      }

      // detachedCriteria.add(Restrictions.in("groupid", groupidlist));
    } else if (groupname != null && !"".equals(groupname)) {
      detachedCriteria
          .createAlias("sysGroup", "sysGroup")
          .add(Restrictions.like("sysGroup.groupname", groupname, MatchMode.ANYWHERE));
    }
    detachedCriteria.setFetchMode("sysGroup", FetchMode.JOIN);

    // 按userid逆序排序
    detachedCriteria.addOrder(Order.desc("userid"));
    BasicService service = (BasicService) getBean("basicService");
    this.page = service.findPageByCriteria(detachedCriteria, pageSize, pageNo);
    // TODO Auto-generated method stub
    return SUCCESS;
  }
  @SuppressWarnings("unchecked")
  @Override
  public List<Oficina> recuperarOficina(Integer idCurso, Integer idPacote) {
    Criteria criteria = getSession().createCriteria(Oficina.class);

    DetachedCriteria subCriteria = DetachedCriteria.forClass(PacoteOficina.class);
    subCriteria.createAlias("pacote", "p");
    subCriteria.add(Property.forName("p.id").eq(idPacote));
    subCriteria.createAlias("p.curso", "c");
    subCriteria.add(Property.forName("c.id").eq(idCurso));
    subCriteria.setProjection(Projections.distinct(Projections.property("oficina.id")));

    criteria.add(Property.forName("id").in(subCriteria));
    return criteria.list();
  }
  private List<Characterization> loadCharacterizations(String sampleId) throws Exception {
    List<Characterization> chars = new ArrayList<Characterization>();

    CaNanoLabApplicationService appService =
        (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
    DetachedCriteria crit = DetachedCriteria.forClass(Characterization.class);
    crit.createAlias("sample", "sample");
    crit.add(Property.forName("sample.id").eq(new Long(sampleId)));
    // fully load characterization
    crit.setFetchMode("pointOfContact", FetchMode.JOIN);
    crit.setFetchMode("pointOfContact.organization", FetchMode.JOIN);
    crit.setFetchMode("protocol", FetchMode.JOIN);
    crit.setFetchMode("protocol.file", FetchMode.JOIN);
    crit.setFetchMode("protocol.file.keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("experimentConfigCollection", FetchMode.JOIN);
    crit.setFetchMode("experimentConfigCollection.technique", FetchMode.JOIN);
    crit.setFetchMode("experimentConfigCollection.instrumentCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection.datumCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection.datumCollection.conditionCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection.fileCollection", FetchMode.JOIN);
    crit.setFetchMode("findingCollection.fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
    List results = appService.query(crit);

    for (int i = 0; i < results.size(); i++) {
      Characterization achar = (Characterization) results.get(i);
      chars.add(achar);
    }
    return chars;
  }
Exemplo n.º 5
0
  public Map<String, Employee> getEmployeeMap() {
    Map employeeHashtable = new HashMap();
    IEmployeeBo esaBo = (IEmployeeBo) SpringBeanFactory.getBean("empBo");
    DetachedCriteria dc = DetachedCriteria.forClass(Employee.class);
    dc.createAlias(Employee.PROP_EMP_BENEFIT_TYPE, "empBenefitType", 1);
    dc.createAlias(Employee.PROP_EMP_BENEFIT, "benefit", 1);
    dc.createAlias(Employee.PROP_EMP_DEPT_NO, "empDeptNo", 1);
    dc.createAlias(Employee.PROP_CONFIG, "config", 1);

    dc.add(Restrictions.eq(Employee.PROP_EMP_STATUS, Integer.valueOf(1)));
    List<Employee> empList = esaBo.findByCriteria(dc);
    for (Employee emp : empList) {
      employeeHashtable.put(emp.getEmpDistinctNo(), emp);
    }
    return employeeHashtable;
  }
  @SuppressWarnings("unchecked")
  public List<DeliveryOrder> getUnexportDeliveryOrderByPlant(Plant plant) {
    DetachedCriteria criteria = DetachedCriteria.forClass(DeliveryOrder.class);
    criteria.createAlias("plantSupplier", "ps");

    criteria.add(Restrictions.eq("ps.plant", plant));
    criteria.add(Restrictions.eq("isPrint", true));
    criteria.add(Restrictions.eq("isExport", false));
    criteria.add(Restrictions.eq("status", "Confirm"));
    criteria.add(Restrictions.eq("ps.needExportDo", true));
    criteria.addOrder(Order.asc("createDate"));

    List<DeliveryOrder> deliveryOrderList = this.findByCriteria(criteria);

    if (deliveryOrderList != null && deliveryOrderList.size() > 0) {
      for (int i = 0; i < deliveryOrderList.size(); i++) {
        DeliveryOrder deliveryOrder = deliveryOrderList.get(i);

        if (deliveryOrder.getDeliveryOrderDetailList() != null
            && deliveryOrder.getDeliveryOrderDetailList().size() > 0) {}
      }
    }

    return deliveryOrderList;
  }
Exemplo n.º 7
0
 @Transactional(readOnly = false)
 public Page<Link> find(Page<Link> page, Link link, boolean isDataScopeFilter) {
   // 更新过期的权重,间隔为“6”个小时
   Date updateExpiredWeightDate = (Date) CacheUtils.get("updateExpiredWeightDateByLink");
   if (updateExpiredWeightDate == null
       || (updateExpiredWeightDate != null
           && updateExpiredWeightDate.getTime() < new Date().getTime())) {
     linkDao.updateExpiredWeight();
     CacheUtils.put("updateExpiredWeightDateByLink", DateUtils.addHours(new Date(), 6));
   }
   DetachedCriteria dc = linkDao.createDetachedCriteria();
   dc.createAlias("category", "category");
   dc.createAlias("category.site", "category.site");
   if (link.getCategory() != null
       && StringUtils.isNotBlank(link.getCategory().getId())
       && !Category.isRoot(link.getCategory().getId())) {
     Category category = categoryDao.get(link.getCategory().getId());
     if (category != null) {
       dc.add(
           Restrictions.or(
               Restrictions.eq("category.id", category.getId()),
               Restrictions.like("category.parentIds", "%," + category.getId() + ",%")));
       dc.add(Restrictions.eq("category.site.id", category.getSite().getId()));
       link.setCategory(category);
     } else {
       dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
     }
   } else {
     dc.add(Restrictions.eq("category.site.id", Site.getCurrentSiteId()));
   }
   if (StringUtils.isNotEmpty(link.getTitle())) {
     dc.add(Restrictions.like("title", "%" + link.getTitle() + "%"));
   }
   if (link.getCreateBy() != null && StringUtils.isNotBlank(link.getCreateBy().getId())) {
     dc.add(Restrictions.eq("createBy.id", link.getCreateBy().getId()));
   }
   if (isDataScopeFilter) {
     dc.createAlias("category.office", "categoryOffice").createAlias("createBy", "createBy");
     dc.add(dataScopeFilter(UserUtils.getUser(), "categoryOffice", "createBy"));
   }
   dc.add(Restrictions.eq(Link.FIELD_DEL_FLAG, link.getDelFlag()));
   dc.addOrder(Order.desc("weight"));
   dc.addOrder(Order.desc("updateDate"));
   return linkDao.find(page, dc);
 }
Exemplo n.º 8
0
 /**
  * Get Account Connection.
  *
  * @param accountId
  * @param proviver
  * @return
  */
 @SuppressWarnings("unchecked")
 public SocialAccount getAccountConnection(final String accountId, final SocialProvider provider) {
   final DetachedCriteria criteria = DetachedCriteria.forClass(SocialAccount.class);
   criteria.createAlias("userAccout", "userAccout");
   criteria.add(Restrictions.eq("userAccout.uid", accountId));
   criteria.add(Restrictions.eq("accounType", provider));
   return (SocialAccount)
       DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
 }
Exemplo n.º 9
0
  public List<Cliente> listaClientePrefixo(Integer prefixo) {

    DetachedCriteria dc = DetachedCriteria.forClass(Cliente.class);
    dc.createAlias("dependencia", "d", org.hibernate.sql.JoinType.INNER_JOIN);
    dc.add(Restrictions.eq("d.prefixo", prefixo));
    List<Cliente> lista = listar(dc);

    return lista;
  }
  public String execute() {
    int to = rows * page;
    int from = to - rows;
    DetachedCriteria criteria = DetachedCriteria.forClass(Cliente.class);

    // Si el campo de busqueda es diferente de nulo
    if (searchField != null) {
      if (searchField.equals("idcliente")) {
        if (searchOper.equals("eq")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.eq("idcliente", searchValue));
        } else if (searchOper.equals("lt")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.lt("idcliente", searchValue));

        } else if (searchOper.equals("gt")) {
          BigDecimal searchValue = new BigDecimal(searchString);
          criteria.add(Restrictions.gt("idcliente", searchValue));
        }
      } else if (searchField.equals("nombre")) {
        // contains
        if (searchOper.equals("cn")) {
          criteria.add(Restrictions.like("nombre", "%" + searchString + "%"));
        }
      } else if (searchField.equals("banco.nombre")) {
        criteria.createAlias("banco", "b");
        if (searchOper.equals("eq")) {
          criteria.add(Restrictions.eq("b.nombre", searchString));
        }
      }
    }

    // Count Customers
    records = clienteService.countByCriteria(criteria);

    // Reset count Projection
    criteria.setProjection(null);
    criteria.setResultTransformer(Criteria.ROOT_ENTITY);

    if (sidx != null && !sidx.equals("")) {
      if (sord.equals("asc")) {
        criteria.addOrder(Order.asc(sidx));
      } else {
        criteria.addOrder(Order.desc(sidx));
      }
    }

    gridModel = clienteService.findByCriteria(criteria, from, rows);

    if (to > records) to = records;

    total = (int) Math.ceil((double) records / (double) rows);

    return "success";
  }
Exemplo n.º 11
0
  private List<Attendmonthly> searchAttendmonthly(Pager pager, String yearMonth) {
    DetachedCriteria dc = DetachedCriteria.forClass(Attendmonthly.class);
    dc.createAlias(Attendmonthly.PROP_ATTM_EMP_ID, "emp", 1);

    if ("SUB".equals(this.authorityCondition)) {
      addSubDC(dc, "emp", 4);
    }

    addCriteria(dc, yearMonth);

    return this.attendmothlyBO.searchAttendmonthly(pager, dc);
  }
Exemplo n.º 12
0
 public Page<User> findUser(Page<User> page, User user) {
   DetachedCriteria dc = userDao.createDetachedCriteria();
   User currentUser = UserUtils.getUser();
   if (!currentUser.isAdmin()) {
     if (user.getArea() == null || user.getArea().getId() == null) {
       user.setArea(currentUser.getArea());
     }
     if (user.getOffice() == null || user.getOffice().getId() == null) {
       user.setOffice(currentUser.getOffice());
     }
   }
   dc.createAlias("area", "area");
   if (user.getArea() != null && user.getArea().getId() != null) {
     dc.add(
         Restrictions.or(
             Restrictions.eq("area.id", user.getArea().getId()),
             Restrictions.eq("area.parent.id", user.getArea().getId()),
             Restrictions.like("area.parentIds", "%," + user.getArea().getId() + ",%")));
   }
   dc.createAlias("office", "office");
   if (user.getOffice() != null && user.getOffice().getId() != null) {
     dc.add(
         Restrictions.or(
             Restrictions.eq("office.id", user.getOffice().getId()),
             Restrictions.eq("office.parent.id", user.getOffice().getId()),
             Restrictions.like("office.parentIds", "%," + user.getOffice().getId() + ",%")));
   }
   if (StringUtils.isNotEmpty(user.getLoginName())) {
     dc.add(Restrictions.like("loginName", "%" + user.getLoginName() + "%"));
   }
   if (StringUtils.isNotEmpty(user.getName())) {
     dc.add(Restrictions.like("name", "%" + user.getName() + "%"));
   }
   dc.add(Restrictions.eq("delFlag", User.DEL_FLAG_NORMAL));
   if (!StringUtils.isNotEmpty(page.getOrderBy())) {
     dc.addOrder(Order.asc("area.code")).addOrder(Order.asc("office.code"));
   }
   return userDao.find(page, dc);
 }
Exemplo n.º 13
0
  public Page<Direct> find(Page<Direct> page, Direct direct) {
    DetachedCriteria dc = directDao.createDetachedCriteria();
    dc.createAlias("supplier", "supplier");
    dc.add(Restrictions.eq("supplier.delFlag", Supplier.DEL_FLAG_NORMAL));
    if (direct.getSupplier() != null) {

      if (StringUtils.isNotBlank(direct.getSupplier().getName())) {
        dc.add(Restrictions.like("supplier.name", "%" + direct.getSupplier().getName() + "%"));
      }
      if (direct.getSupplier().getId() != null) {
        dc.add(Restrictions.eq("supplier.id", direct.getSupplier().getId()));
      }
    }
    dc.createAlias("distributor", "distributor");
    dc.add(Restrictions.eq("distributor.delFlag", Distributor.DEL_FLAG_NORMAL));
    if (direct.getDistributor() != null) {

      if (StringUtils.isNotBlank(direct.getDistributor().getName())) {
        dc.add(
            Restrictions.or(
                Restrictions.like(
                    "distributor.name", "%" + direct.getDistributor().getName() + "%"),
                Restrictions.like(
                    "distributor.username", "%" + direct.getDistributor().getName() + "%"),
                Restrictions.like(
                    "distributor.company", "%" + direct.getDistributor().getName() + "%")));
      }
      if (direct.getDistributor().getId() != null) {
        dc.add(Restrictions.eq("distributor.id", direct.getDistributor().getId()));
      }
    }
    if (StringUtils.isNotBlank(direct.getRemarks())) {

      dc.add(Restrictions.or(Restrictions.gt("balance", 0.0), Restrictions.eq("status", "0")));
    }
    dc.add(Restrictions.eq(Direct.DEL_FLAG, Direct.DEL_FLAG_NORMAL));
    dc.addOrder(Order.desc("id"));
    return directDao.find(page, dc);
  }
 public void updatePOCAssociatedWithCharacterizations(
     String sampleName, Long oldPOCId, Long newPOCId) throws SampleException {
   try {
     CaNanoLabApplicationService appService =
         (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
     DetachedCriteria crit = DetachedCriteria.forClass(Characterization.class);
     crit.createAlias("sample", "sample");
     crit.createAlias("pointOfContact", "poc");
     crit.add(Property.forName("poc.id").eq(oldPOCId));
     crit.add(Property.forName("sample.name").eq(sampleName));
     crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
     List results = appService.query(crit);
     for (int i = 0; i < results.size(); i++) {
       Characterization achar = (Characterization) results.get(i);
       // update POC to the new ID
       achar.getPointOfContact().setId(newPOCId);
       appService.saveOrUpdate(achar);
     }
   } catch (Exception e) {
     String err = "Error in updating POC associated sample characterizations " + sampleName;
     logger.error(err, e);
     throw new SampleException(err, e);
   }
 }
Exemplo n.º 15
0
 /**
  * 设置order(排序)查询条件
  *
  * @param ordername :排序字段名
  * @param ordervalue :排序字段值("asc","desc")
  */
 public void addOrder(String ordername, SortDirection ordervalue) {
   String[] orders = ordername.split("\\.");
   if (ordername.indexOf(".") > 0 && orders.length > 2) {
     for (int i = 0; i < orders.length - 1; i++) {
       if (!alias.contains(orders[i])) {
         detachedCriteria.createAlias(
             (i > 0 ? orders[i - 1] + "." + orders[i] : orders[i]),
             orders[i],
             JoinType.LEFT_OUTER_JOIN);
         alias.add(orders[i]);
       }
     }
     ordername = orders[orders.length - 2] + "." + orders[orders.length - 1];
   }
   ordermap.put(ordername, ordervalue);
 }
  @Override
  public CuentaCorriente getCuentaCorrienteByVenta(Venta venta) {

    DetachedCriteria criteria = DetachedCriteria.forClass(CuentaCorriente.class);
    if (venta != null) {
      criteria.createAlias("venta", "venta").add(Restrictions.eq("venta", venta));
    }
    List<CuentaCorriente> cuentasCorrientes = this.getHibernateTemplate().findByCriteria(criteria);

    CuentaCorriente cuentaCorriente = null;

    if (!cuentasCorrientes.isEmpty()) {
      cuentaCorriente = (CuentaCorriente) DataAccessUtils.requiredUniqueResult(cuentasCorrientes);
    }

    return cuentaCorriente;
  }
  private SampleComposition loadComposition(String sampleId) throws Exception {
    SampleComposition composition = null;

    CaNanoLabApplicationService appService =
        (CaNanoLabApplicationService) ApplicationServiceProvider.getApplicationService();
    DetachedCriteria crit = DetachedCriteria.forClass(SampleComposition.class);
    crit.createAlias("sample", "sample");
    crit.add(Property.forName("sample.id").eq(new Long(sampleId)));
    crit.setFetchMode("nanomaterialEntityCollection", FetchMode.JOIN);
    crit.setFetchMode("nanomaterialEntityCollection.fileCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "nanomaterialEntityCollection.fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("nanomaterialEntityCollection.composingElementCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "nanomaterialEntityCollection.composingElementCollection.inherentFunctionCollection",
        FetchMode.JOIN);
    crit.setFetchMode(
        "nanomaterialEntityCollection.composingElementCollection.inherentFunctionCollection.targetCollection",
        FetchMode.JOIN);
    crit.setFetchMode("functionalizingEntityCollection", FetchMode.JOIN);
    crit.setFetchMode("functionalizingEntityCollection.fileCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "functionalizingEntityCollection.fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("functionalizingEntityCollection.functionCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "functionalizingEntityCollection.functionCollection.targetCollection", FetchMode.JOIN);
    crit.setFetchMode("functionalizingEntityCollection.activationMethod", FetchMode.JOIN);
    crit.setFetchMode("chemicalAssociationCollection", FetchMode.JOIN);
    crit.setFetchMode("chemicalAssociationCollection.fileCollection", FetchMode.JOIN);
    crit.setFetchMode(
        "chemicalAssociationCollection.fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setFetchMode("chemicalAssociationCollection.associatedElementA", FetchMode.JOIN);
    crit.setFetchMode("chemicalAssociationCollection.associatedElementB", FetchMode.JOIN);
    crit.setFetchMode("fileCollection", FetchMode.JOIN);
    crit.setFetchMode("fileCollection.keywordCollection", FetchMode.JOIN);
    crit.setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY);
    List result = appService.query(crit);

    if (!result.isEmpty()) {
      composition = (SampleComposition) result.get(0);
    }
    return composition;
  }
  private List<Object[]> getSharedListResult(List<String> seriesUids) {
    List<Object[]> results = new ArrayList<Object[]>();

    if (seriesUids != null && seriesUids.size() != 0) {
      DetachedCriteria criteria = DetachedCriteria.forClass(CustomSeriesListAttribute.class);
      ProjectionList projectionList = Projections.projectionList();

      projectionList.add(Projections.property("csl.userName"));
      projectionList.add(Projections.property("csl.name"));
      projectionList.add(Projections.property("seriesInstanceUid"));

      criteria.setProjection(Projections.distinct(projectionList));

      criteria.createAlias("parent", "csl");

      criteria.add(Restrictions.in("seriesInstanceUid", seriesUids));

      results = getHibernateTemplate().findByCriteria(criteria);
    }

    return results;
  }
  @Override
  public List<CuentaCorriente> findByCriteria(
      TipoCuentaCorriente tipoCuentaCorriente,
      Date fechaDesde,
      Date fechaHasta,
      String nombre,
      EstadoCuentaCorriente estadoCuentaCorriente,
      Usuario usuario) {

    DetachedCriteria criteria = DetachedCriteria.forClass(CuentaCorriente.class);

    if (fechaDesde != null) {
      criteria.add(Restrictions.ge("fecha", fechaDesde));
    }

    if (fechaHasta != null) {
      criteria.add(Restrictions.le("fecha", fechaHasta));
    }

    //		if(fechaDesde==null && fechaHasta==null){
    //			criteria.add(Restrictions.isNull("fecha"));
    //		}

    if (tipoCuentaCorriente != null) {

      criteria
          .createAlias("tipoCuentaCorriente", "tipoCuentaCorriente")
          .add(Restrictions.eq("tipoCuentaCorriente", tipoCuentaCorriente));

      if (tipoCuentaCorriente.getId().intValue() == 1) {
        if (nombre != null && nombre.length() > 0) {
          criteria
              .createAlias("cliente", "cliente")
              .add(Restrictions.ilike("cliente.nombres", nombre.trim(), MatchMode.ANYWHERE));
        }
      } else {
        if (nombre != null && nombre.length() > 0) {
          criteria
              .createAlias("proveedor", "proveedor")
              .add(
                  Restrictions.ilike(
                      "proveedor.nombreRazonSocial", nombre.trim(), MatchMode.ANYWHERE));
        }
      }
    }

    if (estadoCuentaCorriente != null) {
      criteria
          .createAlias("estadoCuentaCorriente", "estadoCuentaCorriente")
          .add(Restrictions.eq("estadoCuentaCorriente", estadoCuentaCorriente));
    }

    if (usuario != null) {
      criteria.createAlias("usuario", "usuario").add(Restrictions.eq("usuario", usuario));
    }

    List<CuentaCorriente> cuentasCorrientes =
        (List<CuentaCorriente>) this.getHibernateTemplate().findByCriteria(criteria);

    return cuentasCorrientes;
  }
  public List<RecepcionMx> getRecepcionesByFiltro(FiltroMx filtro) {
    Session session = sessionFactory.getCurrentSession();
    Soundex varSoundex = new Soundex();
    Criteria crit = session.createCriteria(RecepcionMx.class, "recepcion");
    crit.createAlias("recepcion.tomaMx", "tomaMx");
    crit.createAlias("tomaMx.estadoMx", "estado");
    // crit.createAlias("orden.idTomaMx", "tomaMx");
    crit.createAlias("tomaMx.idNotificacion", "notifi");
    // siempre se tomam las muestras que no estan anuladas
    crit.add(
        Restrictions.and(
            Restrictions.eq("tomaMx.anulada", false))); // y las ordenes en estado según filtro
    if (filtro.getCodEstado() != null) {
      if (filtro.getIncluirTraslados()) {
        crit.add(
            Restrictions.or(Restrictions.eq("estado.codigo", filtro.getCodEstado()).ignoreCase())
                .add(Restrictions.or(Restrictions.eq("estado.codigo", "ESTDMX|TRAS"))));
      } else {
        crit.add(
            Restrictions.and(
                Restrictions.eq("estado.codigo", filtro.getCodEstado().toLowerCase())
                    .ignoreCase()));
      }
    }

    // se filtra por nombre y apellido persona
    if (filtro.getNombreApellido() != null) {
      // crit.createAlias("notifi.persona", "person");
      String[] partes = filtro.getNombreApellido().split(" ");
      String[] partesSnd = filtro.getNombreApellido().split(" ");
      for (int i = 0; i < partes.length; i++) {
        try {
          partesSnd[i] = varSoundex.encode(partes[i]);
        } catch (IllegalArgumentException e) {
          partesSnd[i] = "0000";
          e.printStackTrace();
        }
      }
      for (int i = 0; i < partes.length; i++) {
        Junction conditGroup = Restrictions.disjunction();
        conditGroup
            .add(
                Subqueries.propertyIn(
                    "notifi.persona.personaId",
                    DetachedCriteria.forClass(SisPersona.class, "person")
                        .add(
                            Restrictions.or(
                                    Restrictions.ilike(
                                        "person.primerNombre", "%" + partes[i] + "%"))
                                .add(
                                    Restrictions.or(
                                            Restrictions.ilike(
                                                "person.primerApellido", "%" + partes[i] + "%"))
                                        .add(
                                            Restrictions.or(
                                                    Restrictions.ilike(
                                                        "person.segundoNombre",
                                                        "%" + partes[i] + "%"))
                                                .add(
                                                    Restrictions.or(
                                                            Restrictions.ilike(
                                                                "person.segundoApellido",
                                                                "%" + partes[i] + "%"))
                                                        .add(
                                                            Restrictions.or(
                                                                Restrictions.ilike(
                                                                    "person.sndNombre",
                                                                    "%" + partesSnd[i] + "%")))))))
                        .setProjection(Property.forName("personaId"))))
            .add(
                Subqueries.propertyIn(
                    "notifi.solicitante.idSolicitante",
                    DetachedCriteria.forClass(Solicitante.class, "solicitante")
                        .add(Restrictions.ilike("solicitante.nombre", "%" + partes[i] + "%"))
                        .setProjection(Property.forName("idSolicitante"))));

        crit.add(conditGroup);
      }
    }
    // se filtra por SILAIS
    if (filtro.getCodSilais() != null) {
      crit.createAlias("notifi.codSilaisAtencion", "silais");
      crit.add(
          Restrictions.and(Restrictions.eq("silais.codigo", Long.valueOf(filtro.getCodSilais()))));
    }
    // se filtra por unidad de salud
    if (filtro.getCodUnidadSalud() != null) {
      crit.createAlias("notifi.codUnidadAtencion", "unidadS");
      crit.add(
          Restrictions.and(
              Restrictions.eq("unidadS.codigo", Long.valueOf(filtro.getCodUnidadSalud()))));
    }
    // Se filtra por rango de fecha de toma de muestra
    if (filtro.getFechaInicioTomaMx() != null && filtro.getFechaFinTomaMx() != null) {
      crit.add(
          Restrictions.and(
              Restrictions.between(
                  "tomaMx.fechaHTomaMx",
                  filtro.getFechaInicioTomaMx(),
                  filtro.getFechaFinTomaMx())));
    }
    // Se filtra por rango de fecha de recepción
    if (filtro.getFechaInicioRecep() != null && filtro.getFechaFinRecep() != null) {
      crit.add(
          Restrictions.and(
              Restrictions.between(
                  "recepcion.fechaHoraRecepcion",
                  filtro.getFechaInicioRecep(),
                  filtro.getFechaFinRecep())));
    }
    // se filtra por tipo de muestra
    if (filtro.getCodTipoMx() != null) {
      crit.add(
          Restrictions.and(
              Restrictions.eq(
                  "tomaMx.codTipoMx.idTipoMx", Integer.valueOf(filtro.getCodTipoMx()))));
    }
    // se filtra por area que procesa
    /*if (filtro.getIdAreaProcesa()!=null){
        crit.createAlias("orden.codExamen", "examen");
        crit.add( Restrictions.and(
                        Restrictions.eq("examen.area.idArea", Integer.valueOf(filtro.getIdAreaProcesa())))
        );
    }*/

    // Se filtra por rango de fecha de recepcion en laboratorio
    if (filtro.getFechaInicioRecepLab() != null && filtro.getFechaFinRecepLab() != null) {
      crit.add(
          Subqueries.propertyIn(
              "recepcion.idRecepcion",
              DetachedCriteria.forClass(RecepcionMxLab.class)
                  .createAlias("recepcionMx", "recepcionGral")
                  .add(
                      Restrictions.between(
                          "fechaHoraRecepcion",
                          filtro.getFechaInicioRecepLab(),
                          filtro.getFechaFinRecepLab()))
                  .setProjection(Property.forName("recepcionGral.idRecepcion"))));
    }

    if (filtro.getIncluirMxInadecuada() != null && filtro.getIncluirMxInadecuada()) {
      crit.add(
          Restrictions.or(Restrictions.isNull("recepcion.calidadMx.codigo"))
              .add(Restrictions.or(Restrictions.ne("recepcion.calidadMx.codigo", "CALIDMX|IDC"))));
    }
    if (filtro.getCodigoUnicoMx() != null) {
      crit.add(
          Restrictions.or(Restrictions.eq("tomaMx.codigoUnicoMx", filtro.getCodigoUnicoMx()))
              .add(
                  Restrictions.or(Restrictions.eq("tomaMx.codigoLab", filtro.getCodigoUnicoMx()))));
    }

    // se filtra por tipo de solicitud
    if (filtro.getCodTipoSolicitud() != null) {
      if (filtro.getCodTipoSolicitud().equals("Estudio")) {
        crit.add(
            Subqueries.propertyIn(
                "tomaMx.idTomaMx",
                DetachedCriteria.forClass(DaSolicitudEstudio.class)
                    .createAlias("idTomaMx", "toma")
                    .setProjection(Property.forName("toma.idTomaMx"))));
      } else {
        crit.add(
            Subqueries.propertyIn(
                "tomaMx.idTomaMx",
                DetachedCriteria.forClass(DaSolicitudDx.class)
                    .createAlias("idTomaMx", "toma")
                    .add(
                        Subqueries.propertyIn(
                            "labProcesa.codigo",
                            DetachedCriteria.forClass(AutoridadLaboratorio.class)
                                .createAlias("laboratorio", "labautorizado")
                                .createAlias("user", "usuario")
                                .add(
                                    Restrictions.eq(
                                        "pasivo", false)) // autoridad laboratorio activa
                                .add(
                                    Restrictions.and(
                                        Restrictions.eq(
                                            "usuario.username",
                                            filtro.getNombreUsuario()))) // usuario
                                .setProjection(Property.forName("labautorizado.codigo"))))
                    .setProjection(Property.forName("toma.idTomaMx"))));
      }
    }

    // nombre solicitud
    if (filtro.getNombreSolicitud() != null) {
      if (filtro.getCodTipoSolicitud() != null) {
        if (filtro.getCodTipoSolicitud().equals("Estudio")) {
          crit.add(
              Subqueries.propertyIn(
                  "solicitudtomaMx.idTomaMx",
                  DetachedCriteria.forClass(DaSolicitudEstudio.class)
                      .createAlias("tipoEstudio", "estudio")
                      .add(
                          Restrictions.ilike(
                              "estudio.nombre", "%" + filtro.getNombreSolicitud() + "%"))
                      .createAlias("idTomaMx", "toma")
                      .setProjection(Property.forName("toma.idTomaMx"))));
        } else {
          crit.add(
              Subqueries.propertyIn(
                  "tomaMx.idTomaMx",
                  DetachedCriteria.forClass(DaSolicitudDx.class)
                      .createAlias("codDx", "dx")
                      .add(Restrictions.ilike("dx.nombre", "%" + filtro.getNombreSolicitud() + "%"))
                      .createAlias("idTomaMx", "toma")
                      .setProjection(Property.forName("toma.idTomaMx"))));
        }
      } else {

        Junction conditGroup = Restrictions.disjunction();
        conditGroup
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudEstudio.class)
                        .createAlias("tipoEstudio", "estudio")
                        .add(
                            Restrictions.ilike(
                                "estudio.nombre", "%" + filtro.getNombreSolicitud() + "%"))
                        .createAlias("idTomaMx", "toma")
                        .setProjection(Property.forName("toma.idTomaMx"))))
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudDx.class)
                        .createAlias("codDx", "dx")
                        .add(
                            Restrictions.ilike(
                                "dx.nombre", "%" + filtro.getNombreSolicitud() + "%"))
                        .createAlias("idTomaMx", "toma")
                        .setProjection(Property.forName("toma.idTomaMx"))));

        crit.add(conditGroup);
      }
    }
    // se filtra que usuario tenga autorizado laboratorio al que se envio la muestra desde ALERTA
    /*if (filtro.getNombreUsuario()!=null) {
        crit.createAlias("tomaMx.envio","envioMx");
        crit.add(Subqueries.propertyIn("envioMx.laboratorioDestino.codigo", DetachedCriteria.forClass(AutoridadLaboratorio.class)
                .createAlias("laboratorio", "labautorizado")
                .createAlias("user", "usuario")
                .add(Restrictions.eq("pasivo",false)) //autoridad laboratorio activa
                .add(Restrictions.and(Restrictions.eq("usuario.username",filtro.getNombreUsuario()))) //usuario
                .setProjection(Property.forName("labautorizado.codigo"))));

    }*/
    if (filtro.getCodEstado() != null) {
      if (filtro
          .getCodEstado()
          .equalsIgnoreCase("ESTDMX|EPLAB")) { // significa que es recepción en laboratorio
        // Se filtra que el área a la que pertenece la solicitud este asociada al usuario
        // autenticado
        Junction conditGroup = Restrictions.disjunction();

        conditGroup
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudEstudio.class)
                        .createAlias("tipoEstudio", "estudio")
                        .createAlias("estudio.area", "area")
                        .add(
                            Subqueries.propertyIn(
                                "area.idArea",
                                DetachedCriteria.forClass(AutoridadArea.class)
                                    .add(Restrictions.eq("pasivo", false)) // autoridad area activa
                                    .add(
                                        Restrictions.and(
                                            Restrictions.eq(
                                                "user.username",
                                                filtro.getNombreUsuario()))) // usuario
                                    .setProjection(Property.forName("area.idArea"))))
                        .createAlias("idTomaMx", "toma")
                        .setProjection(Property.forName("idTomaMx.idTomaMx"))))
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudDx.class)
                        .createAlias("codDx", "dx")
                        .createAlias("dx.area", "area")
                        .add(
                            Subqueries.propertyIn(
                                "area.idArea",
                                DetachedCriteria.forClass(AutoridadArea.class)
                                    .add(Restrictions.eq("pasivo", false)) // autoridad area activa
                                    .add(
                                        Restrictions.and(
                                            Restrictions.eq(
                                                "user.username",
                                                filtro.getNombreUsuario()))) // usuario
                                    .setProjection(Property.forName("area.idArea"))))
                        .createAlias("idTomaMx", "toma")
                        .setProjection(Property.forName("toma.idTomaMx"))));

        crit.add(conditGroup);
      }
    }

    // filtro que las rutinas pertenezcan al laboratorio del usuario que consulta
    crit.createAlias("recepcion.labRecepcion", "labRecep");
    crit.add(
        Subqueries.propertyIn(
            "labRecep.codigo",
            DetachedCriteria.forClass(AutoridadLaboratorio.class)
                .createAlias("laboratorio", "labautorizado")
                .createAlias("user", "usuario")
                .add(Restrictions.eq("pasivo", false)) // autoridad laboratorio activa
                .add(
                    Restrictions.and(
                        Restrictions.eq("usuario.username", filtro.getNombreUsuario()))) // usuario
                .setProjection(Property.forName("labautorizado.codigo"))));

    // sólo la última recepción de cada muestra

    DetachedCriteria maxDateQuery = DetachedCriteria.forClass(RecepcionMx.class);
    maxDateQuery.createAlias("tomaMx", "mx");
    maxDateQuery.add(Restrictions.eqProperty("mx.idTomaMx", "tomaMx.idTomaMx"));
    maxDateQuery.setProjection(Projections.max("fechaHoraRecepcion"));
    crit.add(Property.forName("fechaHoraRecepcion").eq(maxDateQuery));

    // filtro sólo control calidad en el laboratio del usuario
    if (filtro.getControlCalidad() != null) {
      if (filtro
          .getControlCalidad()) { // si hay filtro por control de calidad y es "Si", sólo incluir
                                  // rutinas
        crit.add(
            Subqueries.propertyIn(
                "tomaMx.idTomaMx",
                DetachedCriteria.forClass(DaSolicitudDx.class)
                    .add(Restrictions.eq("controlCalidad", filtro.getControlCalidad()))
                    .createAlias("idTomaMx", "toma")
                    .add(
                        Subqueries.propertyIn(
                            "labProcesa.codigo",
                            DetachedCriteria.forClass(AutoridadLaboratorio.class)
                                .createAlias("laboratorio", "labautorizado")
                                .createAlias("user", "usuario")
                                .add(
                                    Restrictions.eq(
                                        "pasivo", false)) // autoridad laboratorio activa
                                .add(
                                    Restrictions.and(
                                        Restrictions.eq(
                                            "usuario.username",
                                            filtro.getNombreUsuario()))) // usuario
                                .setProjection(Property.forName("labautorizado.codigo"))))
                    .setProjection(Property.forName("toma.idTomaMx"))));
      } else { // si hay filtro por control de calidad y es "No", siempre incluir los estudios
        Junction conditGroup = Restrictions.disjunction();
        conditGroup
            .add(
                Subqueries.propertyIn(
                    "tomaMx.idTomaMx",
                    DetachedCriteria.forClass(DaSolicitudDx.class)
                        .add(Restrictions.eq("controlCalidad", filtro.getControlCalidad()))
                        .createAlias("idTomaMx", "toma")
                        .add(
                            Subqueries.propertyIn(
                                "labProcesa.codigo",
                                DetachedCriteria.forClass(AutoridadLaboratorio.class)
                                    .createAlias("laboratorio", "labautorizado")
                                    .createAlias("user", "usuario")
                                    .add(
                                        Restrictions.eq(
                                            "pasivo", false)) // autoridad laboratorio activa
                                    .add(
                                        Restrictions.and(
                                            Restrictions.eq(
                                                "usuario.username",
                                                filtro.getNombreUsuario()))) // usuario
                                    .setProjection(Property.forName("labautorizado.codigo"))))
                        .setProjection(Property.forName("toma.idTomaMx"))))
            .add(
                Restrictions.or(
                    Subqueries.propertyIn(
                        "tomaMx.idTomaMx",
                        DetachedCriteria.forClass(DaSolicitudEstudio.class)
                            .createAlias("idTomaMx", "idTomaMx")
                            .setProjection(Property.forName("idTomaMx.idTomaMx")))));
        crit.add(conditGroup);
      }
    }
    // filtro para sólo solicitudes aprobadas
    if (filtro.getSolicitudAprobada() != null) {
      Junction conditGroup = Restrictions.disjunction();
      conditGroup
          .add(
              Subqueries.propertyIn(
                  "tomaMx.idTomaMx",
                  DetachedCriteria.forClass(DaSolicitudEstudio.class)
                      .add(Restrictions.eq("aprobada", filtro.getSolicitudAprobada()))
                      .createAlias("idTomaMx", "toma")
                      .setProjection(Property.forName("toma.idTomaMx"))))
          .add(
              Subqueries.propertyIn(
                  "tomaMx.idTomaMx",
                  DetachedCriteria.forClass(DaSolicitudDx.class)
                      .add(Restrictions.eq("aprobada", filtro.getSolicitudAprobada()))
                      // .add(Restrictions.eq("controlCalidad",false)) ¿¿¿¿¿¿¿¿¿?????????????
                      .createAlias("idTomaMx", "toma")
                      .setProjection(Property.forName("toma.idTomaMx"))));

      crit.add(conditGroup);
    }

    return crit.list();
  }
Exemplo n.º 21
0
 /**
  * 创建外键表关联对象
  *
  * @param name外键表实体名
  * @param value引用名
  */
 public void createAlias(String name, String value) {
   if (!alias.contains(name)) {
     detachedCriteria.createAlias(name, value);
     alias.add(name);
   }
 }
 /* (non-Javadoc)
  * @see com.mg.framework.api.orm.DetachedCriteria#createAlias(java.lang.String, java.lang.String)
  */
 @Override
 public DetachedCriteria createAlias(String associationPath, String alias) {
   delegate.createAlias(associationPath, alias);
   return this;
 }
Exemplo n.º 23
0
  public String c_roleToMemberOrgAtt()
      throws NoSuchFieldException, IllegalAccessException, ClassNotFoundException {
    String url = "cfg_c_Role_toMemberOrgAtt.sg";
    if ("1".equals(isPage)) {
      // 返回定制页
      bean = baseDao.get(Role.class, String.valueOf(idField.get(bean)));
      StringBuilder orgTree = new StringBuilder();
      Role role = (Role) bean;
      orgTree.append(
          "<div  style='width:30%;'>"
              + "组织:"
              + role.getDescr()
              + "<a class='easyui-linkbutton' onclick='getChecked()'>保存</a> <a class='easyui-linkbutton' onclick='collapse()'>收起</a> "
              + "<ul id='roletree' class=\"easyui-tree\" data-options=\"url:'"
              + url
              + "?isPage=orgTree&bean.id="
              + role.getId()
              + "',checkbox:true,cascadeCheck:false"
              + " \"></ul>"
              + "</div>");
      // permissionTree.append("<script>$(function(){$('#roletree').tree({onLoadSuccess:function(node, data){ $('#roletree').tree({onCheck:function(node, checked){alert(node.text+checked);}});}});});function tr(){}</script>");
      // permissionTree.append("<script>$(function(){setTimeout('tr()',5000);});function
      // tr(){$('.tree-checkbox').click(function(){alert(1)});}</script>");
      orgTree.append(
          "<script>function collapse(){$('#roletree').tree('collapseAll');} function getChecked(){var nodes = $('#roletree').tree('getChecked');var s = '';	"
              + "for(var i=0; i<nodes.length; i++){if (s != '') s += ',';"
              + "s += nodes[i].id;}"
              + "$.post('"
              + url
              + "?isPage=orgTreeSub',{'id':s,'bean.id':"
              + role.getId()
              + "},function(data){alert(data);});}</script>");

      setOrgHtml(orgTree.toString());

      StringBuilder attSb = new StringBuilder();
      attSb.append(
          "组织属性:<form action='"
              + url
              + "?isPage=attSub' method='POST'><input type='submit' value='提交'><p>");
      DetachedCriteria dc = DetachedCriteria.forClass(RoleAtt.class);
      dc.add(Restrictions.eq("role", bean)).add(Restrictions.eq("enable", Constant.ENABLE_NOR));
      List<RoleAtt> ras = baseDao.find(dc);

      List<NameValuePair> nvlist = Util.nvlist(baseDao, "cfg_org_att");
      for (NameValuePair nv : nvlist) {
        String value = nv.getValue();
        if (Util.notEmptyString(value)) {
          String chk = "";
          for (RoleAtt ra : ras) {
            String att = ra.getAtt();
            if (att.equals(value)) {
              chk = "checked";
            }
          }
          attSb
              .append("<input type='checkbox' name='atts' value='" + value + "' " + chk + ">")
              .append(nv.getName());
        }
      }
      attSb.append("</form>");
      setAttHtml(attSb.toString());
      return "page";
    } else if ("orgTreeSub".equals(isPage)) {
      bean = baseDao.get(Role.class, String.valueOf(idField.get(bean)));
      id = "," + id + ",";
      DetachedCriteria dc = DetachedCriteria.forClass(RoleOrg.class);
      dc.add(Restrictions.eq("role", bean)).add(Restrictions.eq("enable", Constant.ENABLE_NOR));
      List<RoleOrg> rpl = baseDao.find(dc);
      for (RoleOrg ro : rpl) {
        String pid = ro.getOrg().getId();
        if (!id.contains("," + pid + ",")) {
          ro.setEnable(Constant.ENABLE_DEL);
          ro.setUpdateDate(now);
          ro.setUpdateMember(sessionMember);
          baseDao.update(ro);
        } else {
          id = id.replace("," + pid + ",", ",");
        }
      }
      if (id.length() > 1) {
        String[] split = id.split(",");
        for (String s : split) {
          if (Util.notEmptyString(s)) {
            RoleOrg rp = new RoleOrg();
            Org one = new Org();
            one.setId(s);
            rp.setOrg(one);
            rp.setRole((Role) bean);
            rp.setEnable(Constant.ENABLE_NOR);
            rp.setCreateDate(now);
            rp.setCreateMember(sessionMember);
            baseDao.save(rp);
          }
        }
      }

      setBodyHtml(Constant.UPDATE_SUCCESS);
      return "orgTreeSub";
    } else if ("orgTree".equals(isPage)) {

      // 返回角色对应的组织树
      DetachedCriteria dc = DetachedCriteria.forClass(RoleOrg.class);
      dc.add(Restrictions.eq("role", bean)).add(Restrictions.eq("enable", "1"));
      List<RoleOrg> rpl = baseDao.find(dc);
      List<String> mpl = new ArrayList<String>();
      for (RoleOrg rp : rpl) {
        mpl.add(rp.getOrg().getId());
      }
      treeValue = new ArrayList<AsyncTree>();
      List<AsyncTree> findTreeValue = Util.findCheckedTreeValue(mpl, new Org(), null, baseDao);
      treeValue.addAll(findTreeValue);
      return "orgTree";
    } else if ("member".equals(isPage)) {
      setCoeo(new EasyOut<BaseTO>());
      DetachedCriteria dc = DetachedCriteria.forClass(OrgMember.class);
      Member member_sear = getMbean().getMember();
      if (member_sear != null && Util.notEmptyString(member_sear.getDescr())) {
        dc.createAlias("member", "ms");
        dc.add(Restrictions.ilike("ms.descr", member_sear.getDescr(), MatchMode.ANYWHERE));
      }
      if (Util.notEmptyString(inRoleInput)) {}

      Org org = getMbean().getOrg();
      if (org != null && Util.notEmptyString(org.getId())) dc.add(Restrictions.eq("org", org));
      dc.add(Restrictions.eq("enable", "1"));

      getCoeo().setTotal(baseDao.findCount(dc));
      if (Util.emptyString(getSort())) {
        setSort("id");
        setOrder("desc");
      }
      dc = DetachedCriteria.forClass(OrgMember.class);
      if (Util.notEmptyString(getSort()) && !getSort().contains(".")) { // !sortx.contains(".")
        // :在包含点号时,无法用其进行排序
        if ("desc".equals(getOrder())) {
          dc.addOrder(Order.desc(getSort()));
        } else {
          dc.addOrder(Order.asc(getSort()));
        }
        dc.addOrder(Order.asc("id"));
      }
      if (member_sear != null && Util.notEmptyString(member_sear.getDescr())) {
        dc.createAlias("member", "ms");
        dc.add(Restrictions.ilike("ms.descr", member_sear.getDescr(), MatchMode.ANYWHERE));
      }
      if (org != null && Util.notEmptyString(org.getId())) dc.add(Restrictions.eq("org", org));
      dc.add(Restrictions.eq("enable", "1"));
      List<BaseTO> cl = baseDao.findWithPage2(dc, (getPage() - 1) * getRows(), getRows());
      List<BaseTO> ml = new ArrayList<BaseTO>();
      for (BaseTO c : cl) {
        OrgMember x = (OrgMember) c;
        Member_ForRole mf = new Member_ForRole();
        Member member = x.getMember();
        mf.setDescr(member.getDescr());
        mf.setId(member.getId());
        mf.setInRole(inRole(bean, member));
        ml.add(mf);
      }
      getCoeo().setRows(ml);
      return "member";
    } else if ("memberSub".equals(isPage)) {
      if (bean != null
          && getMbean() != null
          && getMbean().getMember() != null
          && Util.notEmptyString(getMbean().getMember().getId())) {
        Member sm = getMbean().getMember();
        DetachedCriteria dc = DetachedCriteria.forClass(RoleMember.class);
        dc.add(Restrictions.eq("role", bean))
            .add(Restrictions.eq("member", sm))
            .add(Restrictions.eq("enable", "1"));
        RoleMember rm = baseDao.findBean(dc);
        if ("1".equals(inOro)) {
          if (rm == null) {
            rm = new RoleMember();
            rm.setMember(sm);
            rm.setRole((Role) bean);
            rm.setEnable("1");
            rm.setCreateDate(now);
            rm.setCreateMember(sessionMember);
            baseDao.save(rm);
          }
        } else {
          if (rm != null) {
            rm.setEnable(Constant.ENABLE_DEL);
            rm.setUpdateDate(now);
            rm.setUpdateMember(sessionMember);
            baseDao.update(rm);
          }
        }
        setBodyHtml("ok");
      }
      return "memberSub";
    }
    return SUCCESS;
  }
Exemplo n.º 24
0
  @Override
  public List<Deal> getDeals(DataTableHandler dataTableHandler, User userToGetDeals)
      throws UnsupportedEncodingException {
    DetachedCriteria criteria = DetachedCriteria.forClass(Deal.class);
    criteria =
        criteria
            .createAlias("customer", "customer", CriteriaSpecification.LEFT_JOIN)
            .createAlias(
                "customer.workingPlace.jobType", "jobType", CriteriaSpecification.LEFT_JOIN)
            .createAlias("credit", "credit", CriteriaSpecification.LEFT_JOIN);

    criteria.add(Restrictions.eq("isEnabled", true));

    if (userToGetDeals != null) {
      criteria.add(Restrictions.eq("user", userToGetDeals));
    }

    DataTableRequest request = dataTableHandler.getDataTableRequest();

    String direction = request.getsSortDirection();
    int index = request.getiSortColumnIndex();
    int start = request.getiDisplayStart();
    int maxResult = request.getiDisplayLength();

    if (index == 0) {
      if (direction.equals("asc")) {
        criteria.addOrder(Order.asc("id"));
      } else {
        criteria.addOrder(Order.desc("id"));
      }
    }

    if (index == 1) {
      if (direction.equals("asc")) {
        criteria.addOrder(Order.asc("customer.lastName"));
      } else {
        criteria.addOrder(Order.desc("customer.lastName"));
      }
    }

    if (index == 2) {
      if (direction.equals("asc")) {
        criteria.addOrder(Order.asc("jobType.code"));
      } else {
        criteria.addOrder(Order.desc("jobType.code"));
      }
    }

    if (index == 3) {
      if (direction.equals("asc")) {
        criteria.addOrder(Order.asc("credit.amount"));
      } else {
        criteria.addOrder(Order.desc("credit.amount"));
      }
    }

    if (index == 4) {
      if (direction.equals("asc")) {
        criteria.addOrder(Order.asc("credit.term"));
      } else {
        criteria.addOrder(Order.desc("credit.term"));
      }
    }

    if (index == 5) {
      if (direction.equals("asc")) {
        criteria.addOrder(Order.asc("creationDate"));
      } else {
        criteria.addOrder(Order.desc("creationDate"));
      }
    }

    String query = request.getsSearch();

    int totalRecordsNumber = getNumberOfDeals(userToGetDeals);
    dataTableHandler.setiTotalRecords(totalRecordsNumber);

    if (!query.equals("")) {
      Criterion criterion =
          Restrictions.disjunction().add(Restrictions.like("customer.lastName", query));

      if (Pattern.matches("^\\d*$", query)) {
        Integer iQuery = Integer.parseInt(query);
        criterion =
            Restrictions.disjunction()
                .add(Restrictions.like("customer.lastName", "%" + query + "%"))
                .add(Restrictions.eq("id", iQuery));
      } else {
        criterion =
            Restrictions.disjunction()
                .add(Restrictions.like("customer.lastName", "%" + query + "%"));
      }

      int totalDisplayRecordsNumber = getNumberOfDeals(criterion, userToGetDeals);
      dataTableHandler.setiTotalDisplayRecords(totalDisplayRecordsNumber);
      criteria.add(criterion);
    } else {
      dataTableHandler.setiTotalDisplayRecords(totalRecordsNumber);
    }

    criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

    @SuppressWarnings("unchecked")
    List<Deal> deals = hibernateTemplate.findByCriteria(criteria, start, maxResult);

    return deals;
  }
Exemplo n.º 25
0
  private void addCriteria(DetachedCriteria dc, String yearMonth) {
    dc.createAlias("emp." + Employee.PROP_EMP_DEPT_NO, "empOrgDept", 1);
    dc.createAlias("emp." + Employee.PROP_EMP_LOCATION_NO, "empOrgLoc", 1);
    dc.createAlias(Attendmonthly.PROP_ATTM_PB_NO, "attmPbNo", 1);

    dc.add(Restrictions.eq(Attendmonthly.PROP_ATTM_YEARMONTH, yearMonth));
    BaseCrit.addEmpDC(dc, "emp", this.emp);

    if (this.employee != null) {
      BaseCrit.addDC(dc, "emp." + Employee.PROP_ID, "eq", new String[] {this.employee.getId()});

      BaseCrit.addDeptDC(
          dc,
          "emp." + Employee.PROP_EMP_DEPT_NO,
          "emp." + Employee.PROP_EMP_PB_NO,
          null,
          this.employee.getEmpDeptNo());
      BaseCrit.addDC(
          dc,
          "emp." + Employee.PROP_EMP_TYPE,
          Emptype.PROP_ID,
          new Object[] {this.employee.getEmpType()});
      BaseCrit.addDC(
          dc,
          "emp." + Employee.PROP_EMP_LOCATION_NO,
          Location.PROP_ID,
          new Object[] {this.employee.getEmpLocationNo()});
    }

    if (this.searchType != 0) {
      switch (this.searchType) {
        case 1:
          dc.add(Restrictions.gt("attmLeaveHours", new BigDecimal(0)));
          break;
        case 2:
          dc.add(Restrictions.gt("attmLateTimes", new BigDecimal(0)));
          break;
        case 3:
          dc.add(Restrictions.gt("attmEarlyLeave", new BigDecimal(0)));
          break;
        case 4:
          dc.add(Restrictions.gt("attmOvertimeHours", new BigDecimal(0)));
          break;
        case 5:
          dc.add(Restrictions.gt("attmOffDutyHours", new BigDecimal(0)));
      }
    }

    if ("export".equals(this.searchOrExport)) {
      dc.setFetchMode(Attendmonthly.PROP_ATTM_DEPT, FetchMode.JOIN);
      dc.setFetchMode(Attendmonthly.PROP_ATTM_LOCATION, FetchMode.JOIN);
      dc.setFetchMode(Attendmonthly.PROP_ATTM_EMPTYPE, FetchMode.JOIN);
      dc.setFetchMode(Attendmonthly.PROP_ATTM_PB_NO, FetchMode.JOIN);

      addOrders(dc, null, new String[] {"emp." + Employee.PROP_EMP_DISTINCT_NO + "-up"});
    } else {
      addOrders(dc, this.page, new String[] {"emp." + Employee.PROP_EMP_DISTINCT_NO + "-up"});

      this.page.splitPage(dc);
    }
  }