diff --git a/.vs/SGGL_CD/v17/.wsuo b/.vs/SGGL_CD/v17/.wsuo index 78356be0..ea051b27 100644 Binary files a/.vs/SGGL_CD/v17/.wsuo and b/.vs/SGGL_CD/v17/.wsuo differ diff --git a/SGGL/BLL/API/APICdPuService.cs b/SGGL/BLL/API/APICdPuService.cs new file mode 100644 index 00000000..980d0c6f --- /dev/null +++ b/SGGL/BLL/API/APICdPuService.cs @@ -0,0 +1,88 @@ +using Microsoft.SqlServer.Dts.Runtime; +using Model; +using NPOI.SS.Formula.Functions; +using Pipelines.Sockets.Unofficial.Arenas; +using RestSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Net; +using System.Net.PeerToPeer; +using System.Runtime.InteropServices.ComTypes; +using System.Text; +using System.Threading.Tasks; + +namespace BLL +{ + public static class APICdPuService + { + public static string PushData() + { + + using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString)) + { + List projectDataItems = new List(); + + var projectlist = ProjectService.GetProjectWorkList().Where(x=>x.ProjectCode== "E21028"); + foreach (var item in projectlist) + { + var getSGName = (from x in db.Project_ProjectUnit + join y in db.Base_Unit on x.UnitId equals y.UnitId + 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); + + string unit_JL = ProjectService.getProjectUnitNameByUnitType(item.ProjectId, Const.ProjectUnitType_3); + if (!string.IsNullOrEmpty(unit_JL)) + { + projectDataItem.supervisoryco = unit_JL; + } + + if (item.EndDate.HasValue) + { + projectDataItem.contractenddate = string.Format("{0:yyyy-MM-dd}", item.EndDate); + + if (item.StartDate.HasValue) + { + int pdays = (item.EndDate.Value - item.StartDate.Value).Days; + if (pdays >= 0) + { + projectDataItem.contractdurition = pdays.ToString(); + } + } + } + projectDataItem.location = item.ProjectAddress; + projectDataItem.safehours = Project_HSSEData_HSSEService.GetSafeWorkingHour(item.ProjectId).ToString(); + projectDataItem.losshours = Project_HSSEData_HSSEService.GetLostWorkingHour(item.ProjectId).ToString(); + List 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(); + projectDataItems.Add(projectDataItem); + } + var JsonBody = Newtonsoft.Json.JsonConvert.SerializeObject(projectDataItems); + + ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; + string Baseurl = "https://pu.chengda.com/cdpu//report/saveNbdData"; + var client = new RestClient(Baseurl); + client.Timeout = -1; + var request = new RestRequest(Method.POST); + //request.AddHeader("ClientId", SysConstSetService.ClientId); + request.AddHeader("OperationCode", Baseurl.Substring(Baseurl.LastIndexOf("/", StringComparison.Ordinal) + 1)); + if (!string.IsNullOrEmpty(JsonBody)) + { + request.AddJsonBody(JsonBody); + } + 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; + } + + } + } +} diff --git a/SGGL/BLL/BLL.csproj b/SGGL/BLL/BLL.csproj index b42381db..1642ce2a 100644 --- a/SGGL/BLL/BLL.csproj +++ b/SGGL/BLL/BLL.csproj @@ -186,6 +186,7 @@ + diff --git a/SGGL/BLL/TaskScheduling/TimerTask/TimerTaskBase.cs b/SGGL/BLL/TaskScheduling/TimerTask/TimerTaskBase.cs index c4459a66..ebf08f23 100644 --- a/SGGL/BLL/TaskScheduling/TimerTask/TimerTaskBase.cs +++ b/SGGL/BLL/TaskScheduling/TimerTask/TimerTaskBase.cs @@ -19,13 +19,12 @@ using System.Threading.Tasks; public static async Task Init() { - + //初始化计划者 StdSchedulerFactory factory = new StdSchedulerFactory(); - // StdSchedulerFactory factory = new StdSchedulerFactory(properties); IScheduler scheduler = await factory.GetScheduler(); - var jobAndTriggerMapping = new Dictionary>(); + var jobAndTriggerMapping = new Dictionary>(); // 将映射关系包装成制度字典集合 var model = new Model.InterFaceTask(); model.Enable = true; @@ -74,15 +73,15 @@ using System.Threading.Tasks; { var jobDetail1 = GetJobDetailByInterFaceTaskId(model.InterFaceTaskId); var trigger1 = GetTriggerByTime(model.InterFaceTaskId, model.Frequency); - await scheduler.ScheduleJob(jobDetail1, trigger1,true); + await scheduler.ScheduleJob(jobDetail1, trigger1, true); } else { - + var jobDetail1 = GetJobDetailByInterFaceTaskId(model.InterFaceTaskId); var trigger1 = GetTriggerByTime(model.InterFaceTaskId, model.Frequency); - await scheduler.ScheduleJob(jobDetail1, trigger1,true); + await scheduler.ScheduleJob(jobDetail1, trigger1, true); } } @@ -91,9 +90,9 @@ using System.Threading.Tasks; if (scheduler.GetJobDetail(jk, default) != null) { await scheduler.DeleteJob(jk, default); - - // SyncScheduledTasks(model.InterFaceTaskId, scheduler, 2); + + // SyncScheduledTasks(model.InterFaceTaskId, scheduler, 2); } } diff --git a/SGGL/FineUIPro.Web/Global.asax.cs b/SGGL/FineUIPro.Web/Global.asax.cs index c413cd2c..4255458a 100644 --- a/SGGL/FineUIPro.Web/Global.asax.cs +++ b/SGGL/FineUIPro.Web/Global.asax.cs @@ -61,7 +61,7 @@ ////通用定时器 try { - QuartzServices.Init(); + QuartzServices.Init(); BLL.MonitorService.StartMonitor(); BLL.MonitorService.StartMonitorEve(); BLL.MonitorService.StartPersonQuarterCheck(); diff --git a/SGGL/Model/APIItem/ProjectDataItem.cs b/SGGL/Model/APIItem/ProjectDataItem.cs new file mode 100644 index 00000000..cca578ae --- /dev/null +++ b/SGGL/Model/APIItem/ProjectDataItem.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Model +{ + public class ProjectDataItem + { /// + /// 项目编号 + /// + public string projectnumber { get; set; } + /// + /// 工程名称 + /// + public string projectname { get; set; } + /// + /// 工程造价(万元) + /// + public string projcost { get; set; } + /// + /// 建设范围 + /// + public string buildco { get; set; } + /// + /// 施工单位 + /// + public string constructionco { get; set; } + /// + /// 监理单位 + /// + public string supervisoryco { get; set; } + /// + /// 合同工期 + /// + public string contractdurition { get; set; } + /// + /// 合同到期时间 + /// + public string contractenddate { get; set; } + /// + /// + /// + public string remains { get; set; } + /// + /// 工程地址 + /// + public string location { get; set; } + /// + /// 安全人工时 + /// + public string safehours { get; set; } + /// + /// 损失安全人工时 + /// + public string losshours { get; set; } + /// + /// 未关闭NCR + /// + public string ncr { get; set; } + /// + /// 项目现场总人数 + /// + public string onsiteworkers { get; set; } + /// + /// 一级风险预警数量 + /// + public string risknum { get; set; } + /// + /// 安全事故数量 + /// + public string accidentsnum { get; set; } + /// + /// 施工项目数量 + /// + public string constructionnum { get; set; } + } +} diff --git a/SGGL/Model/Model.csproj b/SGGL/Model/Model.csproj index 4a6ca202..f27ca851 100644 --- a/SGGL/Model/Model.csproj +++ b/SGGL/Model/Model.csproj @@ -115,6 +115,7 @@ + diff --git a/SGGL/WebAPI/Controllers/HomeController.cs b/SGGL/WebAPI/Controllers/HomeController.cs index 10b37665..d74876ee 100644 --- a/SGGL/WebAPI/Controllers/HomeController.cs +++ b/SGGL/WebAPI/Controllers/HomeController.cs @@ -166,6 +166,27 @@ namespace WebAPI.Controllers { return View(); } + /// + /// 给pu推送数据 + /// + /// + /// + [HttpGet] + public Model.ResponeData PushPuData() + { + var responeData = new Model.ResponeData(); + try + { - } + responeData.data = APICdPuService.PushData(); + } + catch (Exception ex) + { + responeData.code = 0; + responeData.message = ex.Message; + } + + return responeData; + } + } }