Skip to content

Commit

Permalink
merge hu
Browse files Browse the repository at this point in the history
  • Loading branch information
huyinghuan committed Jan 10, 2014
2 parents 3903bc3 + affb573 commit c069937
Show file tree
Hide file tree
Showing 9 changed files with 178 additions and 43 deletions.
44 changes: 25 additions & 19 deletions eccmeteor/private/report/StatisticsReportNoGraphicMonitoring.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,41 @@
<meta charset="utf-8">
</head>
<body>
<div>
<a href="<%= baseData.theFirstPage%>.html">首页</a>
<a href="<%= baseData.theBeforePage%>.html">前一页</a>
<a href="<%= baseData.theAfterPage%>.html">后一页</a>
<a href="<%= baseData.theLastPage%>.html">末页</a>
共 :<%= baseData.theTotalPage%>
当前是第:<%= baseData.theCurrentPage + 1 %>
</div>
<div id="content">
<h3 align="center"><%= basedata.reportTitle%></h3>
<h4 align="center"><%= startTime%> ~ <%= endTime%></h4>
<h3 align="center"><%= baseData.reportTitle%></h3>
<h4 align="center"><%= baseData.startTime%> ~ <%= baseData.endTime%></h4>
<lable>监测</lable>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<tr>
<th>名称</th>
<th>返回值名称</th>
<th>最大值</th>
<th>最小值</th>
<th>平均值</th>
<th>最近一次</th>
<th>最大值时间</th>
<th>正常(%)</th>
<th>危险(%)</th>
<th>错误(%)</th>
<th>禁止(%)</th>
<th>阀值</th>
</tr>
</thead>
<tbody>
<%for(var i = 0 ; i < tableData.length ; i++){%>
<%for(i in records){%>
<tr>
<td><%= tableData[i].MonitorName%></td>
<td><%= tableData[i].ReturnName%></td>
<td><%= tableData[i].max%></td>
<td><%= tableData[i].min%></td>
<td><%= tableData[i].average%></td>
<td><%= tableData[i].latest%></td>
<td><%= tableData[i].when_max%></td>
<td><%= records[i].MonitorName%></td>
<td><%= records[i].okPercent%></td>
<td><%= records[i].warnPercent%></td>
<td><%= records[i].errorPercent%></td>
<td><%= (100 - ((+records[i].okPercent) + (+records[i].warnPercent) + (+records[i].errorPercent))).toFixed(2)%></td>
<td><%= records[i].errorCondition%></td>
</tr>
<%}%>
</tbody>statistical
<%}%>
</tbody>
</table>
</div>
</body>
Expand Down
21 changes: 19 additions & 2 deletions eccmeteor/private/report/StatisticsReportNoGraphicStatistical.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,36 @@
<meta charset="utf-8">
</head>
<body>
<div>
<a href="<%= baseData.theFirstPage%>.html">首页</a>
<a href="<%= baseData.theBeforePage%>.html">前一页</a>
<a href="<%= baseData.theAfterPage%>.html">后一页</a>
<a href="<%= baseData.theLastPage%>.html">末页</a>
共 :<%= baseData.theTotalPage%>
当前是第:<%= baseData.theCurrentPage + 1 %>
</div>
<div id="content">
<lable>统计</lable>
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<th>名称</th>
<th>返回值名称</th>
<th>返回值</th>
<th>最大值</th>
<th>平均值</th>
<th>最近一次</th>
<th>最新值</th>
</tr>
</thead>
<tbody>
<%for(i in records){%>
<tr>
<td><%= records[i].MonitorName%></td>
<td><%= records[i].ReturnName%></td>
<td><%= records[i].max%></td>
<td><%= records[i].average%></td>
<td><%= records[i].latest%></td>
</tr>
<%}%>
</tbody>
</table>
</div>
Expand Down
4 changes: 4 additions & 0 deletions eccmeteor/private/test/test.json
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
<<<<<<< HEAD
[{"name":"StatisticsReportFactoryTest","fn":"test"}]
=======
[{"name":"EccSystemTest","fn":"test"}]
>>>>>>> meteorite-hu
32 changes: 30 additions & 2 deletions eccmeteor/server/lib/EccSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Date:2013-11-04 14:43
Content:增加获取应用根目录的方法 getRootPath
*/
EccSystem = {};
EccSystem = function(){};
Object.defineProperty(EccSystem,"require",{
value:function(modulname){
return Npm.require(modulname);
Expand Down Expand Up @@ -34,4 +34,32 @@ Object.defineProperty(EccSystem,"joinPath",{
var path = EccSystem.require("path");
return path.join.apply(null,arguments);
}
})
});


Object.defineProperty(EccSystem,"mkdir",{
value:function(dirpath,dirname){
var fs = Npm.require("fs");
var path = Npm.require('path');
//判断是否是第一次调用
if(typeof dirname === "undefined"){
if(fs.existsSync(dirpath)){
return;
}else{
arguments.callee(dirpath,path.dirname(dirpath));
}
}else{
//判断第二个参数是否正常,避免调用时传入错误参数
if(dirname !== path.dirname(dirpath)){
arguments.callee(dirpath);
return;
}
if(fs.existsSync(dirname)){
fs.mkdirSync(dirpath)
}else{
arguments.callee(dirname,path.dirname(dirname));
fs.mkdirSync(dirpath);
}
}
}
});
4 changes: 2 additions & 2 deletions eccmeteor/server/lib/svdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ svGetMessageTemplates = function(){
var fmap = meteorSvUniv({'dowhat':'GetSvIniFileBySections',"filename":"TXTtemplate.ini",
"user":"default","sections":"SMS"}, 0);

return fmap["SMS"];
return fmap && fmap["SMS"];
}

//获取发送web短信模板--by zhuqing add
Expand All @@ -775,7 +775,7 @@ svGetWebMessageTemplates=function(){
'user':'default',
'sections':'WebSmsConfige'
},0);
return fmap["WebSmsConfige"];
return fmap && fmap["WebSmsConfige"];
}

//更改短信状态
Expand Down
7 changes: 7 additions & 0 deletions eccmeteor/server/report/ReportExport.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,11 @@ Meteor.Router.add("/TimeContrastReport",'GET',function(){
'Content-type': 'text/html',
'Content-Disposition': "attachment; filename=timecontrast_report.html"
},new Buffer(DrawTimeContrastReport.export(mid,[st1,et1,st2,et2],type))];
});


Meteor.Router.add("/StatisticsReport/:_reportId",'GET',function(){
console.log(_reportId);
var _reportPage = this.request.query.page;
var isDownLoad = this.request.query.isDownLoad;
})
98 changes: 81 additions & 17 deletions eccmeteor/server/report/StatisticsReportFactory.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
var fs = Npm.require('fs');
StatisticsReportFactory = function(reportConfigureId){
this.setting = {};
this.monitorIds = [];
this.extentDate = [];
this.fileType = [];
this._options = {
NoGraphicReportMnotoring:"StatisticsReportNoGraphicMonitoring"
NoGraphicReportMnotoringHtmlTemplate:"StatisticsReportNoGraphicMonitoring.html",
NoGraphicStatisticalHtmlTemplate:"StatisticsReportNoGraphicStatistical.html",
_perPage:24,
}
this.init(reportConfigureId);
};
Expand Down Expand Up @@ -55,7 +58,12 @@ StatisticsReportFactory.prototype.getExtentDate = function(){

//拼接时间
StatisticsReportFactory.prototype.joinTime = function(obj){
return obj.year + "-" + obj.month + "-" + obj.day+ " " +obj.hour + ":" +obj.minute+":"+obj.second;
return obj.year
+ "-" + (obj.month < 10 ? ("0" + obj.month):obj.month )
+ "-" + (obj.day < 10 ? ("0" + obj.day) :obj.day )
+ " " + obj.hour
+ ":" + obj.minute
+ ":" + obj.second;
}

StatisticsReportFactory.prototype.buildTime = function(extent){
Expand Down Expand Up @@ -105,37 +113,93 @@ StatisticsReportFactory.prototype.drawNoGraphicReport = function(){
*/
var monitoringRecords = SvseMonitorDaoOnServer.getMonitorReportDataByfilter(monitorIds,dateExtent[0],dateExtent[1],filter,false);
var statisticalRecords = [];

var perPage = this._options._perPage;

var pagerMonitoringRecords = [];
var totalMonitoringRecords = [];

var pagerStatisticalRecords = [];
var totalStatisticalRecords = [];


for(x in monitoringRecords){
if(x.indexOf("Return") !== -1 || x.indexOf("return") !== -1){
statisticalRecords.push(monitoringRecords[x]);
delete monitoringRecords[x];
pagerStatisticalRecords.push(monitoringRecords[x]);
if(pagerStatisticalRecords.length == perPage){
totalStatisticalRecords.push(pagerStatisticalRecords);
pagerStatisticalRecords = new Array();
}
continue;
}
pagerMonitoringRecords.push(monitoringRecords[x]);
if(pagerMonitoringRecords.length == perPage){
totalMonitoringRecords.push(pagerMonitoringRecords);
pagerMonitoringRecords = new Array();
}
}
var baseData = this.buildNoGraphicReportOtherSetting();
var monitoringContext = {
baseData:baseData,
records:monitoringRecords

if(pagerStatisticalRecords.length){
totalStatisticalRecords.push(pagerStatisticalRecords);
}
var monitoringTemplate = this._option.NoGraphicReportMnotoring;

if(pagerMonitoringRecords.length){
totalMonitoringRecords.push(pagerMonitoringRecords);
}

var uuid = Meteor.uuid();
var monitoring = HtmlTemplate.render(monitoringTemplate,monitoringContext);

var totalPage = totalMonitoringRecords.length + totalStatisticalRecords.length;

var monitoringTemplate = this._options.NoGraphicReportMnotoringHtmlTemplate;

for(var i = 0 ; i < totalMonitoringRecords.length ; i++){
var baseData = this.buildNoGraphicReportOtherSetting(i,totalPage);
var monitoringContext = {
baseData:baseData,
records:totalMonitoringRecords[i]
}
var monitoring = HtmlTemplate.render(monitoringTemplate,monitoringContext);
_self.writeToHtml(monitoring,"/home/ec/testReportWritefile/"+i+".html");
}

var statisticalTemplate = this._options.NoGraphicStatisticalHtmlTemplate;
for(var j = 0 ; j < totalStatisticalRecords.length ; j++){
var baseData = this.buildNoGraphicReportOtherSetting(i+j,totalPage);
var statisticalContext = {
baseData:baseData,
records:totalStatisticalRecords[j]
}
var statistical = HtmlTemplate.render(statisticalTemplate,statisticalContext);
_self.writeToHtml(statistical,"/home/ec/testReportWritefile/"+(i+j)+".html");
}
}

StatisticsReportFactory.prototype.buildNoGraphicReportOtherSetting=function(){
StatisticsReportFactory.prototype.buildNoGraphicReportOtherSetting=function(currentPage,totalPage){
var self = this;
var dateExtent = this.getExtentDate();
var theLastPage = totalPage-1;
return {
reportTitle: self.setting.Title.split("\|")[0],
startTime:self.joinTime(dateExtent[0]),
endTime:self.joinTime(dateExtent[0]),
theLastPage:0,
theBeforePage:0,
theBeforePage:0,
theAfterPage:0
theFirstPage:0,
theLastPage:theLastPage,
theCurrentPage:currentPage,
theBeforePage:currentPage == 0 ? 0 : (currentPage - 1),
theAfterPage:currentPage == theLastPage ? currentPage : (currentPage + 1),
theTotalPage:totalPage
}
}

StatisticsReportFactory.prototype.write = function(string){

StatisticsReportFactory.prototype.writeToHtml = function(htmlContent,fileName){
fs.writeFileSync(fileName,new Buffer(htmlContent));
}


StatisticsReportFactory.prototype.getReportSvaePath = function(uuid){
var path = "/home/ec/testReportWritefile";
path = EccSystem.joinPath(path,uuid);
EccSystem.mkdir(path);
return path;
}
6 changes: 6 additions & 0 deletions eccmeteor/server/test/EccSystemTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
EccSystemTest = function(){};
Object.defineProperty(EccSystemTest,"test",{
value:function(){
EccSystem.mkdir("/home/ec/asdasdsads");
}
});
5 changes: 4 additions & 1 deletion eccmeteor/server/test/StatisticsReportFactoryTest.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
StatisticsReportFactoryTest = function(){};
Object.defineProperty(StatisticsReportFactoryTest,"getRecords",{
value:function(){
var factory = new StatisticsReportFactory("5qSjY2kbgb655MRaD");
var factory = new StatisticsReportFactory("w8rGbu9BKPMbSMkB7");
factory.genaritionReport();

}
Expand All @@ -10,6 +10,9 @@ Object.defineProperty(StatisticsReportFactoryTest,"getRecords",{
Object.defineProperty(StatisticsReportFactoryTest,"test",{
value:function(){
StatisticsReportFactoryTest.getRecords();
//console.log(SvseStatisticalresultlist.find().fetch());{nIndex:reportConfigureId}
//console.log(SvseStatisticalresultlist.findOne("w8rGbu9BKPMbSMkB7"));

}
});
/*
Expand Down

0 comments on commit c069937

Please sign in to comment.