721 lines
		
	
	
		
			31 KiB
		
	
	
	
		
			C#
		
	
	
	
			
		
		
	
	
			721 lines
		
	
	
		
			31 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_new : PageBase
 | 
						||
    {
 | 
						||
        List<Model.Base_Project> allProjects;
 | 
						||
        public static List<Model.Solution_LargerHazard> LargerHazard = new List<Model.Solution_LargerHazard>();
 | 
						||
        protected void Page_Load(object sender, EventArgs e)
 | 
						||
        {
 | 
						||
            if (!IsPostBack)
 | 
						||
            {
 | 
						||
                Model.SGGLDB db = Funs.DB;
 | 
						||
                //未遂事故
 | 
						||
                var wsAccidentList1 = from x in db.Accident_AccidentPersonRecord
 | 
						||
                                      join y in db.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
 | 
						||
                                      where y.AccidentTypeName.Contains("未遂")
 | 
						||
                                      select x;
 | 
						||
                var wsAccidentList2 = from x in db.Accident_AccidentReportOther
 | 
						||
                                      join y in db.Sys_Const on x.AccidentTypeId equals y.ConstValue
 | 
						||
                                      where y.ConstText.Contains("未遂")
 | 
						||
                                      select x;
 | 
						||
                this.divWS.InnerHtml = (wsAccidentList1.Count() + wsAccidentList2.Count()).ToString();
 | 
						||
 | 
						||
                //安全人工时
 | 
						||
                int wHours = db.SitePerson_PersonInOutNumber.Max(x => x.WorkHours) ?? 0;
 | 
						||
                this.divSafeWorkTime.InnerHtml = wHours.ToString();
 | 
						||
 | 
						||
                //本月安全人工时
 | 
						||
                int wHoursMonth = 0;
 | 
						||
                DateTime? sDate = Funs.GetNewDateTime(DateTime.Now.Year.ToString() + "-" + DateTime.Now.Month.ToString());
 | 
						||
                var dayReports = getMonthReportsByCompany(sDate);
 | 
						||
                if (dayReports.Count > 0)
 | 
						||
                {
 | 
						||
                    wHoursMonth = Convert.ToInt32(dayReports[0].DayWorkTime);
 | 
						||
                }
 | 
						||
                this.divSafeWorkTimeMonth.InnerHtml = wHoursMonth.ToString();
 | 
						||
 | 
						||
                //int wHoursMonth = db.SitePerson_PersonInOutNumber.Where(x => x.InOutDate > DateTime.Now.AddDays(-Convert.ToInt32(DateTime.Now.Date.Day)))
 | 
						||
                //    .Max(x => x.WorkHours) ?? 0;
 | 
						||
                //this.divSafeWorkTimeMonth.InnerHtml = wHoursMonth.ToString();
 | 
						||
 | 
						||
                //安全培训累计人员
 | 
						||
                var getTrainRecord = db.EduTrain_TrainRecord.Max(x=>x.TrainPersonNum)??0;
 | 
						||
                this.divSafePersonNum.InnerHtml = getTrainRecord.ToString();
 | 
						||
 | 
						||
                //安全管理人员
 | 
						||
                var allSum = from x in Funs.DB.SitePerson_Person
 | 
						||
                             where x.IsUsed == true
 | 
						||
                             select x;
 | 
						||
                var glAllPerson = from x in allSum
 | 
						||
                                  join y in Funs.DB.Base_WorkPost on x.WorkPostId equals y.WorkPostId
 | 
						||
                                  where (y.PostType == "1" || y.PostType == "4")    //一般管理岗位和特种管理人员
 | 
						||
                                  select x;
 | 
						||
                this.divSafeManagePersonNum.InnerText = glAllPerson.Count().ToString();
 | 
						||
 | 
						||
                //质量管理人员
 | 
						||
                int CqmsManageNum = (from x in Funs.DB.Person_CompanyBranchPerson
 | 
						||
                              where x.IsOnJob == true 
 | 
						||
                              select x).Count();
 | 
						||
                this.divCqmsManageNum.InnerText = CqmsManageNum.ToString();
 | 
						||
 | 
						||
                //质量培训人员
 | 
						||
                DateTime date = DateTime.Now.AddDays(-1);
 | 
						||
                int CqmsPxNum = (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();
 | 
						||
                divCqmsPxNum.InnerText = CqmsPxNum.ToString();
 | 
						||
 | 
						||
                //质量问题
 | 
						||
                getZlwt();
 | 
						||
 | 
						||
                //质量共检
 | 
						||
                getZlgj();
 | 
						||
 | 
						||
                //焊接
 | 
						||
                getHj();
 | 
						||
 | 
						||
                //关键事项
 | 
						||
                getGjsx();
 | 
						||
 | 
						||
                //在建项目
 | 
						||
                allProjects = ProjectService.GetAllProjectDropDownList();
 | 
						||
                int acount = allProjects.Count();
 | 
						||
                int pcount1 = 0;
 | 
						||
                int pcount2 = 0;
 | 
						||
                int pcount3 = 0;
 | 
						||
                if (acount>0)
 | 
						||
                {
 | 
						||
                    pcount1= allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null).Count();
 | 
						||
                    pcount2= (from x in Funs.DB.SitePerson_Person where x.IsUsed == true select x).Count();
 | 
						||
                    pcount3 = Count3();
 | 
						||
                }
 | 
						||
                div_zjxmCount.InnerText = pcount1.ToString();
 | 
						||
                div_cjrsCount.InnerText = pcount2.ToString();
 | 
						||
                div_wdgcCount.InnerText = pcount3.ToString();
 | 
						||
 | 
						||
                //人员信息
 | 
						||
                getSitePerson();
 | 
						||
 | 
						||
                //项目人员图表
 | 
						||
                getProjectSitePerson();
 | 
						||
 | 
						||
                //进度
 | 
						||
                getJd();
 | 
						||
 | 
						||
                //整改数据
 | 
						||
                getZgsj();
 | 
						||
 | 
						||
                //材料到货表格
 | 
						||
                getCldh();
 | 
						||
            }
 | 
						||
        }
 | 
						||
 | 
						||
        #region 当月人工时
 | 
						||
        /// <summary>
 | 
						||
        ///  获取出入记录人工时-月报(项目级别)
 | 
						||
        /// </summary>
 | 
						||
        /// <returns></returns>
 | 
						||
        public static List<Model.SitePerson_MonthReport> getMonthReportsByCompany(DateTime? sDate)
 | 
						||
        {
 | 
						||
            Model.SGGLDB db = Funs.DB;
 | 
						||
            List<Model.SitePerson_MonthReport> reports = new List<Model.SitePerson_MonthReport>();
 | 
						||
            var getAllPersonInOutList = from x in db.SitePerson_PersonInOutNumber
 | 
						||
                                       
 | 
						||
                                        select x;
 | 
						||
            if (getAllPersonInOutList.Count() > 0)
 | 
						||
            {
 | 
						||
                var getInMonths = (from x in getAllPersonInOutList select new { x.InOutDate.Year, x.InOutDate.Month }).Distinct();
 | 
						||
                if (sDate.HasValue)
 | 
						||
                {
 | 
						||
                    getInMonths = getInMonths.Where(x => x.Year == sDate.Value.Year && x.Month == sDate.Value.Month);
 | 
						||
                }
 | 
						||
                foreach (var item in getInMonths)
 | 
						||
                {
 | 
						||
                    DateTime compileDate = Funs.GetNewDateTimeOrNow(item.Year.ToString() + "-" + item.Month.ToString());
 | 
						||
                    var getNow = getAllPersonInOutList.Where(x => x.InOutDate.Year == compileDate.Year && x.InOutDate.Month == compileDate.Month).Max(x => x.WorkHours);
 | 
						||
                    if (getNow.HasValue)
 | 
						||
                    {
 | 
						||
                        Model.SitePerson_MonthReport reportItem = new Model.SitePerson_MonthReport
 | 
						||
                        {
 | 
						||
                            MonthReportId = SQLHelper.GetNewID(),
 | 
						||
                          
 | 
						||
                            CompileDate = Funs.GetNewDateTime(item.Year.ToString() + "-" + item.Month.ToString()),
 | 
						||
                            TotalPersonWorkTime = getNow,
 | 
						||
                        };
 | 
						||
                        DateTime upDate = compileDate.AddMonths(-1);
 | 
						||
                        var getMax = getAllPersonInOutList.Where(x => x.InOutDate.Year == upDate.Year && x.InOutDate.Month == upDate.Month).Max(x => x.WorkHours) ?? 0;
 | 
						||
                        reportItem.DayWorkTime = (getNow ?? 0) - getMax;
 | 
						||
                        reports.Add(reportItem);
 | 
						||
                    }
 | 
						||
 | 
						||
                }
 | 
						||
            }
 | 
						||
            return reports;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region  项目信息
 | 
						||
        protected string Project
 | 
						||
        {
 | 
						||
            get
 | 
						||
            {
 | 
						||
                Model.SingleSerie series = new Model.SingleSerie();
 | 
						||
                var project1s = allProjects.Where(x => x.ProjectState == Const.ProjectState_1 || x.ProjectState == null);
 | 
						||
                var consts = Funs.DB.Sys_Const.Where(x => x.GroupId == ConstValue.GroupId_ProjectState);
 | 
						||
                string name = string.Empty;
 | 
						||
                if (project1s.Count() > 0)
 | 
						||
                {
 | 
						||
                    foreach (var project1 in project1s)
 | 
						||
                    {
 | 
						||
                        string state = string.Empty;
 | 
						||
                        var c = consts.FirstOrDefault(x => x.ConstValue == project1.ProjectState2);
 | 
						||
                        if (c != null)
 | 
						||
                        {
 | 
						||
                            state = c.ConstText;
 | 
						||
                        }
 | 
						||
                        name += "<li style=\"border:1px solid white; padding:3px;\" class=\"c-item disabled swiper-slide\"><div class=\"tit tit-read\"><div class=\"flex\" ><div class=\"tit-t flex1\">" + project1.ProjectName + "</div><div class=\"tit-v\">" + state + "</div></div></div></li>";
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                var provinceDic = from x in Funs.DB.RealName_City select x;
 | 
						||
                List<double> listdata = new List<double>();
 | 
						||
                List<string> jd = new List<string>();
 | 
						||
                List<string> sg = new List<string>();
 | 
						||
                List<string> time = new List<string>();
 | 
						||
                List<string> ht = new List<string>();
 | 
						||
                List<string> convert = new List<string>();
 | 
						||
                List<string> loc = new List<string>();
 | 
						||
                listdata.Add(allProjects.Count());
 | 
						||
                jd.Add("");
 | 
						||
                sg.Add("");
 | 
						||
                time.Add("");
 | 
						||
                ht.Add("");
 | 
						||
                List<string> provinces = new List<string>();
 | 
						||
                provinces.Add("上海");
 | 
						||
                provinces.Add("河北");
 | 
						||
                provinces.Add("山西");
 | 
						||
                provinces.Add("内蒙古");
 | 
						||
                provinces.Add("辽宁");
 | 
						||
                provinces.Add("吉林");
 | 
						||
                provinces.Add("黑龙江");
 | 
						||
                provinces.Add("江苏");
 | 
						||
                provinces.Add("浙江");
 | 
						||
                provinces.Add("安徽");
 | 
						||
                provinces.Add("福建");
 | 
						||
                provinces.Add("江西");
 | 
						||
                provinces.Add("山东");
 | 
						||
                provinces.Add("河南");
 | 
						||
                provinces.Add("湖北");
 | 
						||
                provinces.Add("湖南");
 | 
						||
                provinces.Add("广东");
 | 
						||
                provinces.Add("广西");
 | 
						||
                provinces.Add("海南");
 | 
						||
                provinces.Add("四川");
 | 
						||
                provinces.Add("贵州");
 | 
						||
                provinces.Add("云南");
 | 
						||
                provinces.Add("西藏");
 | 
						||
                provinces.Add("陕西");
 | 
						||
                provinces.Add("甘肃");
 | 
						||
                provinces.Add("青海");
 | 
						||
                provinces.Add("宁夏");
 | 
						||
                provinces.Add("新疆");
 | 
						||
                provinces.Add("北京");
 | 
						||
                provinces.Add("天津");
 | 
						||
                provinces.Add("重庆");
 | 
						||
                provinces.Add("香港");
 | 
						||
                provinces.Add("澳门");
 | 
						||
                provinces.Add("台湾");
 | 
						||
                Model.SGGLDB db = Funs.DB;
 | 
						||
                var accidentList1 = from x in db.Accident_AccidentPersonRecord
 | 
						||
                                    join y in db.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
 | 
						||
                                    where y.AccidentTypeName.Contains("未遂")
 | 
						||
                                    select x;
 | 
						||
                var accidentList2 = from x in db.Accident_AccidentReportOther
 | 
						||
                                    join y in db.Sys_Const on x.AccidentTypeId equals y.ConstValue
 | 
						||
                                    where y.ConstText.Contains("未遂")
 | 
						||
                                    select x;
 | 
						||
                foreach (var province in provinces)
 | 
						||
                {
 | 
						||
                    int accidentNum = 0;
 | 
						||
                    DateTime date = DateTime.Now;
 | 
						||
                    decimal money1 = 0, money2 = 0;
 | 
						||
                    var projects = from x in allProjects
 | 
						||
                                   join y in provinceDic on x.Province equals y.ProvinceCode
 | 
						||
                                   where y.CnShortName == province
 | 
						||
                                   select x;
 | 
						||
                    listdata.Add(projects.Count());
 | 
						||
                    decimal progress = 0;
 | 
						||
                    if (projects.Count() > 0)
 | 
						||
                    {
 | 
						||
                        convert.Add(province);
 | 
						||
                        foreach (var item in projects)
 | 
						||
                        {
 | 
						||
                            //未遂事故
 | 
						||
                            var accidentListProject1 = accidentList1.Where(x => x.ProjectId == item.ProjectId);
 | 
						||
                            var accidentListProject2 = accidentList2.Where(x => x.ProjectId == item.ProjectId);
 | 
						||
                            accidentNum = accidentListProject1.Count() + accidentListProject2.Count();
 | 
						||
                            //时间
 | 
						||
                            if (item.StartDate != null && item.StartDate < date)
 | 
						||
                            {
 | 
						||
                                date = Convert.ToDateTime(item.StartDate);
 | 
						||
                            }
 | 
						||
                            //合同额
 | 
						||
                            if (item.ConstructionMoney != null)
 | 
						||
                            {
 | 
						||
                                money1 += item.ConstructionMoney.Value;
 | 
						||
                            }
 | 
						||
                            if (item.Progress != null)
 | 
						||
                            {
 | 
						||
                                progress = item.Progress.Value;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        jd.Add("进度:" + progress.ToString("0.##") + "%");
 | 
						||
                        sg.Add("未遂事故:" + accidentNum.ToString());
 | 
						||
                        time.Add("时间:" + string.Format("{0:yyyy-MM-dd}", date));
 | 
						||
                        ht.Add("合同额(" + money1.ToString("0.##") + "W);收款额(" + money2 + "W)");
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        jd.Add("");
 | 
						||
                        sg.Add("");
 | 
						||
                        time.Add("");
 | 
						||
                        ht.Add("");
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                foreach (var item in allProjects)
 | 
						||
                {
 | 
						||
                    decimal jdNum = 0;
 | 
						||
                    string mapStr = "";
 | 
						||
                    int accidentNum = 0;
 | 
						||
                    DateTime date = DateTime.Now;
 | 
						||
                    decimal money1 = 0, money2 = 0;
 | 
						||
                    string endDate = string.Empty;
 | 
						||
                    int timeSpan = 0;
 | 
						||
                    if (!string.IsNullOrEmpty(item.MapCoordinates))
 | 
						||
                    {
 | 
						||
                        mapStr = item.MapCoordinates + ",";
 | 
						||
                        //未遂事故
 | 
						||
                        var accidentListProject1 = accidentList1.Where(x => x.ProjectId == item.ProjectId);
 | 
						||
                        var accidentListProject2 = accidentList2.Where(x => x.ProjectId == item.ProjectId);
 | 
						||
                        accidentNum = accidentListProject1.Count() + accidentListProject2.Count();
 | 
						||
                        //时间
 | 
						||
                        if (item.StartDate != null && item.StartDate < date)
 | 
						||
                        {
 | 
						||
                            date = Convert.ToDateTime(item.StartDate);
 | 
						||
                        }
 | 
						||
                        if (item.EndDate != null)
 | 
						||
                        {
 | 
						||
                            endDate = string.Format("{0:yyyy-MM-dd}", item.EndDate);
 | 
						||
                        }
 | 
						||
                        if (item.StartDate != null && item.EndDate != null)
 | 
						||
                        {
 | 
						||
                            TimeSpan t = (TimeSpan)(item.EndDate - item.StartDate);
 | 
						||
                            timeSpan = t.Days / 30;
 | 
						||
                        }
 | 
						||
                        //合同额
 | 
						||
                        if (item.ConstructionMoney != null)
 | 
						||
                        {
 | 
						||
                            money1 += item.ConstructionMoney.Value;
 | 
						||
                        }
 | 
						||
                        if (item.Progress != null)
 | 
						||
                        {
 | 
						||
                            jdNum = item.Progress.Value;
 | 
						||
                        }
 | 
						||
                        mapStr += string.Format("{0:yyyy-MM-dd}", date) + "~" + endDate + ",";
 | 
						||
                        if (timeSpan > 0)
 | 
						||
                        {
 | 
						||
                            mapStr += timeSpan.ToString() + "个月,";
 | 
						||
                        }
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            mapStr += timeSpan.ToString() + ",";
 | 
						||
                        }
 | 
						||
                        //mapStr += accidentNum.ToString() + ",";
 | 
						||
                        mapStr += jdNum.ToString("0.##") + "%,";
 | 
						||
                        mapStr += money1.ToString("0.##") + ",";
 | 
						||
                        mapStr += money2 + ",";
 | 
						||
                        mapStr += item.ShortName + ",";
 | 
						||
                        mapStr += item.ProjectId;
 | 
						||
                        loc.Add(mapStr);
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                series.name = name;
 | 
						||
                series.data = listdata;
 | 
						||
                series.jd = jd;
 | 
						||
                series.sg = sg;
 | 
						||
                series.time = time;
 | 
						||
                series.ht = ht;
 | 
						||
                series.convert = convert;
 | 
						||
                series.loc = loc;
 | 
						||
                return JsonConvert.SerializeObject(series);
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 在施危大工程数量
 | 
						||
        /// <summary>
 | 
						||
        /// 在施危大工程数量
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="state"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        protected int Count3()
 | 
						||
        {
 | 
						||
            int cout1 = 0;
 | 
						||
            cout1 = LargerHazard.Where(x => x.States == Const.State_2).Count();
 | 
						||
            return cout1;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 质量问题
 | 
						||
        //质量问题总计
 | 
						||
        protected string zlallNumber;
 | 
						||
        //质量问题合格数量
 | 
						||
        protected string zlfinishNumber;
 | 
						||
        //质量问题整改率
 | 
						||
        protected string zlzgl;
 | 
						||
 | 
						||
        protected string zgzglDataValue;
 | 
						||
        protected void getZlwt() {
 | 
						||
            zlallNumber = (from x in Funs.DB.Check_CheckControl
 | 
						||
                           where x.CheckDate <= DateTime.Now
 | 
						||
                           select x).Count().ToString();
 | 
						||
            var num2 = (from x in Funs.DB.Check_CheckControl
 | 
						||
                        where x.CheckDate <= DateTime.Now && x.State == "7"
 | 
						||
                        select x).Count();
 | 
						||
            zlfinishNumber = num2.ToString();
 | 
						||
            var num3 = (from x in Funs.DB.Check_CheckControl
 | 
						||
                    where x.CheckDate <= DateTime.Now && x.State != "7"
 | 
						||
                    select x).Count();
 | 
						||
 | 
						||
            var zgl = String.Format("{0:N2}", 100.0 * num2 / (num2 + num3));
 | 
						||
            zlzgl = zgl.ToString();
 | 
						||
            zgzglDataValue = (100 - (100.0 * num2 / (num2 + num3))).ToString();
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 质量共检
 | 
						||
        protected string zlgjallNumber;
 | 
						||
        protected string zlgjfinishNumber;
 | 
						||
        protected string zlgjzgl;
 | 
						||
 | 
						||
        protected string zggjzglDataValue;
 | 
						||
        protected void getZlgj() {
 | 
						||
            //Check_JointCheck
 | 
						||
            zlgjallNumber = (from x in Funs.DB.Check_JointCheck
 | 
						||
                           where x.CheckDate <= DateTime.Now
 | 
						||
                           select x).Count().ToString();
 | 
						||
 | 
						||
            var num2 = (from x in Funs.DB.Check_JointCheck
 | 
						||
                        where x.CheckDate <= DateTime.Now && x.State == BLL.Const.JointCheck_Complete
 | 
						||
                        select x).Count();
 | 
						||
            zlgjfinishNumber = num2.ToString();
 | 
						||
 | 
						||
            var num3 = (from x in Funs.DB.Check_JointCheck
 | 
						||
                        where x.CheckDate <= DateTime.Now && x.State != BLL.Const.JointCheck_Complete
 | 
						||
                        select x).Count();
 | 
						||
 | 
						||
            var zgl = String.Format("{0:N2}", 100.0 * num2 / (num2 + num3));
 | 
						||
            zlgjzgl = zgl.ToString();
 | 
						||
            zggjzglDataValue = (100 - (100.0 * num2 / (num2 + num3))).ToString();
 | 
						||
        }
 | 
						||
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 焊接
 | 
						||
        protected string hjallNumber="0";
 | 
						||
        protected string hjfinishNumber="0";
 | 
						||
        protected string hjzgl="0";
 | 
						||
 | 
						||
        protected string hjDataValue="0";
 | 
						||
        protected void getHj()
 | 
						||
        {
 | 
						||
            Model.SingleSerie series = new Model.SingleSerie();
 | 
						||
            Model.BusinessColumn businessColumn = new Model.BusinessColumn();
 | 
						||
            List<double> listdata = new List<double>();
 | 
						||
            double result = 0;
 | 
						||
            Model.SGGLDB db = Funs.DB;
 | 
						||
            //一次检测合格焊口数
 | 
						||
            int oneCheckJotNum = (from x in db.HJGL_Batch_NDEItem
 | 
						||
                                  join y in db.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals y.TrustBatchItemId
 | 
						||
                                  join z in db.HJGL_Batch_PointBatchItem on y.PointBatchItemId equals z.PointBatchItemId
 | 
						||
                                  join a in db.HJGL_Batch_NDE on x.NDEID equals a.NDEID
 | 
						||
                                  where z.PointDate != null && z.PointState == "1" && y.RepairRecordId == null
 | 
						||
                                  select x.NDEItemID).Count();
 | 
						||
            //一次检测返修焊口数
 | 
						||
            int oneCheckRepairJotNum = (from x in db.HJGL_Batch_NDEItem
 | 
						||
                                        join y in db.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals y.TrustBatchItemId
 | 
						||
                                        join z in db.HJGL_Batch_PointBatchItem on y.PointBatchItemId equals z.PointBatchItemId
 | 
						||
                                        join a in db.HJGL_Batch_NDE on x.NDEID equals a.NDEID
 | 
						||
                                        where z.PointDate != null && z.PointState == "1" && y.RepairRecordId == null && x.CheckResult == "2" 
 | 
						||
                                        select x.NDEItemID).Count();
 | 
						||
            if (oneCheckJotNum > 0)
 | 
						||
            {
 | 
						||
                var a = Convert.ToDouble(oneCheckJotNum - oneCheckRepairJotNum);
 | 
						||
                var b = Convert.ToDouble(oneCheckJotNum);
 | 
						||
                result = Convert.ToDouble(decimal.Round(decimal.Parse((a / b * 100).ToString()), 0));
 | 
						||
 | 
						||
                hjallNumber = b.ToString();
 | 
						||
                hjfinishNumber = a.ToString();
 | 
						||
                hjzgl = result.ToString();
 | 
						||
                hjDataValue = (100 - result).ToString();
 | 
						||
            }
 | 
						||
 | 
						||
            
 | 
						||
        }
 | 
						||
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 关键事项
 | 
						||
        //准点率
 | 
						||
        protected string gjsxZdl = "0";
 | 
						||
        protected void getGjsx()
 | 
						||
        {
 | 
						||
            //Check_JointCheck
 | 
						||
            var znum = (from x in Funs.DB.GJSX
 | 
						||
                             select x).Count();
 | 
						||
            divGjsxzj.InnerHtml = znum.ToString();
 | 
						||
 | 
						||
            //到期应完成
 | 
						||
            var dqnum = (from x in Funs.DB.GJSX where x.CompleteDate<=DateTime.Now
 | 
						||
                         select x).Count().ToString();
 | 
						||
            divGjsxdq.InnerHtml = dqnum;
 | 
						||
 | 
						||
            //未准点完成
 | 
						||
            var wzdnum = (from x in Funs.DB.GJSX
 | 
						||
                          where x.CompleteDate <= DateTime.Now
 | 
						||
                          && x.State !="0"
 | 
						||
                         select x).Count().ToString();
 | 
						||
            divGjsxwzd.InnerHtml = wzdnum;
 | 
						||
 | 
						||
            //准点率,已完成/总数*100
 | 
						||
            var ywcnum =  (from x in Funs.DB.GJSX
 | 
						||
                                       where x.CompleteDate <= DateTime.Now
 | 
						||
                                       && x.State == "0"
 | 
						||
                                       select x).Count();
 | 
						||
            gjsxZdl = Math.Round((100.0 * ywcnum / znum),2).ToString();
 | 
						||
        }
 | 
						||
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 人员信息
 | 
						||
        private void getSitePerson()
 | 
						||
        {
 | 
						||
            int AllCount = 0;
 | 
						||
            int MCount = 0;
 | 
						||
            var getallin = APIPageDataService.getPersonNumByCompany(DateTime.Now);
 | 
						||
            AllCount = getallin.Count();
 | 
						||
            if (AllCount > 0)
 | 
						||
            {
 | 
						||
                MCount = getallin.Where(x => x.PostType == Const.PostType_1).Count();
 | 
						||
            }
 | 
						||
 | 
						||
            if (AllCount > 0)
 | 
						||
            {
 | 
						||
                ////当前现场总人数
 | 
						||
                div_xcrs.InnerHtml = AllCount.ToString();
 | 
						||
                //作业人数
 | 
						||
                div_zyxcrs.InnerHtml = (AllCount - MCount).ToString();
 | 
						||
                //管理人数
 | 
						||
                div_glxcrs.InnerHtml = MCount.ToString();
 | 
						||
            }
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 项目人员图表
 | 
						||
        protected string ProjectPersonCount;
 | 
						||
        protected string ProjectPersonMc;
 | 
						||
        private void getProjectSitePerson()
 | 
						||
        {
 | 
						||
            var list = Funs.DB.Base_Project.Where(x => (x.ProjectState == Const.ProjectState_1 || x.ProjectState == null) && x.Progress != null).ToList();
 | 
						||
            foreach (var item in list)
 | 
						||
            {
 | 
						||
                ProjectPersonMc += "'" + item.ShortName + "',";
 | 
						||
                ProjectPersonCount  += "'" + APIPageDataService.getPersonNum(item.ProjectId,DateTime.Now).Count() + "',";
 | 
						||
            }
 | 
						||
            ProjectPersonMc = ProjectPersonMc.TrimEnd(',');
 | 
						||
            ProjectPersonCount = ProjectPersonCount.TrimEnd(',');
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 进度情况
 | 
						||
        protected string ProjectJd;
 | 
						||
        protected string ProjectMc;
 | 
						||
        protected void getJd() {
 | 
						||
            var list = Funs.DB.Base_Project.Where(x => (x.ProjectState == Const.ProjectState_1 || x.ProjectState == null) && x.Progress != null).ToList();
 | 
						||
            foreach (var item in list)
 | 
						||
            {
 | 
						||
                ProjectJd += "'" + item.Progress + "',";
 | 
						||
                ProjectMc += "'" + item.ShortName + "',";
 | 
						||
            }
 | 
						||
            ProjectJd = ProjectJd.TrimEnd(',');
 | 
						||
            ProjectMc = ProjectMc.TrimEnd(',');
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 整改数据
 | 
						||
        protected void getZgsj() {
 | 
						||
            div_zgsj.InnerHtml = (GetGeneralClosedNum() + GetGeneralNotClosedNum()).ToString();
 | 
						||
            div_zgywc.InnerHtml = GetGeneralClosedNum().ToString();
 | 
						||
            div_zgwwc.InnerHtml = GetGeneralNotClosedNum().ToString();
 | 
						||
            div_zgwcl.InnerHtml= String.Format("{0:N2}", 100.0 * GetGeneralClosedNum() / (GetGeneralNotClosedNum() + GetGeneralClosedNum()))+"%";
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 获取隐患整改闭环项
 | 
						||
        /// </summary>
 | 
						||
        /// <returns></returns>
 | 
						||
        public static int GetGeneralClosedNum()
 | 
						||
        {
 | 
						||
            int result = (from x in Funs.DB.HSSE_Hazard_HazardRegister
 | 
						||
                          where x.States == "3"
 | 
						||
                          select x).Count();
 | 
						||
            return result;
 | 
						||
        }
 | 
						||
        /// <summary>
 | 
						||
        /// 获取隐患未整改完成项
 | 
						||
        /// </summary>
 | 
						||
        /// <returns></returns>
 | 
						||
        public static int GetGeneralNotClosedNum()
 | 
						||
        {
 | 
						||
            int result = (from x in Funs.DB.HSSE_Hazard_HazardRegister
 | 
						||
                          where x.States != "3"
 | 
						||
                          select x).Count();
 | 
						||
            return result;
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
 | 
						||
        #region 材料到货
 | 
						||
        protected string gdclHtml;
 | 
						||
        protected string sbclHtml;
 | 
						||
 | 
						||
        protected string gdclHead = "<span>项目</span><span>管子</span><span>管件</span><span>阀门</span><span>垫片</span><span>紧固件</span>";
 | 
						||
        protected string sbclHead = "<span>项目</span><span>采购量</span><span>到货量</span><span>已到货百分比</span>";
 | 
						||
        private void getCldh() {
 | 
						||
           
 | 
						||
            //项目
 | 
						||
            var list = Funs.DB.Base_Project.Where(x => (x.ProjectState == Const.ProjectState_1 || x.ProjectState == null)).ToList();
 | 
						||
            var PipelinList = Funs.DB.CLGL_PipelineMaterialSumList.Where(x => x.Type == "M");
 | 
						||
            var SbclList = Funs.DB.CLGL_ContractListSum.Where(x => x.C1 == "设备");
 | 
						||
            foreach (var item in list)
 | 
						||
            {
 | 
						||
                #region 管道材料
 | 
						||
                gdclHtml += " <div class=\"tr\">";
 | 
						||
                var pname = item.ShortName;
 | 
						||
                if (item.ShortName.Length > 4)
 | 
						||
                {
 | 
						||
                    pname = item.ShortName.Substring(0, 4) + "...";
 | 
						||
                }
 | 
						||
 | 
						||
                gdclHtml += "<span title=\"" + item.ShortName + "\">" + pname + "</span>";
 | 
						||
                var pid = BLL.ProjectService.GetCLProjectCodeByProjectId(item.ProjectId).ToString();
 | 
						||
                //管子
 | 
						||
                var num1 = PipelinList.Where(x => x.ProjectId == pid && x.C1 == "管子").FirstOrDefault();
 | 
						||
                if (num1 != null)
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>" + (num1.C7 == "" ? "0%" : num1.C7) + "</span>";
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>0%</span>";
 | 
						||
                }
 | 
						||
 | 
						||
                var num2 = PipelinList.Where(x => x.ProjectId == pid && x.C1 == "管件法兰").FirstOrDefault();
 | 
						||
                if (num2 != null)
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>" + (num2.C7 == "" ? "0%" : num2.C7) + "</span>";
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>0%</span>";
 | 
						||
                }
 | 
						||
                var num3 = PipelinList.Where(x => x.ProjectId == pid && x.C1 == "阀门").FirstOrDefault();
 | 
						||
                if (num3 != null)
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>" + (num3.C7 == "" ? "0%" : num3.C7) + "</span>";
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>0%</span>";
 | 
						||
                }
 | 
						||
                var num4 = PipelinList.Where(x => x.ProjectId == pid && x.C1 == "垫片").FirstOrDefault();
 | 
						||
                if (num4 != null)
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>" + (num4.C7 == "" ? "0%" : num4.C7) + "</span>";
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>0%</span>";
 | 
						||
                }
 | 
						||
                var num5 = PipelinList.Where(x => x.ProjectId == pid && x.C1 == "紧固件").FirstOrDefault();
 | 
						||
                if (num5 != null)
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>" + (num5.C7 == "" ? "0%" : num5.C7) + "</span>";
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    gdclHtml += "<span>0%</span>";
 | 
						||
                }
 | 
						||
                gdclHtml += " </div>";
 | 
						||
                #endregion
 | 
						||
 | 
						||
                #region 设备材料
 | 
						||
                sbclHtml += " <div class=\"tr\">";
 | 
						||
                pname=item.ShortName;
 | 
						||
                if (item.ShortName.Length > 6)
 | 
						||
                {
 | 
						||
                    pname = item.ShortName.Substring(0, 6) + "...";
 | 
						||
                }
 | 
						||
                sbclHtml += "<span title=\"" + item.ShortName + "\">" + pname + "</span>";
 | 
						||
                //采购量
 | 
						||
                var SbcllCglList = SbclList.Where(x => x.ProjectId == pid).ToList();
 | 
						||
                double SbcllCgl = 0.0;
 | 
						||
                double Sbdhs = 0.0;
 | 
						||
                foreach (var itemCgl in SbcllCglList)
 | 
						||
                {
 | 
						||
                    if (string.IsNullOrEmpty(itemCgl.C7))
 | 
						||
                    {
 | 
						||
                        SbcllCgl += 0;
 | 
						||
                        Sbdhs += 0;
 | 
						||
                    }
 | 
						||
                    else {
 | 
						||
                        SbcllCgl +=Convert.ToDouble(itemCgl.C7);
 | 
						||
                        Sbdhs += Convert.ToDouble(itemCgl.C9);
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
                sbclHtml += "<span>" + SbcllCgl + "</span>";
 | 
						||
                sbclHtml += "<span>" + Sbdhs + "</span>";
 | 
						||
                //百分比
 | 
						||
                if (SbcllCgl + Sbdhs != 0)
 | 
						||
                {
 | 
						||
                    var dhbfb = String.Format("{0:N2}", 100.0 * Sbdhs / (Sbdhs + SbcllCgl), 2) + "%";
 | 
						||
                    sbclHtml += "<span>" + dhbfb + "</span>";
 | 
						||
                }
 | 
						||
                else {
 | 
						||
                    sbclHtml += "<span>0%</span>";
 | 
						||
                }
 | 
						||
                
 | 
						||
 | 
						||
                
 | 
						||
 | 
						||
                sbclHtml += " </div>";
 | 
						||
                #endregion
 | 
						||
            }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
        }
 | 
						||
        #endregion
 | 
						||
    }
 | 
						||
} |