施工人力
This commit is contained in:
parent
da23e72a7f
commit
07b7d8426a
|
|
@ -0,0 +1,99 @@
|
||||||
|
CREATE TABLE [dbo].[SitePerson_Checking_Statistics] (
|
||||||
|
[ProjectId] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
[UnitId] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
[UnitName] nvarchar(200) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
[WorkAreaId] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
[WorkAreaName] nvarchar(max) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
[WorkPostId] nvarchar(50) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
[WorkPostName] nvarchar(100) COLLATE Chinese_PRC_CI_AS NULL,
|
||||||
|
[IntoOutTime] datetime NULL,
|
||||||
|
[num] int NULL
|
||||||
|
)
|
||||||
|
ON [PRIMARY]
|
||||||
|
GO
|
||||||
|
|
||||||
|
ALTER TABLE [dbo].[SitePerson_Checking_Statistics] SET (LOCK_ESCALATION = TABLE)
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE NONCLUSTERED INDEX [ProjectId_Index]
|
||||||
|
ON [dbo].[SitePerson_Checking_Statistics] (
|
||||||
|
[ProjectId] ASC
|
||||||
|
)
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE NONCLUSTERED INDEX [UnitId_Index]
|
||||||
|
ON [dbo].[SitePerson_Checking_Statistics] (
|
||||||
|
[UnitId] ASC
|
||||||
|
)
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE NONCLUSTERED INDEX [NonClusteredIndex-20220601-105641]
|
||||||
|
ON [dbo].[SitePerson_Checking_Statistics] (
|
||||||
|
[ProjectId] ASC,
|
||||||
|
[IntoOutTime] ASC
|
||||||
|
)
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE NONCLUSTERED INDEX [WorkPostId_Index]
|
||||||
|
ON [dbo].[SitePerson_Checking_Statistics] (
|
||||||
|
[WorkPostId] ASC
|
||||||
|
)
|
||||||
|
GO
|
||||||
|
|
||||||
|
CREATE NONCLUSTERED INDEX [IntoOutTime_Index]
|
||||||
|
ON [dbo].[SitePerson_Checking_Statistics] (
|
||||||
|
[IntoOutTime] ASC
|
||||||
|
)
|
||||||
|
go
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
INSERT INTO dbo.SitePerson_Checking_Statistics (
|
||||||
|
ProjectId,
|
||||||
|
UnitId,
|
||||||
|
UnitName,
|
||||||
|
WorkAreaId,
|
||||||
|
WorkAreaName,
|
||||||
|
WorkPostId,
|
||||||
|
WorkPostName,
|
||||||
|
IntoOutTime,
|
||||||
|
num
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
a.ProjectId,
|
||||||
|
b.UnitId,
|
||||||
|
b.UnitName,
|
||||||
|
b.WorkAreaId,
|
||||||
|
b.WorkAreaName,
|
||||||
|
p.WorkPostId,
|
||||||
|
w.WorkPostName,
|
||||||
|
CAST(b.IntoOutTime AS DATE) AS IntoOutTime,
|
||||||
|
COUNT(1) AS num
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
PersonId,
|
||||||
|
CAST(IntoOutTime AS DATE) AS IntoOutTime,
|
||||||
|
MAX(CheckingId) AS MaxCheckingId,
|
||||||
|
ProjectId
|
||||||
|
FROM SitePerson_Checking
|
||||||
|
GROUP BY PersonId, CAST(IntoOutTime AS DATE), ProjectId
|
||||||
|
) a
|
||||||
|
JOIN SitePerson_Checking b ON a.MaxCheckingId = b.CheckingId
|
||||||
|
LEFT JOIN SitePerson_Person p ON a.PersonId = p.PersonId
|
||||||
|
LEFT JOIN Base_WorkPost w ON p.WorkPostId = w.WorkPostId
|
||||||
|
LEFT JOIN Base_Project bp ON a.ProjectId = bp.ProjectId
|
||||||
|
where bp.ProjectState='1'
|
||||||
|
GROUP BY
|
||||||
|
a.ProjectId,
|
||||||
|
b.UnitId,
|
||||||
|
b.UnitName,
|
||||||
|
b.WorkAreaId,
|
||||||
|
b.WorkAreaName,
|
||||||
|
p.WorkPostId,
|
||||||
|
w.WorkPostName,
|
||||||
|
CAST(b.IntoOutTime AS DATE);";
|
||||||
|
|
@ -18,7 +18,7 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
{
|
{
|
||||||
BLL.UnitService.GetUnit(this.drpUnit, this.CurrUser.LoginProjectId, true);//单位
|
BLL.UnitService.GetUnit(this.drpUnit, this.CurrUser.LoginProjectId, true);//单位
|
||||||
this.txtStartTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(-30));
|
this.txtStartTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(-30));
|
||||||
this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(30));
|
this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||||
DropMainContractCode_SelectedIndexChanged(null, null);
|
DropMainContractCode_SelectedIndexChanged(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -448,7 +448,7 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
// 版本参数
|
// 版本参数
|
||||||
if (drpVersion.SelectedValue != Const._Null && !string.IsNullOrEmpty(drpVersion.SelectedValue))
|
if (drpVersion.SelectedValue != Const._Null && !string.IsNullOrEmpty(drpVersion.SelectedValue))
|
||||||
{
|
{
|
||||||
urlParams += "&drpVersion=" + drpVersion.SelectedValue;
|
urlParams += "&Version=" + drpVersion.SelectedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PageContext.RegisterStartupScript(
|
PageContext.RegisterStartupScript(
|
||||||
|
|
|
||||||
|
|
@ -317,6 +317,7 @@
|
||||||
$('input[name="data-filter"]').change(function() {
|
$('input[name="data-filter"]').change(function() {
|
||||||
var dataType = $(this).val();
|
var dataType = $(this).val();
|
||||||
toggleYearSelect(dataType);
|
toggleYearSelect(dataType);
|
||||||
|
loadAndRenderCharts(dataType);
|
||||||
});
|
});
|
||||||
|
|
||||||
// 监听年份下拉框变化事件
|
// 监听年份下拉框变化事件
|
||||||
|
|
|
||||||
|
|
@ -82,8 +82,57 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
businessColumn.xFontNum = 8;
|
businessColumn.xFontNum = 8;
|
||||||
|
|
||||||
// 延迟执行查询,只获取需要的数据
|
// 延迟执行查询,只获取需要的数据
|
||||||
var actualBaseQuery = Funs.DB.T_d_EmployInOutRecord.Where(x =>
|
// var actualBaseQuery = Funs.DB.T_d_EmployInOutRecord.Where(x =>
|
||||||
x.ProjectId == this.CurrUser.LoginProjectId);
|
// x.ProjectId == this.CurrUser.LoginProjectId);
|
||||||
|
|
||||||
|
// var query = from spc in Funs.DB.SitePerson_Checking
|
||||||
|
// where spc.ProjectId == this.CurrUser.LoginProjectId
|
||||||
|
// select new
|
||||||
|
// {
|
||||||
|
// IntoOutTime = spc.IntoOutTime.Value.Date,
|
||||||
|
// spc.PersonId,
|
||||||
|
// spc.UnitId,
|
||||||
|
// }
|
||||||
|
// into a
|
||||||
|
// group a by new { a.PersonId, a.IntoOutTime, a.UnitId }
|
||||||
|
// into g
|
||||||
|
// select new
|
||||||
|
// {
|
||||||
|
// g.Key.PersonId,
|
||||||
|
// g.Key.UnitId,
|
||||||
|
// g.Key.IntoOutTime,
|
||||||
|
// num = g.Count()
|
||||||
|
// };
|
||||||
|
// //关联人员表
|
||||||
|
// var actualBaseQuery = (from x in query
|
||||||
|
// join y in Funs.DB.SitePerson_Person on x.PersonId equals y.PersonId into yInto
|
||||||
|
// from y in yInto.DefaultIfEmpty()
|
||||||
|
// select new
|
||||||
|
// {
|
||||||
|
// x.PersonId,
|
||||||
|
// x.IntoOutTime,
|
||||||
|
// x.UnitId,
|
||||||
|
// x.num,
|
||||||
|
// PostId = y.WorkPostId,
|
||||||
|
// }
|
||||||
|
// );
|
||||||
|
|
||||||
|
var actualBaseQuery = from spc in Funs.DB.SitePerson_Checking_Statistics
|
||||||
|
where spc.ProjectId == this.CurrUser.LoginProjectId
|
||||||
|
group spc by new
|
||||||
|
{
|
||||||
|
spc.UnitId,
|
||||||
|
spc.WorkPostId,
|
||||||
|
spc.IntoOutTime
|
||||||
|
} into g
|
||||||
|
select new
|
||||||
|
{
|
||||||
|
UnitId = g.Key.UnitId,
|
||||||
|
WorkPostId = g.Key.WorkPostId,
|
||||||
|
IntoOutTime = g.Key.IntoOutTime,
|
||||||
|
num = g.Sum(item => item.Num)
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
var planBaseQuery =
|
var planBaseQuery =
|
||||||
Funs.DB.JDGL_SGManPower.Where(x => x.ProjectId == this.CurrUser.LoginProjectId);
|
Funs.DB.JDGL_SGManPower.Where(x => x.ProjectId == this.CurrUser.LoginProjectId);
|
||||||
|
|
@ -107,14 +156,14 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
else if (chartTitle == "施工单位管理人员统计分析")
|
else if (chartTitle == "施工单位管理人员统计分析")
|
||||||
{
|
{
|
||||||
actualBaseQuery =
|
actualBaseQuery =
|
||||||
actualBaseQuery.Where(x => Units.Contains(x.UnitId) && workPosts.Contains(x.PostId));
|
actualBaseQuery.Where(x => Units.Contains(x.UnitId) && workPosts.Contains(x.WorkPostId));
|
||||||
planBaseQuery =
|
planBaseQuery =
|
||||||
planBaseQuery.Where(x => Units.Contains(x.UnitId) && workPosts.Contains(x.WorkPostId));
|
planBaseQuery.Where(x => Units.Contains(x.UnitId) && workPosts.Contains(x.WorkPostId));
|
||||||
}
|
}
|
||||||
else if (chartTitle == "作业人员统计分析")
|
else if (chartTitle == "作业人员统计分析")
|
||||||
{
|
{
|
||||||
actualBaseQuery =
|
actualBaseQuery =
|
||||||
actualBaseQuery.Where(x => Units.Contains(x.UnitId) && !workPosts.Contains(x.PostId));
|
actualBaseQuery.Where(x => Units.Contains(x.UnitId) && !workPosts.Contains(x.WorkPostId));
|
||||||
planBaseQuery =
|
planBaseQuery =
|
||||||
planBaseQuery.Where(x => Units.Contains(x.UnitId) && !workPosts.Contains(x.WorkPostId));
|
planBaseQuery.Where(x => Units.Contains(x.UnitId) && !workPosts.Contains(x.WorkPostId));
|
||||||
}
|
}
|
||||||
|
|
@ -127,7 +176,7 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
{
|
{
|
||||||
int selectedYear = int.Parse(year);
|
int selectedYear = int.Parse(year);
|
||||||
actualBaseQuery = actualBaseQuery.Where(x =>
|
actualBaseQuery = actualBaseQuery.Where(x =>
|
||||||
x.RecordDate.HasValue && x.RecordDate.Value.Year == selectedYear);
|
x.IntoOutTime.Value.Year == selectedYear);
|
||||||
planBaseQuery =
|
planBaseQuery =
|
||||||
planBaseQuery.Where(x => x.PlanDate.HasValue && x.PlanDate.Value.Year == selectedYear);
|
planBaseQuery.Where(x => x.PlanDate.HasValue && x.PlanDate.Value.Year == selectedYear);
|
||||||
}
|
}
|
||||||
|
|
@ -135,9 +184,9 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
{
|
{
|
||||||
int selectedYear = int.Parse(year);
|
int selectedYear = int.Parse(year);
|
||||||
int selectedMonth = int.Parse(month);
|
int selectedMonth = int.Parse(month);
|
||||||
actualBaseQuery = actualBaseQuery.Where(x => x.RecordDate.HasValue &&
|
actualBaseQuery = actualBaseQuery.Where(x =>
|
||||||
x.RecordDate.Value.Year == selectedYear &&
|
x.IntoOutTime.Value.Year == selectedYear &&
|
||||||
x.RecordDate.Value.Month == selectedMonth);
|
x.IntoOutTime.Value.Month == selectedMonth);
|
||||||
planBaseQuery = planBaseQuery.Where(x => x.PlanDate.HasValue &&
|
planBaseQuery = planBaseQuery.Where(x => x.PlanDate.HasValue &&
|
||||||
x.PlanDate.Value.Year == selectedYear &&
|
x.PlanDate.Value.Year == selectedYear &&
|
||||||
x.PlanDate.Value.Month == selectedMonth);
|
x.PlanDate.Value.Month == selectedMonth);
|
||||||
|
|
@ -152,14 +201,13 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
case "annual":
|
case "annual":
|
||||||
// 按月分组(年度视图显示每个月的数据)
|
// 按月分组(年度视图显示每个月的数据)
|
||||||
var actualAnnualQuery = from x in actualBaseQuery
|
var actualAnnualQuery = from x in actualBaseQuery
|
||||||
where x.RecordDate.HasValue
|
group x by new { x.IntoOutTime.Value.Year, x.IntoOutTime.Value.Month }
|
||||||
group x by new { x.RecordDate.Value.Year, x.RecordDate.Value.Month }
|
|
||||||
into g
|
into g
|
||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
Year = g.Key.Year,
|
Year = g.Key.Year,
|
||||||
Month = g.Key.Month,
|
Month = g.Key.Month,
|
||||||
ActualCount = g.Count()
|
ActualCount = g.Sum(x => x.num)
|
||||||
};
|
};
|
||||||
|
|
||||||
var planAnnualQuery = from x in planBaseQuery
|
var planAnnualQuery = from x in planBaseQuery
|
||||||
|
|
@ -185,15 +233,14 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
case "monthly":
|
case "monthly":
|
||||||
// 按天分组(月度视图显示每天的数据)
|
// 按天分组(月度视图显示每天的数据)
|
||||||
var actualMonthlyQuery = from x in actualBaseQuery
|
var actualMonthlyQuery = from x in actualBaseQuery
|
||||||
where x.RecordDate.HasValue
|
group x by new { x.IntoOutTime.Value.Year, x.IntoOutTime.Value.Month, x.IntoOutTime.Value.Day }
|
||||||
group x by new { x.RecordDate.Value.Year, x.RecordDate.Value.Month, x.RecordDate.Value.Day }
|
|
||||||
into g
|
into g
|
||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
Year = g.Key.Year,
|
Year = g.Key.Year,
|
||||||
Month = g.Key.Month,
|
Month = g.Key.Month,
|
||||||
Day = g.Key.Day,
|
Day = g.Key.Day,
|
||||||
ActualCount = g.Count()
|
ActualCount = g.Sum(x => x.num)
|
||||||
};
|
};
|
||||||
|
|
||||||
var planMonthlyQuery = from x in planBaseQuery
|
var planMonthlyQuery = from x in planBaseQuery
|
||||||
|
|
@ -221,14 +268,13 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
default:
|
default:
|
||||||
// 按月分组(默认情况)
|
// 按月分组(默认情况)
|
||||||
var actualDefaultQuery = from x in actualBaseQuery
|
var actualDefaultQuery = from x in actualBaseQuery
|
||||||
where x.RecordDate.HasValue
|
group x by new { x.IntoOutTime.Value.Year, x.IntoOutTime.Value.Month }
|
||||||
group x by new { x.RecordDate.Value.Year, x.RecordDate.Value.Month }
|
|
||||||
into g
|
into g
|
||||||
select new
|
select new
|
||||||
{
|
{
|
||||||
Year = g.Key.Year,
|
Year = g.Key.Year,
|
||||||
Month = g.Key.Month,
|
Month = g.Key.Month,
|
||||||
ActualCount = g.Count()
|
ActualCount = g.Sum(x => x.num)
|
||||||
};
|
};
|
||||||
|
|
||||||
var planDefaultQuery = from x in planBaseQuery
|
var planDefaultQuery = from x in planBaseQuery
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
{
|
{
|
||||||
BLL.UnitService.GetUnit(this.drpUnit, this.CurrUser.LoginProjectId, true);//单位
|
BLL.UnitService.GetUnit(this.drpUnit, this.CurrUser.LoginProjectId, true);//单位
|
||||||
this.txtStartTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(-30));
|
this.txtStartTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(-30));
|
||||||
this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now.AddDays(30));
|
this.txtEndTime.Text = string.Format("{0:yyyy-MM-dd}", DateTime.Now);
|
||||||
DropMainContractCode_SelectedIndexChanged(null, null);
|
DropMainContractCode_SelectedIndexChanged(null, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
string startTime = Request.Params["StartTime"];
|
string startTime = Request.Params["StartTime"];
|
||||||
string endTime = Request.Params["EndTime"];
|
string endTime = Request.Params["EndTime"];
|
||||||
string workPostId = Request.Params["WorkPostId"];
|
string workPostId = Request.Params["WorkPostId"];
|
||||||
string unitWorkId = Request.Params["UnitWorkId"];
|
string workAreaId = Request.Params["WorkAreaId"];
|
||||||
|
|
||||||
// 检查必要参数
|
// 检查必要参数
|
||||||
if (string.IsNullOrEmpty(startTime) || string.IsNullOrEmpty(endTime))
|
if (string.IsNullOrEmpty(startTime) || string.IsNullOrEmpty(endTime))
|
||||||
|
|
@ -42,87 +42,84 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
DateTime startDate = Convert.ToDateTime(startTime);
|
DateTime startDate = Convert.ToDateTime(startTime);
|
||||||
DateTime endDate = Convert.ToDateTime(endTime);
|
DateTime endDate = Convert.ToDateTime(endTime);
|
||||||
|
|
||||||
// 使用原生SQL查询直接在数据库中进行聚合计算,提高性能
|
var getData = Funs.DB.SitePerson_Checking_Statistics.Where(x =>
|
||||||
string strSql = @"
|
x.ProjectId == this.CurrUser.LoginProjectId && x.IntoOutTime >= startDate && x.IntoOutTime <= endDate);
|
||||||
SELECT e.UnitId, e.PostId, e.RecordDate, p.WorkAreaId as UnitWorkId
|
|
||||||
FROM T_d_EmployInOutRecord e INNER JOIN SitePerson_Person p ON e.IDCardNo = p.IdentityCard AND e.ProjectId = p.ProjectId
|
|
||||||
WHERE e.PostId IS NOT NULL AND e.PostId != ''
|
|
||||||
AND e.ProjectId = @ProjectId
|
|
||||||
AND e.RecordDate >= @StartDate
|
|
||||||
AND e.RecordDate <= @EndDate";
|
|
||||||
|
|
||||||
var parameters = new List<SqlParameter>
|
|
||||||
{
|
|
||||||
new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId),
|
|
||||||
new SqlParameter("@StartDate", startDate),
|
|
||||||
new SqlParameter("@EndDate", endDate)
|
|
||||||
};
|
|
||||||
|
|
||||||
// 添加单位筛选条件
|
// 添加单位筛选条件
|
||||||
if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null)
|
if (!string.IsNullOrEmpty(unitId) && unitId != Const._Null)
|
||||||
{
|
{
|
||||||
strSql += " AND e.UnitId = @UnitId";
|
getData = getData.Where(x => x.UnitId == unitId);
|
||||||
parameters.Add(new SqlParameter("@UnitId", unitId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加岗位筛选条件
|
// 添加岗位筛选条件
|
||||||
if (!string.IsNullOrEmpty(workPostId) && workPostId != Const._Null)
|
if (!string.IsNullOrEmpty(workPostId) && workPostId != Const._Null)
|
||||||
{
|
{
|
||||||
strSql += " AND e.PostId = @WorkPostId";
|
getData = getData.Where(x => x.WorkPostId == workPostId);
|
||||||
parameters.Add(new SqlParameter("@WorkPostId", workPostId));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行查询
|
DataTable dt = this.LINQToDataTable(getData.ToList());
|
||||||
var dt = SQLHelper.GetDataTableRunText(strSql, parameters.ToArray());
|
|
||||||
|
|
||||||
// 创建一个新的DataTable来存储处理后的数据
|
// 创建一个新的DataTable来存储处理后的数据
|
||||||
DataTable processedDt = dt.Clone();
|
DataTable processedDt = dt.Clone();
|
||||||
foreach (System.Data.DataRow row in dt.Rows)
|
foreach (System.Data.DataRow row in dt.Rows)
|
||||||
{
|
{
|
||||||
string ids = row["UnitWorkId"] != DBNull.Value ? row["UnitWorkId"].ToString() : string.Empty;
|
// string ids = row["WorkAreaId"] != DBNull.Value ? row["WorkAreaId"].ToString() : string.Empty;
|
||||||
if (!string.IsNullOrEmpty(ids))
|
// string names = row["WorkAreaName"] != DBNull.Value ? row["WorkAreaName"].ToString() : string.Empty;
|
||||||
{
|
// if (!string.IsNullOrEmpty(names))
|
||||||
string[] unitWorkIdArray = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
// {
|
||||||
foreach (string id in unitWorkIdArray)
|
// string[] unitWorkNameArray =
|
||||||
{
|
// names.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
// 往processedDt里面添加数据,每个UnitWorkId一行
|
// string[] unitWorkIdArray = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
|
// for (var i = 0; i < unitWorkNameArray.Length; i++)
|
||||||
|
// {
|
||||||
|
// // 往processedDt里面添加数据,每个UnitWorkId一行
|
||||||
|
// DataRow newRow = processedDt.NewRow();
|
||||||
|
// newRow["UnitId"] = row["UnitId"];
|
||||||
|
// newRow["UnitName"] = row["UnitName"];
|
||||||
|
// newRow["WorkPostId"] = row["WorkPostId"];
|
||||||
|
// newRow["WorkPostName"] = row["WorkPostName"];
|
||||||
|
// newRow["IntoOutTime"] = row["IntoOutTime"] ?? DBNull.Value;
|
||||||
|
// newRow["WorkAreaId"] = unitWorkIdArray[i].Trim();
|
||||||
|
// newRow["WorkAreaName"] = unitWorkNameArray[i].Trim();
|
||||||
|
// newRow["num"] = row["num"] != DBNull.Value ? Convert.ToInt32(row["num"]) : 0;
|
||||||
|
// a++;
|
||||||
|
// processedDt.Rows.Add(newRow);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
DataRow newRow = processedDt.NewRow();
|
DataRow newRow = processedDt.NewRow();
|
||||||
newRow["UnitId"] = row["UnitId"];
|
newRow["UnitId"] = row["UnitId"];
|
||||||
newRow["PostId"] = row["PostId"];
|
newRow["UnitName"] = row["UnitName"];
|
||||||
newRow["RecordDate"] = row["RecordDate"];
|
newRow["WorkPostId"] = row["WorkPostId"];
|
||||||
newRow["UnitWorkId"] = id.Trim();
|
newRow["WorkPostName"] = row["WorkPostName"];
|
||||||
|
newRow["IntoOutTime"] = row["IntoOutTime"] ?? DBNull.Value;
|
||||||
|
newRow["WorkAreaId"] = row["WorkAreaId"];
|
||||||
|
newRow["WorkAreaName"] = row["WorkAreaName"];
|
||||||
|
newRow["num"] = row["num"] != DBNull.Value ? Convert.ToInt32(row["num"]) : 0;
|
||||||
processedDt.Rows.Add(newRow);
|
processedDt.Rows.Add(newRow);
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DataRow newRow = processedDt.NewRow();
|
|
||||||
newRow["UnitId"] = row["UnitId"];
|
|
||||||
newRow["PostId"] = row["PostId"];
|
|
||||||
newRow["RecordDate"] = row["RecordDate"];
|
|
||||||
newRow["UnitWorkId"] = string.Empty;
|
|
||||||
processedDt.Rows.Add(newRow);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 确定要用于后续处理的数据源
|
// 确定要用于后续处理的数据源
|
||||||
IEnumerable<DataRow> dataSource = processedDt.AsEnumerable();
|
IEnumerable<DataRow> dataSource = processedDt.AsEnumerable();
|
||||||
|
|
||||||
// 如果选择了特定的装置进行筛选
|
// 如果选择了特定的装置进行筛选
|
||||||
if (!string.IsNullOrEmpty(unitWorkId) && unitWorkId != Const._Null)
|
if (!string.IsNullOrEmpty(workAreaId) && workAreaId != Const._Null)
|
||||||
{
|
{
|
||||||
dataSource = dataSource.Where(x => x["UnitWorkId"] != DBNull.Value && x["UnitWorkId"].ToString() == unitWorkId);
|
dataSource = dataSource.Where(x => x["WorkAreaId"] != DBNull.Value && x["WorkAreaId"].ToString() == workAreaId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var da = dataSource.ToList();
|
||||||
|
|
||||||
//针对dt中的数据进行分组
|
//针对dt中的数据进行分组
|
||||||
var data = dataSource
|
var data = dataSource
|
||||||
.GroupBy(row => new {
|
.GroupBy(row => new {
|
||||||
RecordDate = row["RecordDate"]
|
IntoOutTime = row["IntoOutTime"]
|
||||||
}).Select(group => new
|
}).Select(group => new
|
||||||
{
|
{
|
||||||
RecordDate = group.Key.RecordDate,
|
IntoOutTime = group.Key.IntoOutTime,
|
||||||
RecordCount = group.Count()
|
RecordCount = group.Sum(row => row["num"] != DBNull.Value ? Convert.ToInt32(row["num"]) : 0)
|
||||||
}).ToList();
|
}).OrderBy(x => x.IntoOutTime).ToList();
|
||||||
|
|
||||||
|
|
||||||
// 如果没有数据,显示提示信息
|
// 如果没有数据,显示提示信息
|
||||||
|
|
@ -155,13 +152,13 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
// 添加数据点
|
// 添加数据点
|
||||||
foreach (var item in data)
|
foreach (var item in data)
|
||||||
{
|
{
|
||||||
if (item.RecordDate != null)
|
if (item.IntoOutTime != null)
|
||||||
{
|
{
|
||||||
DateTime recordDate = Convert.ToDateTime(item.RecordDate);
|
DateTime IntoOutTime = Convert.ToDateTime(item.IntoOutTime);
|
||||||
|
|
||||||
Model.DataSourcePoint point = new Model.DataSourcePoint
|
Model.DataSourcePoint point = new Model.DataSourcePoint
|
||||||
{
|
{
|
||||||
PointText = recordDate.ToString("MM-dd"),
|
PointText = IntoOutTime.ToString("MM-dd"),
|
||||||
PointValue = item.RecordCount.ToString()
|
PointValue = item.RecordCount.ToString()
|
||||||
};
|
};
|
||||||
dataSourceTeam.DataSourcePoints.Add(point);
|
dataSourceTeam.DataSourcePoints.Add(point);
|
||||||
|
|
|
||||||
|
|
@ -39,13 +39,13 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
|
|
||||||
// 添加隐藏列来存储额外的ID信息
|
// 添加隐藏列来存储额外的ID信息
|
||||||
GridTable.Columns.Add("UnitId");
|
GridTable.Columns.Add("UnitId");
|
||||||
GridTable.Columns.Add("UnitWorkId");
|
GridTable.Columns.Add("WorkAreaId");
|
||||||
GridTable.Columns.Add("WorkPostId");
|
GridTable.Columns.Add("WorkPostId");
|
||||||
|
|
||||||
ListItem[] list = new ListItem[5];
|
ListItem[] list = new ListItem[5];
|
||||||
list[0] = new ListItem("序号", "SerialNumber");
|
list[0] = new ListItem("序号", "SerialNumber");
|
||||||
list[1] = new ListItem("单位", "UnitName");
|
list[1] = new ListItem("单位", "UnitName");
|
||||||
list[2] = new ListItem("装置", "UnitWorkName");
|
list[2] = new ListItem("装置", "WorkAreaName");
|
||||||
list[3] = new ListItem("岗位", "WorkPostName");
|
list[3] = new ListItem("岗位", "WorkPostName");
|
||||||
list[4] = new ListItem("累计", "TotalCount");
|
list[4] = new ListItem("累计", "TotalCount");
|
||||||
|
|
||||||
|
|
@ -160,14 +160,14 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
{
|
{
|
||||||
GridTable.Columns.Add("Id");
|
GridTable.Columns.Add("Id");
|
||||||
GridTable.Columns.Add("UnitId");
|
GridTable.Columns.Add("UnitId");
|
||||||
GridTable.Columns.Add("UnitWorkId");
|
GridTable.Columns.Add("WorkAreaId");
|
||||||
GridTable.Columns.Add("WorkPostId");
|
GridTable.Columns.Add("WorkPostId");
|
||||||
|
|
||||||
// 添加动态日期列(这部分已经在InitGrid中定义了)
|
// 添加动态日期列(这部分已经在InitGrid中定义了)
|
||||||
ListItem[] list = new ListItem[5];
|
ListItem[] list = new ListItem[5];
|
||||||
list[0] = new ListItem("序号", "SerialNumber");
|
list[0] = new ListItem("序号", "SerialNumber");
|
||||||
list[1] = new ListItem("单位", "UnitName");
|
list[1] = new ListItem("单位", "UnitName");
|
||||||
list[2] = new ListItem("装置", "UnitWorkName");
|
list[2] = new ListItem("装置", "WorkAreaName");
|
||||||
list[3] = new ListItem("岗位", "WorkPostName");
|
list[3] = new ListItem("岗位", "WorkPostName");
|
||||||
list[4] = new ListItem("累计", "TotalCount");
|
list[4] = new ListItem("累计", "TotalCount");
|
||||||
foreach (var item in list)
|
foreach (var item in list)
|
||||||
|
|
@ -183,89 +183,69 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
GridTable.Rows.Clear();
|
GridTable.Rows.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 使用原生SQL查询来提高性能,直接在数据库层面进行分组统计
|
var getData = Funs.DB.SitePerson_Checking_Statistics.Where(x =>
|
||||||
string strSql = @"
|
x.ProjectId == this.CurrUser.LoginProjectId && x.IntoOutTime >= Convert.ToDateTime(StartTime) && x.IntoOutTime <= Convert.ToDateTime(EndTime));
|
||||||
SELECT e.UnitId, e.PostId, e.RecordDate, p.WorkAreaId as UnitWorkId
|
DataTable dt = this.LINQToDataTable(getData.ToList());
|
||||||
FROM T_d_EmployInOutRecord e INNER JOIN SitePerson_Person p ON e.IDCardNo = p.IdentityCard AND e.ProjectId = p.ProjectId
|
|
||||||
WHERE e.PostId IS NOT NULL AND e.PostId != ''
|
|
||||||
AND e.ProjectId = @ProjectId
|
|
||||||
AND e.RecordDate >= @StartDate
|
|
||||||
AND e.RecordDate <= @EndDate";
|
|
||||||
|
|
||||||
var parameters = new List<System.Data.SqlClient.SqlParameter>
|
|
||||||
{
|
|
||||||
new System.Data.SqlClient.SqlParameter("@ProjectId", this.CurrUser.LoginProjectId),
|
|
||||||
new System.Data.SqlClient.SqlParameter("@StartDate", Convert.ToDateTime(StartTime)),
|
|
||||||
new System.Data.SqlClient.SqlParameter("@EndDate", Convert.ToDateTime(EndTime))
|
|
||||||
};
|
|
||||||
|
|
||||||
if (UnitId != Const._Null)
|
|
||||||
{
|
|
||||||
strSql += " AND e.UnitId = @UnitId";
|
|
||||||
parameters.Add(new System.Data.SqlClient.SqlParameter("@UnitId", UnitId));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (drpWorkPost.SelectedValue != Const._Null)
|
|
||||||
{
|
|
||||||
strSql += " AND e.PostId = @PostId";
|
|
||||||
parameters.Add(new System.Data.SqlClient.SqlParameter("@PostId", drpWorkPost.SelectedValue));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 执行查询获取分组数据
|
|
||||||
var dt = SQLHelper.GetDataTableRunText(strSql, parameters.ToArray());
|
|
||||||
|
|
||||||
// 创建一个新的DataTable来存储处理后的数据
|
// 创建一个新的DataTable来存储处理后的数据
|
||||||
DataTable processedDt = dt.Clone();
|
DataTable processedDt = dt.Clone();
|
||||||
|
|
||||||
foreach (System.Data.DataRow row in dt.Rows)
|
foreach (System.Data.DataRow row in dt.Rows)
|
||||||
{
|
{
|
||||||
string ids = row["UnitWorkId"] != DBNull.Value ? row["UnitWorkId"].ToString() : string.Empty;
|
// string ids = row["WorkAreaId"] != DBNull.Value ? row["WorkAreaId"].ToString() : string.Empty;
|
||||||
if (!string.IsNullOrEmpty(ids))
|
// string names = row["WorkAreaName"] != DBNull.Value ? row["WorkAreaName"].ToString() : string.Empty;
|
||||||
{
|
// if (!string.IsNullOrEmpty(names))
|
||||||
string[] unitWorkIdArray = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
// {
|
||||||
foreach (string unitWorkId in unitWorkIdArray)
|
// string[] unitWorkNameArray = names.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
{
|
// string[] unitWorkIdArray = ids.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||||
// 往processedDt里面添加数据,每个UnitWorkId一行
|
// for (var i = 0; i < unitWorkNameArray.Length; i++)
|
||||||
|
// {
|
||||||
|
// // 往processedDt里面添加数据,每个UnitWorkId一行
|
||||||
|
// DataRow newRow = processedDt.NewRow();
|
||||||
|
// newRow["UnitId"] = row["UnitId"];
|
||||||
|
// newRow["UnitName"] = row["UnitName"];
|
||||||
|
// newRow["WorkPostId"] = row["WorkPostId"];
|
||||||
|
// newRow["WorkPostName"] = row["WorkPostName"];
|
||||||
|
// newRow["IntoOutTime"] = row["IntoOutTime"] ?? DBNull.Value;
|
||||||
|
// newRow["WorkAreaId"] = unitWorkIdArray[i].Trim();
|
||||||
|
// newRow["WorkAreaName"] = unitWorkNameArray[i].Trim();
|
||||||
|
// newRow["num"] = row["num"] != DBNull.Value ? Convert.ToInt32(row["num"]) : 0;
|
||||||
|
// processedDt.Rows.Add(newRow);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
DataRow newRow = processedDt.NewRow();
|
DataRow newRow = processedDt.NewRow();
|
||||||
newRow["UnitId"] = row["UnitId"];
|
newRow["UnitId"] = row["UnitId"];
|
||||||
newRow["PostId"] = row["PostId"];
|
newRow["UnitName"] = row["UnitName"];
|
||||||
newRow["RecordDate"] = row["RecordDate"];
|
newRow["WorkPostId"] = row["WorkPostId"];
|
||||||
newRow["UnitWorkId"] = unitWorkId.Trim();
|
newRow["WorkPostName"] = row["WorkPostName"];
|
||||||
|
newRow["IntoOutTime"] = row["IntoOutTime"] ?? DBNull.Value;
|
||||||
|
newRow["WorkAreaId"] = row["WorkAreaId"];
|
||||||
|
newRow["WorkAreaName"] = row["WorkAreaName"];
|
||||||
|
newRow["num"] = row["num"] != DBNull.Value ? Convert.ToInt32(row["num"]) : 0;
|
||||||
processedDt.Rows.Add(newRow);
|
processedDt.Rows.Add(newRow);
|
||||||
}
|
// }
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
DataRow newRow = processedDt.NewRow();
|
|
||||||
newRow["UnitId"] = row["UnitId"];
|
|
||||||
newRow["PostId"] = row["PostId"];
|
|
||||||
newRow["RecordDate"] = row["RecordDate"];
|
|
||||||
newRow["UnitWorkId"] = string.Empty;
|
|
||||||
processedDt.Rows.Add(newRow);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//针对dt中的数据进行分组
|
//针对dt中的数据进行分组
|
||||||
var data = processedDt.AsEnumerable()
|
var data = processedDt.AsEnumerable()
|
||||||
.GroupBy(row => new {
|
.Select(row => new
|
||||||
UnitId = row["UnitId"],
|
|
||||||
PostId = row["PostId"],
|
|
||||||
UnitWorkId = row["UnitWorkId"],
|
|
||||||
RecordDate = row["RecordDate"]
|
|
||||||
}).Select(group => new
|
|
||||||
{
|
{
|
||||||
UnitId = group.Key.UnitId,
|
UnitId = row["UnitId"],
|
||||||
PostId = group.Key.PostId,
|
UnitName = row["UnitName"],
|
||||||
UnitWorkId = group.Key.UnitWorkId,
|
WorkPostId = row["WorkPostId"],
|
||||||
RecordDate = group.Key.RecordDate,
|
WorkPostName = row["WorkPostName"],
|
||||||
RecordCount = group.Count()
|
WorkAreaId = row["WorkAreaId"],
|
||||||
|
WorkAreaName = row["WorkAreaName"],
|
||||||
|
IntoOutTime = row["IntoOutTime"],
|
||||||
|
num = row["num"],
|
||||||
}).ToList();
|
}).ToList();
|
||||||
|
|
||||||
var data1 = data;
|
var data1 = data;
|
||||||
// 如果选择了特定的装置进行筛选
|
// 如果选择了特定的装置进行筛选
|
||||||
if (drpUnitWork.SelectedValue != Const._Null)
|
if (drpUnitWork.SelectedValue != Const._Null)
|
||||||
{
|
{
|
||||||
data1 = data.Where(x => x.UnitWorkId.ToString() == drpUnitWork.SelectedValue).ToList();
|
data1 = data.Where(x => x.WorkAreaId.ToString() == drpUnitWork.SelectedValue).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将数据转换为更易处理的格式
|
// 将数据转换为更易处理的格式
|
||||||
|
|
@ -273,23 +253,26 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
var groupedDict = new Dictionary<string, dynamic>();
|
var groupedDict = new Dictionary<string, dynamic>();
|
||||||
foreach (var item in data1)
|
foreach (var item in data1)
|
||||||
{
|
{
|
||||||
string key = $"{item.UnitId}_{item.PostId}_{item.UnitWorkId}";
|
string key = $"{item.UnitId}_{item.WorkPostId}_{item.WorkAreaId}";
|
||||||
DateTime recordDate = Convert.ToDateTime(item.RecordDate);
|
DateTime IntoOutTime = Convert.ToDateTime(item.IntoOutTime);
|
||||||
int count = Convert.ToInt32(item.RecordCount);
|
int count = Convert.ToInt32(item.num);
|
||||||
|
|
||||||
if (!groupedDict.ContainsKey(key))
|
if (!groupedDict.ContainsKey(key))
|
||||||
{
|
{
|
||||||
dynamic group = new System.Dynamic.ExpandoObject();
|
dynamic group = new System.Dynamic.ExpandoObject();
|
||||||
group.UnitId = item.UnitId;
|
group.UnitId = item.UnitId;
|
||||||
group.PostId = item.PostId;
|
group.UnitName = item.UnitName;
|
||||||
group.UnitWorkId = item.UnitWorkId;
|
group.WorkPostId = item.WorkPostId;
|
||||||
|
group.WorkPostName = item.WorkPostName;
|
||||||
|
group.WorkAreaId = item.WorkAreaId;
|
||||||
|
group.WorkAreaName = item.WorkAreaName;
|
||||||
group.DailyCounts = new Dictionary<DateTime, int>();
|
group.DailyCounts = new Dictionary<DateTime, int>();
|
||||||
group.TotalCount = 0;
|
group.TotalCount = 0;
|
||||||
groupedDict[key] = group;
|
groupedDict[key] = group;
|
||||||
groupedData.Add(group);
|
groupedData.Add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
groupedDict[key].DailyCounts[recordDate] = count;
|
groupedDict[key].DailyCounts[IntoOutTime] = count;
|
||||||
groupedDict[key].TotalCount += count;
|
groupedDict[key].TotalCount += count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -298,47 +281,6 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
// 分页处理
|
// 分页处理
|
||||||
var pagedData = groupedData.Skip(Grid1.PageSize * Grid1.PageIndex).Take(Grid1.PageSize).ToList();
|
var pagedData = groupedData.Skip(Grid1.PageSize * Grid1.PageIndex).Take(Grid1.PageSize).ToList();
|
||||||
|
|
||||||
// 只获取当前页需要的单位和岗位信息,避免加载全部数据
|
|
||||||
var unitIds = pagedData.Where(x => x.UnitId != null).Select(x => x.UnitId.ToString()).Distinct().ToList();
|
|
||||||
var postIds = pagedData.Where(x => x.PostId != null).Select(x => x.PostId.ToString()).Distinct().ToList();
|
|
||||||
var unitWorkIds = pagedData.Where(x => x.UnitWorkId != null).Select(x => x.UnitWorkId.ToString()).Distinct().ToList();
|
|
||||||
|
|
||||||
var units = new Dictionary<string, string>();
|
|
||||||
var workPosts = new Dictionary<string, string>();
|
|
||||||
var unitWorks = new Dictionary<string, string>();
|
|
||||||
|
|
||||||
if (unitIds.Any())
|
|
||||||
{
|
|
||||||
var unitQuery = from u in Funs.DB.Base_Unit
|
|
||||||
where unitIds.Contains(u.UnitId)
|
|
||||||
select new { u.UnitId, u.UnitName };
|
|
||||||
foreach (var u in unitQuery)
|
|
||||||
{
|
|
||||||
units[u.UnitId] = u.UnitName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (postIds.Any())
|
|
||||||
{
|
|
||||||
var postQuery = from p in Funs.DB.Base_WorkPost
|
|
||||||
where postIds.Contains(p.WorkPostId)
|
|
||||||
select new { p.WorkPostId, p.WorkPostName };
|
|
||||||
foreach (var p in postQuery)
|
|
||||||
{
|
|
||||||
workPosts[p.WorkPostId] = p.WorkPostName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (unitWorkIds.Any())
|
|
||||||
{
|
|
||||||
var unitWorkQuery = from p in Funs.DB.WBS_UnitWork
|
|
||||||
where unitWorkIds.Contains(p.UnitWorkId)
|
|
||||||
select new { p.UnitWorkId, p.UnitWorkName };
|
|
||||||
foreach (var p in unitWorkQuery)
|
|
||||||
{
|
|
||||||
unitWorks[p.UnitWorkId] = p.UnitWorkName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var group in pagedData)
|
foreach (var group in pagedData)
|
||||||
{
|
{
|
||||||
DataRow row = GridTable.NewRow();
|
DataRow row = GridTable.NewRow();
|
||||||
|
|
@ -348,31 +290,16 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
row["SerialNumber"] = GridTable.Rows.Count + 1; // 序号
|
row["SerialNumber"] = GridTable.Rows.Count + 1; // 序号
|
||||||
|
|
||||||
// 单位信息
|
// 单位信息
|
||||||
string unitName = "";
|
row["UnitName"] = group.UnitName ?? "";
|
||||||
if (group.UnitId != null && units.ContainsKey(group.UnitId.ToString()))
|
|
||||||
{
|
|
||||||
unitName = units[group.UnitId.ToString()];
|
|
||||||
}
|
|
||||||
row["UnitName"] = unitName;
|
|
||||||
row["UnitId"] = group.UnitId ?? (object)DBNull.Value;
|
row["UnitId"] = group.UnitId ?? (object)DBNull.Value;
|
||||||
|
|
||||||
// 装置信息
|
// 装置信息
|
||||||
string unitWorkName = "";
|
row["WorkAreaName"] = group.WorkAreaName ?? "";
|
||||||
if (group.UnitWorkId != null && unitWorks.ContainsKey(group.UnitWorkId.ToString()))
|
row["WorkAreaId"] = group.WorkAreaId ?? (object)DBNull.Value;
|
||||||
{
|
|
||||||
unitWorkName = unitWorks[group.UnitWorkId.ToString()];
|
|
||||||
}
|
|
||||||
row["UnitWorkName"] = unitWorkName;
|
|
||||||
row["UnitWorkId"] = group.UnitWorkId ?? (object)DBNull.Value;
|
|
||||||
|
|
||||||
// 岗位信息
|
// 岗位信息
|
||||||
string workPostName = "";
|
row["WorkPostName"] = group.WorkPostName ?? "";
|
||||||
if (group.PostId != null && workPosts.ContainsKey(group.PostId.ToString()))
|
row["WorkPostId"] = group.WorkPostId ?? (object)DBNull.Value;
|
||||||
{
|
|
||||||
workPostName = workPosts[group.PostId.ToString()];
|
|
||||||
}
|
|
||||||
row["WorkPostName"] = workPostName;
|
|
||||||
row["WorkPostId"] = group.PostId ?? (object)DBNull.Value;
|
|
||||||
|
|
||||||
// 每日数量填充
|
// 每日数量填充
|
||||||
foreach (var kvp in group.DailyCounts)
|
foreach (var kvp in group.DailyCounts)
|
||||||
|
|
@ -531,7 +458,7 @@ namespace FineUIPro.Web.JDGL.SGManPower
|
||||||
// 添加装置参数(如果已选择)
|
// 添加装置参数(如果已选择)
|
||||||
if (drpUnitWork.SelectedValue != Const._Null && !string.IsNullOrEmpty(drpUnitWork.SelectedValue))
|
if (drpUnitWork.SelectedValue != Const._Null && !string.IsNullOrEmpty(drpUnitWork.SelectedValue))
|
||||||
{
|
{
|
||||||
urlParams += "&UnitWorkId=" + drpUnitWork.SelectedValue;
|
urlParams += "&WorkAreaId=" + drpUnitWork.SelectedValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
PageContext.RegisterStartupScript(
|
PageContext.RegisterStartupScript(
|
||||||
|
|
|
||||||
|
|
@ -8892,6 +8892,14 @@ namespace Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public System.Data.Linq.Table<SitePerson_Checking_Statistics> SitePerson_Checking_Statistics
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.GetTable<SitePerson_Checking_Statistics>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public System.Data.Linq.Table<SitePerson_DayReport> SitePerson_DayReport
|
public System.Data.Linq.Table<SitePerson_DayReport> SitePerson_DayReport
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
|
@ -350663,6 +350671,177 @@ namespace Model
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.SitePerson_Checking_Statistics")]
|
||||||
|
public partial class SitePerson_Checking_Statistics
|
||||||
|
{
|
||||||
|
|
||||||
|
private string _ProjectId;
|
||||||
|
|
||||||
|
private string _UnitId;
|
||||||
|
|
||||||
|
private string _UnitName;
|
||||||
|
|
||||||
|
private string _WorkAreaId;
|
||||||
|
|
||||||
|
private string _WorkAreaName;
|
||||||
|
|
||||||
|
private string _WorkPostId;
|
||||||
|
|
||||||
|
private string _WorkPostName;
|
||||||
|
|
||||||
|
private System.Nullable<System.DateTime> _IntoOutTime;
|
||||||
|
|
||||||
|
private System.Nullable<int> _Num;
|
||||||
|
|
||||||
|
public SitePerson_Checking_Statistics()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_ProjectId", DbType="NVarChar(50)")]
|
||||||
|
public string ProjectId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._ProjectId;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._ProjectId != value))
|
||||||
|
{
|
||||||
|
this._ProjectId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UnitId", DbType="NVarChar(50)")]
|
||||||
|
public string UnitId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._UnitId;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._UnitId != value))
|
||||||
|
{
|
||||||
|
this._UnitId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_UnitName", DbType="NVarChar(200)")]
|
||||||
|
public string UnitName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._UnitName;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._UnitName != value))
|
||||||
|
{
|
||||||
|
this._UnitName = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkAreaId", DbType="NVarChar(MAX)", UpdateCheck=UpdateCheck.Never)]
|
||||||
|
public string WorkAreaId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._WorkAreaId;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._WorkAreaId != value))
|
||||||
|
{
|
||||||
|
this._WorkAreaId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkAreaName", DbType="NVarChar(MAX)", UpdateCheck=UpdateCheck.Never)]
|
||||||
|
public string WorkAreaName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._WorkAreaName;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._WorkAreaName != value))
|
||||||
|
{
|
||||||
|
this._WorkAreaName = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkPostId", DbType="NVarChar(50)")]
|
||||||
|
public string WorkPostId
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._WorkPostId;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._WorkPostId != value))
|
||||||
|
{
|
||||||
|
this._WorkPostId = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WorkPostName", DbType="NVarChar(100)")]
|
||||||
|
public string WorkPostName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._WorkPostName;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._WorkPostName != value))
|
||||||
|
{
|
||||||
|
this._WorkPostName = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_IntoOutTime", DbType="DateTime")]
|
||||||
|
public System.Nullable<System.DateTime> IntoOutTime
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._IntoOutTime;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._IntoOutTime != value))
|
||||||
|
{
|
||||||
|
this._IntoOutTime = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[global::System.Data.Linq.Mapping.ColumnAttribute(Name="num", Storage="_Num", DbType="Int")]
|
||||||
|
public System.Nullable<int> Num
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._Num;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if ((this._Num != value))
|
||||||
|
{
|
||||||
|
this._Num = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.SitePerson_DayReport")]
|
[global::System.Data.Linq.Mapping.TableAttribute(Name="dbo.SitePerson_DayReport")]
|
||||||
public partial class SitePerson_DayReport : INotifyPropertyChanging, INotifyPropertyChanged
|
public partial class SitePerson_DayReport : INotifyPropertyChanging, INotifyPropertyChanged
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
using Model;
|
using Model;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.SqlClient;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Web.Http;
|
using System.Web.Http;
|
||||||
|
|
@ -200,5 +202,102 @@ namespace WebAPI.Controllers
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#region 统计考勤人员考勤数据
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 统计考勤人员考勤数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpPost]
|
||||||
|
public Model.ReturnData SynSitePersonCheckingStatistics()
|
||||||
|
{
|
||||||
|
var responeData = new Model.ReturnData();
|
||||||
|
responeData.time = DateTime.Now.ToString();
|
||||||
|
using (SqlConnection Connection = new SqlConnection(Funs.ConnString))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string sql = @"
|
||||||
|
TRUNCATE TABLE dbo.SitePerson_Checking_Statistics;
|
||||||
|
|
||||||
|
INSERT INTO dbo.SitePerson_Checking_Statistics (
|
||||||
|
ProjectId,
|
||||||
|
UnitId,
|
||||||
|
UnitName,
|
||||||
|
WorkAreaId,
|
||||||
|
WorkAreaName,
|
||||||
|
WorkPostId,
|
||||||
|
WorkPostName,
|
||||||
|
IntoOutTime,
|
||||||
|
num
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
a.ProjectId,
|
||||||
|
b.UnitId,
|
||||||
|
b.UnitName,
|
||||||
|
b.WorkAreaId,
|
||||||
|
b.WorkAreaName,
|
||||||
|
p.WorkPostId,
|
||||||
|
w.WorkPostName,
|
||||||
|
CAST(b.IntoOutTime AS DATE) AS IntoOutTime,
|
||||||
|
COUNT(1) AS num
|
||||||
|
FROM (
|
||||||
|
SELECT
|
||||||
|
PersonId,
|
||||||
|
CAST(IntoOutTime AS DATE) AS IntoOutTime,
|
||||||
|
MAX(CheckingId) AS MaxCheckingId,
|
||||||
|
ProjectId
|
||||||
|
FROM SitePerson_Checking
|
||||||
|
GROUP BY PersonId, CAST(IntoOutTime AS DATE), ProjectId
|
||||||
|
) a
|
||||||
|
JOIN SitePerson_Checking b ON a.MaxCheckingId = b.CheckingId
|
||||||
|
LEFT JOIN SitePerson_Person p ON a.PersonId = p.PersonId
|
||||||
|
LEFT JOIN Base_WorkPost w ON p.WorkPostId = w.WorkPostId
|
||||||
|
LEFT JOIN Base_Project bp ON a.ProjectId = bp.ProjectId
|
||||||
|
where bp.ProjectState='1'
|
||||||
|
GROUP BY
|
||||||
|
a.ProjectId,
|
||||||
|
b.UnitId,
|
||||||
|
b.UnitName,
|
||||||
|
b.WorkAreaId,
|
||||||
|
b.WorkAreaName,
|
||||||
|
p.WorkPostId,
|
||||||
|
w.WorkPostName,
|
||||||
|
CAST(b.IntoOutTime AS DATE);";
|
||||||
|
|
||||||
|
Connection.Open();
|
||||||
|
SqlCommand command = new SqlCommand(sql, Connection)
|
||||||
|
{
|
||||||
|
CommandTimeout = 0,
|
||||||
|
CommandType = CommandType.Text
|
||||||
|
};
|
||||||
|
int result = command.ExecuteNonQuery();
|
||||||
|
responeData.message = $"执行成功,共插入 {result} 条记录";
|
||||||
|
}
|
||||||
|
catch (SqlException sqlEx)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = $"数据库操作失败: {sqlEx.Message}";
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
responeData.code = 0;
|
||||||
|
responeData.message = $"执行失败: {ex.Message}";
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Connection.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return responeData;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -94,6 +94,7 @@ namespace WebAPI.Filter
|
||||||
"IDP*SynIDPPreRunData",
|
"IDP*SynIDPPreRunData",
|
||||||
"IDP*SynOADesignDrawingDataBlueprintInfo",
|
"IDP*SynOADesignDrawingDataBlueprintInfo",
|
||||||
"IDP*SynOADesignDrawingDataPrintInfo",
|
"IDP*SynOADesignDrawingDataPrintInfo",
|
||||||
|
"IDP*SynSitePersonCheckingStatistics",
|
||||||
"JGZL*getUserList",
|
"JGZL*getUserList",
|
||||||
"JGZL*getProjedtList",
|
"JGZL*getProjedtList",
|
||||||
"JGZL*getUnitWorkListByProjectId",
|
"JGZL*getUnitWorkListByProjectId",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue