Переглянути джерело

修复网站统计功能

修正网站统计主页的历史发文统计入口,将弹窗指向真实登记的 10219 组件,并补齐该组件的 PC 端运行/编辑 JSP 文件。

增强统计服务接口的容错:近七日访问按日期对齐并补零,文章排行和发布动态按可管理网站过滤,发文报表支持默认当前月并处理空权限网站、自定义日期缺失等情况。

Validation:

- javac 编译 WebsiteStatisticsService.java 通过

- git diff --staged --check 通过

- 本地完整后台重启成功,http://localhost:4188/ 返回 200

- 浏览器验证 网站 > 统计 首页数据、文章排行、历史统计弹窗、月份切换和自定义范围页签可用,控制台无错误
非繁 5 місяців тому
батько
коміт
90ea490cf4

+ 1 - 3
WebRoot/WEB-INF/apps/website/config/services/website.visit.service.xml

@@ -5,8 +5,6 @@
 		<service name="website_visit_getSevenDaysVisit" desc="近七天的访问统计" title="近七天的访问统计" class="space.apps.moudules.sys.services.WebsiteStatisticsService" method="getSevenDaysVisit" />
 		<service name="website_visit_articleHot" desc="文章点击排行" title="文章点击排行" class="space.apps.moudules.sys.services.WebsiteStatisticsService" method="getHotArticle" />
 		<service name="website_visit_getIssueDynamic" desc="文章发布动态" title="文章发布动态" class="space.apps.moudules.sys.services.WebsiteStatisticsService" method="getIssueDynamic" />
-		<service name="website_visit_getWebsiteIssueArticleReport" desc="获取网站发文报表数据" title="获取网站发文报表数据" class="space.apps.moudules.sys.services.WebsiteStatisticsService" method="getWebsiteIssueArticleReport" >
-			<verify required="dateType,startDate" />
-		</service>
+		<service name="website_visit_getWebsiteIssueArticleReport" desc="获取网站发文报表数据" title="获取网站发文报表数据" class="space.apps.moudules.sys.services.WebsiteStatisticsService" method="getWebsiteIssueArticleReport" />
 	</service>
 </services>

+ 1 - 2
WebRoot/web/subassembly/app/pc/10028/10153/1002810153_run.jsp

@@ -346,7 +346,7 @@
 				<div slot="header" class="clearfix" style="line-height: 27px">
 					<span><i class="el-icon-s-data"></i> 各网站本月发文数</span>
 					<div class="box-card-right">
-						<el-button size="mini"type="text" onclick='<app:token page='10332' show='true' />' >查看历史统计</el-button>
+						<el-button size="mini" type="text" onclick='<app:token page='10219' show='true' />' >查看历史统计</el-button>
 					</div>
 				</div>
 				<div class="box-card-body">
@@ -804,4 +804,3 @@
 
 
 
-

+ 197 - 0
WebRoot/web/subassembly/app/pc/10028/10219/1002810219_edit.jsp

@@ -0,0 +1,197 @@
+<html>
+
+<head>
+
+</head>
+
+<body>
+	<div id="space-content">
+
+		<div class="space-tbs">
+			<el-tabs v-model="obj.dateType" @tab-click="handleClick">
+				<el-tab-pane label="按月" name="month"></el-tab-pane>
+				<el-tab-pane label="自定义范围" name="custom"></el-tab-pane>
+			</el-tabs>
+			<div class="tab-right">
+				<div class="tabs-right-search">
+					<el-input placeholder="网站名称模糊查询" v-model="obj.websiteName" size="small" clearable>
+						<i slot="suffix" class="el-input__icon el-icon-search space-search-icon" @click="search"></i>
+					</el-input>
+				</div>
+			</div>
+		</div>
+
+		<div style="margin: 52px 0px 0px 0px; text-align: center;" v-show="obj.dateType == 'month'">
+			<el-radio-group v-model="obj.monthNum" @change="changeMonth">
+				<el-radio-button v-for="count in 12" :label="count + '月'"></el-radio-button>
+			</el-radio-group>
+		</div>
+
+		<div style="margin: 52px 0px 0px 0px; text-align: center;" v-show="obj.dateType == 'custom'">
+			<el-date-picker v-model="obj.customDate" value-format="yyyy-MM-dd" type="daterange" range-separator="至" start-placeholder="开始日期"
+				end-placeholder="结束日期" @change="selectCustomerDate" >
+			</el-date-picker>
+		</div>
+
+		<el-row :gutter="12">
+			<div id="container" style="width: 100%; height: 380px;">
+			</div>
+		</el-row>
+	</div>
+</body>
+
+<script src="/apps/space/plug-in/echarts/echarts.min.js" type="text/javascript" charset="utf-8"></script>
+
+<script type="text/javascript">
+	space.vue = new Vue({
+		el: space.appContent,
+		data() {
+			return {
+				obj: {
+					websiteName: '',
+					monthNum: undefined,
+					customDate: [],
+					dateType: 'month'
+				}
+			};
+		},
+		mounted: function () {
+			var myDate = new Date();
+			this.obj.monthNum = (myDate.getMonth() + 1) + "月";
+		},
+		methods: {
+			handleClick: function (tab, event) {
+			},
+			changeMonth: function (month) {
+				getIssueArticleData({
+					dateType: "month",
+					startDate: month.replace("月", ""),
+					name: this.obj.websiteName
+				});
+			},
+			selectCustomerDate: function () {
+				if(space.utils.isNull(this.obj.customDate)) {
+					return;
+				}
+				getIssueArticleData({
+					dateType: "custom",
+					startDate: this.obj.customDate[0],
+					endDate: this.obj.customDate[1],
+					name: this.obj.websiteName
+				});
+			},
+			search: function () {
+				if (this.obj.dateType == 'month') {
+					this.changeMonth(this.obj.monthNum);
+				}
+				else if(this.obj.dateType == 'custom'){
+					this.selectCustomerDate();
+				}
+				else {
+					space.message.error("系统繁忙,请稍后再试");
+				}
+			}
+		}
+	})
+</script>
+
+
+<script type="text/javascript">
+
+	var myChart = undefined;
+
+	$(document).ready(function () {
+
+		getIssueArticleData({
+			dateType: "month",
+			startDate: 'current'
+		});
+
+	});
+
+	function getIssueArticleData(data) {
+		space.utils.ajax({
+			url: '@service{ name: "website_visit_getWebsiteIssueArticleReport"}@',
+			data: data,
+			dataType: 'json',
+			callback: function (resp) {
+
+				if (resp.code != "success") {
+					return;
+				}
+
+				var chartsDatas = {
+					date: new Array(),
+					label: new Array()
+				}
+
+				var index = 0;
+				for (const key in resp.data) {
+					const element = resp.data[key];
+					chartsDatas.date[index] = element.count;
+					chartsDatas.label[index] = element.name;
+					index++;
+				}
+
+				initIssueArticleCount(chartsDatas);
+			}
+		});
+	}
+
+	function initIssueArticleCount(chartsDatas) {
+
+		var dom = document.getElementById("container");
+		myChart = echarts.init(dom);
+		var app = {};
+		var option = {
+			color: ['#3398DB'],
+			tooltip: {
+				trigger: 'axis',
+				axisPointer: {            // 坐标轴指示器,坐标轴触发有效
+					type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
+				}
+			},
+			grid: {
+				left: '3%',
+				right: '4%',
+				bottom: '3%',
+				containLabel: true
+			},
+			xAxis: [
+				{
+					type: 'category',
+					data: chartsDatas.label,
+					axisLabel: {
+						interval: 0,
+						rotate: 40
+					},
+					axisTick: {
+						alignWithLabel: true
+					}
+				}
+			],
+			yAxis: [
+				{
+					type: 'value',
+				},
+			],
+			series: [
+				{
+					name: '发文数量',
+					type: 'bar',
+					barWidth: '60%',
+					data: chartsDatas.date
+				}
+			]
+		};
+
+		if (option && typeof option === "object") {
+			myChart.setOption(option, true);
+		}
+
+	}
+
+
+</script>
+
+</html>

+ 220 - 0
WebRoot/web/subassembly/app/pc/10028/10219/1002810219_run.jsp

@@ -0,0 +1,220 @@
+<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
+<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
+<%@ taglib uri="/WEB-INF/SpaceCoreApp.tld" prefix="app"%>
+<% pageContext.setAttribute(space.core.apps.common.ConstVars.MODULE_DM_KEY, "website"); %>
+<!DOCTYPE html >
+<html>
+
+<head> <!-- HEAD -->
+ <link rel="stylesheet" type="text/css" href="/css/reset.css">
+ <link rel="stylesheet" type="text/css" href="/apps/space/plug-in/element-ui@2.13.0/index.css">
+ <link rel="stylesheet" type="text/css" href="/apps/space/plug-in/layui/dist/css/layui.css">
+ <link rel="stylesheet" type="text/css" href="/apps/space/css/SpaceIcon/iconfont.css">
+ <link rel="stylesheet" type="text/css" href="/css/components.css">
+ <link rel="stylesheet" href="/css/ckeditor.css">
+ <script>var space = { vars: {} };</script>
+ <script src="/js/jquery1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
+ <script src="/apps/space/plug-in/element-resize-detector/element-resize-detector.min.js"></script>
+ <script src="/apps/space/plug-in/vue/vue.min.js" type="text/javascript" charset="utf-8"></script>
+ <script src="/apps/space/plug-in/element-ui@2.13.0/index.js" type="text/javascript" charset="utf-8"></script>
+ <script src="/js/space.vue.pc.subassembly.js"></script>
+ <script src="/apps/space/plug-in/layui/dist/layui.all.js" type="text/javascript" charset="utf-8"></script>
+ <script src="/js/space.recycle.js" type="text/javascript" charset="utf-8"></script>
+ <script src="/js/space.display.js" type="text/javascript" charset="utf-8"></script>
+ <title>历史发文数统计</title>
+</head>
+
+<body>
+	<div v-cloak id="space-content">
+
+		<div class="space-tbs">
+			<el-tabs v-model="obj.dateType" @tab-click="handleClick">
+				<el-tab-pane label="按月" name="month"></el-tab-pane>
+				<el-tab-pane label="自定义范围" name="custom"></el-tab-pane>
+			</el-tabs>
+			<div class="tab-right">
+				<div class="tabs-right-search">
+					<el-input placeholder="网站名称模糊查询" v-model="obj.websiteName" size="small" clearable>
+						<i slot="suffix" class="el-input__icon el-icon-search space-search-icon" @click="search"></i>
+					</el-input>
+				</div>
+			</div>
+		</div>
+
+		<div style="margin: 52px 0px 0px 0px; text-align: center;" v-show="obj.dateType == 'month'">
+			<el-radio-group v-model="obj.monthNum" @change="changeMonth">
+				<el-radio-button v-for="count in 12" :label="count + '月'"></el-radio-button>
+			</el-radio-group>
+		</div>
+
+		<div style="margin: 52px 0px 0px 0px; text-align: center;" v-show="obj.dateType == 'custom'">
+			<el-date-picker v-model="obj.customDate" value-format="yyyy-MM-dd" type="daterange" range-separator="至" start-placeholder="开始日期"
+				end-placeholder="结束日期" @change="selectCustomerDate" >
+			</el-date-picker>
+		</div>
+
+		<el-row :gutter="12">
+			<div id="container" style="width: 100%; height: 380px;">
+			</div>
+		</el-row>
+	</div>
+</body>
+
+<script src="/apps/space/plug-in/echarts/echarts.min.js" type="text/javascript" charset="utf-8"></script>
+
+<script type="text/javascript">
+	space.vue = new Vue({
+		el: space.appContent,
+		data() {
+			return {
+				obj: {
+					websiteName: '',
+					monthNum: undefined,
+					customDate: [],
+					dateType: 'month'
+				}
+			};
+		},
+		mounted: function () {
+			var myDate = new Date();
+			this.obj.monthNum = (myDate.getMonth() + 1) + "月";
+		},
+		methods: {
+			handleClick: function (tab, event) {
+			},
+			changeMonth: function (month) {
+				getIssueArticleData({
+					dateType: "month",
+					startDate: month.replace("月", ""),
+					name: this.obj.websiteName
+				});
+			},
+			selectCustomerDate: function () {
+				if(space.utils.isNull(this.obj.customDate)) {
+					return;
+				}
+				getIssueArticleData({
+					dateType: "custom",
+					startDate: this.obj.customDate[0],
+					endDate: this.obj.customDate[1],
+					name: this.obj.websiteName
+				});
+			},
+			search: function () {
+				if (this.obj.dateType == 'month') {
+					this.changeMonth(this.obj.monthNum);
+				}
+				else if(this.obj.dateType == 'custom'){
+					this.selectCustomerDate();
+				}
+				else {
+					space.message.error("系统繁忙,请稍后再试");
+				}
+			}
+		}
+	})
+</script>
+
+
+<script type="text/javascript">
+
+	var myChart = undefined;
+
+	$(document).ready(function () {
+
+		getIssueArticleData({
+			dateType: "month",
+			startDate: 'current'
+		});
+
+	});
+
+	function getIssueArticleData(data) {
+		space.utils.ajax({
+			url: '<app:token name='website.website_visit_getWebsiteIssueArticleReport' />',
+			data: data,
+			dataType: 'json',
+			callback: function (resp) {
+
+				if (resp.code != "success") {
+					return;
+				}
+
+				var chartsDatas = {
+					date: new Array(),
+					label: new Array()
+				}
+
+				var index = 0;
+				for (const key in resp.data) {
+					const element = resp.data[key];
+					chartsDatas.date[index] = element.count;
+					chartsDatas.label[index] = element.name;
+					index++;
+				}
+
+				initIssueArticleCount(chartsDatas);
+			}
+		});
+	}
+
+	function initIssueArticleCount(chartsDatas) {
+
+		var dom = document.getElementById("container");
+		myChart = echarts.init(dom);
+		var app = {};
+		var option = {
+			color: ['#3398DB'],
+			tooltip: {
+				trigger: 'axis',
+				axisPointer: {            // 坐标轴指示器,坐标轴触发有效
+					type: 'shadow'        // 默认为直线,可选为:'line' | 'shadow'
+				}
+			},
+			grid: {
+				left: '3%',
+				right: '4%',
+				bottom: '3%',
+				containLabel: true
+			},
+			xAxis: [
+				{
+					type: 'category',
+					data: chartsDatas.label,
+					axisLabel: {
+						interval: 0,
+						rotate: 40
+					},
+					axisTick: {
+						alignWithLabel: true
+					}
+				}
+			],
+			yAxis: [
+				{
+					type: 'value',
+				},
+			],
+			series: [
+				{
+					name: '发文数量',
+					type: 'bar',
+					barWidth: '60%',
+					data: chartsDatas.date
+				}
+			]
+		};
+
+		if (option && typeof option === "object") {
+			myChart.setOption(option, true);
+		}
+
+	}
+
+
+</script>
+
+<script type="text/javascript">space.vars.pageTypeCode = "10005";</script>
+<script type="text/javascript">space.vars.pageHashCode = "uXQAb2G9Wj+V4+lTCledFA==";</script>
+<script type="text/javascript" >removeTokens("<app:token name='sys.removeToken' />", '<%= pageContext.getAttribute(space.core.apps.common.ConstVars.TOKEN_SESSION_LIST_KEY) %>')</script>
+</html>

+ 101 - 36
src/space/apps/moudules/sys/services/WebsiteStatisticsService.java

@@ -2,13 +2,13 @@ package space.apps.moudules.sys.services;
 
 import java.io.IOException;
 import java.text.SimpleDateFormat;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 import org.apache.commons.lang.ArrayUtils;
 
-import apps.pojo.Website;
 import space.apps.moudules.website.template.util.WebsiteUtil;
 import space.apps.moudules.website.util.AppWebsiteManageUtil;
 import space.core.apps.common.BaseTransaction;
@@ -83,9 +83,15 @@ public class WebsiteStatisticsService extends BaseTransaction {
 	 */
 	public void getHotArticle() throws Exception {
 
-		Website website = getWebsite();
+		List<Map<String, Object>> websiteList = AppWebsiteManageUtil.getManageWebsiteListByAppUser(getGdbaInstance(),
+				getAppUser());
+
+		if (websiteList == null || websiteList.size() == 0) {
+			write(getResponseSuccessDataPackage(new ArrayList<Map<String, Object>>()).toJson());
+			return;
+		}
 
-		String cacheKey = CACHE_KEY + website.getWebsiteid() + "_hotArticle";
+		String cacheKey = CACHE_KEY + websiteListIDToStr(websiteList) + "_hotArticle";
 
 		Object retMsgObj = JedisUtil.obj.get(cacheKey);
 		if (StringUtil.notNull(retMsgObj)) {
@@ -94,13 +100,31 @@ public class WebsiteStatisticsService extends BaseTransaction {
 			return;
 		}
 
-		String sql = " Select articleid, title, a.`desc`, thumbnail, read_count, url, w.protocol, w.port, w.domains, w.catalog_uri from article a left join website w on a.websiteid = w.websiteid where a.dcode = 61 order by a.read_count desc, a.release_time asc ";
-		SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
+		SqlCommandImpl sqlCmd = new SqlCommandImpl();
+		StringBuilder sqlBuilder = new StringBuilder();
+		sqlBuilder.append(
+				" Select articleid, title, a.`desc`, thumbnail, read_count, url, w.protocol, w.port, w.domains, w.catalog_uri ");
+		sqlBuilder.append(" from article a left join website w on a.websiteid = w.websiteid where a.dcode = 61 ");
+		GdbaQueryUtil.appendInFieldSql(sqlBuilder, sqlCmd, "a.websiteid",
+				AppWebsiteManageUtil.websiteListIDToAry(websiteList));
+		sqlBuilder.append(" order by a.read_count desc, a.release_time asc ");
+		sqlCmd.setExecuteSql(sqlBuilder);
 		List<Map<String, Object>> articleList = getGdbaInstance().selectAsMapList(sqlCmd, getAppsPageBean());
 		
 		for (Map<String, Object> map : articleList) {
 			String websiteUrl = WebsiteUtil.disposeWebsiteDomain(map);
-			map.put("url", websiteUrl.substring(0, websiteUrl.length() - 1) + map.get("url").toString());
+			Object rawUrl = map.get("url");
+			String articleUrl = rawUrl == null ? "" : rawUrl.toString();
+			if (StringUtil.isNull(articleUrl)) {
+				map.put("url", "#");
+			} else if (StringUtil.notNull(websiteUrl)) {
+				if (websiteUrl.endsWith("/")) {
+					websiteUrl = websiteUrl.substring(0, websiteUrl.length() - 1);
+				}
+				map.put("url", websiteUrl + articleUrl);
+			} else {
+				map.put("url", articleUrl);
+			}
 		}
 
 		ResponsePackage rsdp = getResponseSuccessDataPackage(articleList);
@@ -159,9 +183,15 @@ public class WebsiteStatisticsService extends BaseTransaction {
 	 */
 	public void getIssueDynamic() throws Exception {
 
-		Website website = getWebsite();
+		List<Map<String, Object>> websiteList = AppWebsiteManageUtil.getManageWebsiteListByAppUser(getGdbaInstance(),
+				getAppUser());
+
+		if (websiteList == null || websiteList.size() == 0) {
+			write(getResponseSuccessDataPackage(new ArrayList<Map<String, Object>>()).toJson());
+			return;
+		}
 
-		String cacheKey = CACHE_KEY + website.getWebsiteid() + "_IssueDynamic";
+		String cacheKey = CACHE_KEY + websiteListIDToStr(websiteList) + "_IssueDynamic";
 
 		Object retMsgObj = JedisUtil.obj.get(cacheKey);
 		if (StringUtil.notNull(retMsgObj)) {
@@ -170,12 +200,17 @@ public class WebsiteStatisticsService extends BaseTransaction {
 			return;
 		}
 
-		String sql = "Select p.name as 'uname', d.name as 'dname', pt.name as 'pname', p.icon_path, a.title, date_format(a.release_time, '%Y-%m-%d %H:%i') as 'time', a.url from article a, department d, post pt, person p "
-				+ "where a.create_pid = p.personid and p.departmentid = d.departmentid and p.postid = pt.postid and a.dcode = 61 and p.dcode = 61 "
-				+ "and navigationid in ( Select navigationid from website_navigation where websiteid = :websiteid ) order by a.release_time desc ";
-
-		SqlCommandImpl sqlCmd = new SqlCommandImpl(sql);
-		sqlCmd.setString("websiteid", website.getWebsiteid());
+		SqlCommandImpl sqlCmd = new SqlCommandImpl();
+		StringBuilder sqlBuilder = new StringBuilder();
+		sqlBuilder.append(
+				"Select p.name as 'uname', d.name as 'dname', pt.name as 'pname', p.icon_path, a.title, date_format(a.release_time, '%Y-%m-%d %H:%i') as 'time', a.url from article a, department d, post pt, person p ");
+		sqlBuilder.append(
+				"where a.create_pid = p.personid and p.departmentid = d.departmentid and p.postid = pt.postid and a.dcode = 61 and p.dcode = 61 ");
+		sqlBuilder.append("and navigationid in ( Select navigationid from website_navigation where 1 = 1 ");
+		GdbaQueryUtil.appendInFieldSql(sqlBuilder, sqlCmd, "websiteid",
+				AppWebsiteManageUtil.websiteListIDToAry(websiteList));
+		sqlBuilder.append(" ) order by a.release_time desc ");
+		sqlCmd.setExecuteSql(sqlBuilder);
 		List<Map<String, Object>> articleList = getGdbaInstance().selectAsMapList(sqlCmd, getAppsPageBean());
 
 		ResponsePackage rsdp = getResponseSuccessDataPackage(articleList);
@@ -203,15 +238,10 @@ public class WebsiteStatisticsService extends BaseTransaction {
 		// 没有可管理的网站
 		if (websiteList == null || websiteList.size() == 0) {
 
-			String[] numberAry = new String[beforeSevenDay.length];
-			for (int i = 0; i < beforeSevenDay.length; i++) {
-				numberAry[i] = "0";
-			}
-
 			Map<String, String[]> retMap = new HashMap<String, String[]>();
 			retMap.put("date", beforeSevenDay);
-			retMap.put("normal", numberAry);
-			retMap.put("error", numberAry);
+			retMap.put("normal", getZeroArray(beforeSevenDay.length));
+			retMap.put("error", getZeroArray(beforeSevenDay.length));
 			write(getResponseSuccessDataPackage(retMap).toJson());
 			return;
 		}
@@ -235,32 +265,33 @@ public class WebsiteStatisticsService extends BaseTransaction {
 
 		StringBuilder sqlBuilder = new StringBuilder();
 		sqlBuilder.append(
-				" Select date, sum(data) as 'total', wstcode from ( Select data, date, wstcode from website_statistics where date_format(date, '%Y-%m-%d') in ( ");
+				" Select date, sum(data) as 'total', wstcode from ( Select data, date_format(date, '%Y-%m-%d') as date, wstcode from website_statistics where date_format(date, '%Y-%m-%d') in ( ");
 		sqlBuilder.append(dateStrs).append(" ) and (");
 		sqlBuilder.append(GdbaQueryUtil.getInSql(sqlCmd, "websiteid", AppWebsiteManageUtil.websiteListIDToAry(websiteList)));
-		sqlBuilder.append(" or (websiteid is null and wstcode = 10010)) ) as tempTable group by `date`, `wstcode` ");
+		sqlBuilder.append(" or (websiteid is null and wstcode = 10010)) ) as tempTable group by `date`, `wstcode` order by `date` ");
 
 		sqlCmd.setExecuteSql(sqlBuilder);
 		List<Map<String, Object>> dataList = getGdbaInstance().selectAsMapList(sqlCmd);
 
-		int nIndex = 0;
-		int eIndex = 0;
-		String[] normalAry = new String[7];
-		String[] errorAry = new String[7];
+		String[] normalAry = getZeroArray(beforeSevenDay.length);
+		String[] errorAry = getZeroArray(beforeSevenDay.length);
 
 		for (Map<String, Object> map : dataList) {
 
-			String total = map.get("total").toString();
-			total = total.substring(0, total.lastIndexOf("."));
+			int dateIndex = getDateIndex(beforeSevenDay, map.get("date"));
+			if (dateIndex < 0) {
+				continue;
+			}
+			String total = String.valueOf(getTotalByMap(map));
 			String wstcode = map.get("wstcode").toString();
 
 			// 正常
 			if ("10000".equals(wstcode)) {
-				normalAry[nIndex++] = total;
+				normalAry[dateIndex] = total;
 			}
 			// 异常
 			else if ("10010".equals(wstcode)) {
-				errorAry[eIndex++] = total;
+				errorAry[dateIndex] = total;
 			}
 		}
 
@@ -343,6 +374,10 @@ public class WebsiteStatisticsService extends BaseTransaction {
 		List<Map<String, Object>> websiteList = AppWebsiteManageUtil.getManageWebsiteListByAppUser(getGdbaInstance(),
 				getAppUser());
 
+		if (websiteList == null || websiteList.size() == 0) {
+			return new ArrayList<Map<String, Object>>();
+		}
+
 		SqlCommandImpl sqlCmd = new SqlCommandImpl();
 		StringBuilder sqlBuilder = new StringBuilder();
 
@@ -379,12 +414,17 @@ public class WebsiteStatisticsService extends BaseTransaction {
 		String websiteName = getParameter("name");
 		String startDate = getParameter("startDate");
 		String endDate = getParameter("endDate");
-		String dateTyep = getParameter("dateType");
+		String dateType = getParameter("dateType");
+
+		if (StringUtil.isNull(dateType)) {
+			dateType = "month";
+		}
 
-		if (dateTyep.equals("month")) { // 月
-			if ("current".equals(startDate)) {
+		if (dateType.equals("month")) { // 月
+			if (StringUtil.isNull(startDate) || "current".equals(startDate)) {
 				startDate = DateTimeUtil.getMonth();
 			}
+			startDate = startDate.replace("月", "");
 			String year = DateTimeUtil.getYear() + "-" + startDate;
 			SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
 			int daysOfMonth = DateTimeUtil.getDaysOfMonth(sdf.parse(year));
@@ -392,11 +432,15 @@ public class WebsiteStatisticsService extends BaseTransaction {
 			write(getResponseSuccessDataPackage(getWebsiteIssueArticleCount(getGdbaInstance(), year + "-" + "01",
 					year + "-" + daysOfMonth, websiteName)).toJson());
 
-		} else if (dateTyep.equals("custom")) { // 自定义时间
+		} else if (dateType.equals("custom")) { // 自定义时间
+			if (StringUtil.isNull(startDate) || StringUtil.isNull(endDate)) {
+				write(getResponseErrorMsgPackage("请选择开始日期和结束日期").toJson());
+				return;
+			}
 			write(getResponseSuccessDataPackage(
 					getWebsiteIssueArticleCount(getGdbaInstance(), startDate, endDate, websiteName)).toJson());
 		} else {
-			write(getResponseErrorMsgPackage().toJson());
+			write(getResponseErrorMsgPackage("不支持的统计类型").toJson());
 		}
 
 	}
@@ -429,4 +473,25 @@ public class WebsiteStatisticsService extends BaseTransaction {
 		return iDBuilder.substring(0, iDBuilder.length() - 1);
 	}
 
+	private String[] getZeroArray(int length) {
+		String[] numberAry = new String[length];
+		for (int i = 0; i < length; i++) {
+			numberAry[i] = "0";
+		}
+		return numberAry;
+	}
+
+	private int getDateIndex(String[] dateAry, Object dateObj) {
+		if (dateObj == null) {
+			return -1;
+		}
+		String date = dateObj.toString();
+		for (int i = 0; i < dateAry.length; i++) {
+			if (dateAry[i].equals(date)) {
+				return i;
+			}
+		}
+		return -1;
+	}
+
 }