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

422 lines
15 KiB
C#

using BLL;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.common
{
public partial class main_new1 : PageBase
{
/// <summary>
/// 页面加载
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//质量问题治理数据
getProblemNums();
//质量验收图表
getInspectionManagementInfo();
//NCR数据图表
getNcrInfo();
//资质预警
getEarlyWarningCounts();
}
}
/// <summary>
/// 获取企业总部人数
/// </summary>
/// <returns></returns>
public static int GetCompanyPersonNum()
{
string unitId = string.Empty;
var thisUnit = CommonService.GetIsThisUnit();
if (thisUnit != null)
{
unitId = thisUnit.UnitId;
}
int result = (from x in Funs.DB.Person_CompanyBranchPerson
where x.IsOnJob == true && x.UnitId == unitId
select x).Count();
return result;
}
/// <summary>
/// 获取分支机构人数
/// </summary>
/// <returns></returns>
public static int GetBranchPersonNum()
{
string unitId = string.Empty;
var thisUnit = CommonService.GetIsThisUnit();
if (thisUnit != null)
{
unitId = thisUnit.UnitId;
}
int result = (from x in Funs.DB.Person_CompanyBranchPerson
where x.IsOnJob == true && x.UnitId != unitId
select x).Count();
return result;
}
/// <summary>
/// 获取项目部人数
/// </summary>
/// <returns></returns>
public static int GetProjectPersonNum()
{
int result = (from x in Funs.DB.SitePerson_Person
join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId
where y.IsCQMS == true && x.IsUsed == true
select x).Count();
return result;
}
/// <summary>
/// 获取在用计量器具数
/// </summary>
/// <returns></returns>
public static int GetUseNum()
{
int result = (from x in Funs.DB.Comprehensive_InspectionMachine
where x.IsOnSite == true && x.InspectionType.Contains("计量")
select x).Count();
return result;
}
/// <summary>
/// 获取校准合格数
/// </summary>
/// <returns></returns>
public static int GetOKNum()
{
int result = (from x in Funs.DB.Comprehensive_InspectionMachine
where x.IsOnSite == true && x.InspectionType.Contains("计量") && x.IsCheckOK == true
select x).Count();
return result;
}
/// <summary>
/// 机械预警
/// </summary>
/// <returns></returns>
public static int GetJxyjNum() {
int result = 0;
//机具报验的到期提醒和过期提醒记录数加一起
//机具报验的到期提醒数
var num1 = Funs.DB.Comprehensive_InspectionMachine.Where(x => x.IsOnSite == true && DateTime.Now < x.NextTestDate
&& ((DateTime)x.NextTestDate).AddDays(-15) < DateTime.Now).Count();
//过期提醒记录数
var num2 = Funs.DB.Comprehensive_InspectionMachine.Where(x => x.IsOnSite == true && x.NextTestDate<DateTime.Now).Count();
result = num1 + num2;
return result;
}
/// <summary>
/// 获取质量培训人次数
/// </summary>
/// <returns></returns>
public static int GetTrainPersonNum()
{
DateTime date = DateTime.Now.AddDays(-1);
int result = (from x in Funs.DB.Comprehensive_InspectionPerson
where x.IsTrain == true && x.CompileDate.Value.Year == date.Year && x.CompileDate.Value.Month == date.Month && x.CompileDate.Value.Day == date.Day
select x).Count();
return result;
}
/// <summary>
/// 获取技术交底人次数
/// </summary>
/// <returns></returns>
public static int GetTechnicalDisclosePersonNum()
{
DateTime date = DateTime.Now.AddDays(-1);
var result = (from x in Funs.DB.Comprehensive_DesignDetails
where x.DetailsDate.Value.Year == date.Year && x.DetailsDate.Value.Month == date.Month && x.DetailsDate.Value.Day == date.Day
select x.JoinPersonNum).ToList().Sum(x => x.Value);
var q = Funs.GetNewIntOrZero(result.ToString());
return q;
}
/// <summary>
/// 资质预警
/// </summary>
private void getEarlyWarningCounts()
{
int allCount = 0;
var getPersonQualitys = from x in Funs.DB.QualityAudit_PersonQuality
join y in Funs.DB.SitePerson_Person on x.PersonId equals y.PersonId
where x.LimitDate.HasValue && x.LimitDate < DateTime.Now
select x;
//// 预警人数
allCount = getPersonQualitys.Count();
this.spanQualityChartAnalysis.InnerHtml = allCount.ToString();
}
#region
/// <summary>
/// 获取整改完成数
/// </summary>
/// <returns></returns>
public static int GetProblemCompletedNum()
{
int result = (from x in Funs.DB.Check_CheckControl
where x.CheckDate <= DateTime.Now && x.State == "7"
select x).Count();
return result;
}
/// <summary>
/// 获取未整改数
/// </summary>
/// <returns></returns>
public static int GetProblemNotCompletedNum()
{
int result = (from x in Funs.DB.Check_CheckControl
where x.CheckDate <= DateTime.Now && x.State != "7"
select x).Count();
return result;
}
/// <summary>
/// 整改率
/// </summary>
/// <returns></returns>
public static string GetProblemZgl()
{
string zgl = String.Format("{0:N2}", 100.0 * GetProblemCompletedNum() / (GetProblemCompletedNum() + GetProblemNotCompletedNum()));
return zgl + "%";
}
/// <summary>
/// 质量问题治理数据
/// </summary>
protected string ProblemNum;
protected void getProblemNums()
{
var num1 = GetProblemNum();
var num2 = GetProblemCompletedNum();
var num3 = GetProblemNotCompletedNum();
ProblemNum = "'" + num1 + "'," +
"'" + num2 + "'," +
"'" + num3 + "'," +
"'" + String.Format("{0:N2}", 100.0 * num2 / (num2 + num3)) + "'";
}
/// 获取问题个数
/// </summary>
/// <returns></returns>
public static int GetProblemNum()
{
int result = (from x in Funs.DB.Check_CheckControl
where x.CheckDate <= DateTime.Now
select x).Count();
return result;
}
#endregion
/// <summary>
/// 获取焊工总数
/// </summary>
/// <returns></returns>
public static int GetWelderNum()
{
int result = (from x in Funs.DB.BS_Welder
where x.WED_IfOnGuard == true
select x).Count();
return result;
}
/// <summary>
/// 获取总达因数
/// </summary>
/// <returns></returns>
public static int GetTotalDineNum()
{
int result = 0;
var getD1 = from x in Funs.DB.HJGL_FL_TotalQuantity
select x;
if (getD1.Count() > 0)
{
foreach (var item in getD1)
{
result += Funs.GetNewIntOrZero(item.TotalWeldQuantity.Split('.')[0]);
}
}
else
{
var getD2 = (from x in Funs.DB.HJGL_FL_Data
orderby x.CompileDate descending
select x).FirstOrDefault();
if (getD2 != null)
{
result = Funs.GetNewIntOrZero(getD2.TotalWeldQuantity.Split('.')[0]);
}
}
return result;
}
/// <summary>
/// 获取完成达因数
/// </summary>
/// <returns></returns>
public static int GetCompleteDineNum()
{
int result = 0;
var getD1 = from x in Funs.DB.HJGL_FL_TotalQuantity
select x;
if (getD1.Count() > 0)
{
foreach (var item in getD1)
{
result += Funs.GetNewIntOrZero(item.TotalCompleted.Split('.')[0]);
}
}
else
{
var getD2 = (from x in Funs.DB.HJGL_FL_Data
orderby x.CompileDate descending
select x).FirstOrDefault();
if (getD2 != null)
{
result = Funs.GetNewIntOrZero(getD2.TotalCompleted.Split('.')[0]);
}
}
return result;
}
/// <summary>
/// 获取总片数
/// </summary>
/// <returns></returns>
public static int GetTotalFilmNum()
{
int result = Convert.ToInt32((from x in Funs.DB.CH_CheckItem
join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
select x.CHT_TotalFilm).ToList().Sum());
return result;
}
/// <summary>
/// 获取合格片数
/// </summary>
/// <returns></returns>
public static int GetOKFilmNum()
{
int result = Convert.ToInt32((from x in Funs.DB.CH_CheckItem
join y in Funs.DB.CH_Check on x.CHT_CheckID equals y.CHT_CheckID
select x.CHT_PassFilm).ToList().Sum());
return result;
}
/// <summary>
/// 一次拍片合格率
/// </summary>
/// <returns></returns>
public static string GetOKFilmHgl()
{
string zgl = "0";
if (GetOKFilmNum()>0)
{
zgl = String.Format("{0:N2}", 100.0 * GetOKFilmNum() / GetTotalFilmNum());
}
return zgl + "%";
}
#region
//专业
protected string InspectionManagementZy;
//总计
protected string InspectionManagementSumCount;
//合格
protected string InspectionManagementOkCount;
//一次验收合格率
protected string InspectionManagementOneOkCount;
private void getInspectionManagementInfo() {
var q = (from x in Funs.DB.Base_CNProfessional where x.CNProfessionalId != BLL.Const.CNProfessionalConstructId orderby x.SortIndex select x).ToList();
foreach (var item in q)
{
//获取专业
InspectionManagementZy += "'" + item.ProfessionalName + "',";
//根据专业获取总计
var num1 = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals y.InspectionId
where y.CNProfessionalId == item.CNProfessionalId
select x).ToList().Count;
InspectionManagementSumCount += "'"+ num1 + "',";
//根据专业获取合格数
var num2 = (from x in Funs.DB.ProcessControl_InspectionManagementDetail
join y in Funs.DB.ProcessControl_InspectionManagement on x.InspectionId equals y.InspectionId
where y.CNProfessionalId == item.CNProfessionalId && y.IsOnceQualified==true
select x).ToList().Count;
InspectionManagementOkCount += "'" + num2 + "',";
//一次验收合格率
var hgl = "0";
if (num1>0)
{
hgl+= String.Format("{0:N2}", 100.0 * num2 / num1);
}
InspectionManagementOneOkCount += "'" + hgl + "',";
}
InspectionManagementZy = InspectionManagementZy.TrimEnd(',');
InspectionManagementSumCount = InspectionManagementSumCount.TrimEnd(',');
InspectionManagementOkCount = InspectionManagementOkCount.TrimEnd(',');
InspectionManagementOneOkCount = InspectionManagementOneOkCount.TrimEnd(',');
}
#endregion
#region NCR数据
//整改闭环项
protected string ncrZgbhx;
//未整改完成项
protected string ncrwZgbhx;
//整改率
protected string ncrZgl="0%";
//图表数据
//专业
protected string ncrZy;
protected string ncrCount;
private void getNcrInfo()
{
//闭环项 有完成日期的
var num1 = Funs.DB.Comprehensive_NCRManagement.Where(x => x.CompleteDate != null).Count();
var num2 = Funs.DB.Comprehensive_NCRManagement.Where(x => x.CompleteDate == null).Count();
ncrZgbhx = num1.ToString();
ncrwZgbhx = num2.ToString();
if ((num1 + num2) >0)
{
ncrZgl= String.Format("{0:N2}", 100.0 * num1 / (num1 + num2))+"%";
}
//加载专业
var list = (from x in Funs.DB.Base_CNProfessional where x.CNProfessionalId != BLL.Const.CNProfessionalConstructId orderby x.SortIndex select x).ToList();
foreach (var item in list)
{
ncrZy += "'"+item.ProfessionalName+"',";
//根据专业加载数据量
var num3= Funs.DB.Comprehensive_NCRManagement.Where(x => x.CNProfessionalId==item.CNProfessionalId).Count();
ncrCount += "'"+num3+"',";
}
ncrZy = ncrZy.TrimEnd(',');
ncrCount = ncrCount.TrimEnd(',');
}
#endregion
}
}