📄 headermyselfaction.java
字号:
package edu.yinhe.mis.control;
import java.io.BufferedInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.JOptionPane;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import edu.yinhe.mis.dto.HeaderMyselfDTO;
import edu.yinhe.mis.util.DownLoadFile;
import edu.yinhe.mis.util.ExcelHeadMyself;
import edu.yinhe.system.common.AppException;
import edu.yinhe.system.common.GlobalNames;
import edu.yinhe.system.control.BaseAction;
import edu.yinhe.system.vo.LoginVO;
import edu.yinhe.system.vo.Pagination;
import edu.yinhe.system.vo.PaginationVO;
public class HeaderMyselfAction extends BaseAction {
/**
* @author 姜娟
* 校长查看整体报表
*
*/
@SuppressWarnings("unchecked")
public ActionForward wholeReport(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
@SuppressWarnings("unused")
List alist =null;
HeaderMyselfDTO hdto = new HeaderMyselfDTO();
Object obj[] =null;
int count=0;
// 从页面里得到要的字段
String startdate = request.getParameter("startdate");
String enddate = request.getParameter("enddate");
String currentPage = request.getParameter("currentPage");
if(currentPage==null||"".equals(currentPage)){
currentPage = "1";
}
hdto.setCurrentPage(currentPage);
hdto.setPageSize("5");
hdto.setStartdate(startdate);
hdto.setEnddate(enddate);
try {
service.setDataSource(this.getDataSource(request,"mydatasource"));
//alist=(ArrayList) service.list(hdto);
obj = (Object[])service.alllist(hdto);
count = (Integer)obj[8];
request.setAttribute("alist",obj);
PaginationVO paginationVO = Pagination.paginate(count,String.valueOf(currentPage),5);
request.setAttribute("paginationVO", paginationVO);
} catch (AppException e) {
e.printStackTrace();
}
return mapping.findForward(edu.yinhe.mis.common.GlobalNames.HEADMINISTER);
}
/**
* @author 宋玉萍
* 在组长自我评估表中插入数据
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response){
ActionForward forward = null;
HeaderMyselfForm hform=(HeaderMyselfForm)form;
FormFile formFile=hform.getMyselffile();
String fileName=formFile.getFileName();
//Configuration conf=new Configuration();
fileName=fileName.substring(fileName.lastIndexOf("."));
fileName=System.currentTimeMillis()+fileName;
//String savePath=conf.getProperty("uploadSavePath");
fileName="c:\\"+fileName;
try {
FileOutputStream fout=new FileOutputStream(fileName);
BufferedInputStream fin=new BufferedInputStream(formFile.getInputStream());
//FileInputStream fin=formFile.getInputStream();
byte[] bytes=new byte[1024*2];
int i=0;
while((i=fin.read(bytes, 0, bytes.length))!=-1){
fout.write(bytes, 0, i);
}
fout.flush();
fout.close();
fin.close();
//读文件并采集数据,装入到List集合中;
//插入到数据库中,
ExcelHeadMyself excel = new ExcelHeadMyself();
HeaderMyselfDTO dto = excel.readExcel(fileName);// 把excel文件解析出来封装在ArrayList里
//list=(ArrayList)service.findAll();//调用服务层的方法
Boolean isInsert=false;
try {
service.setDataSource(getDataSource(request,"mydatasource"));//设置连接,固定写法,这个service是从BaseAction继承过来
isInsert = (Boolean) service.create(dto);
} catch (AppException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}// 把数据插入到数据库的表excel里
if (isInsert) {
// request.getRequestDispatcher("/ok.jsp").forward(request,
// response);
forward = mapping.findForward("insert");
} else {
//request.getRequestDispatcher("/error.jsp").forward(
// request, response);// 操作失败的跳转页面----解析或者插入数据不成功
return mapping.findForward("/error.jsp");
}
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return forward;
}
/**
* @author 宋玉萍
* 部长查看自我评估表
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward miniQuery(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionForward forward = null;
List list = new ArrayList();
LoginVO vo = (LoginVO)request.getSession().getAttribute(GlobalNames.SESSION_ID);
HeaderMyselfDTO dto = new HeaderMyselfDTO();
String startdate = request.getParameter("startdate");
String enddate = request.getParameter("enddate");
String teacher = request.getParameter("teacher");
if(teacher != null && !"".equals(teacher)){
dto.setTeacherName(teacher);
}
if(startdate!=null && !"".equals(startdate))
{
dto.setStartdate(startdate);
dto.setEnddate(enddate);
}
try {
service.setDataSource(getDataSource(request,"mydatasource"));
String teano = (String)service.findById(vo);
if(teano!=null&&!"".equals(teano)){
dto.setRemark2(teano);
service.setDataSource(getDataSource(request,"mydatasource"));
list = (ArrayList)service.findAll(dto);
if(list!=null){
request.setAttribute("dto", dto);
request.setAttribute("list", list);
forward = mapping.findForward("miniquery");
}
}
} catch (AppException e) {
e.printStackTrace();
}
return forward;
}
/**
* @author 宋玉萍
* 组长查看自我评估表
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward teamerQuery(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ActionForward forward = null;
List list = new ArrayList();
LoginVO vo = (LoginVO)request.getSession().getAttribute(GlobalNames.SESSION_ID);
HeaderMyselfDTO dto = new HeaderMyselfDTO();
String startdate = request.getParameter("startdate");
String enddate = request.getParameter("enddate");
String teacher = request.getParameter("teacher");
if(teacher != null && !"".equals(teacher)){
dto.setTeacherName(teacher);
}
if(startdate!=null && !"".equals(startdate))
{
dto.setStartdate(startdate);
dto.setEnddate(enddate);
}
try {
service.setDataSource(getDataSource(request,"mydatasource"));
String teano = (String)service.findById(vo);
if(teano!=null&&!"".equals(teano)){
dto.setRemark2(teano);
service.setDataSource(getDataSource(request,"mydatasource"));
list = (ArrayList)service.findAll(dto);
if(list!=null){
request.setAttribute("dto", dto);
request.setAttribute("list", list);
forward = mapping.findForward("teamerquery");
}
}
} catch (AppException e) {
e.printStackTrace();
}
return forward;
}
/**
* @author 姜娟
* 导出整体报表
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward showXML(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
ArrayList arrlist = (ArrayList)session.getAttribute("strlist");
ActionForward forward = null;
DownLoadFile dlf = null;
int i = JOptionPane.showConfirmDialog(null, "你确定导出在d:/fds.xls吗?");
if(i==0){ //是
try {
dlf = new DownLoadFile("d:/fds.xls");
} catch (AppException e) {
e.printStackTrace();
}
String []format={"老师编号","老师姓名","老师性别 ","老师离职状态","老师职务","所属部门","学员满意度问卷表","学员意见反馈表 ","教师品质月度考核表","教师课堂教学评估表","听课记录表","备课记录","部长评分","总分"};
dlf.isHead(true);
dlf.setFormat(format);
dlf.executeDownLoad(arrlist);
JOptionPane.showMessageDialog(null, "操作成功");
}else if(i==1){ //否
JOptionPane.showMessageDialog(null, "您已取消改操作");
}else { //取消
JOptionPane.showMessageDialog(null, "您已取消改操作");
}
return mapping.findForward("excel");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -