劳务人员看板

This commit is contained in:
geh
2026-05-09 11:43:24 +08:00
parent c375bff46b
commit 6c67afae72
19 changed files with 4902 additions and 22 deletions
@@ -0,0 +1,335 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JZYScreen.aspx.cs" Inherits="FineUIPro.Web.HSSE.KqShowScreen.JZYScreen" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../..//res/lib/flex.js"></script>
<link rel="stylesheet" href="../../res/css/jzyscreen.css">
</head>
<style>
.header{
position: relative;
}
.b-wrap{
position: absolute;
top:6px;
right:6px;
font-size: 12px;
padding:2px 6px;
border: 1px solid #ffffff;
text-align: center;
color:#fff;
}
</style>
<body>
<div class="wrap">
<div class="header">
<h1><%=ProjectName%></h1>
<div style="position: absolute;top: 0.5rem;right: 0.2rem;color: #ffffff;" id="divTime"></div>
<div class="b-wrap"><asp:Literal runat="server" Text="全屏"/></div>
</div>
<div class="conterner">
<div class="row">
<%-- <div class="row-1">
<div class="label">距离12·31中交目标还剩余(天)</div>
<div class="number" id ="divDayRel">0</div>
</div>--%>
<div class="row-1" style="margin-top: .25rem;">
<div class="label"><asp:Literal runat="server" Text="累计安全人工时"/></div>
<div class="number" id ="divSafeTotal">0</div>
</div>
<div class="row-1" style="margin-top: .25rem;">
<div class="label"><asp:Literal runat="server" Text="一周安全人工时"/></div>
<div class="number"id ="divSafeWeek">0</div>
</div>
<div id="rs">
</div>
</div>
<div class="c-row">
<div class="table">
<div class="table-head">
<div class="th" style="width: 20%;">
<span><asp:Literal runat="server" Text="施工单位名称"/></span>
</div>
<div class="th" style="width: 20%;">
<span><asp:Literal runat="server" Text="当日总数/系统总数"/></span>
</div>
<div class="th" style="width: 60%;">
<div class="th-1"><asp:Literal runat="server" Text="特种作业人员"/></div>
<div class="th-2">
<span style="width: 50%;"><asp:Literal runat="server" Text="特岗名称"/></span>
<span style="width: 25%;"><asp:Literal runat="server" Text="系统登记人数"/></span>
<span style="width: 25%;"><asp:Literal runat="server" Text="当前在场人数"/></span>
</div>
</div>
</div>
<div class="table-body">
<div class="scroll-box">
<div class="t" id="divScroller">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<script src="../../res/lib/echarts.min.js"></script>
<script src="../../res/lib/jquery.js"></script>
<script>
var projectid = '<%=ProjectId%>'
var timer = null;
function isScroll() {
let mainEle = document.querySelector('.table-body')
let serollEle = document.querySelector('.scroll-box')
if (serollEle.children[0].children.length < 6) {
return
}
serollEle.appendChild(serollEle.children[0].cloneNode(true))
function Marquee() {
if (mainEle.offsetHeight + mainEle.scrollTop < serollEle.offsetHeight) {
mainEle.scrollTop++
console.log(mainEle.offsetHeight, serollEle.offsetHeight)
} else {
serollEle.appendChild(serollEle.children[0].cloneNode(true))
serollEle.removeChild(serollEle.children[0])
}
}
timer = setInterval(Marquee, 90)
mainEle.onmouseover = function () { clearInterval(timer) }
mainEle.onmouseout = function () { timer = setInterval(Marquee, 90) }
}
var temp=[]
function createSM(value1) {
var chartDom = document.getElementById('rs');
var myChart = echarts.init(chartDom);
var option;
let leftLabel = ['施工人员 ', '<%=remark2 %>', '<%=remark3 %>', '<%=remark4 %>', '<%=remark5 %>', '<%=remark6 %>']
option = {
grid: {
top: 4,
left: 4,
right: 4,
bottom: 4,
containLabel: true
},
xAxis: {
type: 'value',
splitLine: {
show: false
},
axisLabel: {
show: false,
}
},
yAxis: [
{
type: 'category',
position: 'left',
axisLine: {
show: false
},
axisTick: {
show: false
},
splitLine: {
show: false
},
axisLabel: {
color: "#ffffff",
fontWeight: "bolder",
fontSize: 24,
textShadowColor: '#000000', // 设置阴影颜色
textShadowBlur: 1, // 设置阴影模糊度
textShadowOffsetX: 1, // 设置阴影水平偏移
textShadowOffsetY: 1 // 设置阴影垂直偏移
},
data: leftLabel,
}, {
type: '',
position: 'right',
axisLine: {
show: false
},
axisTick: {
show: false
},
splitLine: {
show: false
},
axisLabel: {
fontFamily: "DIN",
color: "#CCCCCC",
fontWeight: "bolder",
fontSize: 30,
textShadowColor: '#000000', // 设置阴影颜色
textShadowBlur: 1, // 设置阴影模糊度
textShadowOffsetX: 1, // 设置阴影水平偏移
textShadowOffsetY: 1 // 设置阴影垂直偏移
},
data: value1,
}
],
series: [
{
name: '人数',
type: 'bar',
// stack: 'total',
barWidth: 30,
label: {
show: false,
fontSize: 30,
fontFamily: "DIN",
align: "left",
},
itemStyle: {
color: "#1e7bc9"
},
emphasis: {
focus: 'series'
},
data: value1
}
]
};
if (temp.length != value1.length || (temp[0] != value1[0] || temp[1] != value1[1] || temp[2] != value1[2] || temp[3] != value1[3] || temp[4] != value1[4] || temp[5] != value1[5])) {
myChart.clear();
temp = value1;
option && myChart.setOption(option);
}
}
getData();
function getData() {
$.ajax({
url: "JZYScreen.aspx/getData",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
projectId: projectid
}),
success: function (data) {
if (data.d != null) {
var company = data.d.company;
if (company != null) {
$("#divScroller").html(data.d.company);
//if (timer != null) {
// clearInterval(timer);
//}
//isScroll();
}
debugger
createSM(data.d.num)
$("#divSafeTotal").html(data.d.safeTotal);
$("#divSafeWeek").html(data.d.safeTotalWeek);
//const now = new Date();
//const yearEnd = new Date(now.getFullYear(), 11, 31);
//const diff = yearEnd - now;
//var dayRes = diff > 0 ? Math.ceil(diff / (1000 * 60 * 60 * 24)) + 1 : 0;
//$("#divDayRel").html(dayRes);
}
}
})
}
setInterval(function () { //执行任务
getData();
}, 10000);
setInterval(function () { //执行任务
var now = new Date(); // 获取当前时间
var years = now.getFullYear(); // 小时
var months = now.getMonth()+1; // 小时
var days = now.getDate(); // 小时
var hours = now.getHours(); // 小时
var minutes = now.getMinutes(); // 分钟
var seconds = now.getSeconds(); // 秒
// 确保时间总是以两位数显示
hours = hours < 10 ? '0' + hours : hours;
minutes = minutes < 10 ? '0' + minutes : minutes;
seconds = seconds < 10 ? '0' + seconds : seconds;
// 更新时钟显示
var clock = years + '-' + months+'-'+days+' ' + hours + ':' + minutes + ':' + seconds;
$("#divTime").html(clock);
}, 1000);
$('.b-wrap').on('click', function () {
if (isFullScreen()) {
// 处于全屏
exitFullScreen()
} else {
// 未处于全屏
requestFullScreen(document.querySelector(".wrap"));
}
})
    function isFullScreen() {
        return !!(document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement);
    }
function requestFullScreen(element) {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.webkitRequestFullscreen) {
element.webkitRequestFullscreen();
} else if (element.msRequestFullscreen) {
element.msRequestFullscreen();
}
$('.b-wrap').text('<%=title2 %>')
}
// 退出全屏
function exitFullScreen() {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.webkitExitFullscreen) {
document.webkitExitFullscreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
$('.b-wrap').text('<%=title1 %>')
}
</script>
@@ -0,0 +1,416 @@
using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI.WebControls;
namespace FineUIPro.Web.HSSE.KqShowScreen
{
public partial class JZYScreen : PageBase
{
#region
/// <summary>
/// 项目主键
/// </summary>
public string ProjectId
{
get
{
return (string)ViewState["ProjectId"];
}
set
{
ViewState["ProjectId"] = value;
}
}
public string ProjectName
{
get
{
return (string)ViewState["ProjectName"];
}
set
{
ViewState["ProjectName"] = 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;
var project = Funs.DB.Base_Project.FirstOrDefault(x => x.ProjectId == ProjectId);
string title = "现场人员动态看板";
if (project != null)
{
if (!string.IsNullOrEmpty(project.ShortName))
{
ProjectName = project.ShortName + title;
}
else
{
ProjectName = project.ProjectName + title;
}
}
title1 = "全屏";
title2 = "退出全屏";
remark1 = "施工人员";
remark2 = "建投管理人员";
remark3 = "监理管理人员";
remark4 = "业主管理人员";
remark5 = "当前现场人数";
remark6 = "当日最高人数";
}
}
#endregion
protected string title1 = string.Empty;
protected string title2 = string.Empty;
protected string remark1 = string.Empty;
protected string remark2 = string.Empty;
protected string remark3 = string.Empty;
protected string remark4 = string.Empty;
protected string remark5 = string.Empty;
protected string remark6 = string.Empty;
[WebMethod]
public static object getData(string projectId)
{
//let leftLabel = ['施工人员', '十六化建管理人员', '天辰管理人员', '监理管理人员', '业主管理人员', '当前现场总人数', '当日最高人数']
int num1 = 0;
int num2 = 0;
int num3 = 0;
int num4 = 0;
int num5 = 0;
int num6 = 0;
int num7 = 0;
try
{
int total = 0;
HashSet<string> ids = new HashSet<string>();
HashSet<string> idsIn = new HashSet<string>();
HashSet<string> personAll = 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);
var unitid1 = Funs.DB.Project_ProjectUnit.Where(x => x.ProjectId == projectId && x.UnitType == Const.ProjectUnitType_3).Select(x => x.UnitId).ToArray();
var unitname1 = Funs.DB.Base_Unit.Where(x => unitid1.Contains(x.UnitId)).Select(x => x.UnitName).ToArray();
var unitid2 = Funs.DB.Project_ProjectUnit.Where(x => x.ProjectId == projectId && x.UnitType == Const.ProjectUnitType_4).Select(x => x.UnitId);
var unitname2 = Funs.DB.Base_Unit.Where(x => unitid2.Contains(x.UnitId)).Select(x => x.UnitName).ToArray();
Dictionary<string, int> company = new Dictionary<string, int>();
Dictionary<string, int> companySys = new Dictionary<string, int>();
Dictionary<string, int> workPost = new Dictionary<string, int>();
Dictionary<string, int> workPostSys = new Dictionary<string, int>();
foreach (var io in inout)
{
personAll.Add(io.PersonId);
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);
}
}
}
}
num7 = personAll.Count;
foreach (var id in ids)
{
if (inperson.ContainsKey(id) && !outPerson.ContainsKey(id))//只有入场没有出场 在场
{
idsIn.Add(id);
num6++;
}
else if (inperson.ContainsKey(id) && outPerson.ContainsKey(id))
{
if (inperson[id] > outPerson[id])//最晚入场时间 小于出场时间 在场
{
idsIn.Add(id);
num6++;
}
}
}
num1 = num6;
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 strSql = @"SELECT p.UnitId
,ISNULL((case when u.UnitName=''then null else u.UnitName end),'未知') AS UnitName
,p.WorkPostId as PostId
,w.PostType
,ISNULL((case when W.WorkPostName=''then null else W.WorkPostName end),'未知') AS PostName
,COUNT( distinct PersonId) AS PersonCountSum
FROM dbo.SitePerson_Person AS P
LEFT JOIN dbo.Base_Unit AS U ON P.UnitId=U.UnitId
LEFT JOIN dbo.Base_WorkPost AS W ON P.WorkPostId=W.WorkPostId
LEFT JOIN dbo.Project_ProjectUnit AS pu ON pu.UnitId=p.UnitId and pu.ProjectId=p.ProjectId
WHERE pu.ProjectId is not null and P.ProjectId = '" + projectId + @"' and P.InTime <=GETDATE() and ( P.OutTime is null or P.OutTime > GETDATE()) and p.IsUsed =1
GROUP BY P.ProjectId,P.UnitId,U.UnitName,P.WorkPostId,w.PostType,W.WorkPostName";
System.Data.DataTable tb = SQLHelper.GetDataTableRunText(strSql, null);
if (tb != null && tb.Rows.Count > 0)
{
foreach (DataRow row in tb.Rows)
{
if (!string.IsNullOrEmpty(row["PostName"].ToString()))
{
if (!workPostSys.ContainsKey(row["UnitName"].ToString() + ";" + row["PostName"].ToString()))
{
workPostSys.Add(row["UnitName"].ToString() + ";" + row["PostName"].ToString(), 0);
}
workPostSys[row["UnitName"].ToString() + ";" + row["PostName"].ToString()] = workPostSys[row["UnitName"].ToString() + ";" + row["PostName"].ToString()] + int.Parse(row["PersonCountSum"].ToString());
}
if (!string.IsNullOrEmpty(row["UnitName"].ToString()))
{
if (!companySys.ContainsKey(row["UnitName"].ToString()))
{
companySys.Add(row["UnitName"].ToString(), 0);
}
companySys[row["UnitName"].ToString()] = companySys[row["UnitName"].ToString()] + int.Parse(row["PersonCountSum"].ToString());
}
}
}
string html = "";
List<object> comStatic = new List<object>();
foreach (var key in company.Keys)
{
string unitName = key;
var unit = Funs.DB.Base_Unit.FirstOrDefault(x => x.UnitName == unitName);
if (unit != null && !string.IsNullOrEmpty(unit.ShortUnitName))
{
unitName = unit.ShortUnitName;
}
if (!unitname2.Contains(key) && !unitname1.Contains(key) && "中化学建设投资集团有限公司" != key)
{
html += @" <div class='tr'>
<div class='td' style='width: 20%;'><span>" + unitName + @"</span></div>
<div class='td' style='width: 20%;'>" + company[key] + "/" + (companySys.ContainsKey(key) ? companySys[key] : 0) + @"</div>
<div class='row-box' style='width: 60%;'> ";
}
int MPerson = 0;
int MPersonSys = 0;
int SPerson = 0;
int SPersonSys = 0;
string workPostName = "";
string workPostNum = "";
string workPostSysNum = "";
foreach (var key2 in workPost.Keys)
{
MPerson = 0;
SPerson = 0;
string[] keys = key2.Split(';');
if (key == keys[0])
{
if (unitname2.Contains(key))
{
num5 += workPost[key2];
}
else if ("中化学建设投资集团有限公司" == key)
{
num3 += workPost[key2];
}
else if (unitname1.Contains(key))
{
num4 += workPost[key2];
}
var workPostTemp = workPosts.FirstOrDefault(w => w.WorkPostName == keys[1]);
if (workPostTemp != null)
{
if (workPostTemp.PostType == Const.PostType_1)//管理人员
{
//if (Resources.Lan.ASPXSC_3064 == key)//十六化建管理人员
//{
// num2 += workPost[key2];
//}
//else
num1 -= workPost[key2];
MPerson += workPost[key2];
MPersonSys += workPostSys.ContainsKey(key2) ? workPostSys[key2] : 0;
}
else if (workPostTemp.PostType == Const.PostType_2)//特种作业人员
{
SPerson += workPost[key2];
SPersonSys += workPostSys.ContainsKey(key2) ? workPostSys[key2] : 0;
workPostName += " <span> " + keys[1] + " </span> ";
workPostNum += " <span> " + workPost[key2] + " </span> ";
workPostSysNum += " <span> " + (workPostSys.ContainsKey(key2) ? workPostSys[key2] : 0) + " </span> ";
}
}
}
}
var ZPerson = company[key] - MPerson - SPerson;
var ZPersonSys = company[key] - MPersonSys - SPersonSys;
//workPostName += "<span>作业人员</span> ";
//workPostNum += " <span>" + ZPerson + "</span>";
//workPostSysNum += " <span>" + ZPersonSys + "</span>";
//workPostName += " <span>管理人员</span> ";
//workPostNum += " <span>" + MPerson + "</span>";
//workPostSysNum += " <span>" + MPersonSys + "</span>";
if (!unitname2.Contains(key) && !unitname1.Contains(key) && "中化学建设投资集团有限公司" != key)
{
html += @"<div class='td' style='width: 50%;align-items:start;'>"
+ workPostName +
@"</div>
<div class='td' style='width: 25%;'>"
+ workPostSysNum +
@"</div>
<div class='td' style='width: 25%;'>"
+ workPostNum +
@"</div>
</div>
</div>";
}
}
int safeTotal = 0;
int safeTotalWeek = 0;
var getMax = from x in Funs.DB.SitePerson_DayReportDetail
join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId
where y.ProjectId == projectId
select x;
if (getMax.Count() > 0)
{
safeTotal = Convert.ToInt32(getMax.Sum(x => x.PersonWorkTime) ?? 0);
}
var getWeek = from x in Funs.DB.SitePerson_DayReportDetail
join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId
where y.ProjectId == projectId
where y.CompileDate > DateTime.Now.AddDays(-7)
select x;
if (getWeek.Count() > 0)
{
safeTotalWeek = Convert.ToInt32(getWeek.Sum(x => x.PersonWorkTime) ?? 0);
}
num1 = num6 - num5 - num4 - num3;
return new { company = html, total, num = new int[] { num1, num3, num4, num5, num6, num7 }, safeTotal, safeTotalWeek };
}
catch (Exception e)
{
return new { company = e.Message };
}
}
}
}
@@ -0,0 +1,17 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.HSSE.KqShowScreen
{
public partial class JZYScreen
{
}
}
@@ -0,0 +1,327 @@
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="KqShowScreen.aspx.cs" Inherits="FineUIPro.Web.HSSE.KqShowScreen.KqShowScreen" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<script src="../../res/lib/flex.js"></script>
<link rel="stylesheet" href="../../res/css/kqshowscreen.css">
</head>
<body>
<div class="context">
<div class="left site">
<div class="block">
<div class="title"><asp:Literal runat="server" Text="当前现场总人数"/></div>
<div class="main xc">
<div class="number" id="divTotal">
0
</div>
</div>
</div>
<div class="block1 ">
<div class="title"><asp:Literal runat="server" Text="当前公司现场人数"/></div>
<div class="main gsxc">
<ul id="ulcom" >
</ul>
</div>
</div>
</div>
<div class="right site">
<div class="block1">
<div class="top">
<div class="info">
<ul id="infoul">
</ul>
</div>
<div class="photo">
<img id="header" src="">
</div>
</div>
</div>
<div class="block">
<div class="title"><asp:Literal runat="server" Text="当前现场岗位人数量"/></div>
<div class="main" id="gwnum">
</div>
</div>
</div>
</div>
</body>
</html>
<script src="../../res/lib/echarts.min.js"></script>
<script src="../../res/lib/jquery.js"></script>
<script>
var projectid = '<%=ProjectId%>'
function createGWNUM(name, value1) {
let type = name//['焊工', '电工', '架子工', '木工', '管工', '仪表安装工', '电气安装工', '钢筋工', '起重司机', '钳工', '起重指挥', '混凝土工', '维护电工']
let value = value1// [100, 96, 89, 88, 87, 81, 80, 76, 75, 72, 70, 65, 62, 61]
let opt = {
grid: {
top: 20,
left: 60,
right:60
// bottom: 30
},
xAxis: {
type: 'category',
data: type,
axisLine: {
lineStyle: {
color: '#84D7FE'
}
},
axisTick: {
show: false
},
axisLabel: {
interval: 0, // 坐标轴刻度标签的显示间隔
rotate: -30 // 标签倾斜的角度
}
},
yAxis: {
type: 'value',
axisLine: {
lineStyle: {
color: '#84D7FE'
}
},
splitLine: {
lineStyle: {
color: '#2E87AC',
type: 'dashed'
}
}
},
dataZoom: [
{
show: true,
type: 'slider', // 单独滚动条
filterMode: 'none', // 不过滤数据 - 保证 y 轴数据范围不变
brushSelect: true,
bottom: 0,
height: 10,
backgroundColor: 'transparent',
// 选中范围的填充颜色
fillerColor: 'transparent',
borderWidth: 0,
borderColor: 'transparent',
dataBackground: {
lineStyle: {
color: 'transparent'
},
areaStyle: {
color: 'transparent'
}
},
selectedDataBackground: {
lineStyle: {
color: 'transparent'
},
areaStyle: {
color: 'transparent'
}
},
startValue: 0,
endValue: 10,
xAxisIndex: [0],
showDetail: false,
handleSize: '0%',
// 移动手柄尺寸高度
// 测试发现手柄颜色和边框颜色会出现 偏差,所有设置手柄高度为0, 添加边框高度。由边框撑起高度
moveHandleSize: 0, // 设置拖动手柄高度为0,只由边框负责高度展示
// 不展示拖动手柄图标
moveHandleIcon: 'none',
moveHandleStyle: {
// borderColor: systemTheme === 'light' ? '#E4E6E7' : '#5d6177',
borderColor:'#5d6177',
borderWidth: 10, // 设置边框高度
borderType: 'solid',
borderCap: 'round',
// 保证拖动手柄右边框结尾有圆角
borderJoin: 'round'
},
// 拖动高亮时设置
emphasis: {
moveHandleStyle: {
// borderColor: systemTheme === 'light' ? '#E4E6E7' : '#5d6177',
borderColor: '#5d6177',
borderWidth: 10,
borderType: 'solid',
borderCap: 'round'
}
}
}
],
series: [
{
name: '',
data: value,
type: 'bar',
label: {
show: true,
color: '#ffffff',
position: 'top',
},
barWidth: 16,
itemStyle: {
normal: {
color:function(d){return "#"+Math.floor(Math.random()*(256*256*256-1) ).toString(16);}
}
}
}
]
};
var myEchart = echarts.init(document.getElementById('gwnum'));
myEchart.setOption(opt);
}
getData();
function getData() {
$.ajax({
url: "KqShowScreen.aspx/getData",
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
data: JSON.stringify({
projectId: projectid
}),
success: function (data) {
if (data.d != null) {
var workPost = data.d.workPost;
if (workPost != null) {
createGWNUM(workPost.name, workPost.value)
}
var company = data.d.company;
if (company != null) {
var chtml = '';
company.forEach(function (item, index, arr) {
chtml += ' <li><span>' + item.name + '</span><span>' + item.value +'</span></li>';
})
$("#ulcom").html(chtml)
}
var person = data.d.person;
if (person != null) {
var phtml = '<li><span><asp:Literal runat="server" Text="所属单位"/></span><span>' + person.UnitName +'</span></li>'+
'<li ><span><asp:Literal runat="server" Text="姓名"/></span><span>' + person.PersonName +'</span></li>' +
'<li><span><asp:Literal runat="server" Text="岗位"/></span><span>' + person.WorkPostName+'</span></li>' +
'<li><span><asp:Literal runat="server" Text="班组"/></span><span>' + person.teamGroupName +'</span></li>' +
'<li><span>' + person.inOut+'</span><span>' + person.ChangeTime+'</span></li>';
$("#infoul").html(phtml)
$("#header").attr('src',person.PhotoUrl);
}
$("#divTotal").html(data.d.total)
}
}
})
}
// 设定默认值
var websock = null;
var cishu = 0;
// 每10分钟 通过 websocket 向服务器发送一次心跳 证明客户端没有离线 依然在线可以正常接受消息
setInterval(websocketsend, 20000);
//initWebsocket();
function initWebsocket() {
/*
* 初始化 websock
* 连接 服务器地址
* 并绑定 websock 四个事件方法
*/
websock = new WebSocket('wss://wzgl.hfnbd.com:1000');
// 接收服务器返回的数据
websock.onmessage = this.websocketonmessage;
// 连接建立时触发
websock.onopen = this.websocketonopen;
// 连接中发生异常
websock.onerror = this.websocketonerror;
// 连接关闭时触发
websock.onclose = this.websocketclose;
cishu = 0;
}
function websocketonopen(){
websocketsend();
}
function websocketonerror() {
/*
* websocket 连接建立失败 执行的方法
* 注:我这里加了个判断,如果联系建立失败就在连接几次
*/
if (cishu < 5) {
cishu = cishu + 1;
initWebsocket();
}
}
function websocketsend() {
/*
* websocket 数据发送 通过 websock.send() 方法向服务器发送数据
* 注:这里随便发哈,主要作用就是通过这个动作,让客户端与服务端建立联系
*/
let actions = {
"projectid": projectid
};
websock.send(JSON.stringify(actions));
}
function websocketclose(e) {
/*
* websocket 连接关闭 执行的方法
*/
console.log('断开连接', e);
}
function websocketonmessage(e) {
/*
* websocket 数据接收 执行的方法
* 注:服务器通过 websocke 向客户端发送数据时,这里的方法就会自动触发啦
*/
if ("newinout" == e.data);
{
getData();
}
}
setInterval(function () { //执行任务
getData();
}, 2000);
</script>
@@ -0,0 +1,210 @@
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
protected static string title1 = string.Empty;
protected static string title2 = string.Empty;
#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;
if (!string.IsNullOrEmpty(Request.Params["projectId"]) && Request.Params["projectId"] != this.CurrUser.LoginProjectId)
{
this.ProjectId = Request.Params["projectId"];
}
title1 = "出场时间";
title2 = "入场时间";
}
}
#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.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 = title1;
string PhotoUrl = "";
string PersonName = "";
string UnitName = "";
string WorkPostName = "";
string ChangeTime = "";
if (personInOut != null)
{
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)
{
inOut = title2;
}
if (!string.IsNullOrEmpty(person.TeamGroupId))
{
var teamGroup = Funs.DB.ProjectData_TeamGroup.FirstOrDefault(x => x.TeamGroupId == person.TeamGroupId);
if (teamGroup != null)
{
teamGroupName = teamGroup.TeamGroupName;
}
}
}
List<object> comStatic = new List<object>();
foreach (var key in company.Keys)
{
comStatic.Add(new { name = key, value = company[key] });
}
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]);
}
return new { company = comStatic, total, workPost = new { name = workPostName, value = workPostValue }, person = new { PersonName, UnitName, WorkPostName, inOut, PhotoUrl, teamGroupName, ChangeTime } };
}
}
}
@@ -0,0 +1,17 @@
//------------------------------------------------------------------------------
// <自动生成>
// 此代码由工具生成。
//
// 对此文件的更改可能导致不正确的行为,如果
// 重新生成代码,则所做更改将丢失。
// </自动生成>
//------------------------------------------------------------------------------
namespace FineUIPro.Web.HSSE.KqShowScreen
{
public partial class KqShowScreen
{
}
}