2022-03-15 17:36:38 +08:00
using BLL ;
using Newtonsoft.Json ;
using System ;
using System.Collections.Generic ;
2023-02-14 15:52:33 +08:00
using System.Data.SqlClient ;
using System.Data ;
2022-03-15 17:36:38 +08:00
using System.Linq ;
using System.Web.UI ;
namespace FineUIPro.Web.common
{
public partial class main : PageBase
{
protected void Page_Load ( object sender , EventArgs e )
{
if ( ! IsPostBack )
{
////项目信息
var getProjectLists = getProjectInfo ( ) ;
////合同
getHTContract ( ) ;
///劳务统计
getSitePerson ( ) ;
/// 获取安全人工时
getPersonWorkTime ( ) ;
/// 获取质量问题
getCQMSProblem ( ) ;
/// 获取施工产值
getOutputValue ( getProjectLists ) ;
2024-05-07 16:20:40 +08:00
///危大工程
getSolutionLargerHazard ( ) ;
2022-03-15 17:36:38 +08:00
}
}
#region 项 目 信 息
protected string ProjectInfo ;
/// <summary>
/// 项目信息
/// </summary>
private List < Model . Base_Project > getProjectInfo ( )
{
ProjectInfo = "[]" ;
var getProjects = Funs . DB . Base_Project . Where ( x = > ( x . ProjectState = = Const . ProjectState_1 | | x . ProjectState = = null ) ) ;
this . divProjectNum . InnerHtml = getProjects . Count ( ) . ToString ( ) ;
var getProjectMap = getProjects . Where ( x = > x . MapCoordinates . Length > 0 ) ;
if ( getProjectMap . Count ( ) > 0 )
{
List < Model . SingleSerie > list = new List < Model . SingleSerie > ( ) ;
foreach ( var item in getProjectMap )
{
Model . SingleSerie newS = new Model . SingleSerie
{
name = "【项目名称】:" + item . ProjectName
//+ "</br> 【项目状态】:" + GetProjectState(item.ProjectId)
+ "</br>【开工时间】:" + string . Format ( "{0:yyyy-MM-dd}" , item . StartDate )
+ "</br>【竣工时间】:" + string . Format ( "{0:yyyy-MM-dd}" , item . EndDate )
+ "</br>【项目地址】:" + item . ProjectAddress ,
url = "indexProject.aspx?projectId=" + item . ProjectId ,
cityname = "中国"
} ;
var strMap = Funs . GetStrListByStr ( item . MapCoordinates , ',' ) ;
if ( strMap . Count > 1 )
{
newS . value = new [ ] { Funs . GetNewDecimalOrZero ( strMap [ 0 ] ) , Funs . GetNewDecimalOrZero ( strMap [ 1 ] ) } ;
list . Add ( newS ) ;
2024-05-07 16:20:40 +08:00
}
2022-03-15 17:36:38 +08:00
}
2024-05-07 16:20:40 +08:00
ProjectInfo = JsonConvert . SerializeObject ( list ) ;
2022-03-15 17:36:38 +08:00
}
2024-05-07 16:20:40 +08:00
return getProjects . ToList ( ) ;
2022-03-15 17:36:38 +08:00
}
#endregion
#region 劳 务 统 计
protected double OnDutyRate ;
/// <summary>
/// 劳务统计
/// </summary>
private void getSitePerson ( )
{
OnDutyRate = 0 ;
2023-02-14 15:52:33 +08:00
//int AllCount = 0;
//int MCount = 0;
2022-03-15 17:36:38 +08:00
var getallin = APIPageDataService . getPersonInOutAllNum ( DateTime . Now . AddDays ( - 1 ) ) ;
2023-02-14 15:52:33 +08:00
//AllCount = getallin.Count();
//if (AllCount > 0)
//{
// MCount = getallin.Where(x => x.PostType == Const.PostType_1).Count();
// /////管理人数
// this.divGLPerson.InnerHtml = MCount.ToString();
// /////作业人数
// this.divZYPerson.InnerHtml = (AllCount - MCount).ToString();
// int getPersonCount=Funs.DB.SitePerson_Person.Where(x => x.IsUsed == 1 && x.CardNo.Length > 1
// && x.InTime <= DateTime.Now && !x.OutTime.HasValue && x.AuditorDate.HasValue).Count();
// if (getPersonCount > 0)
// {
// OnDutyRate = Math.Round(AllCount * 1.0 / getPersonCount * 100, 1);
// }
//}
2023-12-25 17:15:12 +08:00
//string sql = @"select c.ConstText,b.PostType,count( *) num from SitePerson_Person a left join Base_WorkPost b on a.WorkPostId=b.WorkPostId
// LEFT JOIN Sys_Const AS c ON c.ConstValue = b.PostType and c.GroupId = 'PostType' where IsUsed =1 and InTime<='" + DateTime.Now.ToString("yyyy-MM-dd") + "' and (OutTime is null or OutTime>'" + DateTime.Now.ToString("yyyy-MM-dd") + @"' )
// and AuditorDate is not null
// group by c.ConstText,b.PostType ";
//List<SqlParameter> listStr = new List<SqlParameter>();
//SqlParameter[] parameter = listStr.ToArray();
//DataTable tb = SQLHelper.GetDataTableRunText(sql, parameter);
//int allcount = 0;
//int mcount = 0;
//if (tb != null)
//{
// foreach (DataRow row in tb.Rows)
// {
// allcount += int.Parse(row["num"].ToString());
// if (!string.IsNullOrEmpty(row["ConstText"].ToString()) && row["ConstText"].ToString().Contains("管理"))
// {
// mcount += int.Parse(row["num"].ToString());
// }
// }
//}
//this.divALLPerson.InnerHtml = allcount.ToString();
var ProjectTotal1 = ( from x in Funs . DB . HSSE_MonthReportItem
2024-05-07 16:20:40 +08:00
join y in Funs . DB . HSSE_MonthReport on x . MonthReportId equals y . MonthReportId
2024-01-03 14:12:27 +08:00
//where ("成达公司HSE管理人数" == x.ReportItem || "分包商HSE管理人数" == x.ReportItem) && y.Years == DateTime.Now.Year
2024-05-07 16:20:40 +08:00
where ( "成达公司现场人数" = = x . ReportItem ) & & y . Years = = DateTime . Now . Year
2024-01-03 14:12:27 +08:00
select x . YearTotal ) . Sum ( ) ;
2023-12-25 17:15:12 +08:00
if ( ProjectTotal1 . HasValue )
2022-03-15 17:36:38 +08:00
{
2024-05-07 16:20:40 +08:00
this . divGLPerson . InnerHtml = ProjectTotal1 . Value . ToString ( ) ;
2022-03-15 17:36:38 +08:00
}
2023-02-14 15:52:33 +08:00
2023-12-25 17:15:12 +08:00
var ProjectTotal2 = ( from x in Funs . DB . HSSE_MonthReportItem
2024-05-07 16:20:40 +08:00
join y in Funs . DB . HSSE_MonthReport on x . MonthReportId equals y . MonthReportId
2024-01-03 14:12:27 +08:00
//where ("成达公司现场人数" == x.ReportItem || "分包商现场人数" == x.ReportItem) && y.Years == DateTime.Now.Year
2024-05-07 16:20:40 +08:00
where ( "分包商现场人数" = = x . ReportItem ) & & y . Years = = DateTime . Now . Year
2024-01-03 14:12:27 +08:00
select x . YearTotal ) . Sum ( ) ;
2023-12-25 17:15:12 +08:00
2024-01-03 14:12:27 +08:00
//if (ProjectTotal2.HasValue && ProjectTotal1.HasValue)
//{
// this.divZYPerson.InnerHtml = (ProjectTotal2.Value - ProjectTotal1.Value).ToString();
//}
//else
if ( ProjectTotal2 . HasValue )
2023-12-25 17:15:12 +08:00
{
this . divZYPerson . InnerHtml = ProjectTotal2 . Value . ToString ( ) ;
}
// OnDutyRate = Math.Round(getallin.Count() * 1.0 / allcount * 100, 1);
2023-02-14 15:52:33 +08:00
2022-03-15 17:36:38 +08:00
}
#endregion
#region 安 全 人 工 时
/// <summary>
/// 获取安全人工时
/// </summary>
private void getPersonWorkTime ( )
{
2023-02-14 15:52:33 +08:00
//var getItem = (from x in Funs.DB.DigData_HSEDataCollectItem
// join y in Funs.DB.DigData_HSEDataCollect on x.HSEDataCollectId equals y.HSEDataCollectId
// where y.Year == DateTime.Now.Year && x.SortIndex == 7
// select x).FirstOrDefault();
//if (getItem != null)
//{
// int wHours = Funs.GetNewIntOrZero(getItem.Month1) + Funs.GetNewIntOrZero(getItem.Month2)
// + Funs.GetNewIntOrZero(getItem.Month3) + Funs.GetNewIntOrZero(getItem.Month4)
// + Funs.GetNewIntOrZero(getItem.Month5) + Funs.GetNewIntOrZero(getItem.Month6)
// + Funs.GetNewIntOrZero(getItem.Month7) + Funs.GetNewIntOrZero(getItem.Month8)
// + Funs.GetNewIntOrZero(getItem.Month9) + Funs.GetNewIntOrZero(getItem.Month10)
// + Funs.GetNewIntOrZero(getItem.Month11) + Funs.GetNewIntOrZero(getItem.Month12);
// if (wHours > 0)
// {
// this.divSafeWorkTime.InnerHtml = wHours.ToString("0000000000");
// }
//}
this . divSafeWorkTime . InnerHtml = "0000000000" ;
var ProjectTotal = ( from x in Funs . DB . HSSE_MonthReportItem
join y in Funs . DB . HSSE_MonthReport on x . MonthReportId equals y . MonthReportId
2024-05-07 16:20:40 +08:00
where "安全生产人工时数" = = x . ReportItem & & y . Years = = DateTime . Now . Year
2023-02-14 15:52:33 +08:00
select x . YearTotal ) . Sum ( ) ;
2022-03-15 17:36:38 +08:00
2023-02-14 15:52:33 +08:00
if ( ProjectTotal . HasValue )
{
this . divSafeWorkTime . InnerHtml = ProjectTotal . Value . ToString ( "0000000000" ) ; ;
}
else
{
this . divSafeWorkTime . InnerHtml = "0000000000" ;
}
2022-03-15 17:36:38 +08:00
///整改单
2023-12-08 18:33:21 +08:00
//var getRectify =from x in Funs.DB.Check_RectifyNotices
// where x.States !=Const.State_0 && x.States != null && x.ProjectId != null
// select x;
//int allcout = getRectify.Count();
//if (allcout > 0)
//{
// this.divAllRectify.InnerHtml = allcout.ToString();
// int ccount = getRectify.Where(x => x.States == "5").Count();
// this.divRectifyRate.InnerHtml = Math.Round(ccount * 1.0 / allcout * 100, 1).ToString();
//}
2024-01-03 14:12:27 +08:00
DateTime time = DateTime . Parse ( DateTime . Now . ToString ( "yyyy-01-01" ) ) ;
2023-12-08 18:33:21 +08:00
var getRectify = from x in Funs . DB . View_Hazard_HazardRegister
2024-05-07 16:20:40 +08:00
where x . States ! = Const . State_0 & & x . States ! = Const . State_R & & x . States ! = null & & x . RegisterDate > = time
2023-12-08 18:33:21 +08:00
group x by x . States into g
select new { g . Key , Count = g . Count ( ) } ;
var allcout = getRectify . ToList ( ) ;
if ( allcout . Count > 0 )
2022-03-15 17:36:38 +08:00
{
2023-12-08 18:33:21 +08:00
int total = 0 ;
int finish = 0 ;
foreach ( var item in allcout )
{
total + = item . Count ;
if ( item . Key . ToString ( ) = = "3" )
{
finish + = item . Count ;
}
}
this . divAllRectify . InnerHtml = total . ToString ( ) ;
//this.divUCRectify.InnerHtml = (total - finish).ToString();
2024-05-07 16:20:40 +08:00
this . divRectifyRate . InnerHtml = Math . Round ( finish * 1.0 / total * 100 , 1 ) . ToString ( ) ;
2022-03-15 17:36:38 +08:00
}
2023-12-08 18:33:21 +08:00
2022-03-15 17:36:38 +08:00
}
#endregion
#region 获 取 合 同
private void getHTContract ( )
2024-05-07 16:20:40 +08:00
{
var ConstructionNum = Funs . DB . Base_Project . Sum ( x = > x . ConstructionNum ) ;
var ConstructionMoney = Funs . DB . Base_Project . Sum ( x = > x . ConstructionMoney ) ;
//var getC = (from x in Funs.DB.PHTGL_ContractReview
// join y in Funs.DB.PHTGL_Approve on x.ContractReviewId equals y.ContractId
// join z in Funs.DB.PHTGL_Contract on x.ContractId equals z.ContractId
// where x.State == 5 && Convert.ToDateTime(y.ApproveDate).Year == DateTime.Now.Year
// select new { x.ContractReviewId, z.ContractAmount }).Distinct();
this . divHTNum . InnerHtml = "0" ;
if ( ConstructionNum . HasValue )
{
this . divHTNum . InnerHtml = ConstructionNum . Value . ToString ( ) ;
}
decimal d = 0 ;
//foreach (var item in getC)
//{
// d += item.ContractAmount ?? 0;
//}
if ( ConstructionMoney . HasValue )
{
this . divHTAmount . InnerHtml = ConstructionMoney . Value . ToString ( "0.####" ) ;
}
else
{
this . divHTAmount . InnerHtml = Math . Round ( ( d / 100000000 ) , 4 ) . ToString ( ) ;
}
2022-03-15 17:36:38 +08:00
}
#endregion
#region 获 取 质 量 问 题
protected double CRectificationRate ;
protected double CQualifiedRate ;
/// <summary>
/// 获取质量问题
/// </summary>
private void getCQMSProblem ( )
{
2024-01-03 14:12:27 +08:00
DateTime time = DateTime . Parse ( DateTime . Now . ToString ( "yyyy-01-01" ) ) ;
2022-03-15 17:36:38 +08:00
///整改率
CRectificationRate = 0 ;
///合格率
CQualifiedRate = 0 ;
var getJointCheckDetail = from x in Funs . DB . Check_JointCheckDetail
2024-01-03 14:12:27 +08:00
where x . CreateDate > = time
2022-03-15 17:36:38 +08:00
select x ;
2024-01-03 14:12:27 +08:00
var getCheckControl = from x in Funs . DB . Check_CheckControl
2024-05-07 16:20:40 +08:00
where x . CheckDate > = time
2024-01-03 14:12:27 +08:00
select x ;
2022-03-15 17:36:38 +08:00
///问题总数
int AllCount = getJointCheckDetail . Count ( ) + getCheckControl . Count ( ) ;
this . divCQMSAllNum . InnerHtml = AllCount . ToString ( ) ;
2023-12-08 18:33:21 +08:00
2022-03-15 17:36:38 +08:00
if ( AllCount > 0 )
{
///问题完成数
var getJOk = getJointCheckDetail . Where ( x = > x . State = = "6" ) . Count ( ) ;
var getCOk = getCheckControl . Where ( x = > x . State = = "7" ) . Count ( ) ;
int CCount = getJOk + getCOk ;
if ( CCount > 0 )
{
CRectificationRate = Math . Round ( CCount * 1.0 / AllCount * 100 , 1 ) ;
}
}
2024-05-07 16:20:40 +08:00
var inspectionManagements = from x in Funs . DB . View_CQMS_InspectionManagementDetail where x . CheckDate > = time select x ;
2023-12-08 18:33:21 +08:00
if ( inspectionManagements . Count ( ) > 0 )
2022-03-15 17:36:38 +08:00
{
2023-12-08 18:33:21 +08:00
int okInspectionManagements = inspectionManagements . Where ( x = > x . IsOnceQualified = = true ) . Count ( ) ;
if ( okInspectionManagements > 0 )
2022-03-15 17:36:38 +08:00
{
2023-12-08 18:33:21 +08:00
CQualifiedRate = Math . Round ( okInspectionManagements * 1.0 / inspectionManagements . Count ( ) * 100 , 1 ) ;
2022-03-15 17:36:38 +08:00
}
}
2023-12-08 18:33:21 +08:00
//var getSpotCheckDetail = from x in Funs.DB.Check_SpotCheckDetail
// join y in Funs.DB.WBS_ControlItemAndCycle on x.ControlItemAndCycleId equals y.ControlItemAndCycleId
// where y.ControlPoint != "C" && y.ControlPoint != "CR" && x.IsOK != null
// select x;
//int AllSpotCount = getSpotCheckDetail.Count();
//if (AllSpotCount > 0)
//{
// int okSpotCount = getSpotCheckDetail.Where(x => x.IsOK == true).Count();
// if (okSpotCount > 0)
// {
// CQualifiedRate = Math.Round(okSpotCount * 1.0 / AllSpotCount * 100, 1);
// }
//}
2022-03-15 17:36:38 +08:00
}
#endregion
/// <summary>
/// 进度
/// </summary>
protected string projectJDHtml ;
/// <summary>
/// 月施工计划产值
/// </summary>
protected string MonthPlanOutPutValue ;
/// <summary>
/// 月施工实际产值
/// </summary>
protected string MonthActualOutPutValue ;
/// <summary>
/// 获取当年施工产值
/// </summary>
private void getOutputValue ( List < Model . Base_Project > getProjectLists )
{
MonthPlanOutPutValue = "[0,0,0,0,0,0,0,0,0,0,0,0]" ;
MonthActualOutPutValue = "[0,0,0,0,0,0,0,0,0,0,0,0]" ;
projectJDHtml = "" ;
DateTime date = DateTime . Now . AddYears ( - 1 ) ;
var getOutputValue = Funs . DB . Sys_OutputValueProject . Where ( x = > x . Year > date . Year | | ( x . Year = = date . Year & & x . Month > = date . Month ) ) ;
if ( getOutputValue . Count ( ) > 0 )
{
2024-05-07 16:20:40 +08:00
this . divYearPlanOutPutValue . InnerHtml = ( getOutputValue . Sum ( x = > x . PlanOutPutValue ? ? 0 ) ) . ToString ( ) ;
2022-03-15 17:36:38 +08:00
this . divYearActualOutPutValue . InnerHtml = ( getOutputValue . Sum ( x = > x . ActualOutPutValue ? ? 0 ) ) . ToString ( ) ;
}
decimal [ ] monthValues = new decimal [ 12 ] ;
decimal [ ] monthValues2 = new decimal [ 12 ] ;
2024-05-07 16:20:40 +08:00
// var getOutYearValues = Funs.DB.Sys_OutputValueProject.Where(x => x.Year == DateTime.Now.Year);
2022-03-15 17:36:38 +08:00
if ( getOutputValue . Count ( ) > 0 )
{
for ( int i = 0 ; i < 12 ; i + + )
{
monthValues [ i ] = 0 ;
monthValues2 [ i ] = 0 ;
var getOutMI = getOutputValue . Where ( x = > x . Month = = i ) ;
if ( getOutMI . Count ( ) > 0 )
{
monthValues [ i ] = getOutMI . Sum ( x = > x . PlanOutPutValue ? ? 0 ) ;
monthValues2 [ i ] = getOutMI . Sum ( x = > x . ActualOutPutValue ? ? 0 ) ;
}
}
MonthPlanOutPutValue = JsonConvert . SerializeObject ( monthValues ) ;
MonthActualOutPutValue = JsonConvert . SerializeObject ( monthValues2 ) ;
if ( getProjectLists . Count ( ) > 0 )
{
foreach ( var item in getProjectLists )
{
string shortName = item . ShortName ;
string jdRate = "0%" ;
var getOutProjectV = getOutputValue . Where ( x = > x . ProjectId = = item . ProjectId ) ;
if ( getOutProjectV . Count ( ) > 0 )
{
decimal sumPlan = getOutProjectV . Sum ( x = > x . PlanOutPutValue ? ? 0 ) ;
if ( sumPlan > 0 )
{
decimal sumActual = getOutProjectV . Sum ( x = > x . ActualOutPutValue ? ? 0 ) ;
jdRate = Math . Round ( sumActual * 100 / sumPlan , 1 ) . ToString ( ) + "%" ;
}
}
projectJDHtml + = @"<div class='sd-rate-item'><span class='sd-rate-status'>【在建】</span><span class='sd-rate-name'>" + shortName + "</span><span class='sd-rate-bar' style='cursor:pointer' title='" + jdRate + "'><span class='sd-rate-bar-value' style='width: " + jdRate + ";'></span></span></div>" ;
}
}
}
else
{
if ( getProjectLists . Count ( ) > 0 )
{
foreach ( var item in getProjectLists )
{
string shortName = item . ShortName ;
string jdRate = "0%" ;
projectJDHtml + = @"<div class='sd-rate-item'><span class='sd-rate-status'>【在建】</span><span class='sd-rate-name'>" + shortName + "</span><span class='sd-rate-bar' style='cursor:pointer' title='" + jdRate + "'><span class='sd-rate-bar-value' style='width: " + jdRate + ";'></span></span></div>" ;
}
}
}
}
2024-05-07 16:20:40 +08:00
private void getSolutionLargerHazard ( )
{
var num1 = Funs . DB . Solution_LargerHazard . Where ( x = > x . States = = "2" ) . Count ( ) ;
var num2 = Funs . DB . Solution_LargerHazard . Where ( x = > x . States = = "3" ) . Count ( ) ;
LargerHazard1 . InnerText = "" + ( num1 + num2 ) ;
LargerHazard2 . InnerText = "" + ( num1 ) ;
LargerHazard3 . InnerText = "" + ( num2 ) ;
}
2022-03-15 17:36:38 +08:00
}
}