Explore Enterprise Education Gitee Premium Gitee AI AI teammates
Fetch the repository succeeded.
Donate
Please sign in before you donate.
Scan WeChat QR to Pay
Cancel
Complete
Prompt
Switch to Alipay.
OK
Cancel
1 Star 0 Fork 15

程序源代码/图书馆预约占座管理系统_1

Create your Gitee Account
Explore and code with more than 14 million developers,Free private repositories !:)
Sign up
Already have an account? Sign in
文件
master
Branches (1)
master
master
Branches (1)
master
Clone or Download
Clone/Download
Prompt
To download the code, please copy the following command and execute it in the terminal
To ensure that your submitted code identity is correctly recognized by Gitee, please execute the following command.
When using the SSH protocol for the first time to clone or push code, follow the prompts below to complete the SSH configuration.
1 Generate RSA keys.
2 Obtain the content of the RSA public key and configure it in SSH Public Keys
To use SVN on Gitee, please visit the usage guide
When using the HTTPS protocol, the command line will prompt for account and password verification as follows. For security reasons, Gitee recommends configure and use personal access tokens instead of login passwords for cloning, pushing, and other operations.
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # Private Token
master
Branches (1)
master
Library_1
/
src
/
dingzhen
/
controller
/
ChartController.java
Library_1
/
src
/
dingzhen
/
controller
/
ChartController.java
ChartController.java 6.14 KB
Copy Edit Raw Blame History
小盼江 authored 2020年01月04日 20:52 +08:00 . no commit message
package dingzhen.controller;
// 统计图
import java.awt.Color;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.logging.SimpleFormatter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.labels.ItemLabelAnchor;
import org.jfree.chart.labels.ItemLabelPosition;
import org.jfree.chart.labels.StandardCategoryItemLabelGenerator;
import org.jfree.chart.plot.CategoryPlot;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.BarRenderer3D;
import org.jfree.chart.title.TextTitle;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.ui.TextAnchor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import dingzhen.entity.Choice;
import dingzhen.entity.Illegal;
import dingzhen.entity.Room;
import dingzhen.entity.Seat;
import dingzhen.service.ChoiceService;
import dingzhen.service.IllegalService;
import dingzhen.service.RoomService;
import dingzhen.service.SeatService;
@RequestMapping("chart")
@Controller
public class ChartController {
@Autowired
private IllegalService<Illegal> illegalService;
private Illegal illegal;
private Room room;
@Autowired
private RoomService<Room> roomService;
private Seat seat;
@Autowired
private SeatService<Seat> seatService;
@Autowired
private ChoiceService<Choice> choiceService;
// 进入违规统计
@RequestMapping("illegalChart")
public String illegalIndex(){
return "chart/illegal";
}
// 违规统计表
@RequestMapping("findIllegalChart")
public void findIllegalChart(HttpServletRequest request,HttpServletResponse response){
try {
double[][] data = new double[1][12]; //一年12月
String[] months = {"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
for(int i=1;i<13;i++){
// 每月违规人数
String start = getCurrentYear();
String end = getCurrentYear();
if(i<10){
start = start + "-0" + i +"-01 00:00:01";
end = end + "-0" + i + "-31 23:59:59";
} else {
start = start + "-" + i +"-01 00:00:01";
end = end + "-" + i + "-31 23:59:59";
}
illegal = new Illegal();
illegal.setStart(start);
illegal.setEnd(end);
int total = illegalService.countIllegal(illegal);
data[0][i-1] = total;
}
bar(request, response, months, new String[]{"违规人数"}, data,getCurrentYear()+"全年度违规人数统计", "违规人数统计", 750);
} catch (Exception e) {
e.printStackTrace();
}
}
// 进入占座统计
@RequestMapping("seatChart")
public String seatIndex(){
return "chart/seat";
}
@RequestMapping("findSeatChart")
public void findSeatChart(HttpServletRequest request,HttpServletResponse response){
try {
List<Room> roomList = roomService.findRoom(new Room());
double[][] data = new double[roomList.size()][12]; //一年12月
String[] months = {"1月","2月","3月","4月","5月","6月","7月","8月","9月","10月","11月","12月"};
for(int i=0;i<roomList.size();i++){
room = roomList.get(i);
for(int j=1;j<13;j++){
// 每月违规人数
String start = getCurrentYear();
String end = getCurrentYear();
if(j<10){
start = start + "-0" + j +"-01 00:00:01";
end = end + "-0" + j + "-31 23:59:59";
} else {
start = start + "-" + j +"-01 00:00:01";
end = end + "-" + j + "-31 23:59:59";
}
Choice c = new Choice();
c.setStart(start);
c.setEnd(end);
c.setRows(room.getId());
int total = choiceService.count(c);
data[i][j-1] = total;
}
}
String[] rooms = new String[roomList.size()];
for(int i=0;i<rooms.length;i++){
rooms[i] = roomList.get(i).getName();
}
bar(request, response, months, rooms, data,getCurrentYear()+"全年度占座人数统计", "占座人数", 750);
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 生成柱状图并写到页面上去
* @param request
* @param response
* @param times
* @param floors
* @param data
* @param subTitle
* @param width
*/
private void bar(HttpServletRequest request, HttpServletResponse response,
String[] times, String[] floors, double[][] data, String title,String subTitle,int width) {
CategoryDataset dataset = DatasetUtilities.createCategoryDataset(floors,times,data);
JFreeChart chart = ChartFactory.createBarChart3D(title, "时间", "人数",
dataset, PlotOrientation.VERTICAL, true, true, true); // 创建柱状图模型
// 副标题
chart.addSubtitle(new TextTitle(subTitle));
CategoryPlot plot = chart.getCategoryPlot();
// 设置网格背景颜色
plot.setBackgroundPaint(Color.white);
// 设置网格竖线颜色
plot.setDomainGridlinePaint(Color.pink);
// 设置网格横线颜色
plot.setRangeGridlinePaint(Color.pink);
// 显示每个柱的数值,并修改该数值的字体属性
BarRenderer3D renderer = new BarRenderer3D();
renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
renderer.setBaseItemLabelsVisible(true);
renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(
ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
renderer.setItemLabelAnchorOffset(10D);
// 设置平行柱的之间距离
renderer.setItemMargin(0.4);
plot.setRenderer(renderer);
// 将图表以数据流的方式返回给客户端
try {
ChartUtilities.writeChartAsPNG(response.getOutputStream(), chart,
width, 350); // 500,300是长和宽
} catch (IOException e) {
e.printStackTrace();
}
}
private String getCurrentYear(){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
return sdf.format(new Date());
}
}
Loading...
Report
Report success
We will send you the feedback within 2 working days through the letter!
Please fill in the reason for the report carefully. Provide as detailed a description as possible.
Please select a report type
Cancel
Send
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

About

本系统基于JSP+SSM+Mysql实现的图书馆预约占座管理系统。主要实现的功能有:用户管理、菜单管理、角色管理、权限管理、学生管理、教师管理、班级管理、图书馆阅览室管理、学生信用管理、预约占座管理、发帖评论管理、违规统计、占座预约统计等,添加学生和教师时会自动在用户表中注册,定时任务会定时生成座位信息,学生被扣分后信用等级低于相应的值后不能预约相应的阅览室座位。创作不易
No labels
AFL-3.0
Use AFL-3.0
Cancel

Releases

No release

Contributors

All

Activities

can not load any more
Edit
About
Homepage
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/itcode-itcode/Library_1.git
git@gitee.com:itcode-itcode/Library_1.git
itcode-itcode
Library_1
图书馆预约占座管理系统_1
master
Going to Help Center

Search

Comment
Repository Report
Back to the top
Login prompt
This operation requires login to the code cloud account. Please log in before operating.
Go to login
No account. Register

AltStyle によって変換されたページ (->オリジナル) /