using BLL; using Model; using System; using System.Collections.Generic; using System.Web.Services; using System.Linq; using System.Web.UI.WebControls; using System.Threading.Tasks; using FineUIPro.Web.ProjectData; using FineUIPro.Web.DataShow; namespace FineUIPro.Web.common { public partial class mainProject : PageBase { //public string userId; protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { string userId = this.CurrUser.UserId; } } /// /// 看板数据 /// /// [WebMethod] public static object GetHSSEData() { try { var db = Funs.DB; var page = new mainProject(); string userId = page.CurrUser.UserId; string projectId = page.CurrUser.LoginProjectId; MainSevice mainSevice = new MainSevice(userId, projectId); var project = ProjectService.GetProjectByProjectId(projectId); //获取HSSE数据 var hsseData = Task.Run(() => mainSevice.GetHsseDataAsync()).Result; //安全云视频【待汇总】待配置 string video_Url = string.Empty; var sysSet16 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控地址" select x).ToList().FirstOrDefault(); if (sysSet16 != null) { video_Url = sysSet16.SetValue; } var sysSet17 = (from x in Funs.DB.Sys_Set where x.SetName == "视频监控密码" select x).ToList().FirstOrDefault(); if (sysSet17 != null) { video_Url = video_Url + "#/screen?username=admin&password=" + Funs.EncryptionPassword(sysSet17.SetValue); } else { video_Url = ""; } //班前会 var classMeetingList = HSSEData_HSSEService.GetProjectClassMeeting(projectId); //周前会 var weekMeetingList = HSSEData_HSSEService.GetProjectWeekMeeting(projectId); //项目总工期 int projectDays = 0; if (project.StartDate.HasValue) { int pdays = (project.EndDate.Value - project.StartDate.Value).Days; if (pdays >= 0) { projectDays = pdays; } } //合同倒计时 int endDays = (project.EndDate.Value - DateTime.Now).Days; // 计算整改率 string hsseZGRate = "0"; double generalRectificationRate = 0; if (hsseData.GeneralClosedNum.HasValue && hsseData.GeneralNotClosedNum.HasValue) { double total = hsseData.GeneralClosedNum.Value + hsseData.GeneralNotClosedNum.Value; if (total > 0) { generalRectificationRate = 100.0 * hsseData.GeneralClosedNum.Value / total; hsseZGRate = String.Format("{0:N2}", generalRectificationRate); } } //设计交底 var designDetailsList = (from x in db.Comprehensive_DesignDetails where x.ProjectId == projectId select x).ToList(); //施工方案 var cqmsConstructSolutionList = (from x in db.Solution_CQMSConstructSolution where x.ProjectId == projectId select x).ToList(); //设备报验 var inspectionEquipmentList = (from x in db.Comprehensive_InspectionEquipment where x.ProjectId == projectId select x).ToList(); //人员报验 var inspectionPersonList = (from x in db.Comprehensive_InspectionPerson where x.ProjectId == projectId select x).ToList(); //机具报验 var inspectionMachineList = (from x in db.Comprehensive_InspectionMachine where x.ProjectId == projectId select x).ToList(); //质量 var cqmsProjectData = (from x in db.Project_CQMSData_CQMS where x.ProjectId == projectId select x).OrderByDescending(x => x.ReportDate).FirstOrDefault(); //质量培训人数 //var cqmsTrainPersonNum = cqmsProjectData.TrainPersonNum; var cqmsTrainPersonNum = db.Comprehensive_InspectionPerson.Where(x => x.IsTrain == true && x.ProjectId == projectId).Count(); //var getJointCheckDetail = from x in Funs.DB.Check_JointCheckDetail // join y in Funs.DB.Check_JointCheck on x.JointCheckId equals y.JointCheckId // where y.ProjectId == projectId // select x; //var getCheckControl = from x in Funs.DB.Check_CheckControl // where x.ProjectId == projectId // select x; // 问题总数 int cqmsProblemNum = cqmsProjectData.ProblemNum ?? 0; int cqmsCompletedNum = cqmsProjectData.ProblemCompletedNum ?? 0; int cqmsNotCompletedNumt = cqmsProjectData.ProblemNotCompletedNum ?? 0; //int cqmsAllCount = getJointCheckDetail.Count() + getCheckControl.Count(); //int cqmsOkNum = 0;//已完成 //int cqmsIncompleteNum = 0; //未完成 double cqmsZGRate = 0;//整改率 if (cqmsCompletedNum > 0) { cqmsZGRate = Math.Round(100 * (double)(cqmsCompletedNum / cqmsProblemNum), 2); ///问题完成数 //var getJOk = getJointCheckDetail.Where(x => x.State == "6").Count(); //var getCOk = getCheckControl.Where(x => x.State == "7").Count(); //cqmsOkNum = getJOk + getCOk; //cqmsIncompleteNum = cqmsAllCount - cqmsOkNum; //if (cqmsOkNum > 0) //{ // cqmsZGRate = Math.Round(cqmsOkNum * 1.0 / cqmsAllCount * 100, 2); //} } classMeetingList = classMeetingList.Where(x => x.ProjectId == projectId).ToList(); weekMeetingList = weekMeetingList.Where(x => x.ProjectId == projectId).ToList(); designDetailsList = designDetailsList.Where(x => x.ProjectId == projectId).ToList(); cqmsConstructSolutionList = cqmsConstructSolutionList.Where(x => x.ProjectId == projectId).ToList(); inspectionEquipmentList = inspectionEquipmentList.Where(x => x.ProjectId == projectId).ToList(); inspectionPersonList = inspectionPersonList.Where(x => x.ProjectId == projectId).ToList(); inspectionMachineList = inspectionMachineList.Where(x => x.ProjectId == projectId).ToList(); int inspectionEquipment = inspectionEquipmentList.Count(); int inspectionPerson = inspectionPersonList.Count(); int inspectionMachine = inspectionMachineList.Count(); int inspectionEquipmentIsCheckOk = inspectionEquipmentList.Where(x => x.SamplingResult == "1").Count(); int inspectionPersonIsCheckOk = inspectionPersonList.Where(x => x.IsOnSite.HasValue && x.IsOnSite == true).Count(); int inspectionMachineIsCheckOk = inspectionMachineList.Where(x => x.IsCheckOK.HasValue && x.IsCheckOK == true).Count(); double inspectionEquipmentRate = inspectionEquipmentIsCheckOk > 0 ? Math.Round((100 * (double)(inspectionEquipmentIsCheckOk / inspectionEquipment)), 2) : 0; double inspectionPersonRate = inspectionPersonIsCheckOk > 0 ? Math.Round((100 * (double)(inspectionPersonIsCheckOk / inspectionPerson)), 2) : 0; double inspectionMachineRate = inspectionMachineIsCheckOk > 0 ? Math.Round((100 * (double)(inspectionMachineIsCheckOk / inspectionMachine)), 2) : 0; //项目进度计划 var scheduleList = (from x in db.Sys_Schedule where x.ProjectId == projectId orderby x.SortId select new { date = x.ScheduleDate, title = x.ScheduleName, description = x.ScheduleName, isClosed = DateTime.Now > x.ScheduleDate }).ToList(); // 构造返回数据 var returnData = new { success = true, data = new { educationIdx = 0, checkIdx = 0, org = new {//组织机构人员 projectSum = (hsseData.ProjectInspectorGeneralNum ?? 0) + (hsseData.ProjectFullTimeNum ?? 0) + (hsseData.ProjectSafetyMonitorNum ?? 0),//项目总人数 projectDirector = hsseData.ProjectInspectorGeneralNum ?? 0,//项目总监 projectFullTime = hsseData.ProjectFullTimeNum ?? 0,//项目专职 projectSafetyMonitoring = hsseData.ProjectSafetyMonitorNum ?? 0,//项目安全监护 projectSecurity = 0,//项目安管人员【待汇总】 projectPersonRatio = "1:5",//项目安管人员与作业人员配比【待汇总】 }, warning = new {//预警警报【待汇总】 hydropower = 0,//水电监测 hydropower2 = 0,//水电监测 towercrane = 0,//塔式起重机预警 foundationpit = 0,//基坑监测预警 car = 0,//车辆冲洗监测 }, hsseCheck = new {//安全检查 generalNum = (hsseData.GeneralClosedNum ?? 0) + (hsseData.GeneralNotClosedNum ?? 0),//安全问题 notClosedNum = hsseData.GeneralNotClosedNum ?? 0,//未完成 closedNum = hsseData.GeneralClosedNum ?? 0,//整改闭环 rectificationRate = Convert.ToDouble(hsseZGRate),//整改率 }, cqmsCheck = new {//质量检查 generalNum = cqmsProblemNum,//质量问题 notClosedNum = cqmsNotCompletedNumt,//未完成 closedNum = cqmsCompletedNum,//整改闭环 rectificationRate = cqmsZGRate,//整改率 }, riskClassification = new {//风险分级管控 highRiskNum = hsseData.HighRiskNum ?? 0,//重大风险 mediumRiskNum = hsseData.MediumRiskNum ?? 0,//较大风险 generalRiskNum = hsseData.GeneralRiskNum ?? 0,//一般风险 lowRiskNum = hsseData.LowRiskNum ?? 0//低风险 }, costEquipmentMeeting = new {//费用、机具及会议 expenseExtraction = hsseData.CostExtract.HasValue ? Math.Round(hsseData.CostExtract.Value / 100000000m, 2) : 0,//安全费用-费用提取(亿元) costUtilization = hsseData.CostUse.HasValue ? Math.Round(hsseData.CostUse.Value / 100000000m, 2) : 0,//安全费用-费用使用(亿元) usingNumbers = hsseData.UseEquipmentNum ?? 0,//施工机具设备-在用个数 specialEquipment = hsseData.SpecialEquipmentNum ?? 0,//施工机具设备-特种设备 classMeeting = classMeetingList.Count(),//会议-班前会 weekMeeting = weekMeetingList.Count()//会议-周例会 }, projectInfo = new {//项目数据 projectDays = projectDays,//项目总工期 projectEndDate = string.Format("{0:yyyy-MM-dd}", project.EndDate),//项目到期时间 projectEndDays = endDays > 0 ? endDays : 0,//合同倒计时 }, xmjdData = scheduleList.Select(x => new {//项目进度计划 x.isClosed, date = ((DateTime)x.date).ToString("yyyy-MM-dd"), x.title, x.description }), dangerousProject = new {//危大工程管控数据 approvalCompleted = hsseData.CompletedNum ?? 0,//审批完成 construction = hsseData.ConstructionNum ?? 0,//施工个数 training = hsseData.TrainPersonNum ?? 0,//培训人次 completed = hsseData.FinishedNum ?? 0,//完工个数 reasoning = 0//论证个数【待汇总】 }, meetAnEmergency = new {//应急管理数据 comprehensive = hsseData.CompanyComprehensivePlanNum ?? 0,//综合预案 special = hsseData.CompanySpecialPlanNum ?? 0,//专项预案 scene = hsseData.CompanyOnSiteDisposalPlan ?? 0,//现场处置 drill = hsseData.CompanyDrillNum ?? 0//演练次数 }, engineeringDivision = new {//工程划分 unitNum = cqmsProjectData.UnitProjectNum ?? 0,//单位工程数 branchNum = cqmsProjectData.SubProjectNum ?? 0,//分部工程数 itemizeNum = cqmsProjectData.SubdivisionalWorksNum ?? 0,//分项工程数 }, //质量验收数据【待汇总】 specialEquipmentSys = 0,//特种设备质保体系【待汇总】 designBriefing = designDetailsList.Count(),//图纸会审、设计交底 hsseEduTrain = new {//安全教育 safeWorkingHour = hsseData.SafeWorkingHour ?? 0,//安全工时数 specialTrainNum = hsseData.SpecialTrainNum ?? 0,//专项培训 safeTrainNum = hsseData.SafeTrainNum ?? 0,//三级安全教育培训 specialOperationTrainNum = hsseData.SpecialOperationTrainNum ?? 0,//特种作业培训 safetyTechnicalBriefing = 0//安全技术交底次数【待汇总】 }, cqmsTrainPersonNum = cqmsTrainPersonNum,//质量教育-培训人数 inspectionRecord = new {//报验记录 equipmentNum = inspectionEquipment,//设备报验 equipmentRate = inspectionEquipmentRate,//设备报验合格率 personNum = inspectionPerson,//人员报验 personRate = inspectionPersonRate,//人员报验合格率 machineNum = inspectionMachine,//机具报验 machineRate = inspectionMachineRate,//机具报验合格率 }, constructSolution = new {//施工方案 total = cqmsConstructSolutionList.Count(),//总数 projectApprove = cqmsConstructSolutionList.Where(x => x.State == "1").Count(),//项目审批数(审批状态:已闭合) enterpriseApprove = 0//企业审批数【待汇总】 }, highRisk = new {//高风险作业许可 closeItem = hsseData.LicensesCloseNum ?? 0,//关闭项 licenseItem = hsseData.LicensesNum ?? 0//许可项 }, measuringInstrumentsData = new {//计量器具数据 useNum = cqmsProjectData.UseNum ?? 0,//计量器具 okNum = cqmsProjectData.OKNum ?? 0,//校准合格 }, } }; return returnData; } catch (Exception ex) { return new { success = false, msg = ex.Message }; } } } }