/**
* projectName: check
* fileName: CheckAction.java
* packageName: com.gxuwz.check.action
* date: 2019年11月25日下午3:22:43
* copyright(c) 2017-2020 xxx公司
*/
package com.gxuwz.check.action;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.servlet.http.HttpServletRequest;
import org.apache.struts2.ServletActionContext;
import com.gxuwz.check.dao.IExportDao;
import com.gxuwz.check.entity.SysAttendance;
import com.gxuwz.check.entity.SysClasses;
import com.gxuwz.check.entity.SysCourse;
import com.gxuwz.check.entity.SysStudent;
import com.gxuwz.check.service.IExportService;
import com.gxuwz.check.util.BaseAction;
import com.gxuwz.check.util.Excel;
import com.gxuwz.check.util.Pager;
import com.opensymphony.xwork2.ModelDriven;
/**
* @title: CheckAction.java
* @package com.gxuwz.check.action
* @description: 考勤Action层
* @author: 梁树鹏
* @date: 2019年11月25日 下午3:22:43
* @version: V1.0
*/
public class ExportAction extends BaseAction implements ModelDriven<SysCourse>{
static final String exportList = "page/teacher/export_list.jsp";
private static final long serialVersionUID = 1L;
private IExportService exportService;
private IExportDao exportDao;
private String class_id;
List<SysClasses> classList;
List<SysStudent> stuList;
List<SysAttendance> attendList;
Set<SysStudent> stuSet = new HashSet<SysStudent>();
SysClasses classes = new SysClasses();
SysStudent stu = new SysStudent();
SysCourse course = new SysCourse();
String classid = "";
Pager<SysStudent> page = new Pager<>();
/**
*
*@title: queryAllClasses
*@description: 查询教师教的所有班级
*@author: 梁树鹏
*@date: 2019年11月29日 下午10:30:31
*/
public String queryAllClasses() throws Exception {
String userid = (String) ServletActionContext.getRequest().getSession().getAttribute("userId");
if(null!=course.getCourseId()){
ServletActionContext.getRequest().getSession().setAttribute("courseid", course.getCourseId());
}
String courseid = (String) ServletActionContext.getRequest().getSession().getAttribute("courseid");
classList = exportService.findClssesById(userid,courseid);
//去重
for (int i = 0; i < classList.size(); i++) {
for (int j = i+1; j < classList.size(); j++) {
if(classList.get(i).getClassName().equals(classList.get(j).getClassName())) {
classList.remove(j);
j--;
}
}
}
setForwardView(exportList);
return SUCCESS;
}
/**
*
*@title: queryAllStu
*@description: 通过calssid查询所有的学生
*@author: 梁树鹏
*@date: 2019年11月30日 上午9:52:29
*/
public String queryAllStu() throws Exception{
if(null!=classid &&!"".equals(classid)){
ServletActionContext.getRequest().getSession().setAttribute("classid", classid);
}
String cid = (String) ServletActionContext.getRequest().getSession().getAttribute("classid");
attendList = exportService.findStuByClassId(cid);
//导出
HttpServletRequest request = ServletActionContext.getRequest();
//定义一个HashMap
List<HashMap<String,Object>> list = null;
list = new ArrayList<HashMap<String,Object>>();
HashMap<String,Object> map = null;
attendList = exportService.findStuByClassId(cid);
for (int i = 0; i < attendList.size(); i++) {
map = new HashMap<String,Object>();
map.put("attendance_id", attendList.get(i).getAttendanceId());
map.put("user_id", attendList.get(i).getUserId());
map.put("attendance_time", attendList.get(i).getAttendanceTime());
String a = "";
if(attendList.get(i).getAttendanceState()==0) {
a = "出勤";
}else if(attendList.get(i).getAttendanceState()==1) {
a = "请假";
}else {
a = "旷课";
}
map.put("attendance_state", a);
map.put("class_id", attendList.get(i).getClassId());
map.put("user_name", attendList.get(i).getUserName());
//将数据添加到list中
list.add(map);
String path1 =request.getRealPath("/")+"page/teacher/excel/student.xls";
Excel export_excel = new Excel();
export_excel.export(list, path1);
}
return queryAllClasses();
}
/**
*
*@title: saveCheckRecord
*@description: 考勤记录单保存
*@author: 梁树鹏
*@date: 2019年12月5日 上午9:48:11
*/
public String saveExportRecord() throws Exception {
HttpServletRequest request = ServletActionContext.getRequest();
String value = request.getParameter("value");
String idd = request.getParameter("idd");
String user_id = request.getParameter("user_id");
/*System.out.println("class_id的值为:"+class_id);
System.out.println("所选考勤状态的值:"+value);
System.out.println("id为:"+idd);
System.out.println("user_id为:"+user_id);*/
String value1[] =value.split(",");
String idd1[] =idd.split(",");
String user_id1[] =user_id.split(",");
String class_id1[] =class_id.split(", ");
//保存
int status = 0;
int ids = 0;
for (int i = 0; i < value1.length; i++) {
status = Integer.valueOf(value1[i]);
ids = Integer.valueOf(idd1[i]);
exportDao.saveByUserId(status,ids,user_id1[i],class_id1[i]);
}
return queryAllStu();
}
public String exportExcel() throws Exception{
return queryAllStu();
}
public SysClasses getClasses() {
return classes;
}
public void setClasses(SysClasses classes) {
this.classes = classes;
}
public List<SysClasses> getClassList() {
return classList;
}
public void setClassList(List<SysClasses> classList) {
this.classList = classList;
}
public List<SysStudent> getStuList() {
return stuList;
}
public void setStuList(List<SysStudent> stuList) {
this.stuList = stuList;
}
public Set<SysStudent> getStuSet() {
return stuSet;
}
public void setStuSet(Set<SysStudent> stuSet) {
this.stuSet = stuSet;
}
public SysStudent getStu() {
return stu;
}
public void setStu(SysStudent stu) {
this.stu = stu;
}
public String getClassid() {
return classid;
}
public void setClassid(String classid) {
this.classid = classid;
}
@Override
public SysCourse getModel() {
return course;
}
public Pager<SysStudent> getPage() {
return page;
}
public void setPage(Pager<SysStudent> page) {
this.page = page;
}
public SysCourse getCourse() {
return course;
}
public void setCourse(SysCourse course) {
this.course = course;
}
public String getClass_id() {
return class_id;
}
public void setClass_id(String class_id) {
this.class_id = class_id;
}
public void setExportService(IExportService exportService) {
this.exportService = exportService;
}
public void setExportDao(IExportDao exportDao) {
this.exportDao = exportDao;
}
public List<SysAttendance> getAttendList() {
return attendList;
}
public void setAttendList(List<SysAttendance> attendList) {
this.attendList = attendList;
}
}
梁同学与Android
- 粉丝: 3w+
- 资源: 78
最新资源
- 问题D:城市韧性与可持续发展能力评价.zip
- 伺服系统基于陷波滤波器双惯量伺服系统机械谐振抑制matlab Simulink仿真 1.模型简介 模型为基于陷波滤波器的双惯量伺服系统机械谐振抑制仿真,采用Matlab R2018a Simul
- 基于滑膜控制的差动制动防侧翻稳定性控制,上层通过滑膜控制产生期望的横摆力矩,下层根据对应的paper实现对应的制动力矩分配,实现车辆的防侧翻稳定性控制,通过通过carsim和simulink联合仿真
- (174755032)抽烟、烟雾检测voc数据集
- Starter SINAMICS S120驱动第三方直线永磁同步电机系列视频-调试演示.mp4
- (175601006)51单片机交通信号灯系统设计
- (177422616)80.基于51单片机的交通灯设计【五岔路,左右拐,固定时间】(仿真).rar
- 光伏MMC并网系统(两级式) 交流故障穿越 电网对称 不对称故障 simulink仿真模型 光伏经模块化多电平流器(MMC)并网 1. MMC部分:正负序分离控制+SOGI锁相环 +定直流母线电压控制
- SINAMICS S120驱动第三方直线永磁同步电机系列视频-配置和优化.mp4
- (176102016)MATLAB代码:考虑灵活性供需不确定性的储能参与电网调峰优化配置 关键词:储能优化配置 电网调峰 风电场景生成 灵活性供需不
- 基于二阶RC模型 自适应无迹卡尔曼滤波算法(AUKF)锂电池SOC估计,噪声系数自适应 Matlab程序 仿真模型建模数据mat Sci一篇参考文献
- 新建 Microsoft Word 文档
- (176721246)200行C++代码写一个Qt俄罗斯方块
- Oracle期末复习题:选择题详解与数据库管理技术
- Unity视频插件AVPro的Win端2.2.3
- (3292010)Java图书管理系统(源码)
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈