码迷,mamicode.com
首页 > 其他好文 > 详细

日志统计

时间:2016-12-16 09:51:38      阅读:246      评论:0      收藏:0      [点我收藏+]

标签:dmi   ring   attr   shm   body   dem   demo   ems   index   

1.SQL语句-查询sys_user的id和username,页面传值,用<iframe>标签嵌入到统计页面

$(function() {
$("#btn2").click(function() {
var userid = $("#select").val();
if(userid != "") {
$("#iframe").attr("src","<%=basePath %>admin/demo/list_ii?userid="+userid)
}
});
});

<select id="select">
<option>请选择用户名</option>
<c:forEach items = "${list }" var = "i" varStatus="s">
<option value="${i.id }">${i.username }</option>
</c:forEach>
</select>
<input type="button" value="搜索" class="btn1" id="btn2"/>
</div>
<iframe id="iframe" frameborder="0" style="width: 700px;height: 600px;"></iframe>

2.SQL语句,统计日志

select count(body) as num,month(createtime) as month
from worklog
where userid = #{userid } and status = 1
group by month(createtime)

3.调用接口,创建map,将month=key,取值value=num

@RequestMapping(value="admin/demo/list_ii")
public String count_journal(int userid,Model model) {
//调用接口,获取数据
List<Map<String, Object>> list = journalService.count_body(userid);
//创建map
Map<Integer, Object> maps = new HashMap<>();
//遍历接口的list
for (Map<String, Object> map : list) {
//month=key,num=value,绑定到新创建的map上
maps.put((Integer) map.get("month"), map.get("num"));
}
model.addAttribute("map", maps);
return "admin/demo/list_ii";
}

4.页面传值-c 标签循环,三目运算判断

<c:forEach begin="1" end="12" varStatus="s">
<tr>
<td>${s.index}月</td>
<td>${map[s.index] eq null?0:map[s.index]}篇</td>
</tr>
</c:forEach>

 

日志统计

标签:dmi   ring   attr   shm   body   dem   demo   ems   index   

原文地址:http://www.cnblogs.com/jietz0407-com/p/6185560.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!