Exemplo n.º 1
0
 /*
  * 刷新并添加没有的学习中心指标
  *
  * @see net.cedu.biz.enrollment.BranchEnrollQuotaBiz#addRefreshBranchEnrollQuotaBybatchId(int, int)
  */
 public int addRefreshBranchEnrollQuotaBybatchId(int batchId, int userId) throws Exception {
   int count = 0;
   List<Object> lst = new ArrayList();
   String hql = "";
   // 批次
   hql += " and batchId=" + Constants.PLACEHOLDER;
   lst.add(batchId);
   // 未删除的
   hql += "and deleteFlag=" + Constants.PLACEHOLDER;
   lst.add(Constants.DELETE_FALSE);
   List<BranchEnrollQuota> brqlist = branchenrollquotaDao.getByProperty(hql, lst.toArray());
   List<Branch> branchlist =
       branchDao.getByProperty(
           " and parentId > "
               + Constants.PLACEHOLDER
               + "and deleteFlag="
               + Constants.PLACEHOLDER
               + " order by id desc ",
           new Object[] {BranchEnum.Parent.value(), Constants.DELETE_FALSE});
   if (brqlist != null && brqlist.size() > 0 && branchlist != null && branchlist.size() > 0) {
     int branchsize = branchlist.size();
     int brqsize = brqlist.size();
     if (branchsize <= brqsize) {
       count = 1;
     } else {
       int index = 0;
       for (Branch branch : branchlist) {
         boolean isback = false;
         for (BranchEnrollQuota brq : brqlist) {
           if (branch.getId() == brq.getId()) {
             isback = true;
             break;
           }
         }
         if (!isback) {
           BranchEnrollQuota beq = new BranchEnrollQuota();
           beq.setBatchId(batchId);
           beq.setBranchId(branch.getId());
           beq.setTarget(0);
           beq.setCreatorId(userId);
           beq.setCreatedTime(new Date());
           this.addBranchEnrollQuota(beq);
           index++;
         }
         if (brqsize + index >= branchsize) {
           break;
         }
       }
       count = 2;
     }
   }
   return count;
 }
Exemplo n.º 2
0
  /*
   * 查询所有学习中心(分配指标)按批次
   *
   * @see net.cedu.biz.admin.BranchBiz#findBranchByBtachId(int,
   * net.cedu.model.page.PageResult)
   */
  public List<Branch> findBranchByBtachId(int batchId, PageResult<Branch> pr) throws Exception {
    List<Branch> branchlst = null;
    PageParame p = new PageParame();
    String hqlparam = "";
    List<Object> list = new ArrayList<Object>();
    hqlparam += " and parentId > " + Constants.PLACEHOLDER;
    list.add(BranchEnum.Parent.value());
    hqlparam += "and deleteFlag=" + Constants.PLACEHOLDER;
    list.add(Constants.DELETE_FALSE);
    p.setHqlConditionExpression(hqlparam);
    p.setValues(list.toArray());
    Long[] branchids = branchBiz.findBranchIds(p);
    //		int year = 0;
    //		int month = 0;
    //		int oldyear = Integer.valueOf(ResourcesTool.getText("enrollment",
    //				"year"));
    //		List<GlobalEnrollBatch> glst = new ArrayList<GlobalEnrollBatch>();

    if (branchids != null && branchids.length != 0) {
      branchlst = new ArrayList<Branch>();
      // Map key:branch value:当前批次指标
      Map<String, Integer> batchTargetMap =
          branchenrollquotaDao.findBranchEnrollQuotaMapByBatch(batchId);
      // 上一批次id
      int lastBatchId = globalenrollbatchBiz.findLastGlobalEnrollBatchIdByGlobalBatchId(batchId);
      Map<String, Integer> lastBatchTargetMap = new HashMap<String, Integer>();
      Map<String, Integer> lastBatchCompleteTargetMap = new HashMap<String, Integer>();
      if (lastBatchId != 0) {
        // Map key:branch value:上一批次指标
        lastBatchTargetMap = branchenrollquotaDao.findBranchEnrollQuotaMapByBatch(lastBatchId);
        // Map key:branch value:上一批次完成指标
        lastBatchCompleteTargetMap =
            studentDao.getCompleteCountAllByGlobalEnrollBatchId(lastBatchId);
      }
      for (int i = 0; i < branchids.length; i++) {
        // 内存获取
        Branch branchObj = branchBiz.findBranchById(Integer.valueOf(branchids[i].toString()));

        //				GlobalEnrollBatch geb = globalenrollbatchBiz
        //						.findGlobalEnrollBatchById(batchId);
        //				if (geb != null) {
        //					year = geb.getBelongYear();
        //				}
        //
        //				month = Integer.valueOf(geb.getBatch().substring(
        //						geb.getBatch().length() - 2));
        //				while (true) {
        //					if (year <= oldyear) {
        //						break;
        //					}
        //					glst = globalenrollbatchBiz
        //							.findGlobalEnrollBatchByYear(year);
        //					if (glst == null) {
        //						year--;
        //						continue;
        //					} else {
        //
        //						int batchid = BatchIdInt(glst, month);
        //						BranchEnrollQuota beq = this
        //								.findBranchEnrollQuotaByBtachIdAndBranchId(
        //										batchid, branchObj.getId());
        //						if (beq != null) {
        //							branchObj.setBatchTarget(beq.getTarget());
        //						}
        //						break;
        //					}
        //
        //				}
        // 员工数量
        branchObj.setUserCount(userBiz.countUserByOrgId(branchObj.getId()));
        // 上一批次指标
        Integer lastTarget = lastBatchTargetMap.get(branchObj.getId() + "");
        branchObj.setBatchTarget(lastTarget == null ? 0 : lastTarget);
        // 上一批次完成指标
        Integer lastCompleteTarget = lastBatchCompleteTargetMap.get(branchObj.getId() + "");
        branchObj.setBatchComplete(lastCompleteTarget == null ? 0 : lastCompleteTarget);
        // 当前批次指标
        Integer currentTarget = batchTargetMap.get(branchObj.getId() + "");
        branchObj.setCurrentBatchTarget(currentTarget == null ? 0 : currentTarget);
        branchlst.add(branchObj);
      }
    }
    return branchlst;
  }