学生奖惩管理系统通过MySQL数据库与Eclipse工具进行开发,学生奖惩管理系统能够实现对出勤率,奖惩信息,分数记录信息,学生信息,学生成绩等数据的管理。通过学生奖惩管理系统对相关信息的处理,让信息处理变的更加的系统,更加的规范,这是一个必然的结果。已经处理好的信息,不管是用来查找,还是分析,在效率上都会成倍的提高,让计算机变得更加符合生产需要,变成人们不可缺少的一种信息处理工具,实现了绿色办公,节省社会资源,为环境保护也做了力所能及的贡献。
目前整个社会发展的速度,严重依赖于互联网,如果没有了互联网的存在,市场可能会一蹶不振,严重影响经济的发展水平,影响人们的生活质量。计算机的发展,不管是从硬件还是软件,都有很多技术储备,每年都有很多的技术和软件产生,纵观各个领域,无一不用互联网软件,办公用的还是电脑居多,但是人手一台智能设备已经变成了现在人们的生活日常,哪怕的普通的老百姓都成了上知天文下知地理的所在,这些都依赖于互联网技术。互联网技术在信息的传播方面是巨大的,而信息的处理就变成了各种产业管理者和维护者的重任。人们已经习惯了互联网的存在,所以经常操作一些互联网产品变成了日常,所以开发一个学生奖惩管理系统,让人们使用是没有一点问题的,并且在这个过程中不仅能够规范学生奖惩信息管理的使用流程还有信息处理流程,也能让整个信息的传播处理,都存在一种可控制的范围,最重要的是,计算机在学生奖惩信息管理方面可以给管理者提供更好的帮助。
2.1 Java简介
Java技术它是一个容易让人学会和使用的一门服务器语言。它在编程的过程当中只需要很少的知识就能建立起一个真正的交互站点。对于这个教程来说它并不需要你完全去了解这种语言,只要能快速融入web站点就可以,还可以进行一些基本知识的编程就可以。
现代社会中,使用Java语言做动态网页是最常用的,主要是Java比较简单易懂,学生掌握的web 服务器编写脚本。Java语言技术在编程技术中具有一定的安全性和跨平台性功能,并且它可以直接支持分布式的网络应用和效率。在Java语言技术当中它的功能是方便简单的。对于这个语言技术来说它就像万花筒一样在进行开发的时候可以随机进行组合最后变成不同颜色的花瓣。随着现在互联网的快速发展和电子商务的不断发展,在各行各业的设施基础上都开始应用到了计算机,对于过去传统的的管理方式和学生需求都不能满足现在正常的供求关系,所以我们必须通过添加现在的新技术来满足学生的需求。从目前来看,Java技术已经在动态网页中应用的是比较广泛的一门技术。
Java语言具有非常多种的特性:(1)跨平台的无关性;(2)面向对象; (3)安全性得以保障;(4)支持多个任务;(5)多种编写方式,代码编写简单。对比其他的低级语言、高级语言,Java语言具有明显的显著优势以及未来开阔的前景,可以广泛的应用在个人笔记本电脑、大数据、大型游戏等等。
Java语言具有面向对象的特性,并且易于理解。关于对象,其实可以理解成每一种事物都是一种对象,包括我们人类自身都是一种对象。利用面向对象语言的基本特征来解决软件开发中的实际问题,为有效软件开发提供了技术支持。
2.2 Mysql数据库
Mysql是一个多学生、多线程的服务器,采用SQL的数据库,数据库管理系统是基于SQL的学生以及服务器模式的关系,它的优点有强大的功能、操作简单、管理方便、可靠安全、运行较快、多线程、跨平台性、完全网络化、稳定性等,非常适合Web站点或者其他应用软件,在数据库后端的开发。此外,利用许多语言,学生可以编写和访问Mysql数据库的程序。Mysql数据库也是开放源代码的,开发者越来越喜欢使用Mysql关系数据库,应用范围也被推而广之。这是由于速度快和易用性, Web站点或应用软件的数据库后端的开发也都在使用它。
mysql 数据库它有很多的优点,例如它在操作上能够让人通俗易懂、功能强大、信息储存量高等优点。所以被人们广泛应用,对于mysql数据库来说它一般主要是对数据进行编码和查询,而且在很多的设计当中都应用到了该数据库,在此过程当中我们可以对常规的数据进行查询和组合,所以我们在进行使用mysql数据库的时候只要对编写一小段的数据就能实现相应的功能。数据库,就是数据存储的储藏室,只不过数据是存储在计算机上的,而不是现实中的储藏室,数据的存放是按固定格式,而不是无序的,则定义就是 :长期有固定格式,可以共享的存储在计算机存储器上。数据库管理主要包括数据表的建立,数据存储、修改和增加数据,为了使数据库系统能够正常运行,相关人员进行的管理工作。数据表的建立,可以对数据表中的数据进行调整,数据的重新组合及重新构造,保证数据的安全性。
2.3 B/S结构
BROWSER/SERVER程序架构方式是使用电脑中安装的各种浏览器来进行访问和使用的,相比C/S的程序结构不需要进行程序的安装就可以直接使用。BROWSER/SERVER架构的运行方式是在远程的服务器上进行安装一个,然后在任何接入互联网的电脑上访问和使用。BROWSER/SERVER架构的开发方式给学生带来了极大的便利,在任何时间和地点都可以使用开发的程序系统。
在B/S的结构中,学生可以在任何可以上网的地方访问和使用系统网站的功能,没有地域和时间等方面的限制,B/S结构是把程序完整放置到计算机网络的服务器上,通过计算机互联网给学生提供远程的网络服务。在三层体系结构的B/S系统中,通过浏览器,学生可以对很多服务器发出请求, B/S系统会很大程度的降低工作量,学生只需要安装运行较少的学生端即可,大量的工作将由服务器承担,另外,服务器也完成包括访问数据库,执行应用程序的工作等等。
B/S结构主要有三层,分别为数据层、控制逻辑层和视图层。学生通过视图层,让控制层调用数据层的数据,从而达到整个访问过程。三层相互独立,维护方便,使用安全,三层有互相调用,提高效率。
2.4 SSM框架
当今流行的“SSM组合框架”是Spring + SpringMVC + MyBatis的缩写,受到很多的追捧,“组合SSM框架”是强强联手、各司其职、协调互补的团队精神。web项目的框架,通常更简单的数据源。Spring属于一个轻量级的反转控制框架(IoC),但它也是一个面向表面的容器(AOP)。SpringMVC常常用于控制器的分类工作模式,与模型对象分开,程序对象的作用与自动取款机进行处理。这种解耦治疗使整个系统的个性化变得更加容易。MyBatis是一个良好的可持续性框架,支持普通SQL查询,同时允许对存储过程的高级映射进行数据的优化处理。大型Java Web应用程序的由于开发成本太高,开发后难以维护和开发过程中一些难以解决的问题,而采用“SSM组合框架”,它允许建立业务层次结构,并为这个问题提供良好的解决方案。
package com.controller;
import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;
import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;
/**
* 字典
* 后端接口
* @author
* @email
*/
@RestController
@Controller
@RequestMapping("/dictionary")
public class DictionaryController {
private static final Logger logger = LoggerFactory.getLogger(DictionaryController.class);
@Autowired
private DictionaryService dictionaryService;
@Autowired
private TokenService tokenService;
//级联表service
@Autowired
private XueshengService xueshengService;
/**
* 后端列表
*/
@RequestMapping("/page")
@IgnoreAuth
public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
if(params.get("orderBy")==null || params.get("orderBy")==""){
params.put("orderBy","id");
}
PageUtils page = dictionaryService.queryPage(params);
//字典表数据转换
List<DictionaryView> list =(List<DictionaryView>)page.getList();
for(DictionaryView c:list){
//修改对应字典表字段
dictionaryService.dictionaryConvert(c, request);
}
return R.ok().put("data", page);
}
/**
* 后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
DictionaryEntity dictionary = dictionaryService.selectById(id);
if(dictionary !=null){
//entity转view
DictionaryView view = new DictionaryView();
BeanUtils.copyProperties( dictionary , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode())
.eq("index_name", dictionary.getIndexName())
;
if(dictionary.getDicCode().contains("_erji_types")){
queryWrapper.eq("super_id",dictionary.getSuperId());
}
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){
dictionary.setCreateTime(new Date());
dictionaryService.insert(dictionary);
//字典表新增数据,把数据再重新查出,放入监听器中
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有相同数据
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.notIn("id",dictionary.getId())
.eq("dic_code", dictionary.getDicCode())
.eq("index_name", dictionary.getIndexName())
;
if(dictionary.getDicCode().contains("_erji_types")){
queryWrapper.eq("super_id",dictionary.getSuperId());
}
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){
dictionaryService.updateById(dictionary);//根据id更新
//如果字典表修改数据的话,把数据再重新查出,放入监听器中
List<DictionaryEntity> dictionaryEntities = dictionaryService.selectList(new EntityWrapper<DictionaryEntity>());
ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}else {
return R.error(511,"表中有相同数据");
}
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
dictionaryService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 最大值
*/
@RequestMapping("/maxCodeIndex")
public R maxCodeIndex(@RequestBody DictionaryEntity dictionary){
logger.debug("maxCodeIndex:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
List<String> descs = new ArrayList<>();
descs.add("code_index");
Wrapper<DictionaryEntity> queryWrapper = new EntityWrapper<DictionaryEntity>()
.eq("dic_code", dictionary.getDicCode())
.orderDesc(descs);
logger.info("sql语句:"+queryWrapper.getSqlSegment());
List<DictionaryEntity> dictionaryEntityList = dictionaryService.selectList(queryWrapper);
if(dictionaryEntityList.size()>0 ){
return R.ok().put("maxCodeIndex",dictionaryEntityList.get(0).getCodeIndex()+1);
}else{
return R.ok().put("maxCodeIndex",1);
}
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName, HttpServletRequest request){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
List<DictionaryEntity> dictionaryList = new ArrayList<>();//上传的东西
Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
Date date = new Date();
int lastIndexOf = fileName.lastIndexOf(".");
if(lastIndexOf == -1){
return R.error(511,"该文件没有后缀");
}else{
String suffix = fileName.substring(lastIndexOf);
if(!".xls".equals(suffix)){
return R.error(511,"只支持后缀为xls的excel文件");
}else{
URL resource = this.getClass().getClassLoader().getResource("../../upload/" + fileName);//获取文件路径
File file = new File(resource.getFile());
if(!file.exists()){
return R.error(511,"找不到上传文件,请联系管理员");
}else{
List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
dataList.remove(0);//删除第一行,因为第一行是提示
for(List<String> data:dataList){
//循环
DictionaryEntity dictionaryEntity = new DictionaryEntity();
// dictionaryEntity.setDicCode(data.get(0)); //字段 要改的
// dictionaryEntity.setDicName(data.get(0)); //字段名 要改的
// dictionaryEntity.setCodeIndex(Integer.valueOf(data.get(0))); //编码 要改的
// dictionaryEntity.setIndexName(data.get(0)); //编码名字 要改的
// dictionaryEntity.setSuperId(Integer.valueOf(data.get(0))); //父字段id 要改的
// dictionaryEntity.setBeizhu(data.get(0)); //备注 要改的
// dictionaryEntity.setCreateTime(date);//时间
dictionaryList.add(dictionaryEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
dictionaryService.insertBatch(dictionaryList);
return R.ok();
}
}
}
}catch (Exception e){
e.printStackTrace();
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
}
package com.entity;
import com.baomidou.mybatisplus.annotations.TableId;
import com.baomidou.mybatisplus.annotations.TableName;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import java.lang.reflect.InvocationTargetException;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import org.springframework.format.annotation.DateTimeFormat;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.beanutils.BeanUtils;
import com.baomidou.mybatisplus.annotations.TableField;
import com.baomidou.mybatisplus.enums.FieldFill;
import com.baomidou.mybatisplus.enums.IdType;
/**
* 出勤率
*
* @author
* @email
*/
@TableName("chuqinlv")
public class ChuqinlvEntity<T> implements Serializable {
private static final long serialVersionUID = 1L;
public ChuqinlvEntity() {
}
public ChuqinlvEntity(T t) {
try {
BeanUtils.copyProperties(this, t);
} catch (IllegalAccessException | InvocationTargetException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
/**
* 主键
*/
@TableId(type = IdType.AUTO)
@TableField(value = "id")
private Integer id;
/**
* 学生
*/
@TableField(value = "xuesheng_id")
private Integer xueshengId;
/**
* 出勤率编号
*/
@TableField(value = "chuqinlv_uuid_number")
private String chuqinlvUuidNumber;
/**
* 月份
*/
@TableField(value = "chuqinlv_yue")
private String chuqinlvYue;
/**
* 出勤率
*/
@TableField(value = "chuqinlv_name")
private String chuqinlvName;
/**
* 出勤率分数
*/
@TableField(value = "chuqinlv_fenshu")
private Integer chuqinlvFenshu;
/**
* 出勤率详情
*/
@TableField(value = "chuqinlv_content")
private String chuqinlvContent;
/**
* 录入时间
*/
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat
@TableField(value = "insert_time",fill = FieldFill.INSERT)
private Date insertTime;
/**
* 创建时间
*/
@JsonFormat(locale="zh", timezone="GMT+8", pattern="yyyy-MM-dd HH:mm:ss")
@DateTimeFormat
@TableField(value = "create_time",fill = FieldFill.INSERT)
private Date createTime;
/**
* 设置:主键
*/
public Integer getId() {
return id;
}
/**
* 获取:主键
*/
public void setId(Integer id) {
this.id = id;
}
/**
* 设置:学生
*/
public Integer getXueshengId() {
return xueshengId;
}
/**
* 获取:学生
*/
public void setXueshengId(Integer xueshengId) {
this.xueshengId = xueshengId;
}
/**
* 设置:出勤率编号
*/
public String getChuqinlvUuidNumber() {
return chuqinlvUuidNumber;
}
/**
* 获取:出勤率编号
*/
public void setChuqinlvUuidNumber(String chuqinlvUuidNumber) {
this.chuqinlvUuidNumber = chuqinlvUuidNumber;
}
/**
* 设置:月份
*/
public String getChuqinlvYue() {
return chuqinlvYue;
}
/**
* 获取:月份
*/
public void setChuqinlvYue(String chuqinlvYue) {
this.chuqinlvYue = chuqinlvYue;
}
/**
* 设置:出勤率
*/
public String getChuqinlvName() {
return chuqinlvName;
}
/**
* 获取:出勤率
*/
public void setChuqinlvName(String chuqinlvName) {
this.chuqinlvName = chuqinlvName;
}
/**
* 设置:出勤率分数
*/
public Integer getChuqinlvFenshu() {
return chuqinlvFenshu;
}
/**
* 获取:出勤率分数
*/
public void setChuqinlvFenshu(Integer chuqinlvFenshu) {
this.chuqinlvFenshu = chuqinlvFenshu;
}
/**
* 设置:出勤率详情
*/
public String getChuqinlvContent() {
return chuqinlvContent;
}
/**
* 获取:出勤率详情
*/
public void setChuqinlvContent(String chuqinlvContent) {
this.chuqinlvContent = chuqinlvContent;
}
/**
* 设置:录入时间
*/
public Date getInsertTime() {
return insertTime;
}
/**
* 获取:录入时间
*/
public void setInsertTime(Date insertTime) {
this.insertTime = insertTime;
}
/**
* 设置:创建时间
*/
public Date getCreateTime() {
return createTime;
}
/**
* 获取:创建时间
*/
public void setCreateTime(Date createTime) {
this.createTime = createTime;
}
@Override
public String toString() {
return "Chuqinlv{" +
"id=" + id +
", xueshengId=" + xueshengId +
", chuqinlvUuidNumber=" + chuqinlvUuidNumber +
", chuqinlvYue=" + chuqinlvYue +
", chuqinlvName=" + chuqinlvName +
", chuqinlvFenshu=" + chuqinlvFenshu +
", chuqinlvContent=" + chuqinlvContent +
", insertTime=" + insertTime +
", createTime=" + createTime +
"}";
}
}