20240624 PU看板接口推送修改

This commit is contained in:
2024-06-25 15:36:52 +08:00
parent e962cf661d
commit f67d7129ae
6 changed files with 88 additions and 39 deletions
+62 -13
View File
@@ -23,7 +23,7 @@ namespace BLL
{
List<ProjectDataItem> projectDataItems = new List<ProjectDataItem>();
var projectlist = ProjectService.GetProjectWorkList().Where(x=>x.ProjectCode== "E21028");
var projectlist = ProjectService.GetProjectWorkList();
foreach (var item in projectlist)
{
var getSGName = (from x in db.Project_ProjectUnit
@@ -31,21 +31,35 @@ namespace BLL
where x.ProjectId == item.ProjectId && x.UnitType == Const.ProjectUnitType_2
select y.UnitName);
ProjectDataItem projectDataItem = new ProjectDataItem();
projectDataItem.projectnumber = item.ProjectCode;
projectDataItem.projectname = item.ProjectName;
projectDataItem.projcost = item.ProjectMoney.ToString();
projectDataItem.buildco = item.WorkRange;
projectDataItem.constructionco= string .Join(",", getSGName);
projectDataItem.projectnumber = item.ProjectCode??"";
projectDataItem.projectname = item.ProjectName ?? "";
projectDataItem.projcost = item.ProjectMoney.ToString() ?? "";
projectDataItem.buildco = "";
projectDataItem.constructionco= string .Join(",", getSGName) ?? "";
projectDataItem.remains = "";
projectDataItem.contractdurition = "";
projectDataItem.contractenddate = "";
projectDataItem.supervisoryco = "";
projectDataItem.onsiteworkers = "";
projectDataItem.risknum = "";
projectDataItem.accidentsnum = "";
projectDataItem.constructionnum = "";
string unit_JL = ProjectService.getProjectUnitNameByUnitType(item.ProjectId, Const.ProjectUnitType_3);
string unit_yz = ProjectService.getProjectUnitNameByUnitType(item.ProjectId, Const.ProjectUnitType_4);
if (!string.IsNullOrEmpty(unit_JL))
{
projectDataItem.supervisoryco = unit_JL;
projectDataItem.supervisoryco = unit_JL ?? "";
}
if (!string.IsNullOrEmpty(unit_yz))
{
projectDataItem.buildco = unit_yz ?? "";
}
if (item.EndDate.HasValue)
{
projectDataItem.contractenddate = string.Format("{0:yyyy-MM-dd}", item.EndDate);
projectDataItem.contractenddate = string.Format("{0:yyyy-MM-dd}", item.EndDate) ?? "";
if (item.StartDate.HasValue)
{
@@ -56,12 +70,47 @@ namespace BLL
}
}
}
projectDataItem.location = item.ProjectAddress;
projectDataItem.safehours = Project_HSSEData_HSSEService.GetSafeWorkingHour(item.ProjectId).ToString();
projectDataItem.losshours = Project_HSSEData_HSSEService.GetLostWorkingHour(item.ProjectId).ToString();
projectDataItem.location = item.ProjectAddress ?? "";
projectDataItem.safehours = Project_HSSEData_HSSEService.GetSafeWorkingHour(item.ProjectId).ToString() ?? "";
projectDataItem.losshours = Project_HSSEData_HSSEService.GetLostWorkingHour(item.ProjectId).ToString() ?? "";
List<Model.Comprehensive_NCRManagement> NondestructiveTestList = (from x in db.Comprehensive_NCRManagement
where x.ProjectId == item.ProjectId && (x.IssuedDate ==null || x.IssuedDate >DateTime.Now) select x).ToList();
projectDataItem.ncr = NondestructiveTestList.Count.ToString();
projectDataItem.ncr = NondestructiveTestList.Count.ToString() ?? "";
var ProjectTotal1 = (from x in Funs.DB.HSSE_MonthReportItem
join y in Funs.DB.HSSE_MonthReport on x.MonthReportId equals y.MonthReportId
// where ("成达公司HSE管理人数" == x.ReportItem || "分包商HSE管理人数" == x.ReportItem) && y.Years == DateTime.Now.Year && y.ProjectId==CurrUser.LoginProjectId
where ("成达公司现场人数" == x.ReportItem) && y.Years == DateTime.Now.Year && y.ProjectId == item.ProjectId
select x.YearTotal).Sum();
var ProjectTotal2 = (from x in Funs.DB.HSSE_MonthReportItem
join y in Funs.DB.HSSE_MonthReport on x.MonthReportId equals y.MonthReportId
// where ("成达公司现场人数" == x.ReportItem || "分包商现场人数" == x.ReportItem) && y.Years == DateTime.Now.Year && y.ProjectId == CurrUser.LoginProjectId
where ("分包商现场人数" == x.ReportItem) && y.Years == DateTime.Now.Year && y.ProjectId == item.ProjectId
select x.YearTotal).Sum();
if (ProjectTotal2.HasValue && ProjectTotal1.HasValue)
{
projectDataItem.onsiteworkers = (ProjectTotal1.Value + ProjectTotal2.Value).ToString();//项目现场总人数
}
var getHazards = from x in Funs.DB.Hazard_HazardSelectedItem
join y in Funs.DB.Base_RiskLevel on x.HazardLevel equals y.RiskLevelId
where x.ProjectId == item.ProjectId && x.IsStart == true
select new { x.HazardSelectedItemId, y.RiskLevel };
projectDataItem.risknum = getHazards.Count(x => x.RiskLevel == 1).ToString();//一级风险预警数量
var accidentNum1 = (from x in Funs.DB.Accident_AccidentPersonRecord
join y in Funs.DB.Base_AccidentType on x.AccidentTypeId equals y.AccidentTypeId
where x.ProjectId == item.ProjectId
select x).Count();
var accidentNum2 = (from x in Funs.DB.Accident_AccidentReport
where x.ProjectId == item.ProjectId
select x).Count();
projectDataItem.accidentsnum = (accidentNum1 + accidentNum2).ToString() ?? "";//安全事故数量
projectDataItem.constructionnum= ProjectService.GetProjectWorkList().Count().ToString();//施工项目数量
projectDataItems.Add(projectDataItem);
}
var JsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(projectDataItems);
@@ -77,7 +126,7 @@ namespace BLL
{
request.AddJsonBody(JsonBody);
}
APICommonService.SaveSysHttpLog("CDPU", Baseurl, " Body :" + JsonBody, "Request|" + request.Method.ToString());
APICommonService.SaveSysHttpLog("CDPU", Baseurl," Body :" + JsonBody, "Request|" + request.Method.ToString());
IRestResponse response = client.Execute(request);
APICommonService.SaveSysHttpLog("CDPU", Baseurl, "Header :" + response.Headers + "| Body :" + response.Content, "Response|" + request.Method.ToString());
return response.Content;