@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; }