/* * 查看项目列表 * */ public List<Project> find(final ProjectQuery p) { Specification<Project> sp = new Specification<Project>() { @Override public Predicate toPredicate( Root<Project> root, CriteriaQuery<?> query, CriteriaBuilder cb) { // TODO Auto-generated method stub List<Predicate> list = new ArrayList<>(); if (p.getId() != null) { list.add(cb.equal(root.get("id").as(Long.class), p.getId())); } if (StringUtils.isNotEmpty(p.getName())) { list.add(cb.like(root.get("name").as(String.class), "%" + p.getName() + "%")); } if (StringUtils.isNotEmpty(p.getPm())) { list.add(cb.like(root.get("pm").as(String.class), "%" + p.getPm() + "%")); } if (p.getState() != null) { list.add(cb.equal(root.get("state").as(Integer.class), p.getState())); } if (p.getProjectBeginTime() != null) { list.add( cb.equal(root.get("projectBeginTime").as(Date.class), p.getProjectBeginTime())); } if (p.getProjectEndTime() != null) { list.add(cb.equal(root.get("projectEndTime").as(Date.class), p.getProjectEndTime())); } Predicate[] ps = new Predicate[list.size()]; query.where(cb.and(list.toArray(ps))); if (StringUtils.isNotEmpty(p.getSort())) { query.orderBy(cb.desc(root.get(p.getSort()))); } return query.getGroupRestriction(); } }; List<Project> plist = projectDao.findAll(sp); if (StringUtils.isNotEmpty(p.getProjectPersonnel())) { List<Project> list = new ArrayList<Project>(); for (Project project : plist) { String[] strs = project.getProjectPersonnel().split(","); for (String s : strs) { if (s.equals(p.getProjectPersonnel())) { list.add(project); break; } } } return list; } else { return plist; } }
/** * 项目管理 * * @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; }