diff --git a/SGGL/FineUIPro.Web/ZHGL/Information/MillionsMonthlyReportSave.aspx.cs b/SGGL/FineUIPro.Web/ZHGL/Information/MillionsMonthlyReportSave.aspx.cs index 92694013..0ef61e7a 100644 --- a/SGGL/FineUIPro.Web/ZHGL/Information/MillionsMonthlyReportSave.aspx.cs +++ b/SGGL/FineUIPro.Web/ZHGL/Information/MillionsMonthlyReportSave.aspx.cs @@ -816,29 +816,99 @@ namespace FineUIPro.Web.ZHGL.Information #region 获取明细 private void GetNewItems(string year, string months) { - //获取项目集合 - List millionsMonthlyReports = (from x in Funs.DB.InformationProject_MillionsMonthlyReport where x.Year.ToString() == year && x.Month.ToString() == months && x.States == BLL.Const.State_2 select x).ToList(); - this.txtInputCosts.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.InputCosts ?? 0)); - this.txtTrainNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.TrainNum ?? 0)); - this.txtGeneralHazardNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.GeneralHazardNum ?? 0)); - this.txtMajorHazardNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.MajorHazardNum ?? 0)); - this.txtNotProofLargeProjectNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.NotProofLargeProjectNum ?? 0)); - this.txtProofLargeProjectNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.ProofLargeProjectNum ?? 0)); - this.txtFireLicenseNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.FireLicenseNum ?? 0)); - this.txtLimitLicenseNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.LimitLicenseNum ?? 0)); - this.txtHighLicenseNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.HighLicenseNum ?? 0)); - this.txtHoistingLicenseNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.HoistingLicenseNum ?? 0)); - this.txtBreakGroundLicenseNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.BreakGroundLicenseNum ?? 0)); - this.txtElectricityLicenseNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.ElectricityLicenseNum ?? 0)); - this.txtRTLicenseNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.RTLicenseNum ?? 0)); - this.txtNightLicenseNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.NightLicenseNum ?? 0)); - this.txtCommissionerNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.CommissionerNum ?? 0)); - this.txtSoleDutyNum.Text = Convert.ToString(millionsMonthlyReports.Sum(x => x.SoleDutyNum ?? 0)); - List projectIds = millionsMonthlyReports.Select(x => x.ProjectId).ToList(); + DateTime nowTime = Funs.GetNewDateTimeOrNow(year + "-" + months); + DateTime starTime = nowTime.AddMonths(-2).AddDays(24); + DateTime endTime = nowTime.AddMonths(-1).AddDays(23); + + var getCosts = from x in Funs.DB.CostGoods_CostManageItem + join y in Funs.DB.CostGoods_CostManage on x.CostManageId equals y.CostManageId + where y.CostManageDate >= starTime && y.CostManageDate <= endTime + select x; + if (getCosts.Count() > 0) + { + this.txtInputCosts.Text = getCosts.Sum(x => x.PriceMoney ?? 0).ToString(); + } + this.txtTrainNum.Text = Funs.DB.EduTrain_TrainRecord.Where(x => x.TrainStartDate >= starTime && x.TrainStartDate <= endTime).Count().ToString(); + + int HazardAll = 0, RectifyAll = 0; + int HazardMajor = 0, RectifyMajor = 0; + var getHazardRegister = Funs.DB.HSSE_Hazard_HazardRegister.Where(x => x.RegisterDate >= starTime && x.RegisterDate <= endTime && x.States == Const.State_3); + HazardAll = getHazardRegister.Count(); + if (HazardAll > 0) + { + HazardMajor = getHazardRegister.Where(x => x.HazardValue == "2").Count(); + } + + var getRectifyNotices = Funs.DB.Check_RectifyNotices.Where(x => x.CheckedDate >= starTime && x.CheckedDate <= endTime && x.States == Const.State_5); + RectifyAll = getRectifyNotices.Count(); + if (RectifyAll > 0) + { + RectifyMajor = getRectifyNotices.Where(x => x.HiddenHazardType == "3").Count(); + } + this.txtGeneralHazardNum.Text = ((HazardAll - HazardMajor) + (RectifyAll - RectifyMajor)).ToString(); + this.txtMajorHazardNum.Text = (HazardMajor + RectifyMajor).ToString(); + + var getLarger = from x in Funs.DB.Solution_LargerHazardListItem + join y in Funs.DB.Solution_LargerHazardList on x.LargerHazardListId equals y.LargerHazardListId + where y.States == Const.State_1 && y.RecordTime >= starTime && y.RecordTime <= endTime + select x; + if (getLarger.Count() > 0) + { + this.txtNotProofLargeProjectNum.Text = Convert.ToString(getLarger.Where(x => x.IsArgument == false).Count()); + this.txtProofLargeProjectNum.Text = Convert.ToString(getLarger.Where(x => x.IsArgument == true).Count()); + } + + var getLicense = from x in Funs.DB.License_LicenseManager + join y in Funs.DB.Base_LicenseType on x.LicenseTypeId equals y.LicenseTypeId + where x.States != Const.State_R && x.StartDate >= starTime && x.StartDate <= endTime + select new { x.LicenseManagerId, x.StartDate, x.EndDate, x.States, y.LicenseTypeId, y.LicenseTypeCode, y.LicenseTypeName }; + + int fire1 = Funs.DB.License_FireWork.Where(x => x.ApplyDate >= starTime && x.ApplyDate <= endTime && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); + int fire2 = getLicense.Where(x => x.LicenseTypeName.Contains("动火")).Count(); + this.txtFireLicenseNum.Text = (fire1 + fire2).ToString(); + + int limit1 = Funs.DB.License_LimitedSpace.Where(x => x.ApplyDate >= starTime && x.ApplyDate <= endTime && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); + int limit2 = getLicense.Where(x => x.LicenseTypeName.Contains("受限空间")).Count(); + this.txtLimitLicenseNum.Text = (limit1 + limit2).ToString(); + + int High1 = Funs.DB.License_HeightWork.Where(x => x.ApplyDate >= starTime && x.ApplyDate <= endTime && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); + int High2 = getLicense.Where(x => x.LicenseTypeName.Contains("登高")).Count(); + this.txtHighLicenseNum.Text = (High1 + High2).ToString(); + + int Hoisting1 = Funs.DB.License_LiftingWork.Where(x => x.ApplyDate >= starTime && x.ApplyDate <= endTime && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); + int Hoisting2 = getLicense.Where(x => x.LicenseTypeName.Contains("吊装")).Count(); + this.txtHoistingLicenseNum.Text = (Hoisting1 + Hoisting2).ToString(); + + int Break1 = Funs.DB.License_BreakGround.Where(x => x.ApplyDate >= starTime && x.ApplyDate <= endTime && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); + int Break2 = getLicense.Where(x => x.LicenseTypeName.Contains("动土")).Count(); + this.txtBreakGroundLicenseNum.Text = (Break1 + Break2).ToString(); + + this.txtElectricityLicenseNum.Text = getLicense.Where(x => x.LicenseTypeName.Contains("临电")).Count().ToString(); + + int rt1 = Funs.DB.License_RadialWork.Where(x => x.ApplyDate >= starTime && x.ApplyDate <= endTime && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); + int rt2 = getLicense.Where(x => x.LicenseTypeName.Contains("射线")).Count(); + this.txtRTLicenseNum.Text = (rt1 + rt2).ToString(); + + int night1 = Funs.DB.License_NightWork.Where(x => x.ApplyDate >= starTime && x.ApplyDate <= endTime && (x.States == Const.State_2 || x.States == Const.State_3)).Count(); + int night2 = getLicense.Where(x => x.LicenseTypeName.Contains("夜间")).Count(); + this.txtNightLicenseNum.Text = (night1 + night2).ToString(); + + var getPersons = from x in Funs.DB.SitePerson_Person + join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId + where x.States == Const.ProjectPersonStates_1 && y.IsHsse == true + select new { x.ProjectId, y.WorkPostName }; + int isHsse = getPersons.Count(); + if (isHsse > 0) + { + this.txtCommissionerNum.Text = Convert.ToString(getPersons.Where(x => x.WorkPostName.Contains("安全总监")).Count()); + } + + this.txtSoleDutyNum.Text = isHsse.ToString(); + //增加明细集合 Model.Information_MillionsMonthlyReportItem item1 = new Information_MillionsMonthlyReportItem { - MillionsMonthlyReportItemId = SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReportItem)), + MillionsMonthlyReportItemId = SQLHelper.GetNewID(), Affiliation = "机关后勤服务", Name = "总部", SortIndex = 10, @@ -874,7 +944,7 @@ namespace FineUIPro.Web.ZHGL.Information items.Add(item1); Model.Information_MillionsMonthlyReportItem item2 = new Information_MillionsMonthlyReportItem { - MillionsMonthlyReportItemId = SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReportItem)), + MillionsMonthlyReportItemId = SQLHelper.GetNewID(), Affiliation = "机关后勤服务", Name = "二级单位", SortIndex = 20, @@ -907,21 +977,16 @@ namespace FineUIPro.Web.ZHGL.Information LossDayNum = 0, }; items.Add(item2); - var projects = (from x in Funs.DB.Base_Project - where projectIds.Contains(x.ProjectId) - select x).ToList(); - if (this.CurrUser.UnitId == BLL.Const.UnitId_SEDIN) - { - projects = BLL.ProjectService.GetProjectWorkList(); - } + + var projects = BLL.ProjectService.GetProjectWorkList(); int i = 20; foreach (var p in projects) { i += 10; Model.Information_MillionsMonthlyReportItem item = new Information_MillionsMonthlyReportItem { - MillionsMonthlyReportItemId = SQLHelper.GetNewID(typeof(Model.Information_MillionsMonthlyReportItem)), + MillionsMonthlyReportItemId = SQLHelper.GetNewID(), Affiliation = "项目现场", Name = p.ProjectName, SortIndex = i @@ -936,70 +1001,51 @@ namespace FineUIPro.Web.ZHGL.Information item.Name = "[" + p.ProjectCode + "]" + p.ProjectName; } } + var getSitePersons = Funs.DB.SitePerson_Person.Where(x => x.ProjectId == p.ProjectId && x.States == Const.ProjectPersonStates_1); + //var getZSOerson = from x in getSitePersons + // join y in Funs.DB.Person_Persons on x.PersonId equals y.PersonId + // where y.PersonType == "1" && x.UnitId == Const.UnitId_SEDIN + // select x; + var getAllSedinPerson = getSitePersons.Where(x => x.UnitId == Const.UnitId_SEDIN).Count(); - Model.InformationProject_MillionsMonthlyReport report = millionsMonthlyReports.FirstOrDefault(x => x.ProjectId == p.ProjectId); - if (report != null) + item.PostPersonNum = getAllSedinPerson; + item.SnapPersonNum = 0; + item.ContractorNum = getSitePersons.Where(x => x.UnitId != Const.UnitId_SEDIN).Count(); + item.SumPersonNum = getSitePersons.Count(); + item.TotalWorkNum = 0; + var getInfo = APISeDinMonthReportService.getSeDinMonthReport2ById(p.ProjectId, year + "-" + months); + if (getInfo != null) { - item.PostPersonNum = report.PostPersonNum; - item.SnapPersonNum = report.SnapPersonNum; - item.ContractorNum = report.ContractorNum; - item.SumPersonNum = report.SumPersonNum; - item.TotalWorkNum = report.TotalWorkNum; - item.SeriousInjuriesNum = report.SeriousInjuriesNum; - item.SeriousInjuriesPersonNum = report.SeriousInjuriesPersonNum; - item.SeriousInjuriesLossHour = report.SeriousInjuriesLossHour; - item.MinorAccidentNum = report.MinorAccidentNum; - item.MinorAccidentPersonNum = report.MinorAccidentPersonNum; - item.MinorAccidentLossHour = report.MinorAccidentLossHour; - item.DeathAccidentNum = report.DeathAccidentNum; - item.DeathAccidentPersonNum = report.DeathAccidentPersonNum; - item.DeathAccidentLossHour = report.DeathAccidentLossHour; - item.RestrictedWorkPersonNum = report.RestrictedWorkPersonNum; - item.RestrictedWorkLossHour = report.RestrictedWorkLossHour; - item.MedicalTreatmentPersonNum = report.MedicalTreatmentPersonNum; - item.MedicalTreatmentLossHour = report.MedicalTreatmentLossHour; - item.FireNum = report.FireNum; - item.EnvironmenNum = report.EnvironmenNum; - item.TrafficNum = report.TrafficNum; - item.EquipmentNum = report.EquipmentNum; - item.QualityNum = report.QualityNum; - item.OtherNum = report.OtherNum; - item.FirstAidDressingsNum = report.FirstAidDressingsNum; - item.AttemptedEventNum = report.AttemptedEventNum; - item.LossDayNum = report.LossDayNum; - } - else - { - item.PostPersonNum = 0; - item.SnapPersonNum = 0; - item.ContractorNum = 0; - item.SumPersonNum = 0; - item.TotalWorkNum = 0; - item.SeriousInjuriesNum = 0; - item.SeriousInjuriesPersonNum = 0; - item.SeriousInjuriesLossHour = 0; - item.MinorAccidentNum = 0; - item.MinorAccidentPersonNum = 0; - item.MinorAccidentLossHour = 0; - item.DeathAccidentNum = 0; - item.DeathAccidentPersonNum = 0; - item.DeathAccidentLossHour = 0; - item.RestrictedWorkPersonNum = 0; - item.RestrictedWorkLossHour = 0; - item.MedicalTreatmentPersonNum = 0; - item.MedicalTreatmentLossHour = 0; - item.FireNum = 0; - item.EnvironmenNum = 0; - item.TrafficNum = 0; - item.EquipmentNum = 0; - item.QualityNum = 0; - item.OtherNum = 0; - item.FirstAidDressingsNum = 0; - item.AttemptedEventNum = 0; - item.LossDayNum = 0; + item.TotalWorkNum = Math.Round(getInfo.MonthWorkTime / 10000 ?? 0, 4); } + + item.SeriousInjuriesNum = 0; + item.SeriousInjuriesPersonNum = 0; + item.SeriousInjuriesLossHour = 0; + item.MinorAccidentNum = 0; + item.MinorAccidentPersonNum = 0; + item.MinorAccidentLossHour = 0; + item.DeathAccidentNum = 0; + item.DeathAccidentPersonNum = 0; + item.DeathAccidentLossHour = 0; + item.RestrictedWorkPersonNum = 0; + item.RestrictedWorkLossHour = 0; + item.MedicalTreatmentPersonNum = 0; + item.MedicalTreatmentLossHour = 0; + item.FireNum = 0; + item.EnvironmenNum = 0; + item.TrafficNum = 0; + item.EquipmentNum = 0; + item.QualityNum = 0; + item.OtherNum = 0; + item.FirstAidDressingsNum = 0; + item.AttemptedEventNum = 0; + item.LossDayNum = 0; items.Add(item); } + + this.Grid1.DataSource = items; + this.Grid1.DataBind(); } #endregion