package cn.edu.tyust.scms.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import com.alibaba.fastjson.JSON;
import cn.edu.tyust.scms.model.LoginlogInfo;
import cn.edu.tyust.scms.model.User;
import cn.edu.tyust.scms.service.LoginlogService;
import cn.edu.tyust.scms.service.LoginlogServiceImpl;
import cn.edu.tyust.scms.service.StatInfoService;
import cn.edu.tyust.scms.service.StatInfoServiceImpl;
import cn.edu.tyust.scms.service.StudentService;
import cn.edu.tyust.scms.service.StudentServiceImpl;
/**
* Servlet implementation class StatisServlet
*/
@WebServlet("/StatisServlet")
public class StatisServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public StatisServlet() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
response.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
StudentService studentService = new StudentServiceImpl();
StatInfoService statInfoService = new StatInfoServiceImpl();
LoginlogService loginlogService = new LoginlogServiceImpl();
String result = null;
String jsonStr = JSON.toJSONString(result);
String status = request.getParameter("status");
if (status.equals("getStuNum")) {
result = studentService.findStudentInfos(null).size()+"";
jsonStr = JSON.toJSONString(result);
} else if (status.equals("getWinNum")) {
Map<String, Object> map1 = new HashMap<String, Object>();
map1.put("award", "未获奖");
Map<String, Object> map2 = new HashMap<String, Object>();
map2.put("award", "待定");
result = statInfoService.findStatInfoCount(null)-statInfoService.findStatInfoCount(map1)-statInfoService.findStatInfoCount(map2)+"";
jsonStr = JSON.toJSONString(result);
} else if (status.equals("getLoserNum")) {
Map<String, Object> map = new HashMap<String, Object>();
map.put("award", "未获奖");
result = statInfoService.findStatInfoCount(map)+"";
jsonStr = JSON.toJSONString(result);
} else if(status.equals("getLoginlog")) {
HttpSession session = request.getSession();
User loginuser = (User) session.getAttribute("user");
Map<String, Object> map = new HashMap<String, Object>();
map.put("userid", loginuser.getUserid());
List<LoginlogInfo> loginlogInfoList = loginlogService.findLoginlogInfos(map);
jsonStr = JSON.toJSONString(loginlogInfoList);
} else if(status.equals("histogram_1")) {
Map<String, Object> map = new HashMap<String, Object>();
List<Integer> countList = new ArrayList<Integer>();
int count = 0;
String competitionid = request.getParameter("competitionid");
if (!competitionid.equals("")) {
map.put("competitionid", competitionid);
}
String daterange = request.getParameter("daterange");
if (!daterange.equals("")) {
String[] dateArray = daterange.split("~");
String startdate = dateArray[0];
String enddate = dateArray[1];
map.put("startdate", startdate);
map.put("enddate", enddate);
}
map.put("majorid", "52");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
map.put("majorid", "53");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
map.put("majorid", "54");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
map.put("majorid", "55");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
map.put("majorid", "56");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
jsonStr = JSON.toJSONString(countList);
} else if(status.equals("histogram_2")) {
Map<String, Object> map = new HashMap<String, Object>();
List<Integer> countList = new ArrayList<Integer>();
int count = 0;
String competitionid = request.getParameter("competitionid");
if (!competitionid.equals("")) {
map.put("competitionid", competitionid);
}
String daterange = request.getParameter("daterange");
if (!daterange.equals("")) {
String[] dateArray = daterange.split("~");
String startdate = dateArray[0];
String enddate = dateArray[1];
map.put("startdate", startdate);
map.put("enddate", enddate);
}
map.put("majorid", "52");
count = statInfoService.findWinStatInfo(map).size();
countList.add(count);
map.put("majorid", "53");
count = statInfoService.findWinStatInfo(map).size();
countList.add(count);
map.put("majorid", "54");
count = statInfoService.findWinStatInfo(map).size();
countList.add(count);
map.put("majorid", "55");
count = statInfoService.findWinStatInfo(map).size();
countList.add(count);
map.put("majorid", "56");
count = statInfoService.findWinStatInfo(map).size();
countList.add(count);
jsonStr = JSON.toJSONString(countList);
} else if(status.equals("pie_1")) {
Map<String, Object> map = new HashMap<String, Object>();
List<Integer> countList = new ArrayList<Integer>();
int count = 0;
String competitionid = request.getParameter("competitionid");
if (!competitionid.equals("")) {
map.put("competitionid", competitionid);
}
String majorid = request.getParameter("majorid");
if (!majorid.equals("")) {
map.put("majorid", majorid);
}
String classid = request.getParameter("classid");
if (!classid.equals("")) {
map.put("classid", classid);
}
int year = new Date().getYear()+1900;
if((new Date().getMonth()+1) < 9) {
year--;
}
countList.add(year);
map.put("grade", year-- + "");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
map.put("grade", year-- + "");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
map.put("grade", year-- + "");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
map.put("grade", year-- + "");
count = statInfoService.findStatInfoCount(map);
countList.add(count);
jsonStr = JSON.toJSONString(countList);
} else if(status.equals("pie_2")) {
Map<String, Object> map = new HashMap<String, Object>();
List<Integer> countList = new ArrayList<Integer>()
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
基于MVC设计模式的《大学生创新竞赛管理平台》设计与实现。前端:基于LayuiUI框架的HTML网页后端:Servlet + MyBatis项目采用eclipse开发,项目使用的技术:Layui、Servlet、FastJSON、AJAX、jQuery、MyBatis等 普通用户: 用户名:user密码:123456 管理员: 用户名:admin 密码:123456 - 用户名:super 密码:123456 二、项目部署 (一)环境 软件环境 JDK 1.8.0_211 Tomcat 8.5.43 MySQL 8.0.13 硬件环境 Windows 10 Linux Ubuntu 开发环境 Eclipse (二)部署流程 创建scms数据库(注意编码,使用utf-8),运行SQL文件创建相关表和视图 向Tomcat中部署SCMC.war到webapps目录下,如果需要修改数据库密码 / 连接字符,串,打开WAR包找到文件:WEB-INF/classes/jdbc.properties修改即可 启动Tomcat,访问项目(http://localhost(或者自己的服务器IP):80
资源推荐
资源详情
资源评论
收起资源包目录
JavaWeb基于MVC设计模式的大学生创新竞赛管理平台设计与实现源代码+数据库,含WAR文件,可直接部署 (813个子文件)
.classpath 2KB
org.eclipse.wst.common.component 464B
org.eclipse.wst.jsdt.ui.superType.container 49B
layui.css 71KB
font-awesome.css 37KB
font-awesome.min.css 30KB
wangEditor.css 17KB
wangEditor.min.css 15KB
layer.css 14KB
stylesheet.css 13KB
layui.mobile.css 10KB
layuimini.css 10KB
zyupload-1.0.0.min.css 9KB
jqtransform.css 8KB
style.css 8KB
laydate.css 7KB
demo.css 3KB
datePicker.css 3KB
datePicker-min.css 2KB
step.css 1KB
code.css 1KB
public.css 740B
wp-syntax.css 719B
treetable.css 294B
fontawesome-webfont.eot 162KB
iconfont.eot 41KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
input_text_left.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
48.gif 3KB
43.gif 3KB
30.gif 2KB
61.gif 2KB
33.gif 2KB
69.gif 2KB
14.gif 2KB
47.gif 2KB
36.gif 2KB
49.gif 2KB
58.gif 2KB
6.gif 2KB
54.gif 2KB
53.gif 2KB
56.gif 2KB
62.gif 2KB
31.gif 2KB
55.gif 2KB
35.gif 2KB
15.gif 2KB
loading-2.gif 2KB
navbg.gif 2KB
37.gif 1KB
共 813 条
- 1
- 2
- 3
- 4
- 5
- 6
- 9
资源评论
程序员柳
- 粉丝: 6094
- 资源: 1195
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功