This commit is contained in:
高飞 2024-09-05 10:55:22 +08:00
commit be1f4b70eb
6 changed files with 172 additions and 49 deletions

View File

@ -0,0 +1,48 @@
Create PROCEDURE [dbo].[SpGetHsseKq]
@ProjectId nvarchar(50),/*表名*/
@startTime nvarchar(50),/*开始时间*/
@endTime nvarchar(50),/*结束时间*/
@UnitId nvarchar(50),/*0没有单位 1分包商 2五环*/
@returnVal int output
AS
/*获取安全月报考勤数据*/
declare @sql nvarchar(500),
@kqcount int;
IF(@UnitId='0')
BEGIN
select @returnVal=count(*) from ( select IdentityCard FROM SitePerson_Checking WHERE PROJECTID=''+@ProjectId+'' AND IntoOut='1'
AND IntoOutTime>=''+@startTime+'' AND IntoOutTime<=''+@endTime+'' Group by IdentityCard,CONVERT(varchar(100), IntoOutTime, 23)
)f;
--select @sql= N' SELECT @kqcount= count(*) from (select IdentityCard FROM SitePerson_Checking WHERE PROJECTID='''+@ProjectId+''' AND IntoOut=''1''
-- AND IntoOutTime>='''+@startTime+''' AND IntoOutTime<='''+@endTime+''' Group by IdentityCard,CONVERT(varchar(100), IntoOutTime, 23))f
--';
--EXEC sp_executesql @sql, N'@kqcount int OUTPUT', @kqcount OUTPUT ;
--set @returnVal=@kqcount;
END
else
begin
if(@UnitId='1')
begin
select @returnVal=count(*) from ( select IdentityCard FROM SitePerson_Checking WHERE PROJECTID=''+@ProjectId+'' AND IntoOut='1'
AND IntoOutTime>=''+@startTime+'' AND IntoOutTime<=''+@endTime+''
and UnitId<>'6d29ed79-e20a-4c19-bb91-d280ea2e442e'
Group by IdentityCard,CONVERT(varchar(100), IntoOutTime, 23)
)f;
end
else
begin
select @returnVal=count(*) from ( select IdentityCard FROM SitePerson_Checking WHERE PROJECTID=''+@ProjectId+'' AND IntoOut='1'
AND IntoOutTime>=''+@startTime+'' AND IntoOutTime<=''+@endTime+''
and UnitId='6d29ed79-e20a-4c19-bb91-d280ea2e442e'
Group by IdentityCard,CONVERT(varchar(100), IntoOutTime, 23)
)f;
end
end

View File

@ -0,0 +1,21 @@
--
update sys_menu set SortIndex=0 where menuid='BC860C85-B224-48A6-B207-D7042BB71088';
update sys_menu set menuname='系统资产导入' where MenuId='F0E06491-B1DA-4510-ABCA-D09F4B24EE50';
update sys_menu set menuname='试车记录管理' where MenuId='29F80818-17A5-4BC0-8C38-A17415B0AC83';
update sys_menu set menuname='投料试车记录管理' where MenuId='B62482DA-9A12-45AC-9427-D0CF8A78EE2C';
update sys_menu set menuname='开车工程师项目工作总结' where MenuId='9EBA628D-E725-4A0B-B765-171F405D0821';
--
CREATE INDEX ProjectId_Index ON SitePerson_Checking (ProjectId);
CREATE INDEX IdentityCard_Index ON SitePerson_Checking (IdentityCard);
CREATE INDEX IntoOutTime_Index ON SitePerson_Checking (IntoOutTime);
CREATE INDEX IntoOut_Index ON SitePerson_Checking (IntoOut);
CREATE INDEX UnitId ON SitePerson_Checking (UnitId);
CREATE NONCLUSTERED INDEX [SitePerson_Checking_ProjectId_IntoOut_IntoOutTime_Index]
ON [dbo].[SitePerson_Checking] ([ProjectId],[IntoOut],[IntoOutTime])
INCLUDE ([IdentityCard]);

View File

@ -369,5 +369,6 @@ namespace BLL
db.SubmitChanges();
}
#endregion
}
}

View File

@ -972,5 +972,44 @@ namespace BLL
maxId = GetIntValue(str);
return maxId;
}
/// <summary>
/// ͨ¹ý´æ´¢¹ý³Ì»ñÈ¡Êý¾Ý
/// </summary>
/// <param name="storedProcName"></param>
/// <returns></returns>
public static int RunProcGetHsseKq(string ProjectId,DateTime startTime,DateTime endTime,string UnitId)
{
string str = "";
using (SqlConnection Connection = new SqlConnection(connectionString))
{
try
{
Connection.Open();
SqlCommand command = new SqlCommand("SpGetHsseKq", Connection)
{
CommandTimeout = 0,
CommandType = CommandType.StoredProcedure
};
SqlParameter[] values = new SqlParameter[]
{
new SqlParameter("@ProjectId", ProjectId),
new SqlParameter("@startTime", startTime.ToString()),
new SqlParameter("@endTime", endTime.ToString()),
new SqlParameter("@UnitId", UnitId),
new SqlParameter("@returnVal", SqlDbType.Int)
};
command.Parameters.AddRange(values);
command.Parameters["@returnVal"].Direction = ParameterDirection.Output;
command.ExecuteNonQuery();
str = command.Parameters["@returnVal"].Value.ToString();
}
finally
{
Connection.Close();
}
return Convert.ToInt32(str);
}
}
}
}

View File

@ -19232,7 +19232,7 @@
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v15.0\WebApplications\Microsoft.WebApplication.targets" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v16.0\WebApplications\Microsoft.WebApplication.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">

View File

@ -1775,7 +1775,8 @@ namespace FineUIPro.Web.HSSE.Manager
int totalSumPersonNum = 0;//总部
int totalSumOutPersonNum = 0;//外聘
int totalHSEPersonNum = 0;
var spckList = db.SitePerson_Checking.Where(x => x.ProjectId == ProjectId && x.IntoOut == "1");
var spckList = db.SitePerson_Checking.Where(x => x.IntoOutTime >= startTime
&& x.IntoOutTime <= endTime && x.ProjectId == ProjectId && x.IntoOut == "1");
if (units.Count() > 0)
{
foreach (Model.Project_ProjectUnit u in units)
@ -1789,8 +1790,7 @@ namespace FineUIPro.Web.HSSE.Manager
};
//本部本月人数,本年考勤人数除当前月份,取平均数
//年度
var yearList = spckList.Where(x => x.IntoOutTime >= startTime
&& x.IntoOutTime <= endTime && x.UnitId == u.UnitId).ToList().Select(x => new hseDayItem()
var yearList = spckList.Where(x => x.UnitId == u.UnitId).ToList().Select(x => new hseDayItem()
{
IdentityCard = x.IdentityCard,
IntoOutTime = getShortTime(x.IntoOutTime)
@ -1896,7 +1896,13 @@ namespace FineUIPro.Web.HSSE.Manager
private void getMonthReportCHSEDay()
{
var spckList = db.SitePerson_Checking.Where(x => x.ProjectId == ProjectId && x.IntoOut == "1");
//数据了太大,查起来有点问题。
//var spckList = db.SitePerson_Checking.Where(x => x.ProjectId == ProjectId && x.IntoOut == "1").Select(x=>new {
// IntoOutTime=x.IntoOutTime,
// IdentityCard=x.IdentityCard,
// UnitId=x.UnitId
//});
//本月项目现场HSE人工日统计
Model.MonthReportCHSEDay hseDay = new Model.MonthReportCHSEDay
{
@ -1905,63 +1911,71 @@ namespace FineUIPro.Web.HSSE.Manager
//累计安全工作天数(当前日期-项目开始日期)
hseDay.SumHSEDay = (endTime - projectStartTime).Days;
//本月HSE人工日、年度累计HSE人工日、总累计HSE人工日考勤中取
//本月
var list = spckList.Where(x => x.IntoOutTime >= startTime
&& x.IntoOutTime <= endTime).ToList().Select(x => new hseDayItem()
{
IdentityCard = x.IdentityCard,
IntoOutTime = getShortTime(x.IntoOutTime)
}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
.ToList();
////本月HSE人工日、年度累计HSE人工日、总累计HSE人工日考勤中取
////本月
//var list = spckList.Where(x => x.IntoOutTime >= startTime
//&& x.IntoOutTime <= endTime).ToList().Select(x => new hseDayItem()
//{
// IdentityCard = x.IdentityCard,
// IntoOutTime = getShortTime(x.IntoOutTime)
//}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
// .ToList();
//本月HSE人工日
hseDay.MonthHSEWorkDay = list.Count();
//本月安全人工时(五环)
hseDay.HseManhours = spckList.Where(x => x.IntoOutTime >= startTime
&& x.IntoOutTime <= endTime && x.UnitId == Const.UnitId_CWCEC).ToList().Select(x => new hseDayItem()
{
IdentityCard = x.IdentityCard,
IntoOutTime = getShortTime(x.IntoOutTime)
}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
.ToList().Count() * 8;
hseDay.MonthHSEWorkDay = SQLHelper.RunProcGetHsseKq(ProjectId, startTime, endTime, "0");
//list.Count();
//本月安全人工时(五环)
//hseDay.HseManhours = spckList.Where(x => x.IntoOutTime >= startTime
//&& x.IntoOutTime <= endTime && x.UnitId == Const.UnitId_CWCEC).ToList().Select(x => new hseDayItem()
//{
// IdentityCard = x.IdentityCard,
// IntoOutTime = getShortTime(x.IntoOutTime)
//}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
// .ToList().Count() * 8;
hseDay.HseManhours = SQLHelper.RunProcGetHsseKq(ProjectId, startTime, endTime, "3");
//本月安全人工时(分包商)
hseDay.SubcontractManHours= spckList.Where(x => x.IntoOutTime >= startTime
&& x.IntoOutTime <= endTime && x.UnitId != Const.UnitId_CWCEC).ToList().Select(x => new hseDayItem()
{
IdentityCard = x.IdentityCard,
IntoOutTime = getShortTime(x.IntoOutTime)
}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
.ToList().Count() * 8;
hseDay.SubcontractManHours = SQLHelper.RunProcGetHsseKq(ProjectId, startTime, endTime, "1");
// spckList.Where(x => x.IntoOutTime >= startTime
//&& x.IntoOutTime <= endTime && x.UnitId != Const.UnitId_CWCEC).ToList().Select(x => new hseDayItem()
//{
// IdentityCard = x.IdentityCard,
// IntoOutTime = getShortTime(x.IntoOutTime)
//}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
// .ToList().Count() * 8;
//年度
var yearList = spckList.Where(x => x.IntoOutTime >= yearStartTime
&& x.IntoOutTime <= endTime).ToList().Select(x => new hseDayItem()
{
IdentityCard = x.IdentityCard,
IntoOutTime = getShortTime(x.IntoOutTime)
}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
.ToList();
//var yearList = spckList.Where(x => x.IntoOutTime >= yearStartTime
// && x.IntoOutTime <= endTime).ToList().Select(x => new hseDayItem()
// {
// IdentityCard = x.IdentityCard,
// IntoOutTime = getShortTime(x.IntoOutTime)
// }).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
// .ToList();
//年度累计人工日
hseDay.YearHSEWorkDay = yearList.Count;
hseDay.YearHSEWorkDay = SQLHelper.RunProcGetHsseKq(ProjectId, yearStartTime, endTime, "0"); ;
//yearList.Count;
//年度累计HSE人工时
hseDay.TotalHseManhoursYear = yearList.Count * 8;
hseDay.TotalHseManhoursYear = hseDay.YearHSEWorkDay*8;
//yearList.Count * 8;
// //项目累计
var pList = spckList.Where(x => x.IntoOutTime >= projectStartTime
&& x.IntoOutTime <= endTime).ToList().Select(x => new hseDayItem()
{
IdentityCard = x.IdentityCard,
IntoOutTime = getShortTime(x.IntoOutTime)
}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
.ToList();
// // //项目累计
// var pList = spckList.Where(x => x.IntoOutTime >= projectStartTime
//&& x.IntoOutTime <= endTime).ToList().Select(x => new hseDayItem()
//{
// IdentityCard = x.IdentityCard,
// IntoOutTime = getShortTime(x.IntoOutTime)
//}).GroupBy(x => new { x.IdentityCard, x.IntoOutTime })
// .ToList();
hseDay.SumHSEWorkDay = pList.Count;
hseDay.SumHSEWorkDay = SQLHelper.RunProcGetHsseKq(ProjectId, projectStartTime, endTime, "0");
//pList.Count;
hseDay.TotalHseManhours = pList.Count * 8;
hseDay.TotalHseManhours = hseDay.SumHSEWorkDay*8;
//pList.Count * 8;
List<Model.MonthReportCHSEDay> listCHSEDay = new List<Model.MonthReportCHSEDay>();
listCHSEDay.Add(hseDay);