2023-08-24 10:00:59 +08:00
using BLL ;
2025-03-14 18:25:51 +08:00
using FineUIPro.Web.DataShow ;
2025-03-13 15:41:27 +08:00
using Model ;
2023-08-24 10:00:59 +08:00
using Newtonsoft.Json ;
using System ;
2025-03-13 15:41:27 +08:00
using System.Collections ;
2023-08-24 10:00:59 +08:00
using System.Collections.Generic ;
using System.Linq ;
2025-03-17 15:53:00 +08:00
using System.Runtime.Caching ;
2025-03-14 18:25:51 +08:00
using System.Threading.Tasks ;
2023-08-24 10:00:59 +08:00
using System.Web ;
using System.Web.UI ;
using System.Web.UI.WebControls ;
2025-03-17 15:53:00 +08:00
using Org.BouncyCastle.Ocsp ;
2025-05-16 17:54:16 +08:00
using FineUIPro.Web.HJGL.FL ;
2025-09-20 18:15:28 +08:00
using System.Data ;
2023-08-24 10:00:59 +08:00
namespace FineUIPro.Web.common
{
public partial class main_new : PageBase
{
List < Model . Base_Project > allProjects ;
public static List < Model . Solution_LargerHazard > LargerHazard = new List < Model . Solution_LargerHazard > ( ) ;
2024-09-11 10:36:09 +08:00
2025-03-19 15:02:56 +08:00
public string [ ] pids { get ; set ; }
protected string On_time_rate = string . Empty ;
protected string main_new_qualityIssuesRectificationRate = string . Empty ;
protected string OnePassRate = string . Empty ;
protected string OnePassRateOfWelding = string . Empty ;
protected string total = string . Empty ;
protected string completed = string . Empty ;
2025-05-16 17:54:16 +08:00
protected string qualified = string . Empty ;
2025-03-19 15:02:56 +08:00
protected string mainI_progressStatistics = string . Empty ;
protected string Percentage_of_progress = string . Empty ;
2025-03-14 18:25:51 +08:00
protected async void Page_Load ( object sender , EventArgs e )
2023-08-24 10:00:59 +08:00
{
2025-03-13 15:41:27 +08:00
if ( ! IsPostBack )
{
InitializeProjectIds ( ) ; // 项目ID初始化封装
2024-04-18 15:04:08 +08:00
2025-03-14 18:25:51 +08:00
var projectTask = GetProjectAsync ( ) ;
var project2Task = GetProject2Async ( ) ;
var otherTasks = new List < Task >
{
BindSafetyStatisticsAsync ( ) , // 安全统计模块
BindQualityStatisticsAsync ( ) , // 质量统计模块
BindProjectStatisticsAsync ( ) , // 项目统计模块
GetZlwtAsync ( ) , // 质量问题
GetZlgjAsync ( ) , // 质量共检
GetHjAsync ( ) , // 焊接
GetGjsxAsync ( ) , // 关键事项
GetSitePersonAsync ( ) , // 人员信息
2025-03-18 11:56:52 +08:00
//GetProjectSitePersonAsync(), // 项目人员图表
2025-03-14 18:25:51 +08:00
GetJdAsync ( ) , // 进度
GetZgsjAsync ( ) , // 整改数据
2025-03-19 15:02:56 +08:00
GetCldhAsync ( ) , // 材料到货表格
getCNEN ( ) //中英文翻译
2025-03-14 18:25:51 +08:00
} ;
await Task . WhenAll ( otherTasks . Concat ( new [ ] { projectTask , project2Task } ) ) ;
// 设置项目信息
Project = await projectTask ;
Project2 = await project2Task ;
2023-08-24 10:00:59 +08:00
}
2025-03-13 15:41:27 +08:00
}
// 初始化项目ID集合
private void InitializeProjectIds ( )
{
var db = Funs . DB ;
pids = ! string . IsNullOrEmpty ( CurrUser . CompanyProjectId )
2025-03-18 11:56:52 +08:00
? CurrUser . CompanyProjectId . Split ( ',' )
: db . Base_Project
. Where ( x = > x . ProjectState = = "1" )
. Select ( x = > x . ProjectId )
2025-05-16 17:54:16 +08:00
. ToArray ( ) ;
2025-03-14 18:25:51 +08:00
//在建项目
if ( pids = = null )
2025-03-13 15:41:27 +08:00
{
2025-03-14 18:25:51 +08:00
allProjects = ProjectService . GetAllProjectDropDownList ( ) ;
2025-03-13 15:41:27 +08:00
}
else
{
2025-03-14 18:25:51 +08:00
allProjects = ProjectService . GetAllProjectDropDownList ( pids ) ;
2025-03-13 15:41:27 +08:00
}
2025-03-14 18:25:51 +08:00
}
// 安全统计模块封装
private async Task BindSafetyStatisticsAsync ( )
{
await Task . Run ( ( ) = >
2025-03-13 15:41:27 +08:00
{
2025-03-14 18:25:51 +08:00
var db = Funs . DB ;
// 未遂事故
divWS . InnerHtml = GetNearMissNum ( ) . ToString ( ) ;
// 安全人工时(合并重复逻辑)
var countAqrgsSum = pids ? . Any ( ) = = true
? CountAqrgs ( d1 : null , d2 : null , pids )
: CountAqrgs ( ) ;
if ( countAqrgsSum > 10000 )
{
countAqrgsSum = countAqrgsSum / Convert . ToDecimal ( 10000.00 ) ;
this . divSafeWorkTime . InnerHtml = Math . Round ( countAqrgsSum , 2 ) . ToString ( ) + "万" ;
}
else
{
this . divSafeWorkTime . InnerHtml = countAqrgsSum . ToString ( ) . Split ( '.' ) [ 0 ] ;
}
2025-03-13 15:41:27 +08:00
2025-03-14 18:25:51 +08:00
// 当月安全人工时
var countMonthAqrgs = pids ? . Any ( ) = = true
2025-05-16 17:54:16 +08:00
? CountAqrgs ( getLastMonthEndDay ( ) , getEndMonth ( ) , pids )
: CountAqrgs ( getLastMonthEndDay ( ) , getEndMonth ( ) ) ;
2025-03-13 15:41:27 +08:00
2025-03-14 18:25:51 +08:00
if ( countMonthAqrgs > 10000 )
{
countMonthAqrgs = countMonthAqrgs / Convert . ToDecimal ( 10000.00 ) ;
2025-03-13 15:41:27 +08:00
2025-03-14 18:25:51 +08:00
this . divSafeWorkTimeMonth . InnerHtml = Math . Round ( countMonthAqrgs , 2 ) . ToString ( ) + "万" ;
}
else
{
this . divSafeWorkTimeMonth . InnerHtml = countMonthAqrgs . ToString ( ) . Split ( '.' ) [ 0 ] ;
2025-03-18 11:56:52 +08:00
}
2025-05-24 14:48:16 +08:00
//// 安全培训人员(合并数据库查询)
//var trainingQuery = db.EduTrain_TrainRecord
// .Where(x => pids.Contains(x.ProjectId))
// .GroupBy(x => 1)
// .Select(g => new
// {
// TrainCount = g.Sum(x => x.TrainPersonNum) ?? 0,
// BoShengCount = db.Bo_Sheng_TrainPerson
// .Where(x => (x.DeleteTag == "False" || x.DeleteTag == null))
// .Where(x => pids.Contains(x.ProjectId))
// .Count()
// }).FirstOrDefault();
//divSafePersonNum.InnerHtml = trainingQuery != null
// ? (trainingQuery.TrainCount + trainingQuery.BoShengCount).ToString()
// : "0";
int getTrainRecord = 0 , boShengCount = 0 ;
if ( pids = = null )
{
getTrainRecord = db . View_EduTrain_TrainFind . Count ( ) ;
//修改:增加博晟教育中的人数
boShengCount = db . Bo_Sheng_TrainPerson . Count ( x = > x . DeleteTag = = "False" | | x . DeleteTag = = null ) ;
}
else
{
getTrainRecord = db . View_EduTrain_TrainFind . Where ( x = > pids . Contains ( x . ProjectId ) ) . Count ( ) ;
//修改:增加博晟教育中的人数
boShengCount = db . Bo_Sheng_TrainPerson . Count ( x = > pids . Contains ( x . ProjectId ) & & ( x . DeleteTag = = "False" | | x . DeleteTag = = null ) ) ;
}
this . divSafePersonNum . InnerHtml = ( getTrainRecord + boShengCount ) . ToString ( ) ;
2025-03-14 18:25:51 +08:00
// 安全管理人员(优化关联查询)
var safetyStaffCount = db . SitePerson_Person
2025-05-16 17:54:16 +08:00
. Where ( x = > x . IsUsed = = true & & x . InTime < DateTime . Now & & ( x . OutTime = = null | | x . OutTime > DateTime . Now ) )
2025-03-14 18:25:51 +08:00
. Where ( x = > pids . Contains ( x . ProjectId ) )
2025-05-16 17:54:16 +08:00
. Join ( db . Base_WorkPost . Where ( x = > x . IsHsse = = true ) ,
2025-03-18 11:56:52 +08:00
person = > person . WorkPostId ,
post = > post . WorkPostId ,
( person , post ) = > person )
2025-03-14 18:25:51 +08:00
. Count ( ) ;
divSafeManagePersonNum . InnerText = safetyStaffCount . ToString ( ) ;
2025-05-16 17:54:16 +08:00
} ) ;
2025-03-13 15:41:27 +08:00
}
// 质量统计模块封装
2025-03-14 18:25:51 +08:00
private async Task BindQualityStatisticsAsync ( )
2025-03-13 15:41:27 +08:00
{
2025-05-16 17:54:16 +08:00
await Task . Run ( ( ) = >
{
2025-03-17 15:53:00 +08:00
2025-05-16 17:54:16 +08:00
var db = Funs . DB ;
2025-03-18 11:56:52 +08:00
// 质量管理人员(合并公司+项目级查询)
var qualityQuery = db . Base_WorkPost
. Where ( x = > x . IsCQMS = = true )
2025-06-09 16:48:27 +08:00
. GroupJoin ( db . SitePerson_Person . Where ( x = > x . IsUsed = = true & & x . InTime < DateTime . Now & & ( x . OutTime = = null | | x . OutTime > DateTime . Now ) ) ,
2025-03-18 11:56:52 +08:00
post = > post . WorkPostId ,
person = > person . WorkPostId ,
( post , persons ) = > new { post , persons } )
. SelectMany ( x = > x . persons . DefaultIfEmpty ( ) ,
2025-03-13 15:41:27 +08:00
( x , person ) = > new { x . post , person } )
. Where ( x = > pids . Contains ( x . person . ProjectId ) ) ;
2025-05-16 17:54:16 +08:00
2025-03-26 18:41:39 +08:00
//企业总部人员和分支机构人员
var query = ( from person in db . Person_CompanyBranchPerson
2025-05-16 17:54:16 +08:00
join unit in db . Base_Unit on person . UnitId equals unit . UnitId into unitJoin
from unit in unitJoin . DefaultIfEmpty ( ) // 左连接
join workPost in db . Base_WorkPost on person . WorkPostId equals workPost . WorkPostId into workPostJoin
from workPost in workPostJoin . DefaultIfEmpty ( ) // 左连接
where person . IsOnJob = = true & & workPost . IsCQMS = = true
select new
{
ID = person . CompanyBranchPersonId ,
UnitName = unit . UnitName ,
PersonName = person . PersonName ,
SexStr = person . Sex = = "1" ? "男" : "女" ,
IdentityCard = person . IdentityCard ,
WorkPostName = workPost . WorkPostName ,
Telephone = person . Telephone ,
IsOnJob = person . IsOnJob ,
Remark = person . Remark ,
ProjectName = ""
} ) . ToList ( ) ;
2025-03-26 18:41:39 +08:00
divCqmsManageNum . InnerText = ( qualityQuery . Count ( ) + query . Count ( ) ) . ToString ( ) ;
2025-03-18 11:56:52 +08:00
// 质量培训人员
2025-05-16 17:54:16 +08:00
divCqmsPxNum . InnerText = db . Comprehensive_InspectionPerson
. Where ( x = > pids . Contains ( x . ProjectId ) )
. Count ( x = > x . IsTrain = = true ) . ToString ( ) ;
2025-03-17 15:53:00 +08:00
} ) ;
2025-03-13 15:41:27 +08:00
}
// 项目统计优化
2025-03-14 18:25:51 +08:00
private async Task BindProjectStatisticsAsync ( )
2025-03-13 15:41:27 +08:00
{
2025-05-16 17:54:16 +08:00
await Task . Run ( ( ) = >
2025-03-13 15:41:27 +08:00
{
2025-05-16 17:54:16 +08:00
var db = Funs . DB ;
int acount = allProjects . Count ( ) ;
int pcount1 = 0 ;
int pcount2 = 0 ;
int pcount3 = 0 ;
if ( acount > 0 )
2025-03-13 15:41:27 +08:00
{
2025-05-16 17:54:16 +08:00
pcount1 = allProjects . Where ( x = > x . ProjectState = = Const . ProjectState_1 | | x . ProjectState = = null ) . Select ( x = > x . ProjectId ) . Count ( ) ;
var pidzjsg = string . Join ( "," , allProjects . Where ( x = > x . ProjectState = = Const . ProjectState_1 | | x . ProjectState = = null ) . Select ( x = > x . ProjectId ) ) . Split ( ',' ) ;
if ( pids = = null )
{
pcount2 = ( from x in Funs . DB . SitePerson_Person where x . IsUsed = = true & & pidzjsg . Contains ( x . ProjectId ) select x . ProjectId ) . Count ( ) ;
}
else
{
pidzjsg = pids ;
pcount2 = ( from x in Funs . DB . SitePerson_Person where x . IsUsed = = true & & pids . Contains ( x . ProjectId ) select x . ProjectId ) . Count ( ) ;
}
pcount3 = Count3 ( pidzjsg ) ;
2025-03-13 15:41:27 +08:00
}
2025-05-16 17:54:16 +08:00
div_zjxmCount . InnerHtml = pcount1 . ToString ( ) + "<div class=\"th\">个</div>" ;
div_cjrsCount . InnerHtml = pcount2 . ToString ( ) + "<div class=\"th\">人</div>" ;
div_wdgcCount . InnerHtml = pcount3 . ToString ( ) + "<div class=\"th\">个</div>" ;
2025-03-17 15:53:00 +08:00
} ) ;
2023-08-24 10:00:59 +08:00
}
2025-03-13 15:41:27 +08:00
2023-08-28 18:26:38 +08:00
#region 当 月 人 工 时
2023-10-31 18:03:55 +08:00
2025-05-16 17:54:16 +08:00
/// <summary>
/// 获取上月的月末日期
/// </summary>
/// <returns></returns>
public static DateTime getLastMonthEndDay ( )
{
// 获取当前日期
DateTime currentDate = DateTime . Now . AddMonths ( - 1 ) ;
// 获取当前月的最后一天
DateTime lastDayOfMonth = new DateTime ( currentDate . Year , currentDate . Month , DateTime . DaysInMonth ( currentDate . Year , currentDate . Month ) ) ;
return lastDayOfMonth ;
}
2023-10-31 18:03:55 +08:00
/// <summary>
/// 获取当前月的月末日期
/// </summary>
/// <returns></returns>
public static DateTime getEndMonth ( )
{
2025-05-16 17:54:16 +08:00
// 获取当前日期
DateTime currentDate = DateTime . Now ;
// 获取当前月的最后一天
DateTime lastDayOfMonth = new DateTime ( currentDate . Year , currentDate . Month , DateTime . DaysInMonth ( currentDate . Year , currentDate . Month ) ) ;
2023-10-31 18:03:55 +08:00
2025-05-16 17:54:16 +08:00
return lastDayOfMonth ;
2023-10-31 18:03:55 +08:00
}
/// <summary>
/// 获取当前月初日期
/// </summary>
/// <returns></returns>
public static DateTime getStartMonth ( )
{
2025-05-16 17:54:16 +08:00
// 获取当前日期
DateTime currentDate = DateTime . Now ;
// 获取当前月的月初日期
DateTime firstDayOfMonth = new DateTime ( currentDate . Year , currentDate . Month , 1 ) ;
return firstDayOfMonth ;
2023-10-31 18:03:55 +08:00
}
//安全人工时(穿透)
/// <summary>
/// 安全工时数
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
2025-02-14 15:21:20 +08:00
protected decimal CountAqrgs ( DateTime ? d1 = null , DateTime ? d2 = null , string [ ] pids = null )
2023-10-31 18:03:55 +08:00
{
decimal cout1 = 0 ;
2024-04-10 15:43:48 +08:00
var datetime1 = d1 ;
var datetime2 = d2 ;
var getAllPersonInOutList = from x in Funs . DB . SitePerson_PersonInOutNumber
2025-05-16 17:54:16 +08:00
select new { x . ProjectId , x . InOutDate , x . WorkHours } ;
2025-02-14 15:21:20 +08:00
if ( pids ! = null )
{
2025-03-13 15:41:27 +08:00
getAllPersonInOutList = getAllPersonInOutList . Where ( x = > pids . Contains ( x . ProjectId ) ) ;
2024-09-11 10:36:09 +08:00
}
2025-03-13 15:41:27 +08:00
if ( datetime1 . HasValue )
2024-04-10 15:43:48 +08:00
{
2025-03-13 15:41:27 +08:00
getAllPersonInOutList = getAllPersonInOutList . Where ( x = > x . InOutDate > = datetime1 ) ;
}
if ( datetime2 . HasValue )
{
getAllPersonInOutList = getAllPersonInOutList . Where ( x = > x . InOutDate < = datetime2 ) ;
2024-04-10 15:43:48 +08:00
}
2025-05-16 17:54:16 +08:00
var projects = getAllPersonInOutList . GroupBy ( x = > x . ProjectId ) . Select ( g = > new
{
Project = g . Key ,
Items = g . OrderBy ( x = > x . InOutDate ) . ToList ( )
} ) . Where ( g = > g . Items . Any ( ) ) ;
2025-03-13 15:41:27 +08:00
2025-05-16 17:54:16 +08:00
if ( ! datetime1 . HasValue & & ! datetime2 . HasValue )
{ //查累计人工时
cout1 = projects . ToList ( ) . Sum ( g = > ( g . Items . Last ( ) . WorkHours ? ? 0 ) ) ;
}
else
{ //查当月人工时
cout1 = projects . ToList ( ) . Sum ( g = > ( g . Items . Last ( ) . WorkHours ? ? 0 ) - ( g . Items . First ( ) . WorkHours ? ? 0 ) ) ;
}
2024-04-10 15:43:48 +08:00
var getD1 = from x in Funs . DB . Accident_AccidentHandle
join y in Funs . DB . Base_Project on x . ProjectId equals y . ProjectId
where y . ProjectState = = Const . ProjectState_1
select x ;
var getD2 = from x in Funs . DB . Accident_AccidentReport
join y in Funs . DB . Base_Project on x . ProjectId equals y . ProjectId
where y . ProjectState = = Const . ProjectState_1
select x ;
2025-02-14 15:21:20 +08:00
if ( pids ! = null )
2024-09-11 10:36:09 +08:00
{
2025-03-13 15:41:27 +08:00
getD1 = getD1 . Where ( x = > pids . Contains ( x . ProjectId ) ) ;
getD2 = getD2 . Where ( x = > pids . Contains ( x . ProjectId ) ) ;
2024-09-11 10:36:09 +08:00
}
2024-04-10 15:43:48 +08:00
if ( datetime1 . HasValue )
{
getD1 = getD1 . Where ( x = > x . AccidentDate > = datetime1 ) ;
getD2 = getD2 . Where ( x = > x . CompileDate > = datetime1 ) ;
}
if ( datetime2 . HasValue )
{
getD1 = getD1 . Where ( x = > x . AccidentDate < = datetime2 ) ;
getD2 = getD2 . Where ( x = > x . CompileDate < = datetime2 ) ;
2025-05-16 17:54:16 +08:00
}
2025-03-13 15:41:27 +08:00
if ( getD1 . Any ( ) )
2024-04-10 15:43:48 +08:00
{
cout1 = cout1 - getD1 . Sum ( x = > x . WorkHoursLoss ? ? 0 ) ;
}
2025-03-13 15:41:27 +08:00
if ( getD2 . Any ( ) )
2024-04-10 15:43:48 +08:00
{
cout1 = cout1 - getD2 . Sum ( x = > x . WorkingHoursLoss ? ? 0 ) ;
}
2023-10-31 18:03:55 +08:00
return cout1 ;
}
2023-08-28 18:26:38 +08:00
/// <summary>
/// 获取出入记录人工时-月报(项目级别)
/// </summary>
/// <returns></returns>
public static List < Model . SitePerson_MonthReport > getMonthReportsByCompany ( DateTime ? sDate )
{
Model . SGGLDB db = Funs . DB ;
List < Model . SitePerson_MonthReport > reports = new List < Model . SitePerson_MonthReport > ( ) ;
var getAllPersonInOutList = from x in db . SitePerson_PersonInOutNumber
2024-04-10 15:43:48 +08:00
2023-08-28 18:26:38 +08:00
select x ;
2025-03-17 15:53:00 +08:00
if ( getAllPersonInOutList . Any ( ) )
2023-08-28 18:26:38 +08:00
{
var getInMonths = ( from x in getAllPersonInOutList select new { x . InOutDate . Year , x . InOutDate . Month } ) . Distinct ( ) ;
if ( sDate . HasValue )
{
getInMonths = getInMonths . Where ( x = > x . Year = = sDate . Value . Year & & x . Month = = sDate . Value . Month ) ;
}
foreach ( var item in getInMonths )
{
DateTime compileDate = Funs . GetNewDateTimeOrNow ( item . Year . ToString ( ) + "-" + item . Month . ToString ( ) ) ;
var getNow = getAllPersonInOutList . Where ( x = > x . InOutDate . Year = = compileDate . Year & & x . InOutDate . Month = = compileDate . Month ) . Max ( x = > x . WorkHours ) ;
if ( getNow . HasValue )
{
Model . SitePerson_MonthReport reportItem = new Model . SitePerson_MonthReport
{
MonthReportId = SQLHelper . GetNewID ( ) ,
2024-04-10 15:43:48 +08:00
2023-08-28 18:26:38 +08:00
CompileDate = Funs . GetNewDateTime ( item . Year . ToString ( ) + "-" + item . Month . ToString ( ) ) ,
TotalPersonWorkTime = getNow ,
} ;
DateTime upDate = compileDate . AddMonths ( - 1 ) ;
var getMax = getAllPersonInOutList . Where ( x = > x . InOutDate . Year = = upDate . Year & & x . InOutDate . Month = = upDate . Month ) . Max ( x = > x . WorkHours ) ? ? 0 ;
reportItem . DayWorkTime = ( getNow ? ? 0 ) - getMax ;
reports . Add ( reportItem ) ;
}
}
}
return reports ;
}
#endregion
2023-08-24 10:00:59 +08:00
#region 项 目 信 息
protected string Project
{
2025-03-14 18:25:51 +08:00
get ;
set ;
}
protected async Task < string > GetProjectAsync ( )
{
return await Task . Run ( ( ) = >
2023-08-24 10:00:59 +08:00
{
Model . SingleSerie series = new Model . SingleSerie ( ) ;
2025-05-16 17:54:16 +08:00
var project1s = allProjects . Where ( x = > x . ProjectState = = Const . ProjectState_1 | | x . ProjectState = = null ) . Select ( x = > new { x . ProjectId , x . ProjectName , x . ProjectState2 , x . Province , x . ShortName } ) . ToList ( ) ;
2025-03-17 15:53:00 +08:00
var consts = Funs . DB . Sys_Const . Where ( x = > x . GroupId = = ConstValue . GroupId_ProjectState ) . ToList ( ) ;
2023-08-24 10:00:59 +08:00
string name = string . Empty ;
2025-03-17 15:53:00 +08:00
if ( project1s . Any ( ) )
2023-08-24 10:00:59 +08:00
{
foreach ( var project1 in project1s )
{
string state = string . Empty ;
var c = consts . FirstOrDefault ( x = > x . ConstValue = = project1 . ProjectState2 ) ;
if ( c ! = null )
{
state = c . ConstText ;
}
name + = "<li style=\"border:1px solid white; padding:3px;\" class=\"c-item disabled swiper-slide\"><div class=\"tit tit-read\"><div class=\"flex\" ><div class=\"tit-t flex1\">" + project1 . ProjectName + "</div><div class=\"tit-v\">" + state + "</div></div></div></li>" ;
}
}
var provinceDic = from x in Funs . DB . RealName_City select x ;
List < double > listdata = new List < double > ( ) ;
List < string > jd = new List < string > ( ) ;
List < string > sg = new List < string > ( ) ;
List < string > time = new List < string > ( ) ;
List < string > ht = new List < string > ( ) ;
List < string > convert = new List < string > ( ) ;
List < string > loc = new List < string > ( ) ;
listdata . Add ( allProjects . Count ( ) ) ;
jd . Add ( "" ) ;
sg . Add ( "" ) ;
time . Add ( "" ) ;
ht . Add ( "" ) ;
List < string > provinces = new List < string > ( ) ;
provinces . Add ( "上海" ) ;
provinces . Add ( "河北" ) ;
provinces . Add ( "山西" ) ;
provinces . Add ( "内蒙古" ) ;
provinces . Add ( "辽宁" ) ;
provinces . Add ( "吉林" ) ;
provinces . Add ( "黑龙江" ) ;
provinces . Add ( "江苏" ) ;
provinces . Add ( "浙江" ) ;
provinces . Add ( "安徽" ) ;
provinces . Add ( "福建" ) ;
provinces . Add ( "江西" ) ;
provinces . Add ( "山东" ) ;
provinces . Add ( "河南" ) ;
provinces . Add ( "湖北" ) ;
provinces . Add ( "湖南" ) ;
provinces . Add ( "广东" ) ;
provinces . Add ( "广西" ) ;
provinces . Add ( "海南" ) ;
provinces . Add ( "四川" ) ;
provinces . Add ( "贵州" ) ;
provinces . Add ( "云南" ) ;
provinces . Add ( "西藏" ) ;
provinces . Add ( "陕西" ) ;
provinces . Add ( "甘肃" ) ;
provinces . Add ( "青海" ) ;
provinces . Add ( "宁夏" ) ;
provinces . Add ( "新疆" ) ;
provinces . Add ( "北京" ) ;
provinces . Add ( "天津" ) ;
provinces . Add ( "重庆" ) ;
provinces . Add ( "香港" ) ;
provinces . Add ( "澳门" ) ;
provinces . Add ( "台湾" ) ;
Model . SGGLDB db = Funs . DB ;
var accidentList1 = from x in db . Accident_AccidentPersonRecord
join y in db . Base_AccidentType on x . AccidentTypeId equals y . AccidentTypeId
where y . AccidentTypeName . Contains ( "未遂" )
2025-05-16 17:54:16 +08:00
select new { x . ProjectId , x . AccidentDate } ;
2023-08-24 10:00:59 +08:00
var accidentList2 = from x in db . Accident_AccidentReportOther
join y in db . Sys_Const on x . AccidentTypeId equals y . ConstValue
where y . ConstText . Contains ( "未遂" )
2025-03-18 11:56:52 +08:00
select new { x . ProjectId , x . AccidentDate } ;
2025-03-17 18:46:22 +08:00
var allProvinceProjectList = ( from x in allProjects
2025-05-16 17:54:16 +08:00
join y in provinceDic on x . Province equals y . ProvinceCode
where provinces . Contains ( y . CnShortName )
select new { x , y . CnShortName } ) . ToList ( ) ;
var allProvinces = allProvinceProjectList . Select ( x = > x . CnShortName ) . Distinct ( ) . ToList ( ) ;
2025-03-17 18:46:22 +08:00
foreach ( var province in allProvinces )
2023-08-24 10:00:59 +08:00
{
int accidentNum = 0 ;
DateTime date = DateTime . Now ;
decimal money1 = 0 , money2 = 0 ;
2025-05-16 17:54:16 +08:00
/* var projects = from x in allProjects
join y in provinceDic on x.Province equals y.ProvinceCode
where y.CnShortName == province
select x;*/
2025-03-17 18:46:22 +08:00
var projects = allProvinceProjectList . Where ( x = > x . CnShortName = = province ) ;
2023-08-24 10:00:59 +08:00
listdata . Add ( projects . Count ( ) ) ;
decimal progress = 0 ;
2025-03-17 15:53:00 +08:00
if ( projects . Any ( ) )
2023-08-24 10:00:59 +08:00
{
convert . Add ( province ) ;
foreach ( var item in projects )
{
//未遂事故
2025-03-17 18:46:22 +08:00
var accidentListProject1 = accidentList1 . Where ( x = > x . ProjectId = = item . x . ProjectId ) ;
var accidentListProject2 = accidentList2 . Where ( x = > x . ProjectId = = item . x . ProjectId ) ;
2023-08-24 10:00:59 +08:00
accidentNum = accidentListProject1 . Count ( ) + accidentListProject2 . Count ( ) ;
//时间
2025-03-17 18:46:22 +08:00
if ( item . x . StartDate ! = null & & item . x . StartDate < date )
2023-08-24 10:00:59 +08:00
{
2025-03-17 18:46:22 +08:00
date = Convert . ToDateTime ( item . x . StartDate ) ;
2023-08-24 10:00:59 +08:00
}
//合同额
2025-03-17 18:46:22 +08:00
if ( item . x . ConstructionMoney ! = null )
2023-08-24 10:00:59 +08:00
{
2025-03-17 18:46:22 +08:00
money1 + = item . x . ConstructionMoney . Value ;
2023-08-24 10:00:59 +08:00
}
2025-03-17 18:46:22 +08:00
if ( item . x . Progress ! = null )
2023-08-24 10:00:59 +08:00
{
2025-03-17 18:46:22 +08:00
progress = item . x . Progress . Value ;
2023-08-24 10:00:59 +08:00
}
}
jd . Add ( "进度:" + progress . ToString ( "0.##" ) + "%" ) ;
sg . Add ( "未遂事故:" + accidentNum . ToString ( ) ) ;
time . Add ( "时间:" + string . Format ( "{0:yyyy-MM-dd}" , date ) ) ;
ht . Add ( "合同额(" + money1 . ToString ( "0.##" ) + "W);收款额(" + money2 + "W) " ) ;
}
else
{
jd . Add ( "" ) ;
sg . Add ( "" ) ;
time . Add ( "" ) ;
ht . Add ( "" ) ;
}
}
foreach ( var item in allProjects )
{
decimal jdNum = 0 ;
string mapStr = "" ;
int accidentNum = 0 ;
DateTime date = DateTime . Now ;
decimal money1 = 0 , money2 = 0 ;
string endDate = string . Empty ;
int timeSpan = 0 ;
if ( ! string . IsNullOrEmpty ( item . MapCoordinates ) )
{
mapStr = item . MapCoordinates + "," ;
//未遂事故
var accidentListProject1 = accidentList1 . Where ( x = > x . ProjectId = = item . ProjectId ) ;
var accidentListProject2 = accidentList2 . Where ( x = > x . ProjectId = = item . ProjectId ) ;
accidentNum = accidentListProject1 . Count ( ) + accidentListProject2 . Count ( ) ;
//时间
if ( item . StartDate ! = null & & item . StartDate < date )
{
date = Convert . ToDateTime ( item . StartDate ) ;
}
if ( item . EndDate ! = null )
{
endDate = string . Format ( "{0:yyyy-MM-dd}" , item . EndDate ) ;
}
if ( item . StartDate ! = null & & item . EndDate ! = null )
{
TimeSpan t = ( TimeSpan ) ( item . EndDate - item . StartDate ) ;
timeSpan = t . Days / 30 ;
}
//合同额
if ( item . ConstructionMoney ! = null )
{
money1 + = item . ConstructionMoney . Value ;
}
if ( item . Progress ! = null )
{
jdNum = item . Progress . Value ;
}
mapStr + = string . Format ( "{0:yyyy-MM-dd}" , date ) + "~" + endDate + "," ;
if ( timeSpan > 0 )
{
mapStr + = timeSpan . ToString ( ) + "个月," ;
}
else
{
mapStr + = timeSpan . ToString ( ) + "," ;
}
//mapStr += accidentNum.ToString() + ",";
mapStr + = jdNum . ToString ( "0.##" ) + "%," ;
mapStr + = money1 . ToString ( "0.##" ) + "," ;
mapStr + = money2 + "," ;
mapStr + = item . ShortName + "," ;
2023-10-31 18:03:55 +08:00
//修改日期 2023-10-30 10:43:57
//内容:项目名称、开工日期、完工日期、剩余天数、进度
2024-04-10 15:43:48 +08:00
mapStr + = item . ProjectId + "," ;
2023-10-31 18:03:55 +08:00
mapStr + = string . Format ( "{0:yyyy-MM-dd}" , item . StartDate ) + "," ;
if ( string . IsNullOrEmpty ( item . EndDate . ToString ( ) ) )
{
mapStr + = "," ;
}
2024-04-10 15:43:48 +08:00
else
{
2023-10-31 18:03:55 +08:00
//获取剩余天数
var residueDay = DateDiff ( DateTime . Now , Convert . ToDateTime ( item . EndDate ) ) . ToString ( ) ;
2024-04-10 15:43:48 +08:00
mapStr + = string . Format ( "{0:yyyy-MM-dd}" , item . EndDate ) + "," + residueDay ;
2023-10-31 18:03:55 +08:00
}
2024-04-10 15:43:48 +08:00
2023-10-31 18:03:55 +08:00
2023-08-24 10:00:59 +08:00
loc . Add ( mapStr ) ;
}
}
series . name = name ;
series . data = listdata ;
series . jd = jd ;
series . sg = sg ;
series . time = time ;
series . ht = ht ;
series . convert = convert ;
series . loc = loc ;
return JsonConvert . SerializeObject ( series ) ;
2025-03-14 18:25:51 +08:00
} ) ;
2023-08-24 10:00:59 +08:00
}
2024-06-14 16:52:37 +08:00
#endregion
#region 项 目 信 息
protected string Project2
{
2025-03-14 18:25:51 +08:00
get ;
set ;
}
protected async Task < string > GetProject2Async ( )
{
return await Task . Run ( ( ) = >
2024-06-14 16:52:37 +08:00
{
Model . SingleSerie series = new Model . SingleSerie ( ) ;
Model . SGGLDB db = Funs . DB ;
string str = string . Empty ;
foreach ( var item in allProjects )
{
if ( ! string . IsNullOrEmpty ( item . MapCoordinates ) )
{
string startDate = string . Empty ;
string endDate = string . Empty ;
string residueDay = string . Empty ;
if ( item . StartDate ! = null )
{
startDate = string . Format ( "{0:yyyy-MM-dd}" , item . StartDate ) ;
}
if ( item . EndDate ! = null )
{
endDate = string . Format ( "{0:yyyy-MM-dd}" , item . EndDate ) ;
residueDay = DateDiff ( DateTime . Now , Convert . ToDateTime ( item . EndDate ) ) . ToString ( ) ;
}
decimal jdNum = 0 ;
if ( item . Progress ! = null )
{
jdNum = item . Progress . Value ;
}
str + = "{name: '" + item . ShortName + "', value: [" + item . MapCoordinates + ", { value:'" + item . ShortName + "',value2:'" + startDate + "',value3:'" + endDate + "',value4:'" + residueDay + "',value5:'" + jdNum . ToString ( "0.##" ) + "%'}]}," ;
}
}
if ( ! string . IsNullOrEmpty ( str ) )
{
str = str . Substring ( 0 , str . Length - 1 ) ;
}
return str ;
2025-03-14 18:25:51 +08:00
} ) ;
2024-06-14 16:52:37 +08:00
}
2023-10-31 18:03:55 +08:00
/// <summary>
/// 计算时间的相差天数
/// </summary>
/// <param name="dateStart"></param>
/// <param name="dateEnd"></param>
/// <returns></returns>
private int DateDiff ( DateTime dateStart , DateTime dateEnd )
{
DateTime start = Convert . ToDateTime ( dateStart . ToShortDateString ( ) ) ;
DateTime end = Convert . ToDateTime ( dateEnd . ToShortDateString ( ) ) ;
TimeSpan sp = end . Subtract ( start ) ;
return sp . Days ;
}
2023-08-24 10:00:59 +08:00
#endregion
#region 在 施 危 大 工 程 数 量
/// <summary>
/// 在施危大工程数量
/// </summary>
/// <param name="state"></param>
/// <returns></returns>
2024-09-11 10:36:09 +08:00
protected int Count3 ( string [ ] pids )
2023-08-24 10:00:59 +08:00
{
int cout1 = 0 ;
2025-03-18 11:56:52 +08:00
cout1 = Funs . DB . Solution_LargerHazard . Count ( x = > x . States = = Const . State_2 & & pids . Contains ( x . ProjectId ) ) ;
2023-08-24 10:00:59 +08:00
return cout1 ;
}
#endregion
#region 质 量 问 题
//质量问题总计
protected string zlallNumber ;
//质量问题合格数量
protected string zlfinishNumber ;
//质量问题整改率
protected string zlzgl ;
protected string zgzglDataValue ;
2025-03-14 18:25:51 +08:00
private async Task GetZlwtAsync ( )
2024-04-10 15:43:48 +08:00
{
2025-03-14 18:25:51 +08:00
await Task . Run ( ( ) = >
2024-09-11 10:36:09 +08:00
{
2025-03-14 18:25:51 +08:00
if ( pids = = null )
{
zlallNumber = ( from x in Funs . DB . Check_CheckControl
select x ) . Count ( ) . ToString ( ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
var num2 = ( from x in Funs . DB . Check_CheckControl
2025-05-16 17:54:16 +08:00
where x . State = = "7"
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
zlfinishNumber = num2 . ToString ( ) ;
var num3 = ( from x in Funs . DB . Check_CheckControl
2025-03-26 18:41:39 +08:00
where x . State ! = "7"
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
var zgl = String . Format ( "{0:N2}" , 100.0 * num2 / ( num2 + num3 ) ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
zlzgl = zgl . ToString ( ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
zgzglDataValue = ( 100 - ( 100.0 * num2 / ( num2 + num3 ) ) ) . ToString ( ) ;
}
else
{
zlallNumber = ( from x in Funs . DB . Check_CheckControl
2025-05-16 17:54:16 +08:00
where pids . Contains ( x . ProjectId )
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) . ToString ( ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
var num2 = ( from x in Funs . DB . Check_CheckControl
2025-05-16 17:54:16 +08:00
where x . State = = "7" & & pids . Contains ( x . ProjectId )
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
zlfinishNumber = num2 . ToString ( ) ;
var num3 = ( from x in Funs . DB . Check_CheckControl
2025-03-26 18:41:39 +08:00
where x . State ! = "7" & & pids . Contains ( x . ProjectId )
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
var zgl = String . Format ( "{0:N2}" , 100.0 * num2 / ( num2 + num3 ) ) ;
2024-09-11 10:36:09 +08:00
2025-03-14 18:25:51 +08:00
zlzgl = zgl . ToString ( ) ;
2025-02-14 15:21:20 +08:00
2025-03-14 18:25:51 +08:00
zgzglDataValue = ( 100 - ( 100.0 * num2 / ( num2 + num3 ) ) ) . ToString ( ) ;
}
} ) ;
2023-08-24 10:00:59 +08:00
}
#endregion
#region 质 量 共 检
protected string zlgjallNumber ;
protected string zlgjfinishNumber ;
protected string zlgjzgl ;
protected string zggjzglDataValue ;
2025-03-14 18:25:51 +08:00
private async Task GetZlgjAsync ( )
2024-04-10 15:43:48 +08:00
{
2025-03-14 18:25:51 +08:00
await Task . Run ( ( ) = >
2025-02-14 15:21:20 +08:00
{
2025-03-14 18:25:51 +08:00
if ( pids = = null )
{
var num1 = ( from x in Funs . DB . ProcessControl_InspectionManagement
select x ) . Count ( ) ;
zlgjallNumber = num1 . ToString ( ) ;
var num2 = ( from x in Funs . DB . ProcessControl_InspectionManagement
2025-10-24 18:27:46 +08:00
where x . IsOnceQualified = = true
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) ;
zlgjfinishNumber = num2 . ToString ( ) ;
var zgl = String . Format ( "{0:N2}" , 100.0 * num2 / num1 ) ;
zlgjzgl = zgl . ToString ( ) ;
zggjzglDataValue = ( 100 - ( 100.0 * num2 / num1 ) ) . ToString ( ) ;
}
else
{
var num1 = ( from x in Funs . DB . ProcessControl_InspectionManagement
where pids . Contains ( x . ProjectId )
select x ) . Count ( ) ;
zlgjallNumber = num1 . ToString ( ) ;
var num2 = ( from x in Funs . DB . ProcessControl_InspectionManagement
2025-10-24 18:27:46 +08:00
where x . IsOnceQualified = = true & & pids . Contains ( x . ProjectId )
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) ;
zlgjfinishNumber = num2 . ToString ( ) ;
var zgl = String . Format ( "{0:N2}" , 100.0 * num2 / num1 ) ;
zlgjzgl = zgl . ToString ( ) ;
zggjzglDataValue = ( 100 - ( 100.0 * num2 / num1 ) ) . ToString ( ) ;
}
} ) ;
2023-08-24 10:00:59 +08:00
}
#endregion
#region 焊 接
2024-04-10 15:43:48 +08:00
protected string hjallNumber = "0" ;
protected string hjfinishNumber = "0" ;
protected string hjzgl = "0" ;
2023-08-24 10:00:59 +08:00
2024-04-10 15:43:48 +08:00
protected string hjDataValue = "0" ;
2025-03-14 18:25:51 +08:00
private async Task GetHjAsync ( )
2023-08-24 10:00:59 +08:00
{
2025-03-14 18:25:51 +08:00
await Task . Run ( ( ) = >
2024-09-11 10:36:09 +08:00
{
2025-03-14 18:25:51 +08:00
Model . SingleSerie series = new Model . SingleSerie ( ) ;
Model . BusinessColumn businessColumn = new Model . BusinessColumn ( ) ;
List < double > listdata = new List < double > ( ) ;
double result = 0 ;
Model . SGGLDB db = Funs . DB ;
2025-05-16 17:54:16 +08:00
var ndtLists = ( from x in db . ProcessControl_NondestructiveTest_New select x ) . ToList ( ) ;
2025-03-14 18:25:51 +08:00
if ( pids ! = null )
{
2025-05-16 17:54:16 +08:00
ndtLists = ndtLists . Where ( x = > pids . Contains ( x . ProjectId ) ) . ToList ( ) ;
2025-03-14 18:25:51 +08:00
}
decimal a = 0 , b = 0 ;
2025-05-16 17:54:16 +08:00
if ( ndtLists . Count > 0 )
{
2025-07-01 17:13:29 +08:00
//取每个项目、单位、专业最新的一条数据
var datalist = ndtLists . GroupBy ( r = > new { r . ProjectId , r . UnitId , r . ProfessionalName } ) . Select ( g = > g . OrderByDescending ( r = > r . CreateDate ) . First ( ) ) . ToList ( ) ;
2025-05-16 17:54:16 +08:00
foreach ( var item in datalist )
{
if ( item . TotalQuantity . HasValue )
{
a + = Math . Floor ( item . TotalQuantity . Value * Funs . GetNewDecimalOrZero ( item . TotalRate ) / 100 ) ;
b + = item . TotalQuantity . Value ;
}
}
2025-07-01 17:13:29 +08:00
//result = Convert.ToDouble(Convert.ToDecimal(100.0) * b / a);
result = Convert . ToDouble ( decimal . Round ( decimal . Parse ( ( a / b * 100 ) . ToString ( ) ) , 2 ) ) ;
2025-05-16 17:54:16 +08:00
}
//else
//{
// var hjglData =
// (from x in db.HJGL_FL_Data
// where x.ProjectId == ProjectId
// orderby x.CompileDate descending
// select x).FirstOrDefault();
// if (hjglData != null)
// {
// a = Funs.GetNewDecimalOrZero(hjglData.OneTimeFilmQualifiedAmount);
// b = Funs.GetNewDecimalOrZero(hjglData.OneTimeFilmAmount);
// if (a > 0 && b > 0)
// {
// result = Convert.ToDouble(Convert.ToDecimal(100.0) * b / a);
// }
// }
//}
2025-03-14 18:25:51 +08:00
if ( b > 0 )
{
hjallNumber = b . ToString ( ) ;
hjfinishNumber = a . ToString ( ) ;
hjzgl = result . ToString ( ) ;
hjDataValue = ( 100 - result ) . ToString ( ) ;
}
2025-05-16 17:54:16 +08:00
//var sumResult = ndtLists
// .GroupBy(x => x.ProjectId)
// .Select(g => new
// {
// TotalQ = g.OrderByDescending(x => x.CreateDate)
// .Select(x => x.TotalQuantity)
// .FirstOrDefault(),
// Rate = g.OrderByDescending(x => x.CreateDate)
// .Select(x => x.TotalRate)
// .FirstOrDefault()
// })
// .Where(x => x.TotalQ.HasValue).ToList()
// .Select(x => new
// {
// A = Math.Floor(x.TotalQ.Value * (decimal.Parse(x.Rate)) / 100),
// B = x.TotalQ.Value
// });
//a = sumResult.Sum(x => x.A);
//b = sumResult.Sum(x => x.B);
//if (b > 0)
//{
// result = Convert.ToDouble(decimal.Round(decimal.Parse((a / b * 100).ToString()), 2));
// hjallNumber = b.ToString();
// hjfinishNumber = a.ToString();
// hjzgl = result.ToString();
// hjDataValue = (100 - result).ToString();
//}
2025-03-14 18:25:51 +08:00
} ) ;
2023-08-24 10:00:59 +08:00
}
#endregion
#region 关 键 事 项
//准点率
protected string gjsxZdl = "0" ;
2025-03-14 18:25:51 +08:00
private async Task GetGjsxAsync ( )
2023-08-24 10:00:59 +08:00
{
2025-03-14 18:25:51 +08:00
await Task . Run ( ( ) = >
2024-09-11 10:36:09 +08:00
{
2025-03-14 18:25:51 +08:00
if ( pids = = null )
{
2025-03-27 18:14:38 +08:00
var znum = ( from x in Funs . DB . GJSX where x . State ! = "1" select x ) . Count ( ) ;
2025-03-14 18:25:51 +08:00
divGjsxzj . InnerHtml = znum . ToString ( ) ;
var dqnum = ( from x in Funs . DB . GJSX
2025-03-27 18:14:38 +08:00
where x . CompleteDate < = DateTime . Now & & x . State ! = "1"
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) . ToString ( ) ;
divGjsxdq . InnerHtml = dqnum ;
var wzdnum = ( from x in Funs . DB . GJSX
where x . CompleteDate < = DateTime . Now
2025-03-27 18:14:38 +08:00
& & x . State ! = "0" & & x . State ! = "1"
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) . ToString ( ) ;
divGjsxwzd . InnerHtml = wzdnum ;
var ywcnum = ( from x in Funs . DB . GJSX
where x . CompleteDate < = DateTime . Now
& & x . State = = "0"
select x ) . Count ( ) ;
gjsxZdl = Math . Round ( ( 100.0 * ywcnum / znum ) , 2 ) . ToString ( ) ;
}
else
{
var znum = ( from x in Funs . DB . GJSX
2025-03-27 18:14:38 +08:00
where pids . Contains ( x . ProjectId ) & & x . State ! = "1"
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) ;
divGjsxzj . InnerHtml = znum . ToString ( ) ;
var dqnum = ( from x in Funs . DB . GJSX
2025-03-27 18:14:38 +08:00
where x . CompleteDate < = DateTime . Now & & pids . Contains ( x . ProjectId ) & & x . State ! = "1"
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) . ToString ( ) ;
divGjsxdq . InnerHtml = dqnum ;
var wzdnum = ( from x in Funs . DB . GJSX
where x . CompleteDate < = DateTime . Now
2025-03-27 18:14:38 +08:00
& & x . State ! = "0" & & pids . Contains ( x . ProjectId ) & & x . State ! = "1"
2025-03-14 18:25:51 +08:00
select x ) . Count ( ) . ToString ( ) ;
divGjsxwzd . InnerHtml = wzdnum ;
var ywcnum = ( from x in Funs . DB . GJSX
where x . CompleteDate < = DateTime . Now
& & x . State = = "0" & & pids . Contains ( x . ProjectId )
select x ) . Count ( ) ;
gjsxZdl = Math . Round ( ( 100.0 * ywcnum / znum ) , 2 ) . ToString ( ) ;
}
} ) ;
2023-08-24 10:00:59 +08:00
}
#endregion
#region 人 员 信 息
2025-03-14 18:25:51 +08:00
private async Task GetSitePersonAsync ( )
2023-08-24 10:00:59 +08:00
{
2025-03-14 18:25:51 +08:00
await Task . Run ( ( ) = >
2023-08-24 10:00:59 +08:00
{
2025-09-20 18:15:28 +08:00
int AllCount = 0 ;
int MCount = 0 ;
//var getallin = new List<Model.PageDataPersonInOutItem>();
//if (pids == null)
//{
// getallin = APIPageDataService.getPersonNum(new List<string>(), DateTime.Now);
//}
//else
//{
// getallin = APIPageDataService.getPersonNum(pids.ToList(), DateTime.Now);
//}
var startDate = DateTime . Now . Date ;
var endDate = startDate . AddDays ( 1 ) ;
string strSql = @"select ProjectId,PostType,COUNT(distinct PersonId)PersonNum from SitePerson_PersonInOutNow
where ChangeTime >= '" + startDate . ToString ( "yyyy-MM-dd" ) + "' and ChangeTime <='" + endDate . ToString ( "yyyy-MM-dd" ) + "' and ProjectId in ('" + string . Join ( "','" , allProjects . Select ( x = > x . ProjectId ) ) + @"')
group by ProjectId,PostType" ;
DataTable dt = SQLHelper . GetDataTableRunText ( strSql , null ) ;
Dictionary < string , int > dic = new Dictionary < string , int > ( ) ;
foreach ( DataRow row in dt . Rows )
2025-03-14 18:25:51 +08:00
{
2025-09-20 18:15:28 +08:00
string projectid = row [ "ProjectId" ] . ToString ( ) ;
string postType = row [ "PostType" ] . ToString ( ) ;
int PersonNum = int . Parse ( row [ "PersonNum" ] . ToString ( ) ) ;
if ( ! dic . ContainsKey ( projectid ) )
{
dic . Add ( projectid , PersonNum ) ;
}
else
{
dic [ projectid ] = dic [ projectid ] + PersonNum ;
}
AllCount + = PersonNum ;
if ( postType = = Const . PostType_1 )
{
MCount + = PersonNum ;
}
2025-03-14 18:25:51 +08:00
}
2023-08-24 10:00:59 +08:00
2025-09-20 18:15:28 +08:00
2025-03-14 18:25:51 +08:00
div_xcrs . InnerHtml = AllCount . ToString ( ) ;
div_zyxcrs . InnerHtml = ( AllCount - MCount ) . ToString ( ) ;
div_glxcrs . InnerHtml = MCount . ToString ( ) ;
2025-03-18 11:56:52 +08:00
//项目现场人员统计
foreach ( var item in allProjects )
{
ProjectPersonMc + = "'" + item . ShortName + "'," ;
2025-09-20 18:15:28 +08:00
if ( dic . ContainsKey ( item . ProjectId ) )
{
ProjectPersonCount + = "'" + dic [ item . ProjectId ] + "'," ;
}
else
{
ProjectPersonCount + = "'0'," ;
}
2025-03-18 11:56:52 +08:00
}
2025-05-16 17:54:16 +08:00
ProjectPersonMc = ! string . IsNullOrWhiteSpace ( ProjectPersonMc ) ? ProjectPersonMc . TrimEnd ( ',' ) : string . Empty ;
ProjectPersonCount = ! string . IsNullOrWhiteSpace ( ProjectPersonCount ) ? ProjectPersonCount . TrimEnd ( ',' ) : string . Empty ;
2025-03-14 18:25:51 +08:00
} ) ;
2023-08-24 10:00:59 +08:00
}
#endregion
#region 项 目 人 员 图 表
protected string ProjectPersonCount ;
protected string ProjectPersonMc ;
2025-03-14 18:25:51 +08:00
private async Task GetProjectSitePersonAsync ( )
2023-08-24 10:00:59 +08:00
{
2025-03-14 18:25:51 +08:00
await Task . Run ( ( ) = >
2024-09-11 10:36:09 +08:00
{
2025-03-17 15:53:00 +08:00
var allperson =
APIPageDataService . getPersonNum ( allProjects . Select ( x = > x . ProjectId ) . ToList ( ) , DateTime . Now ) ;
2025-02-14 15:21:20 +08:00
2025-03-17 15:53:00 +08:00
foreach ( var item in allProjects )
2025-03-14 18:25:51 +08:00
{
ProjectPersonMc + = "'" + item . ShortName + "'," ;
2025-05-16 17:54:16 +08:00
ProjectPersonCount + = "'" + allperson . Count ( x = > x . ProjectId = = item . ProjectId ) + "'," ;
2025-03-14 18:25:51 +08:00
}
ProjectPersonMc = ProjectPersonMc . TrimEnd ( ',' ) ;
ProjectPersonCount = ProjectPersonCount . TrimEnd ( ',' ) ;
} ) ;
2023-08-24 10:00:59 +08:00
}
#endregion
#region 进 度 情 况
protected string ProjectJd ;
protected string ProjectMc ;
2025-03-14 18:25:51 +08:00
protected async Task GetJdAsync ( )
2024-04-10 15:43:48 +08:00
{
2025-03-17 15:53:00 +08:00
var list = allProjects ;
if ( list . Any ( ) )
2023-08-24 10:00:59 +08:00
{
2025-05-16 17:54:16 +08:00
var progressCompletions = from x in Funs . DB . JDGL_ProgressCompletion select x ;
2024-09-11 10:36:09 +08:00
foreach ( var item in list )
{
2025-03-07 09:05:48 +08:00
var pCs = progressCompletions . Where ( x = > x . ProjectId = = item . ProjectId ) . ToList ( ) ;
2025-03-17 15:53:00 +08:00
2025-03-07 09:05:48 +08:00
ProjectJd + = "'" + pCs . Sum ( x = > x . RealNum ? ? 0 ) . ToString ( "0.##" ) + "'," ;
2024-09-11 10:36:09 +08:00
ProjectMc + = "'" + item . ShortName + "'," ;
}
ProjectJd = ProjectJd . TrimEnd ( ',' ) ;
ProjectMc = ProjectMc . TrimEnd ( ',' ) ;
2023-08-24 10:00:59 +08:00
}
}
#endregion
#region 整 改 数 据
2025-03-14 18:25:51 +08:00
protected async Task GetZgsjAsync ( )
2024-04-10 15:43:48 +08:00
{
2025-03-18 11:56:52 +08:00
await Task . Run ( ( ) = >
{
int GeneralClosedNum = GetGeneralClosedNum ( ) ;
int GeneralNotClosedNum = GetGeneralNotClosedNum ( ) ;
div_zgsj . InnerHtml = ( GeneralClosedNum + GeneralNotClosedNum ) . ToString ( ) ;
div_zgywc . InnerHtml = GeneralClosedNum . ToString ( ) ;
div_zgwwc . InnerHtml = GeneralNotClosedNum . ToString ( ) ;
div_zgwcl . InnerHtml = ( 100.0 * GeneralClosedNum / ( GeneralNotClosedNum + GeneralClosedNum ) ) . ToString ( "0.##" ) + "%" ;
} ) ;
2025-05-16 17:54:16 +08:00
2023-08-24 10:00:59 +08:00
}
/// <summary>
/// 获取隐患整改闭环项
/// </summary>
/// <returns></returns>
2025-02-14 15:21:20 +08:00
public int GetGeneralClosedNum ( )
2023-08-24 10:00:59 +08:00
{
2024-09-11 10:36:09 +08:00
int result = 0 ;
2025-02-14 15:21:20 +08:00
if ( pids = = null )
2024-09-11 10:36:09 +08:00
{
result = ( from x in Funs . DB . HSSE_Hazard_HazardRegister
2023-08-24 10:00:59 +08:00
where x . States = = "3"
select x ) . Count ( ) ;
2024-09-11 10:36:09 +08:00
}
2025-02-14 15:21:20 +08:00
else
{
2024-09-11 10:36:09 +08:00
result = ( from x in Funs . DB . HSSE_Hazard_HazardRegister
where x . States = = "3" & & pids . Contains ( x . ProjectId )
select x ) . Count ( ) ;
}
2025-02-14 15:21:20 +08:00
2023-08-24 10:00:59 +08:00
return result ;
}
/// <summary>
/// 获取隐患未整改完成项
/// </summary>
/// <returns></returns>
2025-02-14 15:21:20 +08:00
public int GetGeneralNotClosedNum ( )
2023-08-24 10:00:59 +08:00
{
2024-09-11 10:36:09 +08:00
int result = 0 ;
if ( pids = = null )
{
result = ( from x in Funs . DB . HSSE_Hazard_HazardRegister
2023-08-24 10:00:59 +08:00
where x . States ! = "3"
select x ) . Count ( ) ;
2024-09-11 10:36:09 +08:00
}
2025-02-14 15:21:20 +08:00
else
{
2024-09-11 10:36:09 +08:00
result = ( from x in Funs . DB . HSSE_Hazard_HazardRegister
where x . States ! = "3" & & pids . Contains ( x . ProjectId )
select x ) . Count ( ) ;
}
2025-02-14 15:21:20 +08:00
2023-08-24 10:00:59 +08:00
return result ;
}
#endregion
#region 材 料 到 货
protected string gdclHtml ;
protected string sbclHtml ;
2024-06-14 16:52:37 +08:00
protected string gdclHead = "<div class=\"th-p\">项目</div><div class=\"th-p\">管子</div><div class=\"th-p\">管件</div><div class=\"th-p\">阀门</div><div class=\"th-p\">垫片</div><div class=\"th-p\">紧固件</div>" ;
protected string sbclHead = "<div class=\"th-p\">项目</div><div class=\"th-p\">采购量</div><div class=\"th-p\">到货量</div><div class=\"th-p\">已到货百分比</div>" ;
2025-03-14 18:25:51 +08:00
private async Task GetCldhAsync ( )
2024-04-10 15:43:48 +08:00
{
2025-03-17 15:53:00 +08:00
var list = allProjects ;
2023-08-24 10:00:59 +08:00
var PipelinList = Funs . DB . CLGL_PipelineMaterialSumList . Where ( x = > x . Type = = "M" ) ;
var SbclList = Funs . DB . CLGL_ContractListSum . Where ( x = > x . C1 = = "设备" ) ;
foreach ( var item in list )
{
#region 管 道 材 料
2024-06-14 16:52:37 +08:00
gdclHtml + = " <div class=\"row\">" ;
2023-08-24 10:00:59 +08:00
var pname = item . ShortName ;
2023-10-31 18:03:55 +08:00
if ( item . ShortName . Length > 3 )
2023-08-24 10:00:59 +08:00
{
2023-10-31 18:03:55 +08:00
pname = item . ShortName . Substring ( 0 , 3 ) + "..." ;
2023-08-24 10:00:59 +08:00
}
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\" title =\"" + item . ShortName + "\">" + pname + "</div>" ;
2023-08-24 10:00:59 +08:00
var pid = BLL . ProjectService . GetCLProjectCodeByProjectId ( item . ProjectId ) . ToString ( ) ;
//管子
2025-03-17 15:53:00 +08:00
var num1 = PipelinList . FirstOrDefault ( x = > x . ProjectId = = pid & & x . C1 = = "管子" ) ;
2023-08-24 10:00:59 +08:00
if ( num1 ! = null )
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">" + ( num1 . C7 = = "" ? "0%" : num1 . C7 ) + "</div>" ;
2023-08-24 10:00:59 +08:00
}
else
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">0%</div>" ;
2023-08-24 10:00:59 +08:00
}
var num2 = PipelinList . Where ( x = > x . ProjectId = = pid & & x . C1 = = "管件法兰" ) . FirstOrDefault ( ) ;
if ( num2 ! = null )
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">" + ( num2 . C7 = = "" ? "0%" : num2 . C7 ) + "</div>" ;
2023-08-24 10:00:59 +08:00
}
else
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">0%</div>" ;
2023-08-24 10:00:59 +08:00
}
var num3 = PipelinList . Where ( x = > x . ProjectId = = pid & & x . C1 = = "阀门" ) . FirstOrDefault ( ) ;
if ( num3 ! = null )
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">" + ( num3 . C7 = = "" ? "0%" : num3 . C7 ) + "</div>" ;
2023-08-24 10:00:59 +08:00
}
else
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">0%</div>" ;
2023-08-24 10:00:59 +08:00
}
var num4 = PipelinList . Where ( x = > x . ProjectId = = pid & & x . C1 = = "垫片" ) . FirstOrDefault ( ) ;
if ( num4 ! = null )
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">" + ( num4 . C7 = = "" ? "0%" : num4 . C7 ) + "</div>" ;
2023-08-24 10:00:59 +08:00
}
else
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">0%</div>" ;
2023-08-24 10:00:59 +08:00
}
var num5 = PipelinList . Where ( x = > x . ProjectId = = pid & & x . C1 = = "紧固件" ) . FirstOrDefault ( ) ;
if ( num5 ! = null )
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">" + ( num5 . C7 = = "" ? "0%" : num5 . C7 ) + "</div>" ;
2023-08-24 10:00:59 +08:00
}
else
{
2024-06-14 16:52:37 +08:00
gdclHtml + = "<div class=\"th-p\">0%</div>" ;
2023-08-24 10:00:59 +08:00
}
gdclHtml + = " </div>" ;
#endregion
#region 设 备 材 料
2024-04-10 15:43:48 +08:00
pname = item . ShortName ;
2023-10-31 18:03:55 +08:00
if ( item . ShortName . Length > 5 )
2023-08-24 10:00:59 +08:00
{
2023-10-31 18:03:55 +08:00
pname = item . ShortName . Substring ( 0 , 5 ) + "..." ;
2023-08-24 10:00:59 +08:00
}
//采购量
var SbcllCglList = SbclList . Where ( x = > x . ProjectId = = pid ) . ToList ( ) ;
double SbcllCgl = 0.0 ;
double Sbdhs = 0.0 ;
foreach ( var itemCgl in SbcllCglList )
{
if ( string . IsNullOrEmpty ( itemCgl . C7 ) )
{
SbcllCgl + = 0 ;
Sbdhs + = 0 ;
}
2024-04-10 15:43:48 +08:00
else
{
SbcllCgl + = Convert . ToDouble ( itemCgl . C7 ) ;
2023-08-24 10:00:59 +08:00
Sbdhs + = Convert . ToDouble ( itemCgl . C9 ) ;
}
}
2025-05-16 17:54:16 +08:00
sbclHtml + = "<div class=\"row\">" ;
sbclHtml + = "<div class=\"th-p\" title=\"" + item . ShortName + "\">" + pname + "</div>" ;
2024-06-14 16:52:37 +08:00
sbclHtml + = "<div class=\"th-p\">" + SbcllCgl + "</div>" ;
sbclHtml + = "<div class=\"th-p\">" + Sbdhs + "</div>" ;
2023-08-24 10:00:59 +08:00
//百分比
2025-05-26 16:34:27 +08:00
//if (SbcllCgl + Sbdhs != 0)
//{
// var dhbfb = String.Format("{0:N2}", 100.0 * Sbdhs / (Sbdhs + SbcllCgl), 2) + "%";
// sbclHtml += "<div class=\"th-p\">" + dhbfb + "</div>";
//}
if ( SbcllCgl ! = 0 )
2023-08-24 10:00:59 +08:00
{
2025-05-26 16:34:27 +08:00
var dhbfb = String . Format ( "{0:N2}" , 100.0 * Sbdhs / SbcllCgl , 2 ) + "%" ;
2024-06-14 16:52:37 +08:00
sbclHtml + = "<div class=\"th-p\">" + dhbfb + "</div>" ;
2023-08-24 10:00:59 +08:00
}
2024-04-10 15:43:48 +08:00
else
{
2024-06-14 16:52:37 +08:00
sbclHtml + = "<div class=\"th-p\">0%</div>" ;
2023-08-24 10:00:59 +08:00
}
sbclHtml + = " </div>" ;
#endregion
}
}
#endregion
2023-10-31 18:03:55 +08:00
/// <summary>
/// 获取未遂事件数
/// </summary>
/// <returns></returns>
2025-02-14 15:21:20 +08:00
private int GetNearMissNum ( )
2023-10-31 18:03:55 +08:00
{
2025-05-16 17:54:16 +08:00
Model . SGGLDB db = Funs . DB ;
string cacheKey = "NearMissNum_" + string . Join ( "_" , pids ) ;
2025-03-17 15:53:00 +08:00
var memoryCache = MemoryCache . Default ;
if ( memoryCache . Get ( cacheKey ) ! = null )
{
return ( int ) memoryCache . Get ( cacheKey ) ;
}
int result = 0 ;
2024-09-11 10:36:09 +08:00
if ( pids = = null )
{
2025-05-16 17:54:16 +08:00
var wsAccidentList1 = from x in db . Accident_AccidentPersonRecord
join y in db . Base_AccidentType on x . AccidentTypeId equals y . AccidentTypeId
2025-05-24 14:48:16 +08:00
where y . AccidentTypeName . Contains ( "未遂" )
2025-05-16 17:54:16 +08:00
select x ;
var wsAccidentList2 = from x in db . Accident_AccidentReportOther
join y in db . Sys_Const on x . AccidentTypeId equals y . ConstValue
2025-05-24 14:48:16 +08:00
where y . ConstText . Contains ( "未遂" )
2025-05-16 17:54:16 +08:00
select x ;
result = wsAccidentList1 . Count ( ) + wsAccidentList2 . Count ( ) ;
//result = (from x in Funs.DB.Accident_AccidentPersonRecord
// join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
// where x.IsAttempt == "1" && x.CompileDate > Const.DtmarkTime
// select x).Count();
2024-09-11 10:36:09 +08:00
}
2025-02-14 15:21:20 +08:00
else
{
2025-05-16 17:54:16 +08:00
var wsAccidentList1 = from x in db . Accident_AccidentPersonRecord
join y in db . Base_AccidentType on x . AccidentTypeId equals y . AccidentTypeId
where y . AccidentTypeName . Contains ( "未遂" ) & & pids . Contains ( x . ProjectId )
select x ;
var wsAccidentList2 = from x in db . Accident_AccidentReportOther
join y in db . Sys_Const on x . AccidentTypeId equals y . ConstValue
where y . ConstText . Contains ( "未遂" ) & & pids . Contains ( x . ProjectId )
select x ;
result = wsAccidentList1 . Count ( ) + wsAccidentList2 . Count ( ) ;
//result = (from x in Funs.DB.Accident_AccidentPersonRecord
// join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
// where x.IsAttempt == "1" && x.CompileDate > Const.DtmarkTime
// && pids.Contains(x.ProjectId)
// select x).Count();
2024-09-11 10:36:09 +08:00
}
2025-03-17 15:53:00 +08:00
var policy = new CacheItemPolicy
{
AbsoluteExpiration = DateTimeOffset . Now . AddMinutes ( Const . CacheMinutes ) ,
} ;
memoryCache . Set ( cacheKey , result , policy ) ;
return result ;
2023-10-31 18:03:55 +08:00
}
2025-03-19 15:02:56 +08:00
#region 中 英 文 翻 译
private async Task getCNEN ( )
{
await Task . Run ( ( ) = >
{
On_time_rate = Resources . Lan . On_time_rate ;
main_new_qualityIssuesRectificationRate = Resources . Lan . main_new_qualityIssuesRectificationRate ;
OnePassRate = Resources . Lan . OnePassRate ;
OnePassRateOfWelding = Resources . Lan . OnePassRateOfWelding ;
total = Resources . Lan . total ;
completed = Resources . Lan . completed ;
2025-05-16 17:54:16 +08:00
qualified = Resources . Lan . qualified ;
2025-03-19 15:02:56 +08:00
mainI_progressStatistics = Resources . Lan . mainI_progressStatistics ;
Percentage_of_progress = Resources . Lan . Percentage_of_progress ;
} ) ;
}
#endregion
2023-08-24 10:00:59 +08:00
}
}