/**
   * 查询单体信息
   *
   * @param contentid
   * @param acttype
   * @return
   */
  public Map<String, Object> getAudioInfo(String contentid, String acttype) {
    CacheEle<_CacheDictionary> cache =
        ((CacheEle<_CacheDictionary>) SystemCache.getCache(WtContentMngConstants.CACHE_DICT));
    _CacheDictionary cd = cache.getContent();

    Map<String, Object> audioData = new HashMap<String, Object>();
    MediaAsset ma = mediaService.getMaInfoById(contentid);
    audioData.put("ContentId", ma.getId());
    audioData.put("ContentName", ma.getMaTitle());
    audioData.put("MediaType", acttype);
    audioData.put("ContentImg", ma.getMaImg());
    audioData.put("ContentCTime", ma.getCTime());
    audioData.put("ContentPubTime", ma.getMaPublishTime());
    audioData.put("ContentDesc", ma.getDescn());
    audioData.put("ContentTimes", ma.getCTime());
    audioData.put("ContentSource", ma.getMaPublisher());
    audioData.put("ContentURI", ma.getMaURL());
    audioData.put("ContentPersons", null);

    List<DictRefResPo> listdicref =
        mediaService.getResDictRefByResId(audioData.get("ContentId") + "");
    String catalogs = "";
    for (DictRefResPo dictRefResPo : listdicref) {
      DictDetail dd = cd.getDictDetail(dictRefResPo.getDictMid(), dictRefResPo.getDictDid());
      if (dd != null) catalogs += "," + dd.getNodeName();
    }
    audioData.put(
        "ContentCatalogs",
        (StringUtils.isNullOrEmptyOrSpace(catalogs) || catalogs.toLowerCase().equals("null"))
            ? null
            : catalogs.substring(1));
    return audioData;
  }
  /**
   * 查看专辑及级下节目的信息
   *
   * @param pagesize
   * @param page
   * @param id
   * @param acttype
   * @return
   */
  public Map<String, Object> getSeqInfo(int pagesize, int page, String id, String acttype) {
    List<Map<String, Object>> listaudio = new ArrayList<Map<String, Object>>();
    Map<String, Object> map = new HashMap<String, Object>();
    Map<String, Object> seqData = new HashMap<String, Object>(); // 存放专辑信息
    SeqMediaAsset sma = mediaService.getSmaInfoById(id);
    List<Map<String, Object>> catalist =
        mediaService.getResDictRefByResId("'" + sma.getId() + "'", "wt_SeqMediaAsset");
    List<Map<String, Object>> chlist =
        mediaService.getCHAByAssetId("'" + sma.getId() + "'", "wt_SeqMediaAsset");
    List<SeqMaRefPo> listseqmaref = mediaService.getSeqMaRefBySid(sma.getId());
    Map<String, Object> smap = sma.toHashMap();
    smap.put("count", listseqmaref.size());
    smap.put("smaPublishTime", chlist.get(0).get("pubTime"));
    seqData = ContentUtils.convert2Sma(smap, null, catalist, chlist, null);

    // 查询专辑和单体的联系
    List<String> listaudioid = new ArrayList<String>();

    for (SeqMaRefPo seqMaRefPo : listseqmaref) {
      listaudioid.add(seqMaRefPo.getMId());
    }

    // 查询单体信息
    for (String audid : listaudioid) {
      listaudio.add(getAudioInfo(audid, "wt_MediaAsset"));
    }

    if (listaudio.size() == 0) {
      map.put("audio", null);
    } else {
      map.put("audio", listaudio);
    }
    map.put("sequ", seqData);
    return map;
  }
  /**
   * 修改排序号
   *
   * @param id
   * @param sort
   * @return
   */
  public Map<String, Object> modifySort(String id, String sort) {
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    Map<String, Object> map = new HashMap<String, Object>();
    int num = 0;
    ChannelAsset oldcha = mediaService.getCHAInfoById(id);
    ChannelAsset newcha = new ChannelAsset();
    newcha.setCh(oldcha.getCh());
    newcha.setId(id);
    newcha.setSort(Integer.valueOf(sort));
    newcha.setPubTime(new Timestamp(System.currentTimeMillis()));

    String sql = "update wt_ChannelAsset set sort = ?,pubTime= ? where id = ?";
    try {
      conn = DataSource.getConnection();
      ps = conn.prepareStatement(sql);
      ps.setInt(1, Integer.valueOf(sort));
      Timestamp timestamp = new Timestamp(System.currentTimeMillis());
      ps.setTimestamp(2, timestamp);
      ps.setString(3, id);
      num = ps.executeUpdate();
    } catch (SQLException e) {
      e.printStackTrace();
    } finally {
      closeConnection(conn, ps, rs);
    }
    if (num == 1) {
      map.put("ReturnType", "1001");
    } else {
      map.put("ReturnType", "1011");
      map.put("Message", "修改失败");
    }
    return map;
  }
 /**
  * 修改审核状态
  *
  * @param id 栏目发布表id
  * @param number
  * @return
  */
 public Map<String, Object> modifyStatus(String id, String number) {
   Map<String, Object> map = new HashMap<String, Object>();
   id = id.replaceAll("%2C", ",");
   id = id.substring(0, id.length() - 1);
   String[] ids = id.split(",");
   int num = 0;
   for (int i = 0; i < ids.length; i++) {
     ChannelAsset cha = new ChannelAsset();
     cha.setId(ids[i]);
     cha.setPubTime(new Timestamp(System.currentTimeMillis()));
     cha.setFlowFlag(Integer.valueOf(number));
     num = mediaService.updateCha(cha);
   }
   if (num == 1) {
     map.put("ReturnType", "1001");
   } else {
     map.put("ReturnType", "1011");
     map.put("Message", "修改失败");
   }
   return map;
 }
  /**
   * 查询列表
   *
   * @param flowFlag
   * @param page
   * @param pagesize
   * @param catalogsid
   * @param source
   * @param beginpubtime
   * @param endpubtime
   * @param beginctime
   * @param endctime
   * @return
   */
  public Map<String, Object> getContent(
      int flowFlag,
      int page,
      int pagesize,
      String channelId,
      String publisherId,
      Timestamp beginpubtime,
      Timestamp endpubtime,
      Timestamp beginctime,
      Timestamp endctime) {
    Map<String, Object> mapall = new HashMap<String, Object>();
    Connection conn = null;
    PreparedStatement ps = null;
    ResultSet rs = null;
    List<Map<String, Object>> list2seq = new ArrayList<Map<String, Object>>();
    int numall = 0;
    String sql = "";

    Map<String, Object> m = new HashMap<String, Object>();
    m.put("channelId", channelId);
    m.put("publisherId", publisherId);
    m.put("beginPubtime", beginpubtime);
    m.put("endPubtime", endpubtime);
    m.put("begincTime", beginctime);
    m.put("endcTime", endctime);
    m.put("flowFlag", flowFlag);
    numall = mediaService.getCountInCha(m);

    m.clear();
    m.put("channelId", channelId);
    m.put("publisherId", publisherId);
    m.put("beginPubtime", beginpubtime);
    m.put("endPubtime", endpubtime);
    m.put("begincTime", beginctime);
    m.put("endcTime", endctime);
    m.put("flowFlag", flowFlag);
    m.put("beginNum", page * pagesize);
    m.put("size", pagesize);
    List<ChannelAssetPo> listchapo = mediaService.getContentsByFlowFlag(m);
    for (ChannelAssetPo channelAssetPo : listchapo) {
      Map<String, Object> oneData = new HashMap<String, Object>();
      oneData.put("Id", channelAssetPo.getId()); // 栏目ID修改排序功能时使用
      oneData.put("MediaType", channelAssetPo.getAssetType());
      oneData.put("ContentId", channelAssetPo.getAssetId()); // 内容ID获得详细信息时使用
      oneData.put("ContentImg", channelAssetPo.getPubImg());
      oneData.put("ContentCTime", channelAssetPo.getCTime());
      oneData.put("ContentPubTime", channelAssetPo.getPubTime());
      oneData.put("ContentSort", channelAssetPo.getSort());
      oneData.put("ContentFlowFlag", channelAssetPo.getFlowFlag());
      list2seq.add(oneData);
    }

    // 查询显示的节目名称,发布组织和描述信息
    for (Map<String, Object> map : list2seq) {
      if (map.get("MediaType").equals("wt_SeqMediaAsset")) {
        SeqMediaAsset sma = mediaService.getSmaInfoById(map.get("ContentId") + "");
        map.put("ContentName", sma.getSmaTitle());
        map.put("ContentSource", sma.getPublisher());
        map.put("ContentDesc", sma.getDescn());
      } else {
        if (map.get("MediaType").equals("wt_MediaAsset")) {
          MediaAsset ma = mediaService.getMaInfoById(map.get("ContentId") + "");
          map.put("ContentName", ma.getMaTitle());
          map.put("ContentSource", ma.getMaPublisher());
          map.put("ContentDesc", ma.getDescn());
        } else {
          if (map.get("MediaType").equals("wt_Broadcast")) {
            // 待更改
            sql = "select bcTitle,bcPublisher,descn from wt_Broadcast where id = ? limit 1";
            try {
              conn = DataSource.getConnection();
              ps = conn.prepareStatement(sql);
              ps.setString(1, (String) map.get("ContentId"));
              rs = ps.executeQuery();
              while (rs != null && rs.next()) {
                map.put("ContentName", rs.getString("bcTitle"));
                map.put("ContentSource", rs.getString("bcPublisher"));
                map.put("ContentDesc", rs.getString("descn"));
              }
            } catch (SQLException e) {
              e.printStackTrace();
            } finally {
              closeConnection(conn, ps, rs);
            }
          }
        }
      }
    }
    mapall.put("List", list2seq);
    mapall.put("Count", numall);
    return mapall;
  }