You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
zhky/src/main/java/com/zky/manager/ImportPropertywlExcelServle...

83 lines
2.8 KiB

1 year ago
package com.zky.manager;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.SQLException;
import java.text.ParseException;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.jspsmart.upload.SmartFile;
import com.jspsmart.upload.SmartUpload;
import com.jspsmart.upload.SmartUploadException;
import com.zky.pojo.PropertyInfo;
import com.zky.zhyw.smtj.wltj.StatWltjManageServlet;
import com.zky.zhyw.smtj.zctj.StatZctjManageServlet;
public class ImportPropertywlExcelServlet extends HttpServlet {
String excelFile="";
String path="";
Connection conn=null;
/**
*
*/
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
doPost(req, resp);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
{
Login employee=(Login)request.getSession().getAttribute("login");
String operate="";
try {
SmartUpload upload=new SmartUpload();
upload.initialize(this.getServletConfig(),request,response);
upload.upload("UTF-8");
SmartFile smartFile=upload.getFiles().getFile(0);
if(smartFile.getFileExt()!=null&&!smartFile.getFileExt().equals(""))
{
excelFile=upload.getFiles().getFile(0).getFilePathName();
List<PropertyInfo> fileData=StatWltjManageServlet.importPropertyNetInfoData(excelFile);
if(fileData.size()==0)
{
response.setContentType("text/html;charset=utf-8");
PrintWriter out=response.getWriter();
out.print("<script language='javascript'>alert('无文件数据信息,导入失败!');window.location.href='/zhyw/smtj/wltj/StatNet.jsp';</script>");
out.close();
}
else
{
StatWltjManageServlet.insertPropertyNetData(fileData, request, response);
response.setContentType("text/html;charset=utf-8");
PrintWriter out=response.getWriter();
out.print("<script language='javascript'>alert('文件信息导入成功!');window.location.href='window.location.href='/zhyw/smtj/wltj/StatNet.jsp';</script>");
out.close();
}
}
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SmartUploadException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}