This commit is contained in:
2021-06-21 14:10:40 +08:00
parent 65a719e331
commit 8bc3189f9f
100 changed files with 9736 additions and 1138 deletions
@@ -9,11 +9,12 @@ using System.Web.UI.WebControls;
namespace FineUIPro.Web.CQMS.ProcessControl
{
public partial class InspectionManagementStatistics :PageBase
public partial class InspectionManagementStatistics : PageBase
{
public DateTime StartDate;
public DateTime NextDate;
public DateTime NewDate;
public DateTime EndDate;
public int SunNumber;
protected void Page_Load(object sender, EventArgs e)
@@ -31,63 +32,123 @@ namespace FineUIPro.Web.CQMS.ProcessControl
/// <param name="cNProfessionalId"></param>
public void BindGvInspectionManagement(string cNProfessionalId)
{
List<Model.InspectionManagementStatistics> StatisticsList = new List<Model.InspectionManagementStatistics>();
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
StartDate = Convert.ToDateTime(project.StartDate);
for (int i = 0; i < i + 1; i++)
if (string.IsNullOrEmpty(this.txtStartTime.Text.Trim()) && string.IsNullOrEmpty(this.txtEndTime.Text.Trim())) //未选择日期,统计项目开始起的每月数据
{
Model.InspectionManagementStatistics Statistics = new Model.InspectionManagementStatistics();
if (i == 0)
List<Model.InspectionManagementStatistics> StatisticsList = new List<Model.InspectionManagementStatistics>();
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
StartDate = Convert.ToDateTime(project.StartDate);
for (int i = 0; i < i + 1; i++)
{
NextDate = Convert.ToDateTime(DateTime.Parse(StartDate.ToString("yyyy-MM-dd")).AddMonths(1).ToShortDateString());
NewDate = Convert.ToDateTime(NextDate.Year + "-" + NextDate.Month + "-25");
Statistics.CheckDate = string.Format("{0:yyyy-MM-dd}", StartDate) + " 至 ";
if (StartDate.Day < 25)
Model.InspectionManagementStatistics Statistics = new Model.InspectionManagementStatistics();
if (i == 0)
{
if (DateTime.Now < NewDate)
NextDate = Convert.ToDateTime(DateTime.Parse(StartDate.ToString("yyyy-MM-dd")).AddMonths(1).ToShortDateString());
NewDate = Convert.ToDateTime(NextDate.Year + "-" + NextDate.Month + "-25");
Statistics.CheckDate = string.Format("{0:yyyy-MM-dd}", StartDate) + " 至 ";
if (StartDate.Day < 25)
{
//统计所给时间段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, DateTime.Now, false);
//统计所给时间段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, DateTime.Now, true);
Statistics.CheckDate += string.Format("{0:yyyy-MM-dd}", DateTime.Now);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
if (DateTime.Now < NewDate)
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
//统计所给时间段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, DateTime.Now, false);
//统计所给时间段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, DateTime.Now, true);
Statistics.CheckDate += string.Format("{0:yyyy-MM-dd}", DateTime.Now);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
Statistics.OneStatistics = "0%";
}
StatisticsList.Add(Statistics);
break;
}
else
{
Statistics.OneStatistics = "0%";
NextDate = Convert.ToDateTime(StartDate.Year + "-" + StartDate.Month + "-25");
//统计所给事件段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, NewDate, false);
//统计所给事件段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, NewDate, true);
Statistics.CheckDate += string.Format("{0:yyyy-MM-dd}", NextDate);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
Statistics.OneStatistics = "0%";
}
}
StatisticsList.Add(Statistics);
break;
}
else
{
NextDate = Convert.ToDateTime(StartDate.Year + "-" + StartDate.Month + "-25");
//统计所给事件段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, NewDate, false);
//统计所给事件段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, NewDate, true);
Statistics.CheckDate += string.Format("{0:yyyy-MM-dd}", NextDate);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
if (DateTime.Now < NewDate)
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
//统计所给事件段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, DateTime.Now, false);
//统计所给事件段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, DateTime.Now, true);
Statistics.CheckDate += string.Format("{0:yyyy-MM-dd}", DateTime.Now);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
Statistics.OneStatistics = "0%";
}
StatisticsList.Add(Statistics);
break;
}
else
{
Statistics.OneStatistics = "0%";
//统计所给事件段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, NewDate, false);
//统计所给事件段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, NewDate, true);
Statistics.CheckDate += string.Format("{0:yyyy-MM-dd}", NewDate);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
Statistics.OneStatistics = "0%";
}
}
}
}
else
{
if (StartDate.Day > 25)
{
Statistics.CheckDate = NewDate.Year + "-" + NewDate.Month + "-" + (NewDate.Day + 1) + " 至 ";
StartDate = Convert.ToDateTime(NewDate.Year + "-" + NewDate.Month + "-" + (NewDate.Day + 1));//获取上一记录的结束日期加一天为本次记录的开始日期
}
else
{
Statistics.CheckDate = NextDate.Year + "-" + NextDate.Month + "-" + (NextDate.Day + 1) + " 至 ";
StartDate = Convert.ToDateTime(NextDate.Year + "-" + NextDate.Month + "-" + (NextDate.Day + 1));//获取上一记录的结束日期加一天为本次记录的开始日期
}
NextDate = Convert.ToDateTime(DateTime.Parse(NextDate.ToString("yyyy-MM-dd")).AddMonths(1).ToShortDateString());
NewDate = Convert.ToDateTime(NextDate.Year + "-" + NextDate.Month + "-25");
if (DateTime.Now < NewDate)
{
//统计所给事件段的全部数量
@@ -129,95 +190,72 @@ namespace FineUIPro.Web.CQMS.ProcessControl
}
}
}
StatisticsList.Add(Statistics);
}
Model.InspectionManagementStatistics StatisticsLast = new Model.InspectionManagementStatistics();
StatisticsLast.CheckDate = "合计";
int sum1 = 0;
int sum2 = 0;
foreach (Model.InspectionManagementStatistics item in StatisticsList)
{
sum1 += item.OneStatisticsSunNumber;
sum2 += item.SunNumber;
}
StatisticsLast.OneStatisticsSunNumber = sum1;
StatisticsLast.SunNumber = sum2;
if (sum2 != 0)//被除数不能为零
{
StatisticsLast.OneStatistics = Math.Round((double)sum1 / (double)sum2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
if (StartDate.Day > 25)
{
Statistics.CheckDate = NewDate.Year + "-" + NewDate.Month + "-" + (NewDate.Day + 1) + " 至 ";
StartDate = Convert.ToDateTime(NewDate.Year + "-" + NewDate.Month + "-" + (NewDate.Day + 1));//获取上一记录的结束日期加一天为本次记录的开始日期
}
else
{
Statistics.CheckDate = NextDate.Year + "-" + NextDate.Month + "-" + (NextDate.Day + 1) + " 至 ";
StartDate = Convert.ToDateTime(NextDate.Year + "-" + NextDate.Month + "-" + (NextDate.Day + 1));//获取上一记录的结束日期加一天为本次记录的开始日期
}
NextDate = Convert.ToDateTime(DateTime.Parse(NextDate.ToString("yyyy-MM-dd")).AddMonths(1).ToShortDateString());
NewDate = Convert.ToDateTime(NextDate.Year + "-" + NextDate.Month + "-25");
if (DateTime.Now < NewDate)
{
//统计所给事件段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, DateTime.Now, false);
//统计所给事件段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, DateTime.Now, true);
Statistics.CheckDate += string.Format("{0:yyyy-MM-dd}", DateTime.Now);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
Statistics.OneStatistics = "0%";
}
StatisticsList.Add(Statistics);
break;
}
else
{
//统计所给事件段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, NewDate, false);
//统计所给事件段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, NewDate, true);
Statistics.CheckDate += string.Format("{0:yyyy-MM-dd}", NewDate);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
Statistics.OneStatistics = "0%";
}
}
StatisticsLast.OneStatistics = "0%";
}
StatisticsList.Add(StatisticsLast);
this.Grid1.DataSource = StatisticsList;
this.Grid1.DataBind();
}
else //选择日期,统计对应时间段内的数据
{
List<Model.InspectionManagementStatistics> StatisticsList = new List<Model.InspectionManagementStatistics>();
Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId);
StartDate = Convert.ToDateTime(project.StartDate);
EndDate = DateTime.Now;
if (!string.IsNullOrEmpty(this.txtStartTime.Text.Trim()))
{
StartDate = Convert.ToDateTime(this.txtStartTime.Text.Trim());
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text.Trim()))
{
EndDate = Convert.ToDateTime(this.txtEndTime.Text.Trim());
}
Model.InspectionManagementStatistics Statistics = new Model.InspectionManagementStatistics();
//统计所给时间段的全部数量
List<Model.View_CQMS_InspectionManagementDetail> managementListSunNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, EndDate, false);
//统计所给时间段的合格数量
List<Model.View_CQMS_InspectionManagementDetail> managementListOneNumber = BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate(this.CurrUser.LoginProjectId, cNProfessionalId, StartDate, EndDate, true);
Statistics.CheckDate = string.Format("{0:yyyy-MM-dd}", StartDate) + " 至 " + string.Format("{0:yyyy-MM-dd}", EndDate);
Statistics.SunNumber = managementListSunNumber.Count();
Statistics.OneStatisticsSunNumber = managementListOneNumber.Count();
if (managementListSunNumber.Count() != 0)//被除数不能为零
{
Statistics.OneStatistics = Math.Round((double)managementListOneNumber.Count() / (double)managementListSunNumber.Count() * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
Statistics.OneStatistics = "0%";
}
StatisticsList.Add(Statistics);
this.Grid1.DataSource = StatisticsList;
this.Grid1.DataBind();
}
Model.InspectionManagementStatistics StatisticsLast = new Model.InspectionManagementStatistics();
StatisticsLast.CheckDate = "合计";
int sum1 = 0;
int sum2 = 0;
foreach (Model.InspectionManagementStatistics item in StatisticsList)
{
sum1 += item.OneStatisticsSunNumber;
sum2 += item.SunNumber;
}
StatisticsLast.OneStatisticsSunNumber = sum1;
StatisticsLast.SunNumber = sum2;
if (sum2 != 0)//被除数不能为零
{
StatisticsLast.OneStatistics = Math.Round((double)sum1 / (double)sum2 * 100, 2) + "%";//保留两位小数、后四舍五入
}
else
{
StatisticsLast.OneStatistics = "0%";
}
StatisticsList.Add(StatisticsLast);
this.Grid1.DataSource = StatisticsList;
this.Grid1.DataBind();
}
#endregion
protected void btnSearch_Click(object sender, EventArgs e)
{
if (this.drpCNProfessional.SelectedValue !=BLL.Const._Null)
if (this.drpCNProfessional.SelectedValue != BLL.Const._Null)
{
BindGvInspectionManagement(this.drpCNProfessional.SelectedValue);
}