前台

$(function(){
$.getJSON("/portal/visitor/getVisitorCount?rn="+Math.random(),function(jsondata){
document.getElementById("todaytotal").innerText=jsondata[0].total[29];
var data = [
{
name : 'SW Group',
value:jsondata[0].swCount,
color:'#cbab4f',
line_width:2
},
{
name : 'System S/W R&D 1Part',
value:jsondata[0].sw1Count,
color:'#a5c2d5',
line_width:2
}, {
name : 'System S/W R&D 2Part',
value:jsondata[0].sw2Count,
color:'#76a871',
line_width:2
},
{
name : 'Mon(S)开发Part',
value:jsondata[0].monCount,
color:'#9f7961',
line_width:2
},
{
name : 'SE',
value:jsondata[0].seCount,
color:'#a56f8f',
line_width:2
},{
name : 'SQA&Other',
value:jsondata[0].sqaCount,
color:'#6f83a5',
line_width:2
},{
name : 'Total',
value:jsondata[0].total,
color:'#CC0000',
line_width:2
}
]; var labels = ["",""+(time(-28).getMonth()+1)+"/"+time(-28).getDate()+"","",""+(time(-26).getMonth()+1)+"/"+time(-26).getDate()+"","",""+(time(-24).getMonth()+1)+"/"+time(-24).getDate()+"","",""+(time(-22).getMonth()+1)+"/"+time(-22).getDate()+"","",""+(time(-20).getMonth()+1)+"/"+time(-20).getDate()+"","",""+(time(-18).getMonth()+1)+"/"+time(-18).getDate()+"","",""+(time(-16).getMonth()+1)+"/"+time(-16).getDate()+"","",""+(time(-14).getMonth()+1)+"/"+time(-14).getDate()+"","",""+(time(-12).getMonth()+1)+"/"+time(-12).getDate()+"","",""+(time(-10).getMonth()+1)+"/"+time(-10).getDate()+"","",""+(time(-8).getMonth()+1)+"/"+time(-8).getDate()+"","",""+(time(-6).getMonth()+1)+"/"+time(-6).getDate()+"","",""+(time(-4).getMonth()+1)+"/"+time(-4).getDate()+"","",""+(time(-2).getMonth()+1)+"/"+time(-2).getDate()+"","",""+(time(0).getMonth()+1)+"/"+time(0).getDate()+""];
var line = new iChart.LineBasic2D({
render : 'canvasDiv',
data: data,
align:'center',
//title : 'SW Portal Recent 30D Flow Analysis',
title : {
text:'Access Record',
fontsize:11,
color:'#000000'
}, width : 1500,
height : 320,
background_color : '#FFFFFF',
tip:{
enable :true,
shadow:true,
listeners:{
//tip:提示框对象、name:数据名称、value:数据值、text:当前文本、i:数据点的索引
parseText:function(tip,name,value,text,i){
return name+" : "+value;
}
}
},
legend : {
enable : true,
row:1,//设置在一行上显示,与column配合使用
column : 'max',
valign:'top',
sign:'round',
fontsize:10,
background_color:null,//设置透明背景
offsetx:-220,//设置x轴偏移,满足位置需要
offsety:-5,//设置x轴偏移,满足位置需要
border : true
},
crosshair:{
enable:true,
line_color:'#62bce9'
},
sub_option : {
border:{
enable:false
}, label:false,
point_hollow : false
},
border:{
color:'#ffffff'
}, //去掉外边框
coordinate:{
width:1050,
height:200,
axis:{
color:'#9f9f9f',
width:[0,0,1,1]
},
grids:{ },
scale:[{
position:'left',
scale_enable : true,
start_scale:0,
scale_space:5,
end_scale:10,
label : {color:'#000000',fontsize:11} //竖轴文字样式
},{
position:'bottom',
label : {color:'#000000',fontsize:11},//横轴文字样式
labels:labels,
}]
}
}); //开始画图
line.draw();
});
});

后台controller

@RequestMapping("/getVisitorCount")
@ResponseBody
public void getVisitorCount(HttpServletRequest request,HttpServletResponse response){
Date date=new Date();//取时间
Calendar calendar = new GregorianCalendar();
calendar.setTime(date);
calendar.add(calendar.DATE,-29);//把日期往后增加一天.整数往后推,负数往前移动
date=calendar.getTime(); //这个时间就是日期往后推一天的结果
SimpleDateFormat formatter = new SimpleDateFormat("yyyy/MM/dd");
String[] curdate = new String[30];
curdate[0]=formatter.format(calendar.getTime());
for(int i = 1 ;i<30;i++){
calendar.add(calendar.DATE,+1);//把日期往后增加一天.整数往后推,负数往前移动
curdate[i] =formatter.format(calendar.getTime());
} List<Long> sw1Count = new ArrayList<Long>();
List<Long> sw2Count = new ArrayList<Long>();
List<Long> swCount = new ArrayList<Long>();
List<Long> seCount = new ArrayList<Long>();
List<Long> monCount = new ArrayList<Long>();
List<Long> sqaCount = new ArrayList<Long>();
List<Long> total = new ArrayList<Long>(); for(int i=0;i<30;i++){
sw1Count.add(visitorService.getSW1Count(curdate[i]));
sw2Count.add(visitorService.getSW2Count(curdate[i]));
swCount.add(visitorService.getSWCount(curdate[i]));
seCount.add(visitorService.getSECount(curdate[i]));
monCount.add(visitorService.getMONCount(curdate[i]));
sqaCount.add(visitorService.getSQACount(curdate[i]));
total.add(visitorService.getSW1Count(curdate[i])+visitorService.getSW2Count(curdate[i])+visitorService.getSWCount(curdate[i])+visitorService.getSECount(curdate[i])+visitorService.getMONCount(curdate[i])+visitorService.getSQACount(curdate[i]));
} //request.getSession().setAttribute("eduTotal", categoryTotal);
response.reset();
response.setCharacterEncoding("UTF-8");
//response.setContentType("application/json;charset=utf-8");
response.setContentType("text/html"); JSONArray members = new JSONArray();
PrintWriter out= null;
try {
out= response.getWriter();
JSONObject member = new JSONObject();
member.put("sw1Count", sw1Count);
member.put("sw2Count", sw2Count);
member.put("swCount", swCount);
member.put("seCount", seCount);
member.put("monCount", monCount);
member.put("sqaCount", sqaCount);
member.put("total", total);
members.add(member);
out.write(members.toString()); } catch (Exception e) {
System.out.println(e.getMessage());
out.flush();
out.close();
} out.flush();
out.close();
}

数据库获取数据

@Override
public Long getSW2Count(String curdate) {
List<Visitor> list = getSession().createQuery("FROM Visitor v WHERE v.part like '%System S/W R&D 2Part%' AND v.visitDate like '%"+curdate+"%'").list();
Long sw2Count = Long.valueOf(list.size());
return sw2Count;
}

JSON, list, 前台显示的更多相关文章

  1. MVC Core 网站开发(Ninesky) 2.1、栏目的前台显示

    上次创建了栏目模型,这次主要做栏目的前台显示.涉及到数据存储层.业务逻辑层和Web层.用到了迁移,更新数据库和注入的一些内容. 一.添加数据存储层 1.添加Ninesky.DataLibrary(与上 ...

  2. 关于JSON日期格式显示及My97日期控件

    1.My97日期控件.显示不同的日期格式,可以调整"dateFmt“的参数来配置: 详细DEMO:http://www.my97.net/demo/index.htm <p>日期 ...

  3. MVC Core 网站开发(Ninesky) 2.1、栏目的前台显示(补充)

    在2.1.栏目的前台显示中因右键没有添加视图把微软给鄙视了一下,后来有仔细研究了一下发现应该鄙视自己,其实这个功能是有的,是自己没搞清楚乱吐糟. 其实只要在NuGet中安装两个包(Microsoft. ...

  4. jsp+oracle实现数据库内容以表格形式在前台显示(包含分页)

    jsp+oracle实现数据库内容以表格形式在前台显示(包含分页) 在文件夹内新增list_emp.jsp 代码如下: <%@ page contentType="text/html& ...

  5. webpages框架中使用Html.TextArea()在前台显示多行信息时,如何进行大小、样式的设置

    环境:vs2015 webpages框架+razor语法: 目的:服务器进行数据更新操作后,在前台显示更新的相关信息: 后台代码:将更新条数等相关信息存储在一个变量中: @{ var serverIn ...

  6. 基于Jquery+Ajax+Json实现分页显示

    1.后台action产生json数据. List blackList = blackService.getBlackInfoList(mobileNum, gatewayid, startDate, ...

  7. mysql insert和前台显示乱码

    近期在搞服务端.遇到问题例如以下, 在mysql中插入中文乱码.或mysql中中文正常显示,但jsp在前台显示mysql中的中文时乱码. 解决方法,进入mysql控制台,运行 SET characte ...

  8. Javascript实例技巧精选(6)—滚动鼠标中键读取Json数据分页显示网页内容

    >>点击这里下载完整html源码<< 截图如下: 滚动鼠标中键读取Json数据分页显示网页内容,关键的Javascript如下: <script type="t ...

  9. controller分支实现前台显示弹框同时转发

    controller分支实现前台显示弹框,前台不需要进行什么操作,  前台请求后台的分支即可. controller层(标红的地方是(alert('账号或密码错误!请重新输入!!!!')        ...

  10. JFinal Web开发学习(九)后台添加前台显示博客

    效果: 发博客: 显示博客: 后台:使用hui-admin,文章编辑器是百度开源的ueditor 前台:使用layui前端框架 1.写控制器BlogController controller包中 pa ...

随机推荐

  1. openstack私有云布署实践【16.1 CentOS7.1 只有根分区镜像制作】

    之所以要只有根分区镜像,是因为在创建VM或者调整云主机的硬盘大小时,它能自动扩容.无需人工介入   在原来的物理机10.40.41.1的CentOS 6.7上制作镜像.(当然如果你的制作镜像的宿主机是 ...

  2. 如何解决两个li之间的缝隙

    如何解决两个li之间的缝隙的问题: 在做一个类似按钮左右滑动的选择器的动效,遇到了个是关于li之间的缝隙的问题: HTML如下: <span class="c1mChanger&quo ...

  3. ajaxFileUpload 报这错jQuery.handleError is not a function

    今天刚打个一个技术群,里面有人问标题上的问题,嘿,我恰好遇过,现在大家至少也在用jquery1.9以上的版本,ajaxfileupload的版本早就不更新了,大家可以下载看:地址这里, 它例子里使用的 ...

  4. Access denied for user 'root'@'localhost' (using password:YES) 解决方案[转]

    关于昨天下午说的MySQL服务无法启动的问题,解决之后没有进入数据库,就直接关闭了电脑. 今早打开电脑,开始-运行 输入“mysql -uroot -pmyadmin”后出现以下错误: “Access ...

  5. HDU 1695 GCD#容斥原理

    http://acm.hdu.edu.cn/showproblem.php?pid=1695 翻译题目:给五个数a,b,c,d,k,其中恒a=c=1,x∈[a,b],y∈[c,d],求有多少组(x,y ...

  6. MaskEdit组件的EditText属性和Text属性

    MaskEdit组件主要是EditMask属性 是string属性. 掩码字符串EditMask属性分为3个部分,分别用分号隔开,形式是“XXXXX;X;X” 第一部分是掩码字符串的主要部分,它确定输 ...

  7. jsp页面中EL表达式不能被解析

    原因是:在默认情况下,Servlet 2.4 / JSP 2.0支持 EL 表达式. 用maven插件的生成的webApp的项目结构比较老的是2.3的版本,只要将web中的开头定义换成2.4以上的定义 ...

  8. mysql高级查询

    高级查询: 1.连接查询 select * from Info,Nation #得出的结果称为笛卡尔积select * from Info,Nation where Info.Nation = Nat ...

  9. 将json文件转换为字符串

    //从给定位置读取Json文件    public   String readJson(String path){        //从给定位置获取文件        File file = new ...

  10. NSURL访问项目中的文件

    最近在研究视频处理,具体为:将一个mp4文件,拖入项目工程中,通过url访问文件. 开始代码如下: NSString *path = [[NSBundle mainBundle]pathForReso ...