using BLL; using FineUIPro.Web.BaseInfo; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Runtime.InteropServices.ComTypes; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace FineUIPro.Web.common { public partial class main_new1 : PageBase { protected string divProjectImg; protected string hjallNumber = "0"; protected string hjfinishNumber = "0"; protected string hjzgl = "0"; /// /// 页面加载 /// /// /// protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ProjectService.InitProjectShortNameByStateDropDownList(this.drpProject, this.CurrUser.UserId, BLL.Const.ProjectState_1, false); if (this.drpProject.Items.Count > 0) { this.drpProject.SelectedIndex = 0; } divProjectImg = "
"; //质量问题治理数据 getProblemNums(); //质量验收图表 getInspectionManagementInfo(); //NCR数据图表 getNcrInfo(); //资质预警 getEarlyWarningCounts(); //在建项目 var allProjects = ProjectService.GetAllProjectDropDownList(); //焊接数据 double result = 0; Model.SGGLDB db = Funs.DB; var ndtLists = from x in db.ProcessControl_NondestructiveTest_New where x.ProfessionalName == "工艺管道" select x; decimal a = 0, b = 0; if (ndtLists.Count() > 0) { foreach (var project in allProjects) { var ndt = (from x in ndtLists where x.ProjectId == project.ProjectId orderby x.CreateDate descending select x).FirstOrDefault(); if (ndt != null) { if (ndt.TotalQuantity.HasValue) { a += Math.Floor(ndt.TotalQuantity.Value * Funs.GetNewDecimalOrZero(ndt.TotalRate) / 100); b += ndt.TotalQuantity.Value; } } } } if (b > 0) { result = Convert.ToDouble(decimal.Round(decimal.Parse((a / b * 100).ToString()), 2)); hjallNumber = b.ToString(); hjfinishNumber = a.ToString(); hjzgl = result.ToString() + "%"; } } } /// /// 获取企业总部人数 /// /// 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 join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId where x.IsOnJob == true && x.UnitId == unitId && y.IsCQMS == true select x).Count(); return result; } /// /// 获取分支机构人数 /// /// 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 join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId where x.IsOnJob == true && x.UnitId != unitId && y.IsCQMS == true select x).Count(); return result; } /// /// 获取项目部人数 /// /// 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; } /// /// 获取在用计量器具数 /// /// 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; } /// /// 获取校准合格数 /// /// 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; } /// /// 机械预警 /// /// 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; result = num2; return result; } /// /// 获取质量培训人次数 /// /// public static int GetTrainPersonNum() { int result = (from x in Funs.DB.Comprehensive_InspectionPerson where x.IsTrain == true select x).Count(); return result; } /// /// 获取技术交底人次数 /// /// public static int GetTechnicalDisclosePersonNum() { var result = (from x in Funs.DB.Comprehensive_DesignDetails select x.JoinPersonNum ?? 0).ToList().Sum(); var q = Funs.GetNewIntOrZero(result.ToString()); return q; } /// /// 资质预警 /// private void getEarlyWarningCounts() { int allCount = 0; var getPersonQualitys = from x in Funs.DB.Comprehensive_InspectionPerson where x.ValidityDate.HasValue && x.ValidityDate < DateTime.Now && x.IsOnSite == true select x; //// 预警人数 allCount = getPersonQualitys.Count(); this.spanQualityChartAnalysis.InnerHtml = allCount.ToString(); } #region 质量验收数据 /// /// 共检总数 /// /// public static int getAllInspectionManagement() { int result = 0; ; //统计所给时间段的全部数量 //List managementListSunNumber = // BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate( // null, null, DateTime.Parse("2001-01-01"), DateTime.Now, false); var num1 = (from x in Funs.DB.ProcessControl_InspectionManagement select x).Count(); result = num1; //int result = (from x in Funs.DB.Check_CheckControl // where x.CheckDate <= DateTime.Now && x.State == "7" // select x).Count(); return result; } /// /// 次合格数量 /// /// public static int getIsOnceInspectionManagement() { int result = 0; //统计所给时间段的合格数量 //List managementListOneNumber = // BLL.InspectionManagementService.getInspectionManagementDetailListByCNProfessionalIdAndDate( // null, null, DateTime.Parse("2001-01-01"), DateTime.Now, true); var num2 = (from x in Funs.DB.ProcessControl_InspectionManagement where x.IsOnceQualified == true select x).Count(); result = num2; //int result = (from x in Funs.DB.Check_CheckControl // where x.CheckDate <= DateTime.Now && x.State != "7" // select x).Count(); return result; } /// /// 整改率 /// /// public static string GetInspectionManagementZgl() { string zgl = String.Format("{0:N2}", 100.0 * getIsOnceInspectionManagement() / getAllInspectionManagement()); return zgl + "%"; } #endregion #region 质量问题治理数据 /// /// 获取整改完成数 /// /// 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; } /// /// 获取未整改数 /// /// 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; } /// /// 整改率 /// /// public static string GetProblemZgl() { string zgl = String.Format("{0:N2}", 100.0 * GetProblemCompletedNum() / (GetProblemCompletedNum() + GetProblemNotCompletedNum())); return zgl + "%"; } /// /// 质量问题治理数据 /// 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)) + "'"; } /// 获取问题个数 /// /// public static int GetProblemNum() { int result = (from x in Funs.DB.Check_CheckControl where x.CheckDate <= DateTime.Now select x).Count(); return result; } #endregion /// /// 获取焊工总数 /// /// public static int GetWelderNum() { int result = (from x in Funs.DB.BS_Welder where x.WED_IfOnGuard == true select x).Count(); return result; } /// /// 获取总达因数 /// /// 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; } /// /// 获取完成达因数 /// /// 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; } /// /// 获取总片数 /// /// 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()); int result = 0; var getD2 = (from x in Funs.DB.HJGL_FL_Data orderby x.CompileDate descending select x).FirstOrDefault(); if (getD2 != null) { result = Funs.GetNewIntOrZero(getD2.OneTimeFilmAmount.Split('.')[0]); } return result; } /// /// 获取合格片数 /// /// public static int GetOKFilmNum() { int result = 0; var getD2 = (from x in Funs.DB.HJGL_FL_Data orderby x.CompileDate descending select x).FirstOrDefault(); if (getD2 != null) { result = Funs.GetNewIntOrZero(getD2.OneTimeFilmQualifiedAmount.Split('.')[0]); } return result; } /// /// 一次拍片合格率 /// /// 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; var num1 = (from x in Funs.DB.ProcessControl_InspectionManagement where x.CNProfessionalId == item.CNProfessionalId select x).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; var num2 = (from x in Funs.DB.ProcessControl_InspectionManagement where x.CNProfessionalId == item.CNProfessionalId && x.IsOnceQualified == true select x).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(); var num1 = Funs.DB.Comprehensive_NCRManagement.Where(x => x.ImplementationFrontState == "已闭合").Count(); var num2 = Funs.DB.Comprehensive_NCRManagement.Where(x => x.ImplementationFrontState == "整改中").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 private string GetFileType(string fileName) { string fileType = String.Empty; int lastDotIndex = fileName.LastIndexOf("."); if (lastDotIndex >= 0) { fileType = fileName.Substring(lastDotIndex + 1).ToLower(); } return fileType; } protected void drpProject_SelectedIndexChanged(object sender, EventArgs e) { var project = ProjectService.GetProjectByProjectId(this.drpProject.SelectedValue); var allowExtensions = new List { "jpg", "jpeg", "png", "bmp", "gif", // 图片文件类型 }; var getImag = Funs.DB.AttachFile.FirstOrDefault(x => x.ToKeyId == project.ProjectId); if (getImag != null && !string.IsNullOrEmpty(getImag.AttachUrl)) { string url = getImag.AttachUrl.Replace('\\', '/'); var UrlList = Funs.GetStrListByStr(url, ','); bool isHiddDefaultImg = false; foreach (var item in UrlList) { if (!string.IsNullOrEmpty(item)) { string atturl = Funs.RootPath + item.Replace(';', ' ').Trim(); string fileType = GetFileType(atturl); if (File.Exists(atturl) && allowExtensions.Contains(fileType)) { isHiddDefaultImg = true; divProjectImg += string.Format("
", atturl.Replace(Funs.RootPath, "/")); } } } divProjectImg = divProjectImg.Replace("
", ""); } if (string.IsNullOrEmpty(divProjectImg)) { divProjectImg = "
"; } string jsCode = "var swiperWrapper = document.getElementById('swiper-wrapper');"; jsCode += "swiperWrapper.innerHTML = '" + divProjectImg + "';"; string script2 = " createSwiper();"; PageContext.RegisterStartupScript(jsCode); PageContext.RegisterStartupScript(script2); } } }