/**
* 分页查询预警信息(注:三个对象并无建立对象引用关系,即对应表之间并没有建立外键关联,只是存储了ID值)
* @param yjfl 预警分类
* @param yjjb 预警级别
* @param bq 标签
* @param beginDate 预警时间(开始时间)
* @param endDate 预警时间(结束时间)
* @param xm 人员姓名
* @param gmsfzhm 公民身份证号码
* @param pid 人员ID
* @param pageable 分页信息
* @return*/
@Query(
value = "select t,p from WarningInfo t, BigRelation b, Person p"
+ " where t.id = b.ktId"
+ " and b.ztId = p.id"
+ " and (t.yjfl = ?1 or ?1 is null)"
+ " and (t.yjjb = ?2 or ?2 is null)"
+ " and (t.bq like ?3 or ?3 is null)"
+ " and (t.sj >= ?4 or ?4 is null)"
+ " and (t.sj <= ?5 or ?5 is null)"
+ " and b.gx = 'GX_R_YJXX_ZT'"
+ " and (p.xm like ?6 or ?6 is null)"
+ " and (p.gmsfzhm = ?7 or ?7 is null)"
+ " and (p.id = ?8 or ?8 is null)"
+ " order by ?#{#pageable}",
countQuery =
"select count(*) from WarningInfo t, BigRelation b, Person p"
+ " where t.id = b.ktId"
+ " and b.ztId = p.id"
+ " and (t.yjfl = ?1 or ?1 is null)"
+ " and (t.yjjb = ?2 or ?2 is null)"
+ " and (t.bq like ?3 or ?3 is null)"
+ " and (t.sj >= ?4 or ?4 is null)"
+ " and (t.sj <= ?5 or ?5 is null)"
+ " and b.gx = 'GX_R_YJXX_ZT'"
+ " and (p.xm like ?6 or ?6 is null)"
+ " and (p.gmsfzhm = ?7 or ?7 is null)"
+ " and (p.id = ?8 or ?8 is null)"
+ " order by ?#{#pageable}"
)
Page
@Query("select count(*) as num, t.hy as hy from DataResource t where t.state.code='06'group by t.hy order by t.hy.orderNum ")
List findGroupByHy();
@Query("select count(*) as num, t.yw as yw from DataResource t where t.state.code='06' group by t.yw order by t.yw.orderNum")
List findGroupByYw();
(2)调用示例
public List statisticsThisLv1Group(boolean isYw) {
List list = new ArrayList<>();
if (isYw)
{//业务
List _list = dao.findGroupByYw();
for(Object row:_list)
{
Object[] cells = (Object[]) row;
Long num = (Long) cells[0];
CodeBusinessType sort = (CodeBusinessType) cells[1];
System.out.println(sort.getName()+" "+num);
StatisticsVo vo = new StatisticsVo();
vo.setCount(num);
vo.setCode(sort.getId() + "");
vo.setName(sort.getName());
list.add(vo);
}
}
else
{//行业
List _list = dao.findGroupByHy();
for(Object row:_list)
{
Object[] cells = (Object[]) row;
Long num = (Long) cells[0];
CodeIndustry sort = (CodeIndustry) cells[1];
System.out.println(sort.getName()+" "+num);
StatisticsVo vo = new StatisticsVo();
vo.setCount(num);
vo.setCode(sort.getId() + "");
vo.setName(sort.getName());
list.add(vo);
}
}
return list;
}