修改进度报表
This commit is contained in:
@@ -2,8 +2,12 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Aspose.Words;
|
||||
using Aspose.Words.Drawing;
|
||||
using Aspose.Words.Drawing.Charts;
|
||||
using BLL;
|
||||
using AspNet = System.Web.UI.WebControls;
|
||||
|
||||
@@ -24,59 +28,12 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
|
||||
private void SetEmpty()
|
||||
{
|
||||
this.SimpleForm1.Title = string.Empty;
|
||||
txt3.Text = string.Empty;
|
||||
txt4.Text = string.Empty;
|
||||
txt5.Text = string.Empty;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 获取记录值
|
||||
private void GetValue()
|
||||
{
|
||||
BindChart();
|
||||
//Model.Information_SafetyBriefing report = Funs.DB.Information_SafetyBriefing.FirstOrDefault(e => e.UnitId == drpUnit.SelectedValue && e.Month == month && e.YearId == year);
|
||||
//if (report != null)
|
||||
//{
|
||||
// string upState = string.Empty;
|
||||
// if (report.UpState == BLL.Const.UpState_3)
|
||||
// {
|
||||
// upState = "(已上报)";
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// upState = "(未上报)";
|
||||
// }
|
||||
// this.SimpleForm1.Title = "实业安全简报" + report.YearId + "年 " + report.Month + "月" + upState;
|
||||
// lbUnitName.Text = "填报企业:" + BLL.UnitService.GetUnitNameByUnitId(report.UnitId);
|
||||
// lbCompileMan.Text = "编制人:" + BLL.UserService.GetUserNameByUserId(report.CompileMan);
|
||||
// lbAuditor.Text = "审核人:" + report.Auditor;
|
||||
// lbApprover.Text = "审批人:" + report.Approver;
|
||||
// this.txtMainWork.Text = report.MainWork;
|
||||
// this.txtHazardRecording.Text = report.HazardRecording;
|
||||
// this.txtSafetyAccident.Text = report.SafetyAccident;
|
||||
// this.txtEPAccident.Text = report.EPAccident;
|
||||
// this.txtOHAccident.Text = report.OHAccident;
|
||||
// this.txtWorkPermitNum.Text = report.WorkPermitNum;
|
||||
// this.txtHiddenDangerDetection.Text = report.HiddenDangerDetection;
|
||||
// this.txtRectificationSituation.Text = report.RectificationSituation;
|
||||
// this.txtCheckProblemsRectification.Text = report.CheckProblemsRectification;
|
||||
// this.txtPendingProject.Text = report.PendingProject;
|
||||
// this.txtContractorManagement.Text = report.ContractorManagement;
|
||||
// this.txtEnvironmentalEmissions.Text = report.EnvironmentalEmissions;
|
||||
// this.txtNextMonthWorkPlan.Text = report.NextMonthWorkPlan;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// SetEmpty();
|
||||
//}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 数据绑定
|
||||
/// <summary>
|
||||
/// 数据绑定
|
||||
/// </summary>
|
||||
private void BindChart()
|
||||
{
|
||||
Model.Project_Installation installation = BLL.Project_InstallationService.GetProjectInstallationByProjectId(this.CurrUser.LoginProjectId);
|
||||
if (installation != null && !string.IsNullOrEmpty(this.txtMonths.Text.Trim()))
|
||||
@@ -182,6 +139,7 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
|
||||
{
|
||||
mSPI = mBCWP / mBCWS;
|
||||
}
|
||||
//总体进度
|
||||
DataTable table2 = new DataTable();
|
||||
table2.Columns.Add(new DataColumn("Id", typeof(String)));
|
||||
table2.Columns.Add(new DataColumn("BCWP", typeof(String)));
|
||||
@@ -204,10 +162,190 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
|
||||
table2.Rows.Add(row2);
|
||||
this.Grid2.DataSource = table2;
|
||||
this.Grid2.DataBind();
|
||||
|
||||
this.txt3.Text = "施工进度赢得值参数 BCWP:" + mBCWP.ToString("0.####") + " BCWS:" + mBCWS.ToString("0.####") + " ACWP:" + mACWP.ToString("0.####") + "\r\n赢得值四个评价指标 CV:" + mCV.ToString("0.####") + " SV:" + mSV.ToString("0.####") + " CPI:" + mCPI.ToString("0.####") + " SPI:" + mSPI.ToString("0.####");
|
||||
|
||||
|
||||
//本月进度
|
||||
table2.Rows.Clear();
|
||||
row2[0] = SQLHelper.GetNewID();
|
||||
row2[1] = mBCWP.ToString("0.####");
|
||||
row2[2] = mBCWS.ToString("0.####");
|
||||
row2[3] = mACWP.ToString("0.####");
|
||||
row2[4] = mCV.ToString("0.####");
|
||||
row2[5] = mSV.ToString("0.####");
|
||||
row2[6] = mCPI.ToString("0.####");
|
||||
row2[7] = mSPI.ToString("0.####");
|
||||
table2.Rows.Add(row2);
|
||||
this.Grid3.DataSource = table2;
|
||||
this.Grid3.DataBind();
|
||||
//按专业统计
|
||||
DataTable table4 = new DataTable();
|
||||
table4.Columns.Add(new DataColumn("Id", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("Name1", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("Name2", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("mBCWP", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("mBCWS", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("mACWP", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("mCV", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("mSV", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("mCPI", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("mSPI", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("BCWP", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("BCWS", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("ACWP", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("CV", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("SV", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("CPI", typeof(String)));
|
||||
table4.Columns.Add(new DataColumn("SPI", typeof(String)));
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
var cnProfessionInits = from x in db.WBS_CnProfessionInit select x;
|
||||
var cnProfessions = from x in db.WBS_CnProfession where x.ProjectId == this.CurrUser.LoginProjectId select x;
|
||||
var unitProjectInits = from x in db.Wbs_UnitProjectInit select x;
|
||||
var unitProjects = from x in db.Wbs_UnitProject where x.ProjectId == this.CurrUser.LoginProjectId select x;
|
||||
var details = from x in db.View_WBS_CostControlParentDetail
|
||||
where x.Months == Funs.GetNewDateTime(date)
|
||||
select x;
|
||||
string strSql2 = "select distinct (cast(YEAR(Months) as varchar(4))+'.'+cast(MONTH(Months) as varchar(2))) as 月份,t.Months," +
|
||||
"ThisRealCost as '本月已完工作实际费用-ACWP',ThisPlanCost as '本月已完工作预算费用-BCWP',ThisPlanValue as '本月计划工作预算费用-BCWS',TotalPlanValue as '累计计划工作预算费用-BCWS',TotalRealCost as '累计已完工作实际费用-ACWP',TotalPlanCost as '累计已完工作预算费用-BCWP' " +
|
||||
"from dbo.View_WBS_CostControlParentDetail as t where t.Months=@Months";
|
||||
SqlParameter[] parameter2 = new SqlParameter[]
|
||||
{
|
||||
new SqlParameter("@Months",date),
|
||||
};
|
||||
DataTable dt2 = SQLHelper.GetDataTableRunText(strSql2, parameter2);
|
||||
DataRow row4;
|
||||
decimal cnACWP, cnBCWP, cnBCWS, cnmACWP, cnmBCWP, cnmBCWS, cnCV, cnSV, cnCPI, cnSPI, cnmCV, cnmSV, cnmCPI, cnmSPI,
|
||||
unACWP, unBCWP, unBCWS, unmACWP, unmBCWP, unmBCWS, unCV, unSV, unCPI, unSPI, unmCV, unmSV, unmCPI, unmSPI;
|
||||
foreach (var cn in cnProfessionInits)
|
||||
{
|
||||
cnACWP = 0;
|
||||
cnBCWP = 0;
|
||||
cnBCWS = 0;
|
||||
cnmACWP = 0;
|
||||
cnmBCWP = 0;
|
||||
cnmBCWS = 0;
|
||||
cnCV = 0;
|
||||
cnSV = 0;
|
||||
cnCPI = 0;
|
||||
cnSPI = 0;
|
||||
cnmCV = 0;
|
||||
cnmSV = 0;
|
||||
cnmCPI = 0;
|
||||
cnmSPI = 0;
|
||||
row4 = table4.NewRow();
|
||||
row4[0] = SQLHelper.GetNewID();
|
||||
row4[1] = cn.CnProfessionName;
|
||||
var cnDetails = (from x in details
|
||||
join y in cnProfessions on x.ParentId equals y.CnProfessionId
|
||||
where y.OldId == cn.CnProfessionId
|
||||
select x).ToList();
|
||||
cnmACWP = Funs.GetNewDecimalOrZero(cnDetails.Select(x => x.ThisRealCost).Sum().ToString()) / 10000;
|
||||
cnmBCWP = Funs.GetNewDecimalOrZero(cnDetails.Select(x => x.ThisPlanCost).Sum().ToString()) / 10000;
|
||||
cnmBCWS = Funs.GetNewDecimalOrZero(cnDetails.Select(x => x.ThisPlanValue).Sum().ToString()) / 10000;
|
||||
cnmCV = cnmBCWP - cnmACWP;
|
||||
cnmSV = cnmBCWP - cnmBCWS;
|
||||
if (cnmACWP > 0)
|
||||
{
|
||||
cnmCPI = cnmBCWP / cnmACWP;
|
||||
}
|
||||
if (cnmBCWS > 0)
|
||||
{
|
||||
cnmSPI = cnmBCWP / cnmBCWS;
|
||||
}
|
||||
row4[3] = cnmBCWP.ToString("0.####");
|
||||
row4[4] = cnmBCWS.ToString("0.####");
|
||||
row4[5] = cnmACWP.ToString("0.####");
|
||||
row4[6] = cnmCV.ToString("0.####");
|
||||
row4[7] = cnmSV.ToString("0.####");
|
||||
row4[8] = cnmCPI.ToString("0.####");
|
||||
row4[9] = cnmSPI.ToString("0.####");
|
||||
cnACWP = Funs.GetNewDecimalOrZero(cnDetails.Select(x => x.TotalRealCost).Sum().ToString()) / 10000;
|
||||
cnBCWP = Funs.GetNewDecimalOrZero(cnDetails.Select(x => x.TotalPlanCost).Sum().ToString()) / 10000;
|
||||
cnBCWS = Funs.GetNewDecimalOrZero(cnDetails.Select(x => x.TotalPlanValue).Sum().ToString()) / 10000;
|
||||
cnCV = cnBCWP - cnACWP;
|
||||
cnSV = cnBCWP - cnBCWS;
|
||||
if (cnACWP > 0)
|
||||
{
|
||||
cnCPI = cnBCWP / cnACWP;
|
||||
}
|
||||
if (cnBCWS > 0)
|
||||
{
|
||||
cnSPI = cnBCWP / cnBCWS;
|
||||
}
|
||||
row4[10] = cnBCWP.ToString("0.####");
|
||||
row4[11] = cnBCWS.ToString("0.####");
|
||||
row4[12] = cnACWP.ToString("0.####");
|
||||
row4[13] = cnCV.ToString("0.####");
|
||||
row4[14] = cnSV.ToString("0.####");
|
||||
row4[15] = cnCPI.ToString("0.####");
|
||||
row4[16] = cnSPI.ToString("0.####");
|
||||
table4.Rows.Add(row4);
|
||||
var unLists = (from x in unitProjectInits where x.CnProfessionId == cn.CnProfessionId orderby x.SortIndex select x).ToList();
|
||||
foreach (var un in unLists)
|
||||
{
|
||||
unACWP = 0;
|
||||
unBCWP = 0;
|
||||
unBCWS = 0;
|
||||
unmACWP = 0;
|
||||
unmBCWP = 0;
|
||||
unmBCWS = 0;
|
||||
unCV = 0;
|
||||
unSV = 0;
|
||||
unCPI = 0;
|
||||
unSPI = 0;
|
||||
unmCV = 0;
|
||||
unmSV = 0;
|
||||
unmCPI = 0;
|
||||
unmSPI = 0;
|
||||
row4 = table4.NewRow();
|
||||
row4[0] = SQLHelper.GetNewID();
|
||||
row4[2] = un.UnitProjectName;
|
||||
var unDetails = from x in details
|
||||
join y in unitProjects on x.ParentId equals y.UnitProjectId
|
||||
where y.UnitProjectCode == un.UnitProjectCode
|
||||
select x;
|
||||
unmACWP = Funs.GetNewDecimalOrZero(unDetails.Select(x => x.ThisRealCost).Sum().ToString()) / 10000;
|
||||
unmBCWP = Funs.GetNewDecimalOrZero(unDetails.Select(x => x.ThisPlanCost).Sum().ToString()) / 10000;
|
||||
unmBCWS = Funs.GetNewDecimalOrZero(unDetails.Select(x => x.ThisPlanValue).Sum().ToString()) / 10000;
|
||||
unmCV = unmBCWP - unmACWP;
|
||||
unmSV = unmBCWP - unmBCWS;
|
||||
if (unmACWP > 0)
|
||||
{
|
||||
unmCPI = unmBCWP / unmACWP;
|
||||
}
|
||||
if (unmBCWS > 0)
|
||||
{
|
||||
unmSPI = unmBCWP / unmBCWS;
|
||||
}
|
||||
row4[3] = unmBCWP.ToString("0.####");
|
||||
row4[4] = unmBCWS.ToString("0.####");
|
||||
row4[5] = unmACWP.ToString("0.####");
|
||||
row4[6] = unmCV.ToString("0.####");
|
||||
row4[7] = unmSV.ToString("0.####");
|
||||
row4[8] = unmCPI.ToString("0.####");
|
||||
row4[9] = unmSPI.ToString("0.####");
|
||||
unACWP = Funs.GetNewDecimalOrZero(unDetails.Select(x => x.TotalRealCost).Sum().ToString()) / 10000;
|
||||
unBCWP = Funs.GetNewDecimalOrZero(unDetails.Select(x => x.TotalPlanCost).Sum().ToString()) / 10000;
|
||||
unBCWS = Funs.GetNewDecimalOrZero(unDetails.Select(x => x.TotalPlanValue).Sum().ToString()) / 10000;
|
||||
unCV = unBCWP - unACWP;
|
||||
unSV = unBCWP - unBCWS;
|
||||
if (unACWP > 0)
|
||||
{
|
||||
unCPI = unBCWP / unACWP;
|
||||
}
|
||||
if (unBCWS > 0)
|
||||
{
|
||||
unSPI = unBCWP / unBCWS;
|
||||
}
|
||||
row4[10] = unBCWP.ToString("0.####");
|
||||
row4[11] = unBCWS.ToString("0.####");
|
||||
row4[12] = unACWP.ToString("0.####");
|
||||
row4[13] = unCV.ToString("0.####");
|
||||
row4[14] = unSV.ToString("0.####");
|
||||
row4[15] = unCPI.ToString("0.####");
|
||||
row4[16] = unSPI.ToString("0.####");
|
||||
table4.Rows.Add(row4);
|
||||
}
|
||||
}
|
||||
this.Grid4.DataSource = table4;
|
||||
this.Grid4.DataBind();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
@@ -232,7 +370,14 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
|
||||
/// <param name="e"></param>
|
||||
protected void Window1_Close(object sender, WindowCloseEventArgs e)
|
||||
{
|
||||
GetValue();
|
||||
if (!string.IsNullOrEmpty(this.txtMonths.Text.Trim()))
|
||||
{
|
||||
GetValue();
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择月份", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
@@ -243,18 +388,72 @@ namespace FineUIPro.Web.JDGL.CostAnalysis
|
||||
/// <param name="e"></param>
|
||||
protected void btnOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Response.ClearContent();
|
||||
//string filename = Funs.GetNewFileName();
|
||||
//Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("工作量统计" + filename, System.Text.Encoding.UTF8) + ".xls");
|
||||
//Response.ContentType = "application/excel";
|
||||
//Response.ContentEncoding = Encoding.UTF8;
|
||||
//this.Grid1.PageSize = Grid1.RecordCount;
|
||||
//Response.Write(GetGridTableHtml2(Grid1));
|
||||
//Response.End();
|
||||
//DateTime months = Convert.ToDateTime(this.txtMonths.Text.Trim());
|
||||
//DataTable table = BLL.WorkloadStatisticsService.GetTreeDataTable(this.CurrUser.LoginProjectId, months, BLL.Const._Null, this.drpCnProfession.SelectedValue, this.drpUnitProject.SelectedValue, this.drpWbsSet.SelectedValue);
|
||||
//Grid1.DataSource = table;
|
||||
//Grid1.DataBind();
|
||||
if (!string.IsNullOrEmpty(this.txtMonths.Text.Trim()))
|
||||
{
|
||||
string rootPath = Server.MapPath("~/");
|
||||
string initTemplatePath = string.Empty;
|
||||
string uploadfilepath = string.Empty;
|
||||
string newUrl = string.Empty;
|
||||
string filePath = string.Empty;
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
initTemplatePath = Const.JDReportTemplateUrl;
|
||||
uploadfilepath = rootPath + initTemplatePath;
|
||||
newUrl = uploadfilepath.Replace(".docx", "(" + this.txtMonths.Text.Trim() + ")" + ".docx");
|
||||
if (File.Exists(newUrl))
|
||||
{
|
||||
File.Delete(newUrl);
|
||||
}
|
||||
File.Copy(uploadfilepath, newUrl);
|
||||
//更新书签内容
|
||||
Document doc = new Aspose.Words.Document(newUrl);
|
||||
DocumentBuilder builder = new DocumentBuilder(doc);
|
||||
string projectName = string.Empty;
|
||||
var project = ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
|
||||
if (project != null)
|
||||
{
|
||||
projectName = project.ProjectName;
|
||||
}
|
||||
Bookmark bookmarkProjectName = doc.Range.Bookmarks["ProjectName"];
|
||||
if (bookmarkProjectName != null)
|
||||
{
|
||||
bookmarkProjectName.Text = projectName;
|
||||
}
|
||||
Bookmark bookmarkMonths = doc.Range.Bookmarks["Months"];
|
||||
if (bookmarkMonths != null)
|
||||
{
|
||||
string[] strs = this.txtMonths.Text.Trim().Split('-');
|
||||
bookmarkMonths.Text = strs[0] + "年" + strs[1] + "月";
|
||||
}
|
||||
|
||||
//插入图表
|
||||
builder.MoveToBookmark("Chart");
|
||||
Shape shape = builder.InsertChart(ChartType.Line, 432, 252);
|
||||
Chart chart = shape.Chart;
|
||||
chart.Title.Text = "赢得值曲线";
|
||||
ChartSeriesCollection seriesColl = chart.Series;
|
||||
seriesColl.Clear();
|
||||
string[] categories = new string[] { "1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月" };
|
||||
seriesColl.Add("自有人员", categories, new double[] { 1, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
seriesColl.Add("施工人员", categories, new double[] { 3, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
seriesColl.Add("累计安全人工时", categories, new double[] { 5, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 });
|
||||
|
||||
doc.Save(newUrl);
|
||||
string fileName = Path.GetFileName(newUrl);
|
||||
FileInfo info = new FileInfo(newUrl);
|
||||
long fileSize = info.Length;
|
||||
Response.Clear();
|
||||
Response.ContentType = "application/x-zip-compressed";
|
||||
Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
Response.AddHeader("Content-Length", fileSize.ToString());
|
||||
Response.TransmitFile(newUrl, 0, fileSize);
|
||||
Response.Flush();
|
||||
Response.Close();
|
||||
File.Delete(newUrl);
|
||||
}
|
||||
else
|
||||
{
|
||||
ShowNotify("请选择月份", MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user