前台ajax:
"ajax": {
"url": "${base}/platform/oms/task/dataTable1",
"type": "post",
"dataType":'json',
success:function(json){
var nextDate = new Date();
nextDate.setHours(23);
nextDate.setMinutes(59);
nextDate.setSeconds(59);
var div1 = document.getElementById('tb1');
var code = '';
$.each(json,function (i,ele) {
var newDate = new Date();
newDate.setTime(ele.daytime * 1000);
var time = newDate.format('yyyy-MM-dd hh:mm:ss')
code += ''+ele.stationname+''+ele.typename+''+ele.scount+' ';
})
div1.innerHTML = code;
div1.style.fontWeight="normal";//取消加粗
}
}
Controller层:
@At("/dataTable1")
@Ok("json")
@RequiresPermissions("platform.oms.task.datatable")
public Object dataTable1() {
List list=omsTaskService.CountByStationType();
return list;
}
ServiceImpl层:
@Override
public List CountByStationType() {
Sql sql = Sqls.create("select s.name
stationname,k.* from (SELECT t.stationId, t.type ,t.deadline daytime, count(*) scount from oms_task t GROUP BY t.stationId, t.type ORDER BY t.stationId,t.type)k,oms_station s where k.stationId=s.id");
Entity entity = dao().getEntity(Record.class);
sql.setEntity(entity);
sql.setCallback(Sqls.callback.entities());
dao().execute(sql);
List list = sql.getList(Record.class);
return list;
}
6 回复
@Override
public List CountByStationType(Pager pager) {
Sql sql = Sqls.queryRecord("select s.name stationname,k.* from (SELECT t.stationId, t.type ,t.deadline daytime, count(*) scount from oms_task t GROUP BY t.stationId, t.type ORDER BY t.stationId,t.type)k,oms_station s where k.stationId=s.id");
sql.setPager(pager);
dao().execute(sql);
List list = sql.getList(Record.class);
return list;
}
总得传个页数吧??
添加回复
请先登陆