String sqlstr = "/*月度告警*/\n" +
"with get_month_total as (\n" +
" select count(*),'month' as type from fa_detection t1 where t1.del_flag = '0' and to_char(time,'yyyy-MM') = to_char(now(),'yyyy-MM') and t1.user_code =@userCode \n" +
"),\n" +
"/*周度告警*/\n" +
" get_week_total as(\n" +
" select count(*),'week' as type from fa_detection t1 where t1.del_flag = '0' and time>to_date(@sdate,'yyyy-MM-dd') and time<=to_date(@edate,'yyyy-MM-dd') and t1.user_code =@userCode \n" +
"),\n" +
"/*今日告警*/\n" +
" get_day_total as(\n" +
" select count(*),'day' as type from fa_detection t1 where t1.del_flag = '0' and to_char(time,'yyyy-MM-dd') = to_char(now(),'yyyy-MM-dd') and t1.user_code =@userCode \n" +
"),\n" +
"/*今日告警--待处理*/\n" +
"get_day_total_untreated as(\n" +
" select count(*),'day_untreated' as type from fa_detection t1 where t1.del_flag = '0' and t1.state ='0' and to_char(time,'yyyy-MM-dd') = to_char(now(),'yyyy-MM-dd') and t1.user_code =@userCode \n" +
"),\n" +
"/*今日告警--已处理*/\n" +
"get_day_total_processed as(\n" +
" select count(*),'day_processed' as type from fa_detection t1 where t1.del_flag = '0' and t1.state ='1' and to_char(time,'yyyy-MM-dd') = to_char(now(),'yyyy-MM-dd') and t1.user_code =@userCode \n" +
")\n" +
"select * from get_month_total union all\n" +
"select * from get_week_total union all\n" +
"select * from get_day_total union all\n" +
"select * from get_day_total_untreated union all\n" +
"select * from get_day_total_processed";
sqlstr = "with get_month_total as (\n" +
" select count(*),'month' as type from fa_detection t1 where t1.del_flag = '0' and to_char(time,'yyyy-MM') = to_char(now(),'yyyy-MM') and t1.user_code =@userCode \n" +
"),\n" +
" get_week_total as(\n" +
" select count(*),'week' as type from fa_detection t1 where t1.del_flag = '0' and time>to_date(@sdate,'yyyy-MM-dd') and time<=to_date(@edate,'yyyy-MM-dd') and t1.user_code =@userCode \n" +
"),\n" +
" get_day_total as(\n" +
" select count(*),'day' as type from fa_detection t1 where t1.del_flag = '0' and to_char(time,'yyyy-MM-dd') = to_char(now(),'yyyy-MM-dd') and t1.user_code =@userCode \n" +
"),\n" +
"get_day_total_untreated as(\n" +
" select count(*),'day_untreated' as type from fa_detection t1 where t1.del_flag = '0' and t1.state ='0' and to_char(time,'yyyy-MM-dd') = to_char(now(),'yyyy-MM-dd') and t1.user_code =@userCode \n" +
"),\n" +
"get_day_total_processed as(\n" +
" select count(*),'day_processed' as type from fa_detection t1 where t1.del_flag = '0' and t1.state ='1' and to_char(time,'yyyy-MM-dd') = to_char(now(),'yyyy-MM-dd') and t1.user_code =@userCode \n" +
")\n" +
"select * from get_month_total union all\n" +
"select * from get_week_total union all\n" +
"select * from get_day_total union all\n" +
"select * from get_day_total_untreated union all\n" +
"select * from get_day_total_processed";
//周一
String sweek = DateUtils.getMondayOfThisWeek();
String edate = DateUtils.getDate("yyyy-MM-dd");
Sql sql = Sqls.create(sqlstr);
sql.params().set("sdate",sweek).set("edate",edate).set("userCode",userCode);
sql.setCallback(Sqls.callback.maps());
sql.forceExecQuery();//强制设置为查询
sql.setEntity(basicDao.getDao().getEntity(NutMap.class));
basicDao.getDao().execute(sql);
List<NutMap> list = sql.getList(NutMap.class);
return list;
如果使用上面注释sql查询,会出现异常
org.nutz.dao.DaoException: !Nutz SQL Error: 'beetlException>>错找不到指定模板或者加载错(TEMPLATE_LOAD_ERROR): 位于0行 资源:/*月度告警*/
这个是和我设置了Sqls.setSqlBorning(BeetlSqlTpl.class); 有关么,
如果改成下面的sql代码就没有异常