diff --git a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SKController.cs b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SKController.cs index 947f894..e97ce22 100644 --- a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SKController.cs +++ b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/SKController.cs @@ -3471,7 +3471,8 @@ namespace APT.PP.WebApi.Controllers.Api { endtime = DateTime.Now.AddMonths(3); } - var notice = NotificationTaskService.InsertUserNoticeTaskModel(item.CHECK_TYPE.GetDescription() + "安全检查通知" + date + item.Nav_CheckType?.NAME, safeNotice.ID, filter.OrgId, userInfo.ID, userInfo.NAME, DateTime.Now, endtime, (int)FMNoticeTypeEnum.消息, "SK006"); + var checkType = checkTypes.FirstOrDefault(t => t.ID == item.CHECK_TYPE_ID); + var notice = NotificationTaskService.InsertUserNoticeTaskModel(item.CHECK_TYPE.GetDescription() + checkType?.NAME + date + item.Nav_CheckType?.NAME, safeNotice.ID, filter.OrgId, userInfo.ID, userInfo.NAME, DateTime.Now, endtime, (int)FMNoticeTypeEnum.消息, "SK006"); notices.Add(notice); } } @@ -3547,7 +3548,8 @@ namespace APT.PP.WebApi.Controllers.Api { endtime = DateTime.Now.AddMonths(3); } - var notice = NotificationTaskService.InsertUserNoticeTaskModel(item.CHECK_TYPE.GetDescription() + "安全检查通知" + date + item.Nav_CheckType?.NAME, safeNotice.ID, filter.OrgId, userInfo.ID, userInfo.NAME, DateTime.Now, endtime, (int)FMNoticeTypeEnum.消息, "SK006"); + var checkType = checkTypes.FirstOrDefault(t => t.ID == item.CHECK_TYPE_ID); + var notice = NotificationTaskService.InsertUserNoticeTaskModel(item.CHECK_TYPE.GetDescription() + checkType?.NAME + date + item.Nav_CheckType?.NAME, safeNotice.ID, filter.OrgId, userInfo.ID, userInfo.NAME, DateTime.Now, endtime, (int)FMNoticeTypeEnum.消息, "SK006"); notices.Add(notice); } } @@ -5584,7 +5586,8 @@ namespace APT.PP.WebApi.Controllers.Api { endtime = DateTime.Now.AddMonths(3); } - var notice = NotificationTaskService.InsertUserNoticeTaskModel(item.CheckCycle + "安全检查通知" + date, safeNotice.ID, filter.OrgId, userInfo.ID, userInfo.NAME, DateTime.Now, endtime, (int)FMNoticeTypeEnum.消息, "SK006"); + var checkType = checkTypes.FirstOrDefault(t => t.ID == item.CheckTypeId); + var notice = NotificationTaskService.InsertUserNoticeTaskModel(item.CheckCycle + checkType?.NAME + date, safeNotice.ID, filter.OrgId, userInfo.ID, userInfo.NAME, DateTime.Now, endtime, (int)FMNoticeTypeEnum.消息, "SK006"); notices.Add(notice); j++; } @@ -5838,6 +5841,7 @@ namespace APT.PP.WebApi.Controllers.Api { dt = DateTime.Parse(filter.Parameter1); } + var checkTypes = GetEntities(i => !i.IS_DELETED, new BaseFilter(filter.OrgId)).ToList(); List notices = new List(); List details = new List(); List tasks = new List(); @@ -5915,7 +5919,8 @@ namespace APT.PP.WebApi.Controllers.Api { endtime = DateTime.Now.AddMonths(3); } - var task = NotificationTaskService.InsertUserNoticeTaskModel(set.CHECK_CYCLE.GetDescription() + "安全检查通知" + date, notice.ID, set.ORG_ID, user.ID, user.NAME, DateTime.Now, endtime, (int)FMNoticeTypeEnum.消息, "SK006"); + var checkType = checkTypes.FirstOrDefault(t => t.ID == set.CHECK_TYPE_ID); + var task = NotificationTaskService.InsertUserNoticeTaskModel(set.CHECK_CYCLE.GetDescription() + checkType?.NAME + date, notice.ID, set.ORG_ID, user.ID, user.NAME, DateTime.Now, endtime, (int)FMNoticeTypeEnum.消息, "SK006"); tasks.Add(task); j++; } diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs index a245f09..9bf3bd6 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIKanBanController.cs @@ -237,7 +237,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI [HttpPost, Route("ReturnAllData")] public JsonActionResult ReturnAllData([FromBody] KeywordFilter filter) { - string connhead = ConfigurationManager.ConnectionStrings["head"]; + //string connhead = ConfigurationManager.ConnectionStrings["head"]; JsonActionResult result = new JsonActionResult(); result.Data = new ReturnAll(); DataTable tableRisk = new DataTable(); @@ -256,8 +256,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI DataSet ds = new DataSet(); GETDBDATA(strConn, listVNAME, ref ds);//获取视图 数据 listVNAME 与 ds.Tables 一一对应 result.Data.listSETrainSum = GetTrainInfo(ds.Tables[0], ListAllORG); - - using (SqlConnection connection = new SqlConnection(connhead)) + using (SqlConnection connection = new SqlConnection(strConn)) { try { @@ -267,7 +266,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI SqlCommand comRisk = new SqlCommand(sqlRisk, connection); SqlDataAdapter riskData = new SqlDataAdapter(comRisk); riskData.Fill(tableRisk); - result.Data.riskTypeRate = RiskTypeRateData(connhead, tableRisk); + result.Data.riskTypeRate = RiskTypeRateData(tableRisk); //当日工作票排名前三 string sqlJob = "select * from vhome_jobtop3_today "; SqlCommand comJob = new SqlCommand(sqlJob, connection); @@ -277,37 +276,37 @@ namespace APT.SC.WebApi.Controllers.Api.BI SqlCommand comJobGroup = new SqlCommand(sqlJobGroup, connection); SqlDataAdapter jobGroupData = new SqlDataAdapter(comJobGroup); jobGroupData.Fill(tableJobGroup); - result.Data.jobTodayTop3 = JobTodayTopData(connhead, filter.OrgId.Value, tableJob, tableJobGroup); + result.Data.jobTodayTop3 = JobTodayTopData(filter.OrgId.Value, tableJob, tableJobGroup); //隐患整改率 string sqlHidden = "select * from vhome_hidden_data_result "; SqlCommand comHidden = new SqlCommand(sqlHidden, connection); SqlDataAdapter hiddenData = new SqlDataAdapter(comHidden); hiddenData.Fill(tableHidden); - result.Data.hiddenRectify = HiddenRectifyData(connhead, tableHidden); + result.Data.hiddenRectify = HiddenRectifyData(tableHidden); //各事项排名前三 string sqlTask = "select * from vhome_task_data_result "; SqlCommand comTask = new SqlCommand(sqlTask, connection); SqlDataAdapter taskData = new SqlDataAdapter(comTask); taskData.Fill(tableTask); - result.Data.taskTop3 = TaskTopData(connhead, tableTask); + result.Data.taskTop3 = TaskTopData(tableTask); //作业现场完成情况统计 string sqlJobRate = "select * from vhome_jobrecord_data "; SqlCommand comJobRate = new SqlCommand(sqlJobRate, connection); SqlDataAdapter jobRateData = new SqlDataAdapter(comJobRate); jobRateData.Fill(tableJobRate); - result.Data.jobFinishRate = jobFinishRateData(connhead, tableJobRate); + result.Data.jobFinishRate = jobFinishRateData(tableJobRate); //各公司安全检查统计 string sqlSafecCheck = "select * from vhome_check_total "; SqlCommand comSafecCheck = new SqlCommand(sqlSafecCheck, connection); SqlDataAdapter safecCheckData = new SqlDataAdapter(comSafecCheck); safecCheckData.Fill(tableSafeCheck); - result.Data.safeCheckSum = safeCheckSumData(connhead, tableSafeCheck); + result.Data.safeCheckSum = safeCheckSumData(tableSafeCheck); //各公司危险分类统计 string sqlLink = "select * from vhome_operationLink_data "; SqlCommand comLink = new SqlCommand(sqlLink, connection); SqlDataAdapter linkData = new SqlDataAdapter(comLink); linkData.Fill(tableLink); - result.Data.linkSum = linkSumData(connhead, tableLink); + result.Data.linkSum = linkSumData(tableLink); connection.Close(); } @@ -364,7 +363,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// 风险等级占比 /// /// 分页过滤实体 - public List RiskTypeRateData(string connhead, DataTable Table) + public List RiskTypeRateData(DataTable Table) { List result = new List(); if (Table != null && Table.Rows.Count > 0) @@ -387,7 +386,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List JobTodayTopData(string connhead, Guid orgId, DataTable Table, DataTable Table2) + public List JobTodayTopData(Guid orgId, DataTable Table, DataTable Table2) { List result = new List(); var details = new List(); @@ -441,7 +440,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public HiddenRectify HiddenRectifyData(string connhead, DataTable Table) + public HiddenRectify HiddenRectifyData(DataTable Table) { HiddenRectify result = new HiddenRectify(); if (Table != null && Table.Rows.Count > 0) @@ -459,7 +458,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List TaskTopData(string connhead, DataTable Table) + public List TaskTopData(DataTable Table) { List result = new List(); var dataTemps = new List(); @@ -508,7 +507,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List jobFinishRateData(string connhead, DataTable Table) + public List jobFinishRateData(DataTable Table) { List result = new List(); if (Table != null && Table.Rows.Count > 0) @@ -533,7 +532,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List safeCheckSumData(string connhead, DataTable Table) + public List safeCheckSumData(DataTable Table) { List result = new List(); if (Table != null && Table.Rows.Count > 0) @@ -555,7 +554,7 @@ namespace APT.SC.WebApi.Controllers.Api.BI /// /// 参数 /// - public List linkSumData(string connhead, DataTable Table) + public List linkSumData(DataTable Table) { List result = new List(); if (Table != null && Table.Rows.Count > 0) diff --git a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIStatiscialAnalysisController.cs b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIStatiscialAnalysisController.cs index fb1ca4a..3ad58cb 100644 --- a/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIStatiscialAnalysisController.cs +++ b/APT.MicroApi/APT.SC.WebApi/Controllers/Api/BIController/BIStatiscialAnalysisController.cs @@ -6,8 +6,10 @@ using APT.BaseData.Domain.Enums; using APT.BaseData.Domain.Enums.PF; using APT.BaseData.Domain.IServices; using APT.BaseData.Domain.IServices.FM; +using APT.BaseData.Domain.IServices.OP; using APT.BaseData.Services.DomainServices; using APT.BaseData.Services.Services.FM; +using APT.BaseData.Services.Services.OP; using APT.Infrastructure.Api; using APT.Infrastructure.Api.Redis; using APT.Infrastructure.Core; @@ -179,11 +181,13 @@ namespace APT.SC.WebApi.Controllers.Api.BIController /// [Route("api/BI/BIStatiscialAnalysisController")] public class BIStatiscialAnalysisController : AuthorizeApiController - { + { + IOPTenantDBConnService OPTenantDBConnService { get; set; } IPFApproveCallBackService ApproveCallBackService { get; set; } - public BIStatiscialAnalysisController(IPFApproveCallBackService approveCallBackService) + public BIStatiscialAnalysisController(IPFApproveCallBackService approveCallBackService,IOPTenantDBConnService opTenantDBConnService) { - ApproveCallBackService = approveCallBackService; + ApproveCallBackService = approveCallBackService; + OPTenantDBConnService = opTenantDBConnService; } #region 安全事务执行情况汇总 /// @@ -11183,11 +11187,12 @@ namespace APT.SC.WebApi.Controllers.Api.BIController [HttpPost, Route("GetTaskViewInfo")] public JsonActionResult> GetTaskViewInfo([FromBody] KeywordFilter filter) { - string connhead = ConfigurationManager.ConnectionStrings["head"]; + //string connhead = ConfigurationManager.ConnectionStrings["head"]; + string strConn = OPTenantDBConnService.GetConnByORGID(filter.OrgId.Value);//获取数据库链接 JsonActionResult> result = new JsonActionResult>(); result.Data = new List(); DataTable Table = new DataTable(); - using (SqlConnection connection = new SqlConnection(connhead)) + using (SqlConnection connection = new SqlConnection(strConn)) { try { diff --git a/APT.MicroApi/APT.SC.WebApi/appsettings.Development.json b/APT.MicroApi/APT.SC.WebApi/appsettings.Development.json index 328af38..ee6b8e8 100644 --- a/APT.MicroApi/APT.SC.WebApi/appsettings.Development.json +++ b/APT.MicroApi/APT.SC.WebApi/appsettings.Development.json @@ -2,7 +2,7 @@ "ConnectionStrings": { //"default": "User ID=postgres;Password=dfdn!energy;Host=36.134.166.114;Port=5432;Database=mh_op;CommandTimeout=1024;" "default": "Server=121.41.2.71;Database=mh_jy_ops;uid=sa;pwd=mhsafe!2021;", - "head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" + //"head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" }, "AppSettings": { "DataBaseType": "sqlserver", diff --git a/APT.MicroApi/APT.SC.WebApi/appsettings.Pdev.json b/APT.MicroApi/APT.SC.WebApi/appsettings.Pdev.json index 2062be9..e162680 100644 --- a/APT.MicroApi/APT.SC.WebApi/appsettings.Pdev.json +++ b/APT.MicroApi/APT.SC.WebApi/appsettings.Pdev.json @@ -9,7 +9,7 @@ //"default": "User ID=postgres;Password=dfdn!energy;Host=36.133.75.96;Port=5432;Database=postgres;CommandTimeout=1024;" //"default": "Server=120.25.146.51;Database=mh_jy_ops;uid=sa;pwd=mhsafe!2021;" "default": "Server=124.117.209.78;Database=mh_jy_ops;uid=sa;pwd=JySafe@2025*;", - "head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" + //"head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" }, "AppSettings": { "DataBaseType": "sqlserver", diff --git a/APT.MicroApi/APT.SC.WebApi/appsettings.Production.json b/APT.MicroApi/APT.SC.WebApi/appsettings.Production.json index f568de8..1e6013c 100644 --- a/APT.MicroApi/APT.SC.WebApi/appsettings.Production.json +++ b/APT.MicroApi/APT.SC.WebApi/appsettings.Production.json @@ -9,7 +9,7 @@ //"default": "User ID=postgres;Password=dfdn!energy;Host=36.133.75.96;Port=5432;Database=postgres;CommandTimeout=1024;" //"default": "Server=172.26.13.0;Database=mh_jy_ops;uid=sa;pwd=mhsafe!2021;" "default": "Server=127.0.0.1;Database=mh_jy_ops;uid=sa;pwd=JySafe@2025*;", - "head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" + //"head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" }, "AppSettings": { "DataBaseType": "sqlserver", diff --git a/APT.MicroApi/APT.SC.WebApi/appsettings.Test.json b/APT.MicroApi/APT.SC.WebApi/appsettings.Test.json index d79e9b7..d4376ed 100644 --- a/APT.MicroApi/APT.SC.WebApi/appsettings.Test.json +++ b/APT.MicroApi/APT.SC.WebApi/appsettings.Test.json @@ -2,7 +2,7 @@ "ConnectionStrings": { //"default": "User ID=postgres;Password=dfdn!energy;Host=36.134.166.114;Port=5432;Database=mh_op;CommandTimeout=1024;" "default": "Server=121.41.2.71;Database=mh_jy_ops;uid=sa;pwd=mhsafe!2021;", - "head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" + //"head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" }, "AppSettings": { "DataBaseType": "sqlserver", diff --git a/APT.MicroApi/APT.SC.WebApi/appsettings.json b/APT.MicroApi/APT.SC.WebApi/appsettings.json index d5a20f0..25866dc 100644 --- a/APT.MicroApi/APT.SC.WebApi/appsettings.json +++ b/APT.MicroApi/APT.SC.WebApi/appsettings.json @@ -5,7 +5,7 @@ //"default": "Data Source=172.20.8.83:1521/DB2;User Id=\"dbo\";Password=mssuat;Pooling=false;PERSIST SECURITY INFO=True;" //"default": "User ID=postgres;Password=ldxmesadm;Host=172.20.8.91;Port=5432;Database=mes;CommandTimeout=1024;" "default": "Server=127.0.0.1;Database=mh_jy_ops;uid=sa;pwd=123456;", - "head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" + //"head": "Server=124.117.209.78;Database=mh_jy_head;uid=sa;pwd=JySafe@2025*;" //"default": "User ID=postgres;Password=opt!energy;Host=36.133.75.96;Port=5432;Database=postgres;CommandTimeout=1024;" }, "AppSettings": { diff --git a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/HiddenDangerRectifyNoticeController.cs b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/HiddenDangerRectifyNoticeController.cs index 57a7907..60ebcd7 100644 --- a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/HiddenDangerRectifyNoticeController.cs +++ b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/HiddenDangerRectifyNoticeController.cs @@ -57,7 +57,11 @@ namespace APT.SK.WebApi.Controllers.Api List deleteDetailIds = new List(); List fileList = new List(); List basicList = new List(); - List reasonList = new List(); + List reasonList = new List(); + if (details != null) + { + details = details.Where(t => !t.IS_DELETED).ToList(); + } if (details != null && details.Any()) { var evaluationIsExist = this.GetEntity(t => t.ID == entity.ID, new string[] { "Nav_RectifyDetails", "Nav_RectifyDetails.Nav_RectifyDetailFiles", "Nav_RectifyDetails.Nav_RectifyDetailBasics", "Nav_RectifyDetails.Nav_RectifyDetailReasons" }); diff --git a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/HiddenDangerReportController.cs b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/HiddenDangerReportController.cs index 2ec0e15..f3eb8af 100644 --- a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/HiddenDangerReportController.cs +++ b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/HiddenDangerReportController.cs @@ -72,7 +72,11 @@ namespace APT.SK.WebApi.Controllers.Api List fileList = new List(); List basicList = new List(); List reasonList = new List(); - SKHiddenLevel? hiddenLevel = SKHiddenLevel.General; + SKHiddenLevel? hiddenLevel = SKHiddenLevel.General; + if (details != null) + { + details = details.Where(t => !t.IS_DELETED).ToList(); + } if (details != null && details.Any()) { var evaluationIsExist = this.GetEntity(t => t.ID == entity.ID, new string[] { "Nav_ReportDetails", "Nav_ReportDetails.Nav_ReportDetailFiles", "Nav_ReportDetails.Nav_ReportDetailBasics" , "Nav_ReportDetails.Nav_ReportDetailReasons" }); diff --git a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionNoticeController.cs b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionNoticeController.cs index e4bd0c8..81158f1 100644 --- a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionNoticeController.cs +++ b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionNoticeController.cs @@ -176,8 +176,11 @@ namespace APT.SK.WebApi.Controllers.Api List deleteUserIds = new List(); List deleteBasicIds = new List(); List deleteDetailIds = new List(); - List userList = new List(); - List basicList = new List(); + List userList = new List(); + if (details != null) + { + details = details.Where(t => !t.IS_DELETED).ToList(); + } if (details != null && details.Any()) { var evaluationIsExist = this.GetEntity(t => t.ID == entity.ID, new string[] { "Nav_CheckNoticeDetails", "Nav_CheckNoticeDetails.Nav_CheckNoticeDetailUsers", "Nav_CheckNoticeDetails.Nav_CheckNoticeDetailBasics" }); diff --git a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionRecordController.cs b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionRecordController.cs index 421537b..734ee9f 100644 --- a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionRecordController.cs +++ b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionRecordController.cs @@ -474,7 +474,11 @@ namespace APT.SK.WebApi.Controllers.Api List userList = new List(); List basicList = new List(); List fileList = new List(); - List reasonList = new List(); + List reasonList = new List(); + if (details != null) + { + details = details.Where(t => !t.IS_DELETED).ToList(); + } if (details != null && details.Any()) { var evaluationIsExist = this.GetEntity(t => t.ID == entity.ID, new string[] { "Nav_CheckRecordDetails", "Nav_CheckRecordDetails.Nav_CheckRecordDetailUsers", "Nav_CheckRecordDetails.Nav_CheckRecordDetailFiles", "Nav_CheckRecordDetails.Nav_CheckRecordDetailBasics", "Nav_CheckRecordDetails.Nav_CheckRecordDetailReasons" }); @@ -506,6 +510,7 @@ namespace APT.SK.WebApi.Controllers.Api deleteDetailIds.Add(t.ID); }); } + foreach (var item in details) { if (item.CHECK_RESULT == null) diff --git a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionRecordSummaryController.cs b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionRecordSummaryController.cs index 8a2b5e6..c13de47 100644 --- a/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionRecordSummaryController.cs +++ b/APT.MicroApi/APT.SK.WebApi/Controllers/Api/SecurityInspectionRecordSummaryController.cs @@ -68,7 +68,11 @@ namespace APT.SK.WebApi.Controllers.Api List userList = new List(); List basicList = new List(); List reasonList = new List(); - List fileList = new List(); + List fileList = new List(); + if (details != null) + { + details = details.Where(t => !t.IS_DELETED).ToList(); + } if (details != null && details.Any()) { var groupDetails = details.Where(m => m.CHECK_RESULT == SKCheckResultEnum.Yes && m.IS_DELETED == false).GroupBy(t => new { t.RISK_AREA_ID, t.CHECK_CONTENTS_ID, t.CHECK_QUESTION_ID }).ToList(); @@ -107,8 +111,8 @@ namespace APT.SK.WebApi.Controllers.Api } deleteDetailIds.Add(t.ID); }); - } - + } + foreach (var item in details) { if (item.CHECK_RESULT == null) @@ -118,6 +122,26 @@ namespace APT.SK.WebApi.Controllers.Api if (item.CHECK_RESULT == SKCheckResultEnum.None) { item.HIDDEN_LEVEL = null; + } + var isExsists = details.FirstOrDefault(t => t.CHECK_RESULT == SKCheckResultEnum.Yes && (t.CHECK_QUESTION_ID == null || t.HIDDEN_LEVEL == null || t.HIDDEN_PLACE == null)); + if (isExsists != null) + { + throw new Exception("有隐患必须选择隐患描述和隐患等级隐患地点"); + } + var isExsistFirsts = details.FirstOrDefault(t => t.CHECK_RESULT == SKCheckResultEnum.Yes && (t.Nav_CheckRecordDetailFiles == null || !t.Nav_CheckRecordDetailFiles.Any())); + if (isExsistFirsts != null) + { + throw new Exception("有隐患必须上传隐患照片"); + } + var noExsists = details.FirstOrDefault(t => t.CHECK_RESULT != SKCheckResultEnum.Yes && (t.CHECK_QUESTION_ID != null || t.HIDDEN_LEVEL != null || t.HIDDEN_PLACE != null)); + if (noExsists != null) + { + throw new Exception("无隐患、不涉及无需填写隐患描述和隐患等级隐患地点,请确认检查情况"); + } + var noExsistTwos = details.FirstOrDefault(t => t.CHECK_RESULT != SKCheckResultEnum.Yes && t.Nav_CheckRecordDetailFiles != null && t.Nav_CheckRecordDetailFiles.Where(m => !m.IS_DELETED).Any()); + if (noExsistTwos != null) + { + throw new Exception("无隐患、不涉及无需上传隐患照片"); } if (item.Nav_CheckRecordDetailUsers != null && item.Nav_CheckRecordDetailUsers.Any()) { @@ -771,8 +795,13 @@ namespace APT.SK.WebApi.Controllers.Api } item.Nav_CheckRecordDetailUsers = userTemps; - } - result.Nav_CheckRecordDetails = details.OrderByDescending(t=>t.CHECK_RESULT).ToList(); + } + //有隐患的排前面 + var tempsYes = result.Nav_CheckRecordDetails.Where(t => t.CHECK_RESULT == SKCheckResultEnum.Yes).OrderBy(m => m.RISK_AREA_ID).ToList(); + var tempsNo = result.Nav_CheckRecordDetails.Where(t => t.CHECK_RESULT != SKCheckResultEnum.Yes).OrderBy(m => m.RISK_AREA_ID).ToList(); + tempsYes.AddRange(tempsNo); + result.Nav_CheckRecordDetails = tempsYes.OrderByDescending(n => (int)n.MARK).ToList(); + //result.Nav_CheckRecordDetails = details.OrderByDescending(t=>t.CHECK_RESULT).ToList(); } } return result;