CNCEC_SUBQHSE_WUHUAN/SGGL/FineUIPro.Web/common/mainProject.aspx.cs

376 lines
24 KiB
C#

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
using BLL;
namespace FineUIPro.Web.common
{
public partial class mainProject : PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Model.SGGLDB db = Funs.DB;
//未遂事故
var wsAccidentList1 = from x in db.Accident_AccidentPersonRecord
join y in db.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
where y.AccidentTypeName.Contains("未遂") && x.ProjectId == this.CurrUser.LoginProjectId
select x;
var wsAccidentList2 = from x in db.Accident_AccidentReportOther
join y in db.Sys_Const on x.AccidentTypeId equals y.ConstValue
where y.ConstText.Contains("未遂") && x.ProjectId == this.CurrUser.LoginProjectId
select x;
this.divWS.InnerHtml = (wsAccidentList1.Count() + wsAccidentList2.Count()).ToString();
//隐患整改
var getRectify = db.Check_RectifyNotices.Where(x => x.ProjectId == this.CurrUser.LoginProjectId);
this.divYH.InnerHtml = getRectify.Count().ToString();
//安全人工时
int wHours = db.SitePerson_PersonInOutNumber.Where(x => x.ProjectId == this.CurrUser.LoginProjectId).Max(x => x.WorkHours) ?? 0;
this.divRGS.InnerHtml = wHours.ToString();
//教育培训
var getTrainRecord = from x in db.EduTrain_TrainRecord where x.ProjectId == this.CurrUser.LoginProjectId select x;
this.divPX.InnerHtml = getTrainRecord.Count().ToString();
//质量问题
var checkList = from x in db.Check_CheckControl where x.ProjectId == this.CurrUser.LoginProjectId select x;
this.divZLWT.InnerHtml = checkList.Count().ToString();
//质量共检数据
var inspectionManagements = from x in db.ProcessControl_InspectionManagement where x.ProjectId == this.CurrUser.LoginProjectId select x;
this.divZLGJ.InnerHtml = inspectionManagements.Count().ToString();
//验收数据
this.divYS.InnerHtml = inspectionManagements.Count(x => x.IsOnceQualified == true).ToString();
//竣工资料
this.divJGZL.InnerHtml = inspectionManagements.Count(x => x.IsOnceQualified == true).ToString();
//NCR
var NCRManagements = from x in db.Comprehensive_NCRManagement where x.ProjectId == this.CurrUser.LoginProjectId select x;
this.divNCR.InnerHtml = NCRManagements.Count().ToString();
//变更单
var designChangeOrders = from x in db.Comprehensive_DesignChangeOrder where x.ProjectId == this.CurrUser.LoginProjectId select x;
this.divBG.InnerHtml = designChangeOrders.Count().ToString();
//工程量完成情况
string date = string.Empty;
var quantityCompletions = from x in Funs.DB.View_JDGL_QuantityCompletion where x.ProjectId == this.CurrUser.LoginProjectId orderby x.SortIndex, x.Name select x;
if (quantityCompletions.Count() > 0)
{
string quantityCompletionStr = "<div class='jd-item'><div class='item jd-title'>序号</div><div class='item jd-title'>类型</div><div class='item jd-title'>单位</div><div class='item jd-title'>设计数量</div><div class='item jd-title'>计划完成</div><div class='item jd-title'>实际完成</div><div class='item jd-title'>计划完成率</div><div class='item jd-title'>累计计划完成</div><div class='item jd-title'>累计实际完成</div><div class='item jd-title'>累计计划完成率</div><div class='item jd-title'>总完成率</div></div>";
int i = 1;
foreach (var item in quantityCompletions)
{
quantityCompletionStr += "<div class='jd-item'><div class='item'>"
+ i + "</div><div class='item'>"
+ item.Name + "</div><div class='item'>"
+ item.Unit + "</div><div class='item'>"
+ (item.DesignNum != null ? item.DesignNum.Value.ToString("F0") : "0") + "</div><div class='item'>"
+ (item.PlanNum != null ? item.PlanNum.Value.ToString("F0") : "0") + "</div><div class='item'>"
+ (item.RealNum != null ? item.RealNum.Value.ToString("F0") : "0") + "</div><div class='item'>"
+ item.Rate + "</div><div class='item'>"
+ item.TotalPlanNum + "</div><div class='item'>"
+ item.TotalRealNum + "</div><div class='item'>"
+ item.TotalRate + "</div><div class='item'>"
+ item.SumRate + "</div></div>";
i++;
}
divGZL.InnerHtml = quantityCompletionStr;
if (quantityCompletions.Count() > 0)
{
if (quantityCompletions.First() != null && quantityCompletions.First().EndDate != null)
{
date = " (" + string.Format("{0:yyyy-MM}", quantityCompletions.First().EndDate) + ")";
}
}
}
else //低温储罐项目显示低温储罐数据
{
var lowTankCompletions = from x in Funs.DB.View_JDGL_LowTankCompletion where x.ProjectId == this.CurrUser.LoginProjectId orderby x.Code select x;
string quantityCompletionStr = "<div class='jd-item'><div class='item jd-title'>序号</div><div class='item jd-title'>储罐编号</div><div class='item jd-title'>类型</div><div class='item jd-title'>单位</div><div class='item jd-title'>设计数量</div><div class='item jd-title'>计划完成</div><div class='item jd-title'>实际完成</div><div class='item jd-title'>计划完成率</div><div class='item jd-title'>累计计划完成</div><div class='item jd-title'>累计实际完成</div><div class='item jd-title'>累计计划完成率</div><div class='item jd-title'>总完成率</div></div>";
int i = 1;
foreach (var item in lowTankCompletions)
{
quantityCompletionStr += "<div class='jd-item'><div class='item'>"
+ i + "</div><div class='item'>"
+ item.Code + "</div><div class='item'>"
+ item.Name + "</div><div class='item'>"
+ item.Unit + "</div><div class='item'>"
+ (item.TotalNum != null ? item.TotalNum.Value.ToString("F0") : "0") + "</div><div class='item'>"
+ (item.PlanNum != null ? item.PlanNum.Value.ToString("F0") : "0") + "</div><div class='item'>"
+ (item.RealNum != null ? item.RealNum.Value.ToString("F0") : "0") + "</div><div class='item'>"
+ item.Rate + "</div><div class='item'>"
+ item.TotalPlanNum + "</div><div class='item'>"
+ item.TotalRealNum + "</div><div class='item'>"
+ item.TotalRate + "</div><div class='item'>"
+ item.SumRate + "</div></div>";
i++;
}
divGZL.InnerHtml = quantityCompletionStr;
if (lowTankCompletions.Count() > 0)
{
if (lowTankCompletions.First() != null && lowTankCompletions.First().EndDate != null)
{
date = " (" + string.Format("{0:yyyy-MM}", lowTankCompletions.First().EndDate) + ")";
}
}
}
divMonth.InnerHtml = "专业工作量表" + date;
}
}
#region 线
protected string Two
{
get
{
List<Model.SingleSerie> series = new List<Model.SingleSerie>();
Model.BusinessColumn businessColumn = new Model.BusinessColumn();
List<string> listCategories = new List<string>();
businessColumn.title = "赢得值曲线";
Model.Project_Installation installation = BLL.Project_InstallationService.GetProjectInstallationByProjectId(this.CurrUser.LoginProjectId);
if (installation != null)
{
Model.SingleSerie s = new Model.SingleSerie();
Model.SingleSerie s2 = new Model.SingleSerie();
Model.SingleSerie s3 = new Model.SingleSerie();
Model.SingleSerie s4 = new Model.SingleSerie();
Model.SingleSerie s5 = new Model.SingleSerie();
Model.SingleSerie s6 = new Model.SingleSerie();
List<double> listdata = new List<double>();
List<double> listdata2 = new List<double>();
List<double> listdata3 = new List<double>();
List<double> listdata4 = new List<double>();
List<double> listdata5 = new List<double>();
List<double> listdata6 = new List<double>();
string strSql = "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 ParentId=@Id order by t.Months";
//string date = DateTime.Now.Year + "-" + DateTime.Now.Month + "-01";
SqlParameter[] parameter = new SqlParameter[]
{
new SqlParameter("@Id",installation.InstallationId),
//new SqlParameter("@Months",date),
};
DataTable dt = SQLHelper.GetDataTableRunText(strSql, parameter);
decimal lastbcws = 0, bcws = 0, lastacwp = 0, acwp = 0, lastbcwp = 0, bcwp = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
dt.Rows[i]["本月已完工作实际费用-ACWP"] = Funs.GetNewDecimalOrZero(dt.Rows[i]["本月已完工作实际费用-ACWP"].ToString()) / 10000;
dt.Rows[i]["本月已完工作预算费用-BCWP"] = Funs.GetNewDecimalOrZero(dt.Rows[i]["本月已完工作预算费用-BCWP"].ToString()) / 10000;
dt.Rows[i]["本月计划工作预算费用-BCWS"] = Funs.GetNewDecimalOrZero(dt.Rows[i]["本月计划工作预算费用-BCWS"].ToString()) / 10000;
bcws = Funs.GetNewDecimalOrZero(dt.Rows[i]["累计计划工作预算费用-BCWS"].ToString());
acwp = Funs.GetNewDecimalOrZero(dt.Rows[i]["累计已完工作实际费用-ACWP"].ToString());
bcwp = Funs.GetNewDecimalOrZero(dt.Rows[i]["累计已完工作预算费用-BCWP"].ToString());
if (bcws == lastbcws)
{
if (Funs.GetNewDateTimeOrNow(dt.Rows[i]["Months"].ToString()) > DateTime.Now)
{
dt.Rows[i]["累计计划工作预算费用-BCWS"] = 0;
}
else
{
dt.Rows[i]["累计计划工作预算费用-BCWS"] = bcws / 10000;
}
}
else
{
dt.Rows[i]["累计计划工作预算费用-BCWS"] = bcws / 10000;
}
if (acwp == lastacwp)
{
if (Funs.GetNewDateTimeOrNow(dt.Rows[i]["Months"].ToString()) > DateTime.Now)
{
dt.Rows[i]["累计已完工作实际费用-ACWP"] = 0;
}
else
{
dt.Rows[i]["累计已完工作实际费用-ACWP"] = acwp / 10000;
}
}
else
{
dt.Rows[i]["累计已完工作实际费用-ACWP"] = acwp / 10000;
}
if (bcwp == lastbcwp)
{
if (Funs.GetNewDateTimeOrNow(dt.Rows[i]["Months"].ToString()) > DateTime.Now)
{
dt.Rows[i]["累计已完工作预算费用-BCWP"] = 0;
}
else
{
dt.Rows[i]["累计已完工作预算费用-BCWP"] = bcwp / 10000;
}
}
else
{
dt.Rows[i]["累计已完工作预算费用-BCWP"] = bcwp / 10000;
}
lastbcws = bcws;
lastacwp = acwp;
lastbcwp = bcwp;
listCategories.Add(dt.Rows[i]["月份"].ToString());
if (Funs.GetNewDateTimeOrNow(dt.Rows[i]["Months"].ToString()) <= DateTime.Now)
{
listdata.Add(Convert.ToDouble(dt.Rows[i]["本月计划工作预算费用-BCWS"]));
listdata2.Add(Convert.ToDouble(dt.Rows[i]["累计计划工作预算费用-BCWS"]));
listdata3.Add(Convert.ToDouble(dt.Rows[i]["本月已完工作预算费用-BCWP"]));
listdata4.Add(Convert.ToDouble(dt.Rows[i]["累计已完工作预算费用-BCWP"]));
listdata5.Add(Convert.ToDouble(dt.Rows[i]["本月已完工作实际费用-ACWP"]));
listdata6.Add(Convert.ToDouble(dt.Rows[i]["累计已完工作实际费用-ACWP"]));
}
}
s.data = listdata;
s2.data = listdata2;
s3.data = listdata3;
s4.data = listdata4;
s5.data = listdata5;
s6.data = listdata6;
series.Add(s);
series.Add(s2);
series.Add(s3);
series.Add(s4);
series.Add(s5);
series.Add(s6);
businessColumn.categories = listCategories;
businessColumn.series = series;
}
return JsonConvert.SerializeObject(businessColumn);
}
}
#endregion
#region
protected string Person
{
get
{
Model.SGGLDB db = Funs.DB;
List<Model.SingleSerie> series = new List<Model.SingleSerie>();
Model.BusinessColumn businessColumn = new Model.BusinessColumn();
List<string> listCategories = new List<string>();
var persons = from x in db.SitePerson_Person where x.ProjectId == this.CurrUser.LoginProjectId && x.IsUsed == true select x;
var posts = (from x in persons
join y in db.Base_WorkPost on x.WorkPostId equals y.WorkPostId
select y).Distinct();
Model.SingleSerie s = new Model.SingleSerie();
List<double> listdata = new List<double>();
//木工
listCategories.Add("木工");
int workPostCount1 = persons.Count(x => x.WorkPostId == Const.WorkPost_Carpentry);
listdata.Add(workPostCount1);
//钢筋工
listCategories.Add("钢筋工");
int workPostCount2 = persons.Count(x => x.WorkPostId == Const.WorkPost_SteelWorker);
listdata.Add(workPostCount2);
//瓦工
listCategories.Add("瓦工");
int workPostCount3 = persons.Count(x => x.WorkPostId == Const.WorkPost_Bricklayer);
listdata.Add(workPostCount3);
//混凝土工
listCategories.Add("混凝土工");
int workPostCount4 = persons.Count(x => x.WorkPostId == Const.WorkPost_ConcreteWorker);
listdata.Add(workPostCount4);
//钳工
listCategories.Add("钳工");
int workPostCount5 = persons.Count(x => x.WorkPostId == Const.WorkPost_Fitter1 || x.WorkPostId == Const.WorkPost_Fitter2);
listdata.Add(workPostCount5);
//焊工
listCategories.Add("焊工");
int workPostCount6 = persons.Count(x => x.WorkPostId == Const.WorkPost_Welder1 || x.WorkPostId == Const.WorkPost_Welder2 ||
x.WorkPostId == Const.WorkPost_Welder3 || x.WorkPostId == Const.WorkPost_Welder4 || x.WorkPostId == Const.WorkPost_Welder5);
listdata.Add(workPostCount6);
//铆工
listCategories.Add("铆工");
int workPostCount7 = persons.Count(x => x.WorkPostId == Const.WorkPost_Riveter);
listdata.Add(workPostCount7);
//管工
listCategories.Add("管工");
int workPostCount8 = persons.Count(x => x.WorkPostId == Const.WorkPost_Foreman);
listdata.Add(workPostCount8);
//电工
listCategories.Add("电工");
int workPostCount9 = persons.Count(x => x.WorkPostId == Const.WorkPost_Electrician1 || x.WorkPostId == Const.WorkPost_Electrician2
|| x.WorkPostId == Const.WorkPost_Electrician3);
listdata.Add(workPostCount9);
//仪表工
listCategories.Add("仪表工");
int workPostCount10 = persons.Count(x => x.WorkPostId == Const.WorkPost_Instrumentalist);
listdata.Add(workPostCount10);
//防腐保温工
listCategories.Add("防腐保温工");
int workPostCount11 = persons.Count(x => x.WorkPostId == Const.WorkPost_AnticorrosionWorker);
listdata.Add(workPostCount11);
//防腐保温工
listCategories.Add("管理人员");
int workPostCount12 = (from x in persons
join y in db.Base_WorkPost on x.WorkPostId equals y.WorkPostId
where y.PostType == Const.PostType_1
select x).Count();
listdata.Add(workPostCount12);
//其他
listCategories.Add("其他");
int workPostCount13 = persons.Count() - workPostCount1 - workPostCount2 - workPostCount3 - workPostCount4 - workPostCount5 - workPostCount6 - workPostCount7
- workPostCount8 - workPostCount9 - workPostCount10 - workPostCount11 - workPostCount12;
listdata.Add(workPostCount13);
s.data = listdata;
series.Add(s);
businessColumn.categories = listCategories;
businessColumn.title = persons.Count().ToString();
businessColumn.series = series;
return JsonConvert.SerializeObject(businessColumn);
}
}
#endregion
#region
protected string swiper_One
{
get
{
var getGJSX = (from x in Funs.DB.GJSX
join y in Funs.DB.Base_QuestionType on x.QuestionTypeID equals y.QuestionTypeID
where x.ProjectId == this.CurrUser.LoginProjectId && x.State != "0"
orderby x.CreateDate
select new { x.GJSXID, x.Detail, x.CreateDate, x.ProjectId, y.QuestionTypeName }).Distinct().Take(20);
string strNoticeHtml = string.Empty;
var readIds = from x in Funs.DB.Sys_UserRead where x.UserId == this.CurrUser.UserId select x.DataId;
foreach (var item in getGJSX)
{
string url = "../PZHGL/GJSX/GJSXListEdit.aspx?EditType=Edit&Id=" + item.GJSXID;
//var attachFile = BLL.AttachFileService.GetAttachFile(item.NoticeId, BLL.Const.ServerNoticeMenuId);
//if (attachFile != null && !string.IsNullOrEmpty(attachFile.AttachUrl))
//{
// url = "../" + attachFile.AttachUrl.Split(',')[0].Replace("\\", "/");
//}
if (item.QuestionTypeName.Contains("紧急"))
{
strNoticeHtml += "<li data-id=\"" + url + "\" notice-id=\"" + item.GJSXID + "\" class=\"c-item swiper-slide\"><div class=\"tit\" title=\"" + item.Detail + "\"><div class=\"flex\" ><div class=\"tit-t flex1\" style=\"color:red;\">" + item.Detail + "</div><div class=\"tit-v\">" + string.Format("{0:yyyy-MM-dd}", item.CreateDate) + "</div></div></div></li>";
}
else if (item.QuestionTypeName.Contains("重要"))
{
strNoticeHtml += "<li data-id=\"" + url + "\" notice-id=\"" + item.GJSXID + "\" class=\"c-item swiper-slide\"><div class=\"tit\" title=\"" + item.Detail + "\"><div class=\"flex\" ><div class=\"tit-t flex1\" style=\"color:yellow;\">" + item.Detail + "</div><div class=\"tit-v\">" + string.Format("{0:yyyy-MM-dd}", item.CreateDate) + "</div></div></div></li>";
}
else
{
strNoticeHtml += "<li data-id=\"" + url + "\" notice-id=\"" + item.GJSXID + "\" class=\"c-item swiper-slide\"><div class=\"tit\" title=\"" + item.Detail + "\"><div class=\"flex\" ><div class=\"tit-t flex1\">" + item.Detail + "</div><div class=\"tit-v\">" + string.Format("{0:yyyy-MM-dd}", item.CreateDate) + "</div></div></div></li>";
}
}
return "<ul class=\"content-ul swiper-wrapper\">" + strNoticeHtml + "</ul>";
}
}
#endregion
protected void imgBtn_Click(object sender, EventArgs e)
{
Model.GJSX gjsx = BLL.GJSXService.GetGJSXById(this.hdNoticeId.Value);
if (gjsx != null)
{
BLL.APIUserService.getSaveUserRead(BLL.Const.GJSXMenuId, gjsx.ProjectId, this.CurrUser.UserId, gjsx.GJSXID);
}
}
}
}