コード例 #1
0
  @SuppressWarnings("unchecked")
  public String troubleStatisticsForOne() {
    try {
      String hql =
          "SELECT new map(ftr.fun.name as name, ftr.funTroubleVariable.code as code, "
              + "ftr.funTroubleVariable.description as description, count(ftr) as count, max(ftr.startTime) as maxTime) "
              + "FROM FunTroubleRecode ftr "
              + "WHERE ftr.fun.id=? "
              + "AND ftr.startTime>? AND ftr.startTime<? AND ftr.funTroubleVariable.type.id=? "
              + "GROUP BY ftr.funTroubleVariable.id";
      statisticsList =
          funTroubleRecodeService.executeHQLQueryPaging(
              hql,
              (page - 1) * rows,
              rows,
              funTroubleRecode.getFun().getId(),
              funTroubleRecode.getStartTime(),
              funTroubleRecode.getEndTime(),
              funTroubleRecode.getFunTroubleVariable().getType().getId());

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

      int total =
          funTroubleRecodeService
              .executeHQLQuery(
                  totalHql,
                  funTroubleRecode.getFun().getId(),
                  funTroubleRecode.getStartTime(),
                  funTroubleRecode.getEndTime(),
                  funTroubleRecode.getFunTroubleVariable().getType().getId())
              .size();

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

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

    return SUCCESS;
  }
コード例 #2
0
  @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;
  }