225 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			C#
		
	
	
	
		
		
			
		
	
	
			225 lines
		
	
	
		
			7.8 KiB
		
	
	
	
		
			C#
		
	
	
	
| 
								 | 
							
								using BLL;
							 | 
						|||
| 
								 | 
							
								using FastReport.Data;
							 | 
						|||
| 
								 | 
							
								using FineUIPro.Web.HSSE.SitePerson;
							 | 
						|||
| 
								 | 
							
								using FineUIPro.Web.ProjectData;
							 | 
						|||
| 
								 | 
							
								using System;
							 | 
						|||
| 
								 | 
							
								using System.Collections.Generic;
							 | 
						|||
| 
								 | 
							
								using System.Linq;
							 | 
						|||
| 
								 | 
							
								using System.Web;
							 | 
						|||
| 
								 | 
							
								using System.Web.Services;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI;
							 | 
						|||
| 
								 | 
							
								using System.Web.UI.WebControls;
							 | 
						|||
| 
								 | 
							
								using System.Windows.Forms;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								namespace FineUIPro.Web.HSSE.KqShowScreen
							 | 
						|||
| 
								 | 
							
								{
							 | 
						|||
| 
								 | 
							
								    public partial class JZYScreenOld : PageBase
							 | 
						|||
| 
								 | 
							
								    {
							 | 
						|||
| 
								 | 
							
								        #region 项目主键
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 项目主键
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        public string ProjectId
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            get
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                return (string)ViewState["ProjectId"];
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            set
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ViewState["ProjectId"] = value;
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        #region 加载
							 | 
						|||
| 
								 | 
							
								        /// <summary>
							 | 
						|||
| 
								 | 
							
								        /// 加载页面
							 | 
						|||
| 
								 | 
							
								        /// </summary>
							 | 
						|||
| 
								 | 
							
								        /// <param name="sender"></param>
							 | 
						|||
| 
								 | 
							
								        /// <param name="e"></param>
							 | 
						|||
| 
								 | 
							
								        protected void Page_Load(object sender, EventArgs e)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            if (!IsPostBack)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                this.ProjectId = this.CurrUser.LoginProjectId;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								        #endregion
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								        [WebMethod]
							 | 
						|||
| 
								 | 
							
								        public static object getData(string projectId)
							 | 
						|||
| 
								 | 
							
								        {
							 | 
						|||
| 
								 | 
							
								            int total = 0;
							 | 
						|||
| 
								 | 
							
								            HashSet<string> ids = new HashSet<string>();
							 | 
						|||
| 
								 | 
							
								            HashSet<string> idsIn = new HashSet<string>();
							 | 
						|||
| 
								 | 
							
								            Dictionary<string, DateTime> inperson = new Dictionary<string, DateTime>();
							 | 
						|||
| 
								 | 
							
								            Dictionary<string, DateTime> outPerson = new Dictionary<string, DateTime>();
							 | 
						|||
| 
								 | 
							
								            DateTime dateTime = DateTime.Now.AddDays(-1);
							 | 
						|||
| 
								 | 
							
								            var inout = Funs.DB.SitePerson_PersonInOut.Where(x => x.ProjectId == projectId && x.ChangeTime > dateTime).OrderByDescending(x => x.ChangeTime);
							 | 
						|||
| 
								 | 
							
								            Dictionary<string, int> company = new Dictionary<string, int>();
							 | 
						|||
| 
								 | 
							
								            Dictionary<string, int> workPost = new Dictionary<string, int>();
							 | 
						|||
| 
								 | 
							
								            foreach (var io in inout)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                ids.Add(io.PersonId);
							 | 
						|||
| 
								 | 
							
								                if (io.IsIn.HasValue && io.IsIn.Value) //24小时内最晚的入场
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    if (inperson.ContainsKey(io.PersonId))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (inperson[io.PersonId] < io.ChangeTime.Value)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            inperson[io.PersonId] = io.ChangeTime.Value;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (io.ChangeTime.HasValue)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            inperson.Add(io.PersonId, io.ChangeTime.Value);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else  //24小时内最晚的出场
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    if (outPerson.ContainsKey(io.PersonId))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (outPerson[io.PersonId] < io.ChangeTime.Value)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            outPerson[io.PersonId] = io.ChangeTime.Value;
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    else
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (io.ChangeTime.HasValue)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            outPerson.Add(io.PersonId, io.ChangeTime.Value);
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								            foreach (var id in ids)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (inperson.ContainsKey(id) && !outPerson.ContainsKey(id))//只有入场没有出场  在场
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    idsIn.Add(id);
							 | 
						|||
| 
								 | 
							
								                    total++;
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                else if (inperson.ContainsKey(id) && outPerson.ContainsKey(id))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    if (inperson[id] > outPerson[id])//最晚入场时间 小于出场时间   在场
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        idsIn.Add(id);
							 | 
						|||
| 
								 | 
							
								                        total++;
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            HashSet<string> keys1 = new HashSet<string>();
							 | 
						|||
| 
								 | 
							
								            HashSet<string> keys2 = new HashSet<string>();
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            foreach (var io in inout)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								                if (idsIn.Contains(io.PersonId))
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    if (!string.IsNullOrEmpty(io.WorkPostName))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (!keys1.Contains(io.PersonId))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            keys1.Add(io.PersonId);
							 | 
						|||
| 
								 | 
							
								                            if (workPost.ContainsKey(io.UnitName+";"+io.WorkPostName))
							 | 
						|||
| 
								 | 
							
								                            {
							 | 
						|||
| 
								 | 
							
								                                workPost[io.UnitName + ";" + io.WorkPostName] = workPost[io.UnitName + ";" + io.WorkPostName] + 1;
							 | 
						|||
| 
								 | 
							
								                            }
							 | 
						|||
| 
								 | 
							
								                            else
							 | 
						|||
| 
								 | 
							
								                            {
							 | 
						|||
| 
								 | 
							
								                                workPost[io.UnitName + ";" + io.WorkPostName] = 1;
							 | 
						|||
| 
								 | 
							
								                            }
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                    if (!string.IsNullOrEmpty(io.UnitName))
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        if (!keys2.Contains(io.PersonId))
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            keys2.Add(io.PersonId);
							 | 
						|||
| 
								 | 
							
								                            if (company.ContainsKey(io.UnitName))
							 | 
						|||
| 
								 | 
							
								                            {
							 | 
						|||
| 
								 | 
							
								                                company[io.UnitName] = company[io.UnitName] + 1;
							 | 
						|||
| 
								 | 
							
								                            }
							 | 
						|||
| 
								 | 
							
								                            else
							 | 
						|||
| 
								 | 
							
								                            {
							 | 
						|||
| 
								 | 
							
								                                company[io.UnitName] = 1;
							 | 
						|||
| 
								 | 
							
								                            }
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								            } 
							 | 
						|||
| 
								 | 
							
								       
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            var workPosts = Funs.DB.Base_WorkPost.ToList(); 
							 | 
						|||
| 
								 | 
							
								            string html = "";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            List<object> comStatic = new List<object>();
							 | 
						|||
| 
								 | 
							
								            foreach (var key in company.Keys)
							 | 
						|||
| 
								 | 
							
								            {
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                html += @" <li>  
							 | 
						|||
| 
								 | 
							
								                                <div class='container'>           
							 | 
						|||
| 
								 | 
							
								                                    <div class='column' style='width: 10rem;line-height:2.8rem' > "+ key + @"</div> 
							 | 
						|||
| 
								 | 
							
								                                              <div class='column' style='width: 3rem;line-height:2.8rem'>"+ company[key] + @"</div> ";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                int MPerson = 0;
							 | 
						|||
| 
								 | 
							
								                int SPerson = 0;
							 | 
						|||
| 
								 | 
							
								                string workPostName = "";
							 | 
						|||
| 
								 | 
							
								                string workPostNum = "";
							 | 
						|||
| 
								 | 
							
								                foreach (var key2 in workPost.Keys)
							 | 
						|||
| 
								 | 
							
								                {
							 | 
						|||
| 
								 | 
							
								                    MPerson = 0;
							 | 
						|||
| 
								 | 
							
								                    SPerson = 0;
							 | 
						|||
| 
								 | 
							
								                    string[] keys = key2.Split(';');
							 | 
						|||
| 
								 | 
							
								                    if (key == keys[0])
							 | 
						|||
| 
								 | 
							
								                    {
							 | 
						|||
| 
								 | 
							
								                        var workPostTemp = workPosts.FirstOrDefault(w => w.WorkPostName == keys[1]);
							 | 
						|||
| 
								 | 
							
								                        if (workPostTemp != null)
							 | 
						|||
| 
								 | 
							
								                        {
							 | 
						|||
| 
								 | 
							
								                            if (workPostTemp.PostType == Const.PostType_1)//管理人员
							 | 
						|||
| 
								 | 
							
								                            {
							 | 
						|||
| 
								 | 
							
								                                MPerson += workPost[key2];
							 | 
						|||
| 
								 | 
							
								                            }
							 | 
						|||
| 
								 | 
							
								                            else if (workPostTemp.PostType == Const.PostType_2)//特种作业人员
							 | 
						|||
| 
								 | 
							
								                            {
							 | 
						|||
| 
								 | 
							
								                                SPerson += workPost[key2];
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                                  workPostName += " <div> "+ keys[1] + " </div> ";
							 | 
						|||
| 
								 | 
							
								                                  workPostNum += " <div> "+ workPost[key2] + " </div> ";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                            }
							 | 
						|||
| 
								 | 
							
								                        }
							 | 
						|||
| 
								 | 
							
								                    }
							 | 
						|||
| 
								 | 
							
								                }
							 | 
						|||
| 
								 | 
							
								                var ZPerson = company[key] - MPerson - SPerson;
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                workPostName += "<div>作业人员</div> ";
							 | 
						|||
| 
								 | 
							
								                workPostNum += " <div>" + ZPerson + "</div>";
							 | 
						|||
| 
								 | 
							
								                workPostName += " <div>管理人员</div> ";
							 | 
						|||
| 
								 | 
							
								                workPostNum += " <div>" + MPerson + "</div>";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								                html += "<div class='column'style='width: 8rem;'>"+ workPostName + "</div>";
							 | 
						|||
| 
								 | 
							
								                html += "<div class='column'style='width: 3rem;'> "+ workPostNum + "</div> </div>       </li>";
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								              
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								            return new { company = html, total  };
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								             
							 | 
						|||
| 
								 | 
							
								        }
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								
							 | 
						|||
| 
								 | 
							
								    }
							 | 
						|||
| 
								 | 
							
								}
							 |