示例#1
0
  public EfficiencyProjectBo findEfficiencyProjectByProId(Long proId) {
    int a = 0;
    int b = 0;
    int c = 0;
    EfficiencyProjectBo eff_pro = new EfficiencyProjectBo();
    Project pro = (Project) projectDao.findOne(proId);
    List<Efficiency> eff_list = null;
    /** beging */
    if (null != pro && null != pro.getId()) {
      eff_list = (List<Efficiency>) efficiencyDao.findByProjectId(proId.intValue());
      if (null != eff_list && eff_list.size() > 0) {
        for (Efficiency temp : eff_list) {
          if (null != temp.getPlanHours()) {
            a += temp.getPlanHours();
          }
          if (null != temp.getActualHours()) {
            b += temp.getActualHours();
          }
          if (null != temp.getOutputHours()) {
            c += temp.getOutputHours();
          }
        }
      }
    }
    /** 结束 */
    eff_pro.setActualHoursAll(b);
    eff_pro.setPlanHoursAll(a);
    eff_pro.setOutputHoursAll(c);
    eff_pro.setName(pro.getName());
    eff_pro.setPm(pro.getPm());
    eff_pro.setProjectPersonnel(pro.getProjectPersonnel());
    eff_pro.setState(pro.getState());
    eff_pro.setProId(pro.getId());

    return eff_pro;
  }
示例#2
0
  /**
   * 项目管理
   *
   * @return
   */
  public Page<EfficiencyProjectBo> findAllPro(final ProjectQuery q) {
    List<EfficiencyProjectBo> list_eff_pro = new ArrayList<EfficiencyProjectBo>();

    Specification<Project> sp =
        new Specification<Project>() {
          @Override
          public Predicate toPredicate(
              Root<Project> root, CriteriaQuery<?> query, CriteriaBuilder cb) {
            List<Predicate> list = new ArrayList<>();
            if (StringUtils.isNotEmpty(q.getName())) {
              list.add(cb.equal(root.get("name").as(String.class), q.getName()));
            }
            if (StringUtils.isNotEmpty(q.getPm())) {
              list.add(cb.equal(root.get("pm").as(String.class), q.getPm()));
            }

            if (q.getId() != null) {
              list.add(cb.equal(root.get("id").as(Integer.class), q.getId()));
            }
            if (q.getState() != null) {
              list.add(cb.equal(root.get("state").as(Integer.class), q.getState()));
            }
            if (q.getProjectPersonnel() != null) {
              list.add(
                  cb.like(
                      root.get("projectPersonnel").as(String.class),
                      "%" + q.getProjectPersonnel() + "%"));
            }

            Predicate[] ps = new Predicate[list.size()];
            query.where(cb.and(list.toArray(ps)));
            if (StringUtils.isNotEmpty(q.getSort())) {
              query.orderBy(cb.desc(root.get(q.getSort())));
            }
            return query.getGroupRestriction();
          }
        };
    PageRequest pageRequest = null;
    if (q.getPageIndex() != null && q.getPageSize() != null) {
      pageRequest = new PageRequest(q.getPageIndex(), q.getPageSize());
    }
    Page<Project> pageList = projectDao.findAll(sp, pageRequest);

    List<Project> pro_list = pageList.getContent();

    long tatol = pageList.getTotalElements();
    if (null != pro_list && pro_list.size() > 0) {
      for (Project t_pro : pro_list) {
        /** beging */
        if (null != t_pro && null != t_pro.getId()) {
          EfficiencyProjectBo bo = findEfficiencyProjectByProId(t_pro.getId());
          if (q.getPlanHoursSearch() != null && q.getPlanHoursSearch() != bo.getPlanHoursAll()) {
            continue;
          }
          if (q.getActualHoursSearch() != null
              && q.getActualHoursSearch() != bo.getActualHoursAll()) {
            continue;
          }
          if (q.getOutputHoursSearch() != null
              && q.getOutputHoursSearch() != bo.getOutputHoursAll()) {
            continue;
          }
          list_eff_pro.add(bo);
        }
      }
    }
    Page<EfficiencyProjectBo> page =
        new PageImpl<EfficiencyProjectBo>(list_eff_pro, pageRequest, tatol);
    return page;
  }