读取页面部分
edb_number_province.jsp
<%@ page contentType="text/html;charset=GBK" language="java" isELIgnored="false"%>
<%@ page import="java.util.*" %>
<%@ page import="com.ninemax.animation.toolkit.io.StringTool"%>
<%@ page import="com.ninemax.animation.toolkit.date.DateProcess"%>
<%@ page import="com.ninemax.animation.business.general.InitSysParams" %>
<%@ page import="com.ninemax.nacao.to.system.*" %>
<%@ page import="java.sql.Timestamp" %>
<%
response.setHeader("Pragma","public");
response.setHeader("Cache-Control","cache, must-revalidate");
String startYear = DateProcess.getSysDate().substring(0,4);
/*session 中取登录用户*/
clsRegUserTO loginUser = (clsRegUserTO)session.getAttribute("loginUser");
if(loginUser == null){
loginUser = new clsRegUserTO();
}
String userId = loginUser.getUser_id();
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GBK" />
<title>各省认定企业数量比例</title>
<link rel="stylesheet" href="../Contents/Style.css" type="text/css" />
<META HTTP-EQUIV="pragma" CONTENT="public">
<META HTTP-EQUIV="Cache-Control" CONTENT="cache, must-revalidate">
<link href="/css/css.css" rel="stylesheet" type="text/css" />
<script language="JavaScript" src="../JSClass/FusionCharts.js"></script>
</head>
<body>
<div class="page_main">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="page_top_li">
<tr>
<td><table border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="top_li_font1">当前位置:</td>
<td class="top_li_font2">业务管理</td>
<td class="top_li_font2">动漫企业信息统计</td>
<td class="top_li_font3">各省认证企业数量比例</td>
<td> </td>
</tr>
</table></td>
<td align="right"></td>
</tr>
</table>
<table width="650" border="0" cellspacing="0" cellpadding="3" align="center">
<tr>
<td align="left">
<div class="page_so_bj">
统计年度:<select id="startYear" name="startYear">
<%
Date date = new Date();
String dateStr2 = new Timestamp(date.getTime()).toString();
int dataStr;
dataStr = Integer.parseInt(dateStr2.substring(0,4));
for(int i=2000;i<=dataStr;i++){
%>
<option value="<%=i%>" <%if(startYear.equals(i+"")){out.println("selected");}%>><%=i%>年</option>
<%
}
%>
</select>
<input type="submit" name="button" id="button" value=" 查 询 " onclick="_load()"/>
<br/>
</div>
</td>
</tr>
<tr>
<td valign="top" class="text" align="center">
<div id="chartdiv" align="left">
</div>
<script type="text/javascript">
function _load(){
var chart = new FusionCharts("../Charts/Pie3D.swf", "ChartId", "600", "350", "0", "0");
chart.setDataURL(escape("edb_number_province_xml.jsp?startYear="+document.getElementById("startYear").value));
chart.render("chartdiv");
}
_load();
</script>
</td>
</tr>
<tr>
<td valign="top" class="text" align="center"> </td>
</tr>
</table>
</body>
</html>
Data数据部分
edb_number_province_xml.jsp
<%@ page contentType="text/xml;charset=GBK" language="java" isELIgnored="false"%>
<%@ page import="com.ninemax.animation.business.statistics.EdbStatBus" %>
<%@ page import="java.util.*" %>
<%@ page import="com.ninemax.animation.toolkit.io.StringTool"%>
<%@ page import="com.ninemax.animation.business.general.InitSysParams" %>
<%@ page import="com.ninemax.nacao.to.system.*" %>
<%
response.setHeader("Pragma","public");
response.setHeader("Cache-Control","cache, must-revalidate");
String startYear = request.getParameter("startYear");
if(StringTool.isEmpty(startYear))startYear = "";
List<clsProvinceTO> provinces = InitSysParams.Provices;
EdbStatBus statBus = new EdbStatBus();
HashMap<String,HashMap<String,String>> map = statBus.edb_number_year(startYear);
StringBuffer sb = new StringBuffer("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
//sb.append("<graph palette='4' caption='"+startYear+"年 各省认证企业数量比例' shownames='1' showvalues='0' useRoundEdges='1' decimals='0' enableSmartLabels='1' enableRotation='0' bgColor='99CCFF,FFFFFF' bgAlpha='40,100' bgRatio='0,100' bgAngle='360' showBorder='1' startingAngle='70' size='18' color='FF0000' pieBorderColor='FFFFFF'>");
sb.append("<graph palette='4' caption='"+startYear+"年各省认证企业数量比例' decimalPrecision='0' showBorder='1' showPercentageValues='0' showNames='1' numberPrefix='' showValues='1' showPercentageInLabel='0' bgColor='FFFFFF,CC3300' bgAngle='270' bgAlpha='10,10' pieYScale='45' pieBorderAlpha='100' pieRadius='100' animation='1' shadowXShift='4' shadowYShift='4' shadowAlpha='40' pieFillAlpha='95' pieBorderColor='FFFFFF' color='FF0000' divLineColor='CC3300' baseFontSize='12'>");
HashMap<String,String> map_2 = map.get("2");
Iterator<String> iterator = map_2.keySet().iterator();
while(iterator.hasNext()){
String key = iterator.next();
String val = map_2.get(key);
for(clsProvinceTO provinceTO : provinces){
if(!map_2.get(key).equals("0") && key.equals(provinceTO.getId())){
sb.append("<set label='"+provinceTO.getProvinceName()+"' value='"+map_2.get(key)+"'/>");
}
}
}
sb.append("</graph>");
out.println(sb.toString());
%>
Java代码部分
/**
* 动漫企业认证数量,按年度按省份通过认定统计
* @param number
* @param year
* @param province
*/
public HashMap<String,HashMap<String,String>> edb_number_year(String year){
EdbStat stat = new EdbStat();
return stat.edb_number_year(year);
}
/**
* 动漫企业认证数量,按年度按省份统计
* @param number
* @param year
* @param province
*/
public HashMap<String,HashMap<String,String>> edb_number_year(String year){
HashMap<String,HashMap<String,String>> returnMap = new HashMap<String,HashMap<String,String>>();
String status = "";
DataAccessObject dataAccessObject = new DataAccessObject();
String sql = "select case when edb_checkstatus is null then '合计' else edb_checkstatus end as status,";
List<clsProvinceTO> provinces = InitSysParams.Provices;
for(int i=0;i<provinces.size();i++){
clsProvinceTO provinceTO = (clsProvinceTO)provinces.get(i);
String provinceId = provinceTO.getId();
if(i==0){
sql += " count(decode(edb_province,'"+provinceId+"',1)) as \""+provinceId+"\"";
}else{
sql += " ,count(decode(edb_province,'"+provinceId+"',1)) as \""+provinceId+"\"";
}
}
sql +="from sc_enterprisedb where EDB_CHECKSTATUS != '0'";
if(!StringTool.isEmpty(year)){
sql += " and substr(edb_checktime,0,4) = '"+year+"'";
}
sql += " and EDB_CHECKSTATUS = '2'";
sql += " group by ROLLUP(edb_checkstatus)";
try{
CachedRowSet crs = dataAccessObject.query(sql);
//System.out.println(sql);
while(crs.next()){
HashMap<String,String> provinceMap = new HashMap<String,String>();
status = crs.getString("status");
for(clsProvinceTO provinceTO : provinces){
provinceMap.put(provinceTO.getId(),crs.getString(provinceTO.getId()));
}
returnMap.put(status,provinceMap);
}
}catch (Exception e){
e.printStackTrace();
}
return returnMap;
}