2023-12-04 18:12:02 +08:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
namespace FineUIPro.Web.HSSE.KqShowScreen
|
|
|
|
|
{
|
|
|
|
|
public partial class KqShowScreen : 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;
|
2023-12-08 18:33:21 +08:00
|
|
|
|
HashSet<string> ids = new HashSet<string>();
|
2023-12-04 18:12:02 +08:00
|
|
|
|
HashSet<string> idsIn = new HashSet<string>();
|
2023-12-08 18:33:21 +08:00
|
|
|
|
Dictionary<string, DateTime> inperson = new Dictionary<string, DateTime>();
|
2023-12-04 18:12:02 +08:00
|
|
|
|
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.WorkPostName))
|
|
|
|
|
{
|
|
|
|
|
workPost[io.WorkPostName] = workPost[io.WorkPostName] + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
workPost[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 personInOut = inout.FirstOrDefault();
|
|
|
|
|
string teamGroupName = "";
|
|
|
|
|
string inOut = "出场";
|
|
|
|
|
string PhotoUrl = "";
|
2023-12-08 18:33:21 +08:00
|
|
|
|
string PersonName = "";
|
|
|
|
|
string UnitName = "";
|
|
|
|
|
string WorkPostName = "";
|
|
|
|
|
string ChangeTime = "";
|
|
|
|
|
if (personInOut != null)
|
2023-12-04 18:12:02 +08:00
|
|
|
|
{
|
2023-12-08 18:33:21 +08:00
|
|
|
|
var person = Funs.DB.SitePerson_Person.FirstOrDefault(x => x.PersonId == personInOut.PersonId);
|
|
|
|
|
PersonName = personInOut.PersonName;
|
|
|
|
|
UnitName = personInOut.UnitName;
|
|
|
|
|
WorkPostName = personInOut.WorkPostName;
|
|
|
|
|
ChangeTime = personInOut.ChangeTime.Value.ToString("yyyy-MM-dd HH:mm");
|
|
|
|
|
PhotoUrl = "../../" + person.PhotoUrl;
|
|
|
|
|
if (personInOut.IsIn == true)
|
2023-12-04 18:12:02 +08:00
|
|
|
|
{
|
2023-12-08 18:33:21 +08:00
|
|
|
|
inOut = "入场";
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(person.TeamGroupId))
|
|
|
|
|
{
|
|
|
|
|
var teamGroup = Funs.DB.ProjectData_TeamGroup.FirstOrDefault(x => x.TeamGroupId == person.TeamGroupId);
|
|
|
|
|
if (teamGroup != null)
|
|
|
|
|
{
|
|
|
|
|
teamGroupName = teamGroup.TeamGroupName;
|
|
|
|
|
}
|
2023-12-04 18:12:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-12-08 18:33:21 +08:00
|
|
|
|
List<object> comStatic = new List<object>();
|
2023-12-04 18:12:02 +08:00
|
|
|
|
foreach (var key in company.Keys)
|
|
|
|
|
{
|
2023-12-08 18:33:21 +08:00
|
|
|
|
comStatic.Add(new { name = key, value = company[key] });
|
2023-12-04 18:12:02 +08:00
|
|
|
|
}
|
|
|
|
|
List<string> workPostName = new List<string>();
|
|
|
|
|
List<int> workPostValue = new List<int>();
|
|
|
|
|
foreach (var key in workPost.Keys)
|
|
|
|
|
{
|
|
|
|
|
workPostName.Add(key);
|
|
|
|
|
workPostValue.Add(workPost[key]);
|
|
|
|
|
}
|
2023-12-08 18:33:21 +08:00
|
|
|
|
return new { company = comStatic, total, workPost = new { name = workPostName, value = workPostValue }, person = new { PersonName, UnitName, WorkPostName, inOut, PhotoUrl, teamGroupName, ChangeTime } };
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-12-04 18:12:02 +08:00
|
|
|
|
}
|
|
|
|
|
}
|