JSP文件:
<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:
<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:
<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:
<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:
<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:
<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:
<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:
<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}JSP文件:<%@ page contentType="text/html; charset=GBK" %><%@ taglib uri="/WEB-INF/hollycrm-view.tld" prefix="view" %><%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %><html><html:base/><head><title>顺丰投诉系统</title></head><script>function importFile(){ var regex=/(.+)\.xls$/i; if(regex.test(document.form1.excelFile.value)==false){ alert("文件格式不正确,请上传Excel文件且扩展名为xls"); return false; } document.form1.submit();}</script><LINK href="../../framework/public/css/style.css" rel="stylesheet" type="text/css"><LINK href="../../framework/public/css/bj.css" rel="stylesheet" type="text/css"><%String message=(String)request.getAttribute("message");%><body bgcolor="#ffffff" ><form name="form1" method="post" enctype="multipart/form-data" action="../../../deptTimeAction.do?dept=importDeptTime" > <br><center><b><font size="4" color="red"><%=message==null?"":message%></font></b></center>
<view:restitle name="导入地区下班时间信息"> <view:titleitem> <img src="../../../framework/public/p_w_picpaths/bc.gif" class="a7" onClick="importFile()"></view:titleitem></view:restitle>
<view:qrytable> <view:qrytr> <view:label text ="内 容:"/> <view:input> <input type="file" name="excelFile" /> </view:input>
</view:qrytr> </view:qrytable></form></body></html>
Form文件:
package com.sfexpress.csc.web.form;
import org.apache.struts.action.*;
import javax.servlet.http.*;import org.apache.struts.upload.*;/*** 地区下班时间设置* */public class DeptTimeActionForm
extends ActionForm {//编号,部门ID,时间
private String[] deptID; private long id; private String time; private FormFile excelFile; public String[] getDeptID() { return deptID; } public void setDeptID(String[] deptID) { this.deptID = deptID; } public long getId() { return id; } public void setId(long id) { this.id = id; } public String getTime() { return time; } public void setTime(String time) { this.time = time; } public ActionErrors validate(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { : finish this method, this is just the skeleton.*/ return null; } public void reset(ActionMapping actionMapping, HttpServletRequest httpServletRequest) { } public FormFile getExcelFile() { return excelFile; } public void setExcelFile(FormFile excelFile) { this.excelFile = excelFile; }} Action类,解析excel文件package com.sfexpress.csc.web.action;
import com.sfexpress.csc.web.form.*;
import com.sfexpress.csc.web.*;import org.apache.struts.action.*;import javax.servlet.http.*;import com.sfexpress.csc.common.Tools;import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory;import com.sfexpress.csc.service.*;import java.util.*;import com.sfexpress.csc.web.form.*;import com.sfexpress.csc.domain.*;import java.io.*;import org.apache.poi.hssf.usermodel.*;import org.apache.poi.poifs.filesystem.POIFSFileSystem;import org.apache.struts.upload.*;
public class DeptTimeAction
extends BaseDispatchAction { private static Log logger = LogFactory.getLog(DeptTimeAction.class);/**
* 功能: 批量导入地区下班时间信息 * 读取excel文件 * 参数: ActionMapping * ActionForm * HttpServletRequest * HttpServletResponse * 返回值: ActionForward * 异常: Exception * */ public ActionForward importDeptTime(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse){ if (!this.isVerify(httpServletRequest)) { return actionMapping.findForward("sessionout"); } MemberService memberService=(MemberService)this.getObjectService( "memberService"); SequenceService sequence=(SequenceService)this.getObjectService( "sequenceService"); DeptTimeActionForm deptTimeForm = (DeptTimeActionForm)actionForm; String forward=null; //转发对象 DeptTime depttime = new DeptTime(); POIFSFileSystem fs = null; HSSFWorkbook wb = null; try{ FormFile formFile = deptTimeForm.getExcelFile(); //获取form的excel文件 InputStream myxls = formFile.getInputStream(); fs = new POIFSFileSystem(myxls); wb = new HSSFWorkbook(fs); HSSFSheet sheet = wb.getSheetAt(0);HSSFCell cellOne = null;
HSSFCell cellTwo = null; String name = null; int time = 0; HSSFRow row = null; String depatmentID = null; int rows = sheet.getLastRowNum(); //获取最后的行数 String temp = ""; for (int i = 0; i <= rows; i++) { row = sheet.getRow(i); //获取当前行 cellOne = row.getCell( (short) 0); //获取第一列 name = cellOne.getStringCellValue();//获取第一列的值 cellTwo = row.getCell( (short) 1); //获取第二列 time = (int) cellTwo.getNumericCellValue(); 获取第二列的值temp=temp+" "+name;
List departmentList = memberService.getDepartmentInfo(name); if (departmentList.size() != 0) { Iterator iDepartment = departmentList.iterator(); while (iDepartment.hasNext()) { Department d = (Department) iDepartment.next(); depatmentID = d.getId(); List depttimeList = (List) memberService.getTimeInfo( Long.parseLong(depatmentID)); if (depttimeList.size()==0) { depttime.setId(sequence.getSequence("depttime")); depttime.setDeptID(depatmentID+""); depttime.setTime(time+""); } else{ httpServletRequest.setAttribute("message", temp+",已经配置该信息!"); } } } else { httpServletRequest.setAttribute("message", "提供的信息有错误!"); } } List list=memberService.deptTimeList(); //获取部门列表 httpServletRequest.setAttribute("deptList",list); forward = "deptTimeList"; Tools.printlnLog("批量导入地区下班时间信息......成功"); } catch(Exception e){ logger.error("批量导入地区下班时间信息异常", e); httpServletRequest.setAttribute("ERROR", e.toString()); forward = "error"; } return actionMapping.findForward(forward);}