@SuppressWarnings("unchecked")
  public String troubleStatisticsForOneQuery() {

    String totalHql;
    Long total;

    try {
      if (funTroubleRecode.getFunTroubleVariable().getCode().equals("all")) {
        String hql =
            "SELECT new map(ftr.fun.name as name, ftr.funTroubleVariable.code as code, ftr.startTime as startTime, "
                + "ftr.endTime as endTime, ftr.funTroubleVariable.description as description) "
                + "FROM FunTroubleRecode ftr "
                + "WHERE ftr.fun.id=? "
                + "AND ftr.startTime>? "
                + "AND ftr.startTime<? "
                + "AND ftr.funTroubleVariable.type.id=? ";

        statisticsList =
            funTroubleRecodeService.executeHQLQueryPaging(
                hql,
                (page - 1) * rows,
                rows,
                funTroubleRecode.getFun().getId(),
                funTroubleRecode.getStartTime(),
                funTroubleRecode.getEndTime(),
                funTroubleRecode.getFunTroubleVariable().getType().getId());

        totalHql =
            "SELECT count(*) From FunTroubleRecode ftr "
                + "WHERE ftr.fun.id=? "
                + "AND ftr.startTime>? "
                + "AND ftr.startTime<? "
                + "AND ftr.funTroubleVariable.type.id=? ";

        total =
            (Long)
                funTroubleRecodeService.uniqueResult(
                    totalHql,
                    funTroubleRecode.getFun().getId(),
                    funTroubleRecode.getStartTime(),
                    funTroubleRecode.getEndTime(),
                    funTroubleRecode.getFunTroubleVariable().getType().getId());

      } else {
        String hql =
            "SELECT new map(ftr.fun.name as name, ftr.funTroubleVariable.code as code, ftr.startTime as startTime, "
                + "ftr.endTime as endTime, ftr.funTroubleVariable.description as description) "
                + "FROM FunTroubleRecode ftr "
                + "WHERE ftr.fun.id=? "
                + "AND ftr.startTime>? "
                + "AND ftr.startTime<? "
                + "AND ftr.funTroubleVariable.type.id=? "
                + "AND ftr.funTroubleVariable.code=? ";

        statisticsList =
            funTroubleRecodeService.executeHQLQueryPaging(
                hql,
                (page - 1) * rows,
                rows,
                funTroubleRecode.getFun().getId(),
                funTroubleRecode.getStartTime(),
                funTroubleRecode.getEndTime(),
                funTroubleRecode.getFunTroubleVariable().getType().getId(),
                funTroubleRecode.getFunTroubleVariable().getCode());

        totalHql =
            "SELECT count(*) From FunTroubleRecode ftr "
                + "WHERE ftr.fun.id=? "
                + "AND ftr.startTime>? "
                + "AND ftr.startTime<? "
                + "AND ftr.funTroubleVariable.type.id=? "
                + "AND ftr.funTroubleVariable.code=? ";

        total =
            (Long)
                funTroubleRecodeService.uniqueResult(
                    totalHql,
                    funTroubleRecode.getFun().getId(),
                    funTroubleRecode.getStartTime(),
                    funTroubleRecode.getEndTime(),
                    funTroubleRecode.getFunTroubleVariable().getType().getId(),
                    funTroubleRecode.getFunTroubleVariable().getCode());
      }

      result.put("total", total);
      result.put("rows", statisticsList);

    } catch (Exception e) {
      e.printStackTrace();
    }

    return SUCCESS;
  }