% /**
* **********************************************************
* @@ Program Name : statistics_excel.jsp
* @@ Description : /Áý°èÀÚ/º¸°í¹®¼ ¸ñ·Ï °øÅë
* @@ Author : ±âÇöÅ×Å©
* @@ Create Date : 2010.11.21
* @@ History : 2014.10.14 Update by jskim
* @@***********************************************************
*/
%>
<%@ page contentType="text/html; charset=euc-kr"
import="java.util.Date"
import="java.util.List"
import="java.text.SimpleDateFormat"
import="java.net.URLEncoder"
import="java.net.URLDecoder"
import="kr.co.kihyun.beans.user.HttpSSOLogin"
import="kr.co.kihyun.util.MDate"
import="kr.co.kihyun.lang.MString"
import="kr.co.kihyun.lang.MInteger"
import="kr.co.kihyun.lang.MLong"
import="kr.co.kihyun.lang.Encoder"
import="kr.co.kihyun.moumi.MoumiConfig"
import="kr.co.kihyun.moumi.doc.MDoc"
import="kr.co.kihyun.moumi.report.MReport"
import="kr.co.kihyun.beans.user.User"
import="kr.co.kihyun.beans.user.Dept"
import="kr.co.kihyun.beans.totsys.report.Report"
import="kr.co.kihyun.beans.totsys.doc.Doc"
import="javax.jdo.PersistenceManager"
import="javax.jdo.Transaction"
import="kr.co.kihyun.beans.entity.util.*"
import="kr.co.kihyun.beans.entity.*"
import="org.slf4j.Logger"
import="org.slf4j.LoggerFactory"
import="kr.co.kihyun.service.*" import="kr.co.kihyun.service.vo.*"
import="java.util.*" import="java.text.*"
import="javax.jdo.Query"%>
<%@ include file="/totsys/common/inc/sec/secure.inc.jsp"%>
<% PersistenceManager pm = new MPersistenceManager(PMF.get().getPersistenceManager());
Transaction tx = pm.currentTransaction();
try {
Logger LOG = LoggerFactory.getLogger(this.getClass());
/**
* ******** session³»ÀÇ userId *********
*/
String usID = HttpSSOLogin.getLoginID(request);
int sysAuth = HttpSSOLogin.getSysAuth(request);
String dpID = HttpSSOLogin.getDeptID(request);
/**
* **** Parameter *****
*/
String searchType = clearXSS(request.getParameter("searchType"), "");
String dateType = clearXSS(request.getParameter("dateType"), "");
String stDate = clearXSS(request.getParameter("stDate"), "");
String edDate = clearXSS(request.getParameter("edDate"), "");
String searchOrgan = clearXSS(request.getParameter("search_organ"), "");
String searchDept = clearXSS(request.getParameter("search_dept"), "");
String chkboxDept = clearXSS(request.getParameter("chkbox_dept"), "");
String chkboxSchool = clearXSS(request.getParameter("chkbox_school"), "");
tx.begin();
String deptName = "";
if (searchOrgan.equals("ALL")) {
MDept mDept = pm.getObjectById(MDept.class, dpID);
deptName = mDept.getRootDept(pm).getName();
} else {
if (searchDept.equals("ALL")) {
MDept mDept = pm.getObjectById(MDept.class, searchOrgan);
deptName = mDept.getName();
} else {
if (chkboxDept.equals("D")) {
MDept mDept = pm.getObjectById(MDept.class, searchOrgan);
deptName = mDept.getName() + " - ";
}
MDept mDept = pm.getObjectById(MDept.class, searchDept);
deptName += mDept.getName();
}
}
//===========================================================
String txtStartDate = stDate;
String txtEndDate = edDate;
String sDeptSchoolType = MString.checkNull(chkboxDept, chkboxSchool);
StatisticsService service = new StatisticsService(pm);
List list = null;
Map params = new HashMap();
params.put("organId", searchOrgan);
params.put("deptId", searchDept);
params.put("deptSchoolType", sDeptSchoolType);
if (searchType.equals("all")) {
params.put("startDate", stDate);
params.put("endDate", edDate);
list = service.getStatisticsForAll(params);
} else if (searchType.equals("period")) {
params.put("dateType", dateType);
params.put("stDate", stDate);
params.put("edDate", edDate);
list = service.getStatisticsByDate(params);
if (dateType.equals("month")) {
txtStartDate = stDate.substring(0, stDate.lastIndexOf("-"));
txtEndDate = edDate.substring(0, stDate.lastIndexOf("-"));
} else if (dateType.equals("year")) {
txtStartDate = stDate.substring(0, stDate.indexOf("-"));
txtEndDate = edDate.substring(0, stDate.indexOf("-"));
}
}
tx.rollback();
DecimalFormat numberFormat = new DecimalFormat("#,###,###");
response.setHeader("Accept-Ranges", "bytes");
//response.setHeader("Content-Disposition","attachment; filename="+(URLEncoder.encode(docName, "UTF-8")).replaceAll(":","_").replace("+","%20" )+".xls;");
//LJH
//v2. 11.HTTP ÀÀ´äºÐÇÒ : Update by KWON,HAN
//response.setHeader("Content-Disposition", "attachment; filename=statistics_"+searchType+".xls;");
//¼öÁ¤ : ¿ÜºÎ ÀԷ°ª ÇÊÅ͸µ
String filtered_searchType = searchType.replaceAll("\r", "").replaceAll("\n", "");
response.setHeader("Content-Disposition", "attachment; filename=statistics_" + filtered_searchType + ".xls;");
//=================================================================================================
%>
<% if (searchType.equals("") || searchType.equals("period")) {%>
<%= deptName%>
|
<%= txtStartDate%> ~ <%= txtEndDate%>
|
|
<%
int prssTot = 0; //Áý°èÁøÇàÇÕ°è
int endTot = 0; //Áý°è¿Ï·áÇÕ°è
int acceptTot = 0; //Á¢¼öÇÕ°è
int tempTot = 0; //Á¦ÃâÁøÇàÇÕ°è
int compTot = 0; //Á¦Ãâ¿Ï·áÇÕ°è
for (int i = 0; i < list.size(); i++) {
Object[] row = (Object[]) list.get(i);
prssTot += Integer.parseInt(row[1].toString());
endTot += Integer.parseInt(row[2].toString());
acceptTot += Integer.parseInt(row[3].toString());
tempTot += Integer.parseInt(row[4].toString());
compTot += Integer.parseInt(row[5].toString());
%>
<%= row[0]%> |
<%= numberFormat.format(row[1])%> |
<%= numberFormat.format(row[2])%> |
<%= numberFormat.format(row[3])%> |
<%= numberFormat.format(row[4])%> |
<%= numberFormat.format(row[5])%> |
<%
}
%>
|
<%
} else if (searchType.equals("all")) {
Object[] row = (Object[]) list.get(0);
%>
<%= deptName%>
|
<%= txtStartDate%> ~ <%= txtEndDate%>
|
|
<%=MoumiConfig.getMessageBundle().getString("moumi.message.statistics.tot_doc")%>
|
<%= numberFormat.format(row[0]).trim()%> <%=MoumiConfig.getMessageBundle().getString("moumi.message.statistics.job")%>
|
<%= numberFormat.format(row[1]).trim()%> <%=MoumiConfig.getMessageBundle().getString("moumi.message.statistics.job")%>
|
<%=MoumiConfig.getMessageBundle().getString("moumi.message.statistics.tot_report")%>
|
<%= numberFormat.format(row[2]).trim()%> <%=MoumiConfig.getMessageBundle().getString("moumi.message.statistics.job")%>
|
<%= numberFormat.format(row[3]).trim()%> <%=MoumiConfig.getMessageBundle().getString("moumi.message.statistics.job")%>
|
<%= numberFormat.format(row[4]).trim()%> <%=MoumiConfig.getMessageBundle().getString("moumi.message.statistics.job")%>
|
|
|
<% } %>
<%
} catch (Exception ex) {
//ex.printStackTrace();
out.println(kr.co.kihyun.text.html.ServletUtil.getJavaScript("location='/servlet/kr.co.kihyun.beans.user.HttpSSOLogin?mode=logout';"));
} finally {
if (tx.isActive()) {
tx.rollback();
}
pm.close();
}
%>