/**
   * 生成日志
   *
   * @param logType 1 为系统管理日志 2为登录日志 3为业务日志
   * @param logContent 日志内容
   * @param result 操作结果
   * @return
   */
  public boolean insertSystemLog(String logType, String logContent, boolean result) {
    DbContextHolder.setDbType(DbContextHolder.DATA_SOURCE_COMMON);
    Systemdiary systemLog = new Systemdiary();
    systemLog.setDiaryCode(GenUUID.generateUUID());
    systemLog.setOperContent(logContent);
    systemLog.setDiaryType(logType);
    systemLog.setOperTime(CurrentDate.getCurrentDate());
    if (result) {
      systemLog.setOperResult("操作成功");
    } else {
      systemLog.setOperResult("操作失败");
    }
    Map<String, Object> session = (Map<String, Object>) ActionContext.getContext().getSession();
    User nowuser = (User) session.get("currentUser");
    if (nowuser != null) {
      systemLog.setOperPerson(nowuser.getUserName());
    }

    if (logType != null) {
      if (logType.equals("1")) {
        systemLog.setDiaryName("系统管理日志");
      } else if (logType.equals("2")) {
        systemLog.setDiaryName("系统登录日志");
      } else {
        systemLog.setDiaryName("系统业务日志");
      }
    }
    return systemLogDao.executeInsertEntity(systemLog);
  }
  /**
   * 查询记录数
   *
   * @param user
   * @return
   * @throws SQLException
   * @throws NullPointerException
   * @throws HibernateException
   */
  public long searchUserCount(Systemdiary systemLog)
      throws HibernateException, NullPointerException, SQLException {
    DbContextHolder.setDbType(DbContextHolder.DATA_SOURCE_COMMON);

    StringBuilder hql = new StringBuilder("select count(*) from DSDATA.Systemdiary where 1=1 ");
    hql.append(generateSQL(systemLog));
    return systemLogDao.executeQueryCountSQL_throwEX(hql.toString());
  }
  /**
   * 查询日志
   *
   * @param systemLog
   * @param pageNum
   * @param pageSize
   * @return
   * @throws SQLException
   * @throws HibernateException
   */
  @SuppressWarnings("unchecked")
  public List<Systemdiary> searchSystemdiarys(Systemdiary systemLog, int pageNum, int pageSize)
      throws HibernateException, SQLException {
    DbContextHolder.setDbType(DbContextHolder.DATA_SOURCE_COMMON);
    // 带条件
    StringBuilder hql = new StringBuilder("from Systemdiary where 1=1 ");
    hql.append(generateSQL(systemLog));
    hql.append(" order by  operTime desc");
    if (pageNum > 0) {

      return systemLogDao.executeQueryByPage_throwsEx(
          hql.toString(), (pageNum - 1) * pageSize, pageSize);
    }
    return null;
  }
 /**
  * 查询记录数
  *
  * @param user
  * @return
  */
 public long searchUserCount(Systemdiary systemLog) {
   DbContextHolder.setDbType(DbContextHolder.DATA_SOURCE_COMMON);
   StringBuilder hql = new StringBuilder("select count(*) from Systemdiary where 1=1 ");
   hql.append(generateSQL(systemLog));
   return systemLogDao.executeQueryCount(hql.toString());
 }