/*
   * 批量添加学习中心指标
   *
   * @see
   * net.cedu.biz.enrollment.BranchEnrollQuotaBiz#addBranchEnrollQuotas(int,
   * int[], int[], int)
   */
  public boolean addBranchEnrollQuotas(
      int batchId, Object[] branchIds, Object[] branchTarget, int managerId) throws Exception {

    if (batchId != 0
        && branchIds != null
        && branchIds.length > 0
        && branchTarget != null
        && branchTarget.length > 0) {

      deleteBranchEnrollQuotaBybatchId(batchId);
      for (int i = 0; i < branchIds.length; i++) {
        BranchEnrollQuota beq = new BranchEnrollQuota();
        beq.setBatchId(batchId);
        beq.setBranchId(Integer.valueOf(branchIds[i].toString()));
        beq.setTarget(Integer.valueOf(branchTarget[i].toString()));
        beq.setCreatorId(managerId);
        beq.setCreatedTime(new Date());
        this.addBranchEnrollQuota(beq);
      }
      EnrollQuotaBatch eqb = eqbBiz.findEnrollQuotaBatchByQuotaIdBatchId(0, batchId);
      eqb.setTypes(Constants.STATUS_ENABLED);
      eqbBiz.updateEnrollQuotaBatch(eqb);
      return true;
    }
    return false;
  }
 /*
  * 刷新并添加没有的学习中心指标
  *
  * @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;
 }