Exemplo n.º 1
0
  /**
   * 取配置信息,构建成JSON对象
   *
   * @param userId -- 用户信息
   * @return
   */
  public String getPortalJson(String userId) {
    // 取用户所属角色的模板信息
    List<Map<String, String>> lsTemp = queryTemplet(userId);
    if (lsTemp.isEmpty()) {
      // "构建首页失败,因为用户所属角色没有定义PORTAL模板!"
      setMessage(JsMessage.getValue("portalquery.notemp"));
      return _returnFaild;
    }

    // 构建PORTAL的JSON
    StringBuilder sbtemps = new StringBuilder();
    for (int i = 0, n = lsTemp.size(); i < n; i++) {
      Map<String, String> mpTemp = lsTemp.get(i);

      try {
        String tempJson = templetJson(mpTemp);

        sbtemps.append(tempJson);
        sbtemps.append((i < n - 1) ? ",\n" : "\n");
      } catch (BoException e) {
        _log.showError(e);
        setMessage(e.getMessage());
        return _returnFaild;
      }
    }

    String portalJson = "{portalnum:" + lsTemp.size() + ", portals:[\n" + sbtemps.toString() + "]}";
    _log.showDebug("---------portalJson=" + portalJson);
    setReturnData(portalJson);

    return _returnSuccess;
  }
Exemplo n.º 2
0
  /**
   * 输出图片到指定的单元格。
   *
   * @param funId -- 功能ID
   * @param field -- 图片字段
   * @param mpData -- 当前数据记录,取记录主键值
   * @param cell -- 输出图片的指定单元格
   */
  private static boolean printCellImage(
      String funId, String fieldName, Map<String, String> mpData, HSSFCell cell) {
    // 取功能基础信息
    Map<String, String> mpFun = FunDefineDao.queryFun(funId);
    if (mpFun == null || mpFun.isEmpty()) {
      _log.showDebug("--------printCellImage(): not find function is null!!");
      return false;
    }
    // 取功能表名
    String tableName = mpFun.get("table_name");
    // 取主键,不带表名
    String pkcol = mpFun.get("pk_col");
    pkcol = StringUtil.getNoTableCol(pkcol);
    // 取主键值
    String dataId = mpData.get(pkcol);
    if (dataId == null || dataId.length() == 0) {
      _log.showDebug("--------printCellImage(): not find data id!!");
      return false;
    }

    AttachBO attachBO = new AttachBO();
    // 取图文附件记录
    Map<String, String> mpAttach = null;
    try {
      mpAttach = attachBO.queryAttach(dataId, tableName, fieldName);
    } catch (BoException e1) {
      e1.printStackTrace();
    }
    if (mpAttach == null || mpAttach.isEmpty()) {
      _log.showDebug(
          "--------printCellImage(): not attach dataId="
              + dataId
              + "; tableName="
              + tableName
              + ";fieldName="
              + fieldName);
      return false;
    }

    // 取图文附件字节信息
    byte[] bytes = null;
    try {
      bytes = attachBO.queryAttachContent(mpAttach);
    } catch (BoException e1) {
      e1.printStackTrace();
    }
    if (bytes == null || bytes.length == 0) {
      _log.showDebug("--------printCellImage(): not find attach image file!!");
      return false;
    }

    // 输出图片到指定位置
    addImageToSheet(cell, bytes);

    return true;
  }
Exemplo n.º 3
0
  /**
   * 批量发布公告。
   *
   * @param keyIds -- 消息数组ID
   * @return
   */
  public String gridSendMsg(String[] keyIds) {
    if (keyIds == null || keyIds.length == 0) {
      // "发送消息ID为空!"
      setMessage(JsMessage.getValue("portlet.msgidisnull"));
      return _returnFaild;
    }

    // 发送消息
    try {
      for (int i = 0, n = keyIds.length; i < n; i++) {
        sendMsg(keyIds[i]);
      }
    } catch (BoException e) {
      _log.showError(e);
      setMessage(e.getMessage());
      return _returnFaild;
    }

    return _returnSuccess;
  }
Exemplo n.º 4
0
  /**
   * 发布公告,如果有消息ID说明是先保存了再发送的,如果没有消息ID则需要先保存再发送。
   *
   * @param requestContext
   * @return
   */
  public String formSendMsg(RequestContext requestContext) {
    String sKeyID = requestContext.getRequestValue(JsParam.KEYID);

    // 消息ID为空,先保存再发送
    if (sKeyID == null || sKeyID.length() == 0) {
      CreateEvent ce = new CreateEvent();
      String bret = ce.create(requestContext);
      if (bret.equals(_returnFaild)) return _returnFaild;

      sKeyID = requestContext.getRequestValue(JsParam.KEYID);
    }

    // 发送消息
    try {
      sendMsg(sKeyID);
    } catch (BoException e) {
      _log.showError(e);
      setMessage(e.getMessage());
      return _returnFaild;
    }

    return _returnSuccess;
  }