考勤优化
This commit is contained in:
parent
2710d1d947
commit
bfc46a7830
|
|
@ -3,6 +3,7 @@ using FineUIPro.Web.DataShow;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
namespace FineUIPro.Web.common
|
namespace FineUIPro.Web.common
|
||||||
|
|
@ -35,9 +36,9 @@ namespace FineUIPro.Web.common
|
||||||
{
|
{
|
||||||
this.ProjectId = this.CurrUser.LoginProjectId;
|
this.ProjectId = this.CurrUser.LoginProjectId;
|
||||||
}
|
}
|
||||||
getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList();
|
//getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList();
|
||||||
getAllPersons = Funs.DB.SitePerson_Person.Where(x => x.ProjectId == this.CurrUser.LoginProjectId).ToList();
|
//getAllPersons = Funs.DB.SitePerson_Person.Where(x => x.ProjectId == this.CurrUser.LoginProjectId).ToList();
|
||||||
getPersons = getAllPersons.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)).ToList();
|
//getPersons = getAllPersons.Where(x => x.IsUsed == true && x.InTime <= DateTime.Now && (!x.OutTime.HasValue || x.OutTime > DateTime.Now)).ToList();
|
||||||
///当前现场总人数
|
///当前现场总人数
|
||||||
getSitePerson();
|
getSitePerson();
|
||||||
}
|
}
|
||||||
|
|
@ -53,9 +54,12 @@ namespace FineUIPro.Web.common
|
||||||
|
|
||||||
//var getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.ProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList();
|
//var getEmployInOutRecords = Funs.DB.T_d_EmployInOutRecord.Where(x => x.ProjectId == this.ProjectId && x.RecordDate.Value == DateTime.Now.Date).ToList();
|
||||||
// int AllCount = getEmployInOutRecords.Count();
|
// int AllCount = getEmployInOutRecords.Count();
|
||||||
|
var AllCount = (from x in Funs.DB.T_d_EmployInOutRecord
|
||||||
var getallin = APIPageDataService.getPersonNum(this.ProjectId, DateTime.Now);
|
join y in Funs.DB.SitePerson_Person on new { ss1 = x.ProjectId, ss = x.IDCardNo } equals new { ss1 = y.ProjectId, ss = y.IdentityCard }
|
||||||
int AllCount = getallin.Count();
|
where y.ProjectId == this.CurrUser.LoginProjectId && y.IsUsed == true && x.ProjectId == this.CurrUser.LoginProjectId && x.RecordDate.Value == DateTime.Now.Date
|
||||||
|
select x.IDCardNo).Distinct().Count();
|
||||||
|
//var getallin = APIPageDataService.getPersonNum(this.ProjectId, DateTime.Now);
|
||||||
|
// int AllCount = getallin.Count();
|
||||||
if (AllCount > 0)
|
if (AllCount > 0)
|
||||||
{
|
{
|
||||||
////总人数
|
////总人数
|
||||||
|
|
@ -103,18 +107,18 @@ namespace FineUIPro.Web.common
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 现场人员
|
#region 现场人员
|
||||||
/// <summary>
|
///// <summary>
|
||||||
///
|
/////
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public static List<Model.T_d_EmployInOutRecord> getEmployInOutRecords;
|
//public static List<Model.T_d_EmployInOutRecord> getEmployInOutRecords;
|
||||||
/// <summary>
|
///// <summary>
|
||||||
///
|
/////
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public static List<Model.SitePerson_Person> getAllPersons;
|
//public static List<Model.SitePerson_Person> getAllPersons;
|
||||||
/// <summary>
|
///// <summary>
|
||||||
///
|
/////
|
||||||
/// </summary>
|
///// </summary>
|
||||||
public static List<Model.SitePerson_Person> getPersons;
|
//public static List<Model.SitePerson_Person> getPersons;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 按单位统计
|
/// 按单位统计
|
||||||
|
|
@ -123,6 +127,24 @@ namespace FineUIPro.Web.common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
string sql = @"SELECT
|
||||||
|
p.UnitId
|
||||||
|
,ISNULL((case when u.UnitName=''then null else u.UnitName end),'未知') AS UnitName
|
||||||
|
,COUNT( distinct IDCardNo) AS numa
|
||||||
|
,COUNT( distinct PersonId) AS numb
|
||||||
|
FROM dbo.SitePerson_Person AS P
|
||||||
|
LEFT JOIN ( select ProjectId,IDCardNo,SUM(ISNULL(ManHours,0)) ManHours from t_d_EmployInOutRecord where RecordDate >='" + DateTime.Now.ToString("yyyy-MM-dd") + @"'
|
||||||
|
AND RecordDate <= '" + DateTime.Now.ToString("yyyy-MM-dd") + @"'
|
||||||
|
group by ProjectId,IDCardNo) T ON P.ProjectId=T.ProjectId AND T.IDCardNo=P.IdentityCard
|
||||||
|
LEFT JOIN dbo.Base_Unit AS U ON P.UnitId=U.UnitId
|
||||||
|
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 ='" + CurrUser.LoginProjectId + @"' and P.InTime <=GETDATE() and ( P.OutTime is null or P.OutTime > GETDATE()) and p.IsUsed =1
|
||||||
|
|
||||||
|
GROUP BY P.UnitId,U.UnitName
|
||||||
|
|
||||||
|
";
|
||||||
|
DataTable tb41 = SQLHelper.GetDataTableRunText(sql);
|
||||||
|
|
||||||
List<Model.SingleSerie> series = new List<Model.SingleSerie>();
|
List<Model.SingleSerie> series = new List<Model.SingleSerie>();
|
||||||
Model.BusinessColumn businessColumn = new Model.BusinessColumn();
|
Model.BusinessColumn businessColumn = new Model.BusinessColumn();
|
||||||
List<string> listCategories = new List<string>();
|
List<string> listCategories = new List<string>();
|
||||||
|
|
@ -131,35 +153,54 @@ namespace FineUIPro.Web.common
|
||||||
List<double> listdata = new List<double>();
|
List<double> listdata = new List<double>();
|
||||||
List<double> listdata2 = new List<double>();
|
List<double> listdata2 = new List<double>();
|
||||||
businessColumn.title = "现场人员";
|
businessColumn.title = "现场人员";
|
||||||
int manCount = 0;
|
if (tb41.Rows.Count > 0)
|
||||||
var units = getAllPersons.Select(x => x.UnitId).Distinct();
|
|
||||||
if (units.Count() > 0)
|
|
||||||
{
|
{
|
||||||
foreach (var unitId in units)
|
foreach (DataRow row in tb41.Rows)
|
||||||
{
|
{
|
||||||
var unitRords = from x in getEmployInOutRecords
|
listCategories.Add(UnitService.GetShortUnitNameByUnitId(row["UnitId"].ToString()) ?? "未知");
|
||||||
join y in getAllPersons on x.IDCardNo equals y.IdentityCard
|
if (!string.IsNullOrEmpty(row["numa"].ToString()))
|
||||||
where y.UnitId == unitId && y.PersonId != null && x.UnitId == unitId
|
|
||||||
select x;
|
|
||||||
var unitPersons = getPersons.Where(x => x.UnitId == unitId);
|
|
||||||
int rcount = unitRords.Distinct().Count();
|
|
||||||
if (rcount > 0)
|
|
||||||
{
|
{
|
||||||
manCount += rcount;
|
listdata.Add(double.Parse(row["numa"].ToString()));
|
||||||
listCategories.Add(UnitService.GetShortUnitNameByUnitId(unitId));
|
|
||||||
listdata.Add(rcount);
|
|
||||||
listdata2.Add(unitPersons.Count());
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
listdata.Add(0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
listdata2.Add(double.Parse(row["numb"].ToString()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int nullCount = getEmployInOutRecords.Count() - manCount;
|
//int manCount = 0;
|
||||||
if (nullCount > 0)
|
//var units = getAllPersons.Select(x => x.UnitId).Distinct();
|
||||||
{
|
//if (units.Count() > 0)
|
||||||
listCategories.Add("未知");
|
//{
|
||||||
listdata.Add(nullCount);
|
// foreach (var unitId in units)
|
||||||
listdata2.Add(0);
|
// {
|
||||||
}
|
// var unitRords = from x in getEmployInOutRecords
|
||||||
|
// join y in getAllPersons on x.IDCardNo equals y.IdentityCard
|
||||||
|
// where y.UnitId == unitId && y.PersonId != null && x.UnitId == unitId
|
||||||
|
// select x;
|
||||||
|
// var unitPersons = getPersons.Where(x => x.UnitId == unitId);
|
||||||
|
// int rcount = unitRords.Distinct().Count();
|
||||||
|
// if (rcount > 0)
|
||||||
|
// {
|
||||||
|
// manCount += rcount;
|
||||||
|
// listCategories.Add(UnitService.GetShortUnitNameByUnitId(unitId));
|
||||||
|
// listdata.Add(rcount);
|
||||||
|
// listdata2.Add(unitPersons.Count());
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//int nullCount = getEmployInOutRecords.Count() - manCount;
|
||||||
|
//if (nullCount > 0)
|
||||||
|
//{
|
||||||
|
// listCategories.Add("未知");
|
||||||
|
// listdata.Add(nullCount);
|
||||||
|
// listdata2.Add(0);
|
||||||
|
//}
|
||||||
s.data = listdata;
|
s.data = listdata;
|
||||||
series.Add(s);
|
series.Add(s);
|
||||||
|
|
||||||
|
|
@ -179,6 +220,20 @@ namespace FineUIPro.Web.common
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
|
string sql = @"
|
||||||
|
select b.*,a.numa,c.WorkPostName from(
|
||||||
|
select a.PostId, a.PostName, COUNT(1) numa from T_d_EmployInOutRecord a left join SitePerson_Person b on a.IDCardNo = b.IdentityCard and a.ProjectId =b.ProjectId
|
||||||
|
where a.ProjectId = '" + CurrUser.LoginProjectId + "' and RecordDate = '" + DateTime.Now.ToString("yyyy-MM-dd") + @"' and IsUsed = 1 and InTime < '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and(OutTime is null or OutTime > '" + DateTime.Now.ToString("yyyy-MM-dd") + @"')
|
||||||
|
group by PostId,PostName)a right join
|
||||||
|
(
|
||||||
|
select WorkPostId, COUNT(1) numb from SitePerson_Person
|
||||||
|
where ProjectId = '" + CurrUser.LoginProjectId + "' and IsUsed = 1 and InTime < '" + DateTime.Now.ToString("yyyy-MM-dd") + "' and(OutTime is null or OutTime > '" + DateTime.Now.ToString("yyyy-MM-dd") + @"')
|
||||||
|
group by WorkPostId
|
||||||
|
)b on a.PostId = b.WorkPostId left join Base_WorkPost c on b.WorkPostId=c.WorkPostId
|
||||||
|
";
|
||||||
|
|
||||||
|
DataTable tb41 = SQLHelper.GetDataTableRunText(sql);
|
||||||
|
|
||||||
List<Model.SingleSerie> series = new List<Model.SingleSerie>();
|
List<Model.SingleSerie> series = new List<Model.SingleSerie>();
|
||||||
Model.BusinessColumn businessColumn = new Model.BusinessColumn();
|
Model.BusinessColumn businessColumn = new Model.BusinessColumn();
|
||||||
List<string> listCategories = new List<string>();
|
List<string> listCategories = new List<string>();
|
||||||
|
|
@ -187,34 +242,51 @@ namespace FineUIPro.Web.common
|
||||||
Model.SingleSerie s2 = new Model.SingleSerie();
|
Model.SingleSerie s2 = new Model.SingleSerie();
|
||||||
List<double> listdata2 = new List<double>();
|
List<double> listdata2 = new List<double>();
|
||||||
businessColumn.title = "现场人员";
|
businessColumn.title = "现场人员";
|
||||||
var getTypes = (from x in getEmployInOutRecords
|
if (tb41.Rows.Count > 0)
|
||||||
join y in getAllPersons on x.IDCardNo equals y.IdentityCard
|
|
||||||
join z in Funs.DB.Base_WorkPost on y.WorkPostId equals z.WorkPostId
|
|
||||||
select new { y.WorkPostId, z.WorkPostName }).Distinct();
|
|
||||||
if (getTypes.Count() > 0)
|
|
||||||
{
|
{
|
||||||
foreach (var item in getTypes)
|
foreach (DataRow item in tb41.Rows)
|
||||||
{
|
{
|
||||||
listCategories.Add(item.WorkPostName ?? "未知");
|
listCategories.Add(item["WorkPostName"].ToString());
|
||||||
var unitRords = getEmployInOutRecords.Where(x => x.PostId == item.WorkPostId);
|
if (!string.IsNullOrEmpty(item["numa"].ToString()))
|
||||||
var unitPersons = getPersons.Where(x => x.WorkPostId == item.WorkPostId);
|
{
|
||||||
listdata.Add(unitRords.Count());
|
listdata.Add(double.Parse(item["numa"].ToString()));
|
||||||
listdata2.Add(unitPersons.Count());
|
}
|
||||||
}
|
else
|
||||||
}
|
{
|
||||||
else
|
listdata.Add(0);
|
||||||
{
|
}
|
||||||
var getpTypes = getPersons.Select(x => x.WorkPostId).Distinct();
|
listdata2.Add(double.Parse(item["numb"].ToString()));
|
||||||
foreach (var item in getpTypes)
|
|
||||||
{
|
|
||||||
listCategories.Add(WorkPostService.getWorkPostNameById(item));
|
|
||||||
var unitRords = getEmployInOutRecords.Where(x => x.PostId == item);
|
|
||||||
var unitPersons = getPersons.Where(x => x.WorkPostId == item);
|
|
||||||
listdata.Add(unitRords.Count());
|
|
||||||
listdata2.Add(unitPersons.Count());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//var getTypes = (from x in getEmployInOutRecords
|
||||||
|
// join y in getAllPersons on x.IDCardNo equals y.IdentityCard
|
||||||
|
// join z in Funs.DB.Base_WorkPost on y.WorkPostId equals z.WorkPostId
|
||||||
|
// select new { y.WorkPostId, z.WorkPostName }).Distinct();
|
||||||
|
//if (getTypes.Count() > 0)
|
||||||
|
//{
|
||||||
|
// foreach (var item in getTypes)
|
||||||
|
// {
|
||||||
|
// listCategories.Add(item.WorkPostName ?? "未知");
|
||||||
|
// var unitRords = getEmployInOutRecords.Where(x => x.PostId == item.WorkPostId);
|
||||||
|
// var unitPersons = getPersons.Where(x => x.WorkPostId == item.WorkPostId);
|
||||||
|
// listdata.Add(unitRords.Count());
|
||||||
|
// listdata2.Add(unitPersons.Count());
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// var getpTypes = getPersons.Select(x => x.WorkPostId).Distinct();
|
||||||
|
// foreach (var item in getpTypes)
|
||||||
|
// {
|
||||||
|
// listCategories.Add(WorkPostService.getWorkPostNameById(item));
|
||||||
|
// var unitRords = getEmployInOutRecords.Where(x => x.PostId == item);
|
||||||
|
// var unitPersons = getPersons.Where(x => x.WorkPostId == item);
|
||||||
|
// listdata.Add(unitRords.Count());
|
||||||
|
// listdata2.Add(unitPersons.Count());
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
s.data = listdata;
|
s.data = listdata;
|
||||||
series.Add(s);
|
series.Add(s);
|
||||||
s2.data = listdata2;
|
s2.data = listdata2;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue