Ejemplo n.º 1
0
  private static void wrapSiteEpisodeLog(AuditEpisodeLogBo auditEpisodeLogBo, int siteId)
      throws Exception {
    Criteria crit = new Criteria();
    crit.add(ProgrammeSitePeer.FK_PROGRAMME_ID, auditEpisodeLogBo.getId());
    List<ProgrammeSite> psList = ProgrammeSitePeer.doSelect(crit);
    List<AuditEpisodeLogBo.SiteEpisodeLog> siteEpisodeLogList =
        new ArrayList<AuditEpisodeLogBo.SiteEpisodeLog>();
    List<AuditEpisodeLogBo.SiteEpisodeLog> hasEpisodeSiteList =
        new ArrayList<AuditEpisodeLogBo.SiteEpisodeLog>();
    if (psList != null && !psList.isEmpty()) {
      for (ProgrammeSite ps : psList) {
        // log.info("siteId" + siteId);
        if (siteId > 0 && ps.getSourceSite() != siteId) {
          continue;
        }
        AuditEpisodeLogBo.SiteEpisodeLog siteEpisode =
            getSiteEpisodeLog(ps.getId(), ps.getSourceSite());

        hasEpisodeSiteList.add(getHasEpisodeSite(ps.getId(), ps.getSourceSite()));

        /*//审核特殊显示全剧情况
        if(auditEpisodeLogBo.getConcernLevel() == Constants.CONCERN_FLAG) {
        	AuditEpisodeLogBo.SiteEpisodeLog allEpisode = processConcernProgramme(ps.getId(), siteId);
        	if(allEpisode.getEpisodeLogList() != null) {
        		siteEpisode.getEpisodeLogList().addAll(allEpisode.getEpisodeLogList());
        	}
        	Collections.sort(siteEpisode.getEpisodeLogList(), new Comparator<EpisodeLog>() {

        		@Override
        		public int compare(EpisodeLog o1, EpisodeLog o2) {
        			return o1.getOrderId() - o2.getOrderId();
        		}
        	});
        }*/
        siteEpisodeLogList.add(siteEpisode);
      }
    }

    auditEpisodeLogBo.setHasEpisodeSiteIds(hasEpisodeSiteList);
    auditEpisodeLogBo.setSiteEpisodeLogList(siteEpisodeLogList);
    auditEpisodeLogBo.setCateName(
        CategoryService.getCategoryMap().get(auditEpisodeLogBo.getCateId()));
  }
Ejemplo n.º 2
0
  public static void searchVideoInfo(SearchParameter param, PageInfo pageInfo) throws Exception {

    log.info("serarch word: " + param.getSearchWord());
    List<AuditEpisodeLogBo> resultList = new ArrayList<AuditEpisodeLogBo>();

    String mainSql =
        "programme p, programme_search_number psn WHERE p.id = psn.fk_programme_id and audit_all = 0";
    String likeSql = "";
    if (param.getSearchWord() != null && !param.getSearchWord().equals("")) {
      likeSql = " AND p.name LIKE ? ";
    }

    if (param.getCategoryId() > 0) {
      mainSql += " AND p.cate = " + param.getCategoryId();
    }

    if (param.getConcernLevel() > 0) {
      mainSql += " AND p.concern_level = " + param.getConcernLevel();
    }

    if (param.isAccuratelyMatched()) {
      param.setSearchWord(param.getSearchWord());
    } else {
      param.setSearchWord("%" + param.getSearchWord() + "%");
    }

    String countsql = "SELECT COUNT(*) FROM " + mainSql;
    countsql += likeSql;

    PreparedStatement pstcnt = null;
    ResultSet rscnt = null;

    Connection conn = null;
    PreparedStatement pst = null;
    ResultSet rs = null;
    try {
      conn = DataBase.getLibraryConn();
      pstcnt = conn.prepareStatement(countsql);
      if (!likeSql.equals("")) {
        pstcnt.setString(1, param.getSearchWord());
        if (param.getStatus() == SearchParameter.WITH_SERIES) {
          pstcnt.setString(2, param.getSearchWord());
        }
      }
      log.info("pstcnt: " + pstcnt.toString());
      rscnt = pstcnt.executeQuery();
      int recordCount = 0;
      while (rscnt.next()) {
        recordCount = rscnt.getInt(1);
      }
      if (recordCount == 0) {
        return;
      }
      int totalPageNumber = (int) Math.ceil((double) recordCount / pageInfo.getPageSize());
      pageInfo.setTotalPageNumber(totalPageNumber);
      pageInfo.setTotalRecords(recordCount);
      String sql =
          "SELECT * FROM "
              + mainSql
              + likeSql
              + " ORDER BY psn.search_number desc LIMIT "
              + pageInfo.getOffset()
              + ", "
              + pageInfo.getPageSize();

      pst = conn.prepareStatement(sql);
      log.info("likeSql " + likeSql);
      if (!likeSql.equals("")) {
        log.info("param.getSearchWord()" + param.getSearchWord());
        pst.setString(1, param.getSearchWord());
        if (param.getStatus() == SearchParameter.WITH_SERIES) {
          pst.setString(2, param.getSearchWord());
        }
      }
      log.info("pst toString " + pst.toString());
      rs = pst.executeQuery();
      while (rs.next()) {
        AuditEpisodeLogBo logBo = new AuditEpisodeLogBo();
        logBo.setId(rs.getInt("p.id"));
        logBo.setName(rs.getString("p.name"));
        logBo.setCateId(rs.getInt("p.cate"));
        logBo.setConcernLevel(rs.getInt("p.concern_level"));
        resultList.add(logBo);
      }

      for (AuditEpisodeLogBo logBo : resultList) {
        wrapSiteEpisodeLog(logBo, param.getSiteId());
      }

      pageInfo.setResults(resultList);
    } catch (Exception e) {
      log.error(e.getMessage(), e);
    } finally {
      try {
        if (pst != null) {
          pst.close();
        }
        if (rs != null) {
          rs.close();
        }
        if (pstcnt != null) {
          pstcnt.close();
        }
        if (rscnt != null) {
          rscnt.close();
        }
        JdbcUtil.close(conn);
      } catch (SQLException e) {
        log.error(e.getMessage(), e);
      }
    }
  }