Ejemplo 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;
 }
Ejemplo n.º 2
0
 /*
  * 查询学习中心 按学习中心Id&(多),批次Id&(多)
  *
  * @see
  * net.cedu.biz.enrollment.BranchEnrollQuotaBiz#findBranchEnrollQuotaByBranchId
  * (int)
  */
 public List<BranchEnrollQuota> findBranchEnrollQuotaByBranchIds(String batchIds, String branchIds)
     throws Exception {
   if ((null != batchIds && !"".equals(batchIds))
       && (null != branchIds && !"".equals(branchIds))) {
     return branchenrollquotaDao.getByProperty(
         "and batchId in ("
             + Constants.PLACEHOLDER
             + ")"
             + "and branchId in ("
             + Constants.PLACEHOLDER
             + ")"
             + " and deleteFlag="
             + Constants.PLACEHOLDER,
         new Object[] {"$" + batchIds, "$" + branchIds, Constants.DELETE_FALSE});
   } else if ((null != batchIds && !"".equals(batchIds))
       && (null == branchIds || "".equals(branchIds))) {
     return branchenrollquotaDao.getByProperty(
         "and batchId in ("
             + Constants.PLACEHOLDER
             + ")"
             + " and deleteFlag="
             + Constants.PLACEHOLDER,
         new Object[] {"$" + batchIds, Constants.DELETE_FALSE});
   } else if ((null == batchIds || "".equals(batchIds))
       && (null != branchIds || !"".equals(branchIds))) {
     return branchenrollquotaDao.getByProperty(
         "and branchId in ("
             + Constants.PLACEHOLDER
             + ")"
             + " and deleteFlag="
             + Constants.PLACEHOLDER,
         new Object[] {"$" + branchIds, Constants.DELETE_FALSE});
   } else {
     return branchenrollquotaDao.findAllNotDeleted();
   }
 }