mh_sms/APT.MicroApi/APT.PP.WebApi/Controllers/Api/PEController.cs

1085 lines
65 KiB
C#
Raw Normal View History

2024-01-22 09:17:01 +08:00
using APT.BaseData.Domain.Entities;
using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Enums.PF;
using APT.BaseData.Domain.IServices.FM;
using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.SC.PE;
using APT.MS.Domain.Entities.SC.PM;
using APT.MS.Domain.Entities.SC.PT;
using APT.MS.Domain.Enums;
using APT.Utility;
using APT.WebApi.Models;
using Google.Protobuf.WellKnownTypes;
using log4net.Filter;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Server.IISIntegration;
using MySqlX.XDevAPI.Common;
using NPOI.SS.Formula.Functions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
namespace APT.PP.WebApi.Controllers.Api
{
/// <summary>
/// 绩效测量与评价
/// </summary>
[Route("api/PP/PEController")]
[TypeFilter(typeof(CustomActionFilterAttribute))]
public class PEController : AuthorizeApiController<T_FM_BASE_CONFIG>
{
IFMNotificationTaskService NotificationTaskService { get; set; }
public PEController(IFMNotificationTaskService notificationTaskService)
{
NotificationTaskService = notificationTaskService;
}
/// <summary>
/// 触发纠正与预防措施通知单
/// </summary>
/// <returns></returns>
[HttpPost, Route("CorrectivePreventiveSync")]
public JsonActionResult<bool> CorrectivePreventiveSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
var dtNow = DateTime.Now;
var month = dtNow.Month;
var day = dtNow.Day;
var time = dtNow.TimeOfDay;
var week = dtNow.DayOfWeek;
T_FM_NOTIFICATION_TASK sendNotice = null;
T_PE_CORRECTIVE_PREVENTIVE corrective = null;
var newFilter = new BaseFilter(filter.OrgId);
newFilter.SelectField = new List<string> { "ID", "NAME" };
var userInfo = this.GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部负责人" && t.ENABLE_STATUS == 0, newFilter);
if (userInfo == null && filter.OrgId.ToString() == "3efd5276-632b-e379-9ff3-7a7546591fca")
{
userInfo = this.GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部安全员" && t.ENABLE_STATUS == 0);
}
if (userInfo != null)
{
bool isSend = false;
newFilter.SelectField = new List<string> { "PLANCHECKFREQUENCY", "MONTH", "DATA", "WEEKDATA" };
var timeSet = GetEntity<T_PT_TIME_SET>(i => i.SET_TYPE == PTSetTypeEnum.CorrectivePreventive, newFilter);
if (timeSet != null)
{
switch (timeSet.PLANCHECKFREQUENCY)
{
//case BSPLANCHECKFREQUENCYEnum.OneTime:
case BSPLANCHECKFREQUENCYEnum.Year:
if (timeSet.MONTH == month && timeSet.DATA == day)
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.HalfYear:
if ((timeSet.MONTH == month && timeSet.DATA == day) || ((timeSet.MONTH + 6) == month && (timeSet.DATA + 183) == day))
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Date:
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Week:
if (timeSet.WEEKDATA != null && (int)timeSet.WEEKDATA.Value == (int)week)
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Month:
if (timeSet.DATA == day)
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Quarter:
if (timeSet.MONTH == 1)
{
if ((month == 1 || month == 4 || month == 7 || month == 10) && timeSet.DATA == day)
isSend = true;
}
if (timeSet.MONTH == 2)
{
if ((month == 2 || month == 5 || month == 8 || month == 11) && timeSet.DATA == day)
isSend = true;
}
if (timeSet.MONTH == 3)
{
if ((month == 3 || month == 6 || month == 9 || month == 12) && timeSet.DATA == day)
isSend = true;
}
break;
default:
break;
}
}
if (isSend)
{
if (!string.IsNullOrEmpty(filter.Parameter1))
{
if (DateTime.Now.Hour.ToString() == filter.Parameter1)
isSend = true;
else
isSend = false;
}
var safe = this.GetEntity<T_PE_CORRECTIVE_PREVENTIVE>(t => t.USER_ID == userInfo.ID && t.CREATE_TIME.Value.Date == DateTime.Now.Date);
if (safe == null)
{
corrective = new T_PE_CORRECTIVE_PREVENTIVE();
corrective.ORG_ID = filter.GetOrgId();
corrective.USER_ID = userInfo.ID;
corrective.DEPARTMENT_ID = userInfo.DEPARTMENT_ID;
corrective.STATUS = PFStandardStatus.Draft;
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("纠正与预防措施通知单", corrective.ID, filter.GetOrgId(), userInfo.ID, userInfo.NAME, DateTime.Now, DateTime.Now.AddDays(30), (int)FMNoticeTypeEnum., "PE005");
}
}
}
UnifiedCommit(() =>
{
if (corrective != null)
UpdateEntityNoCommit(corrective);
if (sendNotice != null)
UpdateEntityNoCommit(sendNotice);
});
return true;
});
}
/// <summary>
/// 触发安全绩效监测计划表
/// </summary>
/// <returns></returns>
[HttpPost, Route("SafetyMonitorPlanSync")]
public JsonActionResult<bool> SafetyMonitorPlanSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
var dtNow = DateTime.Now;
var year = dtNow.Year;
var month = dtNow.Month;
var day = dtNow.Day;
var time = dtNow.TimeOfDay;
var week = dtNow.DayOfWeek;
List<T_FM_NOTIFICATION_TASK> sendNotices = new List<T_FM_NOTIFICATION_TASK>();
List<T_PE_SAFETY_MONITOR_PLAN> monitorPlans = new List<T_PE_SAFETY_MONITOR_PLAN>();
List<T_PE_SAFETY_MONITOR_PLAN_DETAIL> monitorPlanDetails = new List<T_PE_SAFETY_MONITOR_PLAN_DETAIL>();
var newFilter = new BaseFilter(filter.OrgId);
newFilter.SelectField = new List<string> { "ID", "NAME" };
var userInfo = this.GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部负责人" && t.ENABLE_STATUS == 0, newFilter);
if (userInfo == null && filter.OrgId.ToString() == "3efd5276-632b-e379-9ff3-7a7546591fca")
{
userInfo = this.GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部安全员" && t.ENABLE_STATUS == 0);
}
if (userInfo != null)
{
bool isSend = false;
newFilter.SelectField = new List<string> { "PLANCHECKFREQUENCY", "MONTH", "DATA", "WEEKDATA" };
var timeSet = GetEntity<T_PT_TIME_SET>(i => i.SET_TYPE == PTSetTypeEnum.SafetyMonitorPlan, newFilter);
if (timeSet != null)
{
switch (timeSet.PLANCHECKFREQUENCY)
{
//case BSPLANCHECKFREQUENCYEnum.OneTime:
case BSPLANCHECKFREQUENCYEnum.Year:
if (timeSet.MONTH == month && timeSet.DATA == day)
{
isSend = true;
}
break;
case BSPLANCHECKFREQUENCYEnum.HalfYear:
if ((timeSet.MONTH == month && timeSet.DATA == day) || ((timeSet.MONTH + 6) == month && (timeSet.DATA + 183) == day))
{
isSend = true;
}
break;
case BSPLANCHECKFREQUENCYEnum.Date:
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Week:
if (timeSet.WEEKDATA != null && (int)timeSet.WEEKDATA.Value == (int)week)
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Month:
if (timeSet.DATA == day)
{
isSend = true;
//if (month == 1)
// year = year - 1;
}
break;
case BSPLANCHECKFREQUENCYEnum.Quarter:
if (timeSet.MONTH == 1)
{
if ((month == 1 || month == 4 || month == 7 || month == 10) && timeSet.DATA == day)
isSend = true;
}
if (timeSet.MONTH == 2)
{
if ((month == 2 || month == 5 || month == 8 || month == 11) && timeSet.DATA == day)
isSend = true;
}
if (timeSet.MONTH == 3)
{
if ((month == 3 || month == 6 || month == 9 || month == 12) && timeSet.DATA == day)
isSend = true;
}
//if ((month == 1 && day == timeSet.DATA) || (month == 4 && day == timeSet.DATA) || (month == 7 && day == timeSet.DATA) || (month == 10 && day == timeSet.DATA))
//{
// isSend = true;
// if (month == 1 && day == timeSet.DATA)
// year = year - 1;
//}
break;
default:
break;
}
}
if (isSend)
{
if (!string.IsNullOrEmpty(filter.Parameter1))
{
if (DateTime.Now.Hour.ToString() == filter.Parameter1)
isSend = true;
else
isSend = false;
}
//newFilter.SelectField = new List<string> { "ID", "NAME" };
//var productUnit = this.GetEntities<T_PE_STANDARDIZED_SCORE_IMPORT>(t => t.PARENT_ID == null, newFilter).Distinct().ToList();
//if (productUnit != null && productUnit.Any())
//{
// foreach (var item in productUnit)
// {
// }
//}
var safe = this.GetEntity<T_PE_SAFETY_MONITOR_PLAN>(t => t.USER_ID == userInfo.ID && t.CREATE_TIME.Value.Date == DateTime.Now.Date);
if (safe == null)
{
T_PE_SAFETY_MONITOR_PLAN monitorPlan = new T_PE_SAFETY_MONITOR_PLAN();
monitorPlan.ORG_ID = filter.GetOrgId();
monitorPlan.USER_ID = userInfo.ID;
monitorPlan.DEPARTMENT_ID = userInfo.DEPARTMENT_ID;
monitorPlan.STATUS = PFStandardStatus.Draft;
monitorPlan.YEAR = year.ToString();
monitorPlan.PRODUCTION_UNIT_ID = null;
monitorPlans.Add(monitorPlan);
newFilter.SelectField = new List<string> { "ORG_ID", "ID" };
var monitorProjects = this.GetEntities<T_PE_MONITOR_PROJECT>(t => !t.IS_DELETED, newFilter).ToList();
if (monitorProjects != null && monitorProjects.Any())
{
foreach (var project in monitorProjects)
{
T_PE_SAFETY_MONITOR_PLAN_DETAIL detail = new T_PE_SAFETY_MONITOR_PLAN_DETAIL();
detail.ORG_ID = project.ORG_ID;
detail.SAFETY_MONITOR_PLAN_ID = monitorPlan.ID;
detail.PROJECT_ID = project.ID;
detail.ASSESSMENT_CYCLE = PTAssessmentCycleEnums.Year;
monitorPlanDetails.Add(detail);
}
}
T_FM_NOTIFICATION_TASK sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("年度安全绩效监测计划", monitorPlan.ID, filter.GetOrgId(), userInfo.ID, userInfo.NAME, DateTime.Now, DateTime.Now.AddDays(30), (int)FMNoticeTypeEnum., "PE019");
sendNotices.Add(sendNotice);
}
}
}
UnifiedCommit(() =>
{
if (monitorPlans != null && monitorPlans.Any())
this.BantchSaveEntityNoCommit(monitorPlans);
if (monitorPlanDetails != null && monitorPlanDetails.Any())
this.BantchSaveEntityNoCommit(monitorPlanDetails);
if (sendNotices != null && sendNotices.Any())
this.BantchSaveEntityNoCommit(sendNotices);
});
return true;
});
}
/// <summary>
/// 触发安全绩效监测记录表
/// </summary>
/// <returns></returns>
[HttpPost, Route("SafetyMonitorRecordSync")]
public JsonActionResult<bool> SafetyMonitorRecordSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
var dtNow = DateTime.Now;
var year = dtNow.Year;
var month = dtNow.Month;
var day = dtNow.Day;
var time = dtNow.TimeOfDay;
var week = dtNow.DayOfWeek;
var isSend = true;
List<T_FM_NOTIFICATION_TASK> sendNotices = new List<T_FM_NOTIFICATION_TASK>();
var newFilter = new BaseFilter(filter.OrgId);
//newFilter.SelectField = new List<string> { "YEAR", "ID" };
var monitorPlan = this.GetEntities<T_PE_SAFETY_MONITOR_PLAN>(e => (e.YEAR == year.ToString()) && e.STATUS == PFStandardStatus.Archived && e.IS_RUN == DisableStatusEnum., new BaseFilter(filter.OrgId), "Nav_Details").ToList();
if (monitorPlan.Count < 1)
return true;
List<T_PE_SAFETY_MONITOR_PLAN> monitorPlanList = new List<T_PE_SAFETY_MONITOR_PLAN>();
List<T_PE_SAFETY_MONITOR_PLAN_DETAIL> monitorPlanDetails = new List<T_PE_SAFETY_MONITOR_PLAN_DETAIL>();
List<T_PE_SAFETY_MONITOR_RECORD> monitorRecords = new List<T_PE_SAFETY_MONITOR_RECORD>();
List<T_PE_SAFETY_MONITOR_RECORD_DETAIL> monitorRecordDetails = new List<T_PE_SAFETY_MONITOR_RECORD_DETAIL>();
var timeSet = GetEntities<T_PT_TIME_SET>(i => i.SET_TYPE == PTSetTypeEnum.SafetyMonitorRecord, new BaseFilter(filter.OrgId));
if (timeSet != null && timeSet.Any())
{
if (isSend)
{
if (!string.IsNullOrEmpty(filter.Parameter1))
{
if (DateTime.Now.Hour.ToString() == filter.Parameter1)
isSend = true;
else
isSend = false;
}
var monitorPlanIds = monitorPlan.Select(t => t.ID).ToList();
foreach (var itemSet in timeSet)
{
var monitorPlanNew = new List<T_PE_SAFETY_MONITOR_PLAN>();
//newFilter.SelectField = new List<string> { "SAFETY_MONITOR_PLAN_ID" };
//var monitorRecordTemp = GetEntities<T_PE_SAFETY_MONITOR_RECORD>(i => monitorPlanIds.Contains(i.SAFETY_MONITOR_PLAN_ID.Value), new BaseFilter(filter.OrgId)).ToList();
//var existIds = monitorRecordTemp.Select(t => t.SAFETY_MONITOR_PLAN_ID).Distinct().ToList();
switch (itemSet.PLANCHECKFREQUENCY)
{
//case BSPLANCHECKFREQUENCYEnum.OneTime:
case BSPLANCHECKFREQUENCYEnum.HalfYear:
if ((itemSet.MONTH == month && itemSet.DATA == day) || ((itemSet.MONTH + 6) == month && (itemSet.DATA + 183) == day))
{
monitorPlanNew = monitorPlan.Where(t => t.YEAR == year.ToString()).ToList();//&& !existIds.Contains(t.ID)
if (monitorPlanNew != null && monitorPlanNew.Any())
{
foreach (var item in monitorPlanNew)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
var temp = item.Nav_Details.Where(t => t.ASSESSMENT_CYCLE == PTAssessmentCycleEnums.HalfYear).ToList();
monitorPlanDetails.AddRange(temp);
}
monitorPlanList.Add(item);
}
}
}
break;
case BSPLANCHECKFREQUENCYEnum.Year:
if (itemSet.MONTH == month && itemSet.DATA == day)
{
monitorPlanNew = monitorPlan.Where(t => t.YEAR == year.ToString()).ToList();//&& !existIds.Contains(t.ID)
if (monitorPlanNew != null && monitorPlanNew.Any())
{
foreach (var item in monitorPlanNew)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
var temp = item.Nav_Details.Where(t => t.ASSESSMENT_CYCLE == PTAssessmentCycleEnums.Year).ToList();
monitorPlanDetails.AddRange(temp);
}
monitorPlanList.Add(item);
}
}
}
break;
case BSPLANCHECKFREQUENCYEnum.Date:
monitorPlanNew = monitorPlan.Where(t => t.YEAR == year.ToString()).ToList();//&& !existIds.Contains(t.ID)
if (monitorPlanNew != null && monitorPlanNew.Any())
{
foreach (var item in monitorPlanNew)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
var temp = item.Nav_Details.Where(t => t.ASSESSMENT_CYCLE == PTAssessmentCycleEnums.Day).ToList();
monitorPlanDetails.AddRange(temp);
}
monitorPlanList.Add(item);
}
}
break;
case BSPLANCHECKFREQUENCYEnum.Week:
if (itemSet.WEEKDATA != null && (int)itemSet.WEEKDATA.Value == (int)week)
{
monitorPlanNew = monitorPlan.Where(t => t.YEAR == year.ToString()).ToList();// && !existIds.Contains(t.ID)
if (monitorPlanNew != null && monitorPlanNew.Any())
{
foreach (var item in monitorPlanNew)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
var temp = item.Nav_Details.Where(t => t.ASSESSMENT_CYCLE == PTAssessmentCycleEnums.Week).ToList();
monitorPlanDetails.AddRange(temp);
}
monitorPlanList.Add(item);
}
}
}
break;
case BSPLANCHECKFREQUENCYEnum.Month:
if (itemSet.DATA == day)
{
monitorPlanNew = monitorPlan.Where(t => t.YEAR == year.ToString()).ToList();// && !existIds.Contains(t.ID)
if (monitorPlanNew != null && monitorPlanNew.Any())
{
foreach (var item in monitorPlanNew)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
var temp = item.Nav_Details.Where(t => t.ASSESSMENT_CYCLE == PTAssessmentCycleEnums.Month).ToList();
monitorPlanDetails.AddRange(temp);
}
monitorPlanList.Add(item);
}
}
}
break;
case BSPLANCHECKFREQUENCYEnum.Quarter:
if (itemSet.MONTH == 1)
{
if ((month == 1 || month == 4 || month == 7 || month == 10) && itemSet.DATA == day)
{
monitorPlanNew = monitorPlan.Where(t => t.YEAR == year.ToString()).ToList();//&& !existIds.Contains(t.ID)
if (monitorPlanNew != null && monitorPlanNew.Any())
{
foreach (var item in monitorPlanNew)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
var temp = item.Nav_Details.Where(t => t.ASSESSMENT_CYCLE == PTAssessmentCycleEnums.Quarter).ToList();
monitorPlanDetails.AddRange(temp);
}
monitorPlanList.Add(item);
}
}
}
}
if (itemSet.MONTH == 2)
{
if ((month == 2 || month == 5 || month == 8 || month == 11) && itemSet.DATA == day)
{
monitorPlanNew = monitorPlan.Where(t => t.YEAR == year.ToString()).ToList();//&& !existIds.Contains(t.ID)
if (monitorPlanNew != null && monitorPlanNew.Any())
{
foreach (var item in monitorPlanNew)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
var temp = item.Nav_Details.Where(t => t.ASSESSMENT_CYCLE == PTAssessmentCycleEnums.Quarter).ToList();
monitorPlanDetails.AddRange(temp);
}
monitorPlanList.Add(item);
}
}
}
}
if (itemSet.MONTH == 3)
{
if ((month == 3 || month == 6 || month == 9 || month == 12) && itemSet.DATA == day)
{
monitorPlanNew = monitorPlan.Where(t => t.YEAR == year.ToString()).ToList();//&& !existIds.Contains(t.ID)
if (monitorPlanNew != null && monitorPlanNew.Any())
{
foreach (var item in monitorPlanNew)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
var temp = item.Nav_Details.Where(t => t.ASSESSMENT_CYCLE == PTAssessmentCycleEnums.Quarter).ToList();
monitorPlanDetails.AddRange(temp);
}
monitorPlanList.Add(item);
}
}
}
}
break;
default:
break;
}
}
}
}
if (monitorPlanDetails != null && monitorPlanDetails.Any())
{
var userIds = monitorPlanDetails.Select(t => t.USER_ID).Distinct().ToList();
newFilter.SelectField = new List<string> { "DEPARTMENT_ID", "ID", "NAME" };
var users = this.GetEntities<T_FM_USER>(t => userIds.Contains(t.ID) && t.ENABLE_STATUS == 0, newFilter).Distinct().ToList();
var planTemps = monitorPlanDetails.GroupBy(t => new { t.SAFETY_MONITOR_PLAN_ID, t.ASSESSMENT_CYCLE, t.USER_ID }).ToList();
foreach (var detailP in planTemps)
{
var userInfo = users.FirstOrDefault(t => t.ID == detailP.Key.USER_ID);
T_PE_SAFETY_MONITOR_RECORD monitorRecord = new T_PE_SAFETY_MONITOR_RECORD();
monitorRecord.ORG_ID = filter.GetOrgId();
monitorRecord.USER_ID = detailP.Key.USER_ID;
monitorRecord.DEPARTMENT_ID = userInfo?.DEPARTMENT_ID;
monitorRecord.STATUS = PFStandardStatus.Draft;
monitorRecord.SAFETY_MONITOR_PLAN_ID = detailP.Key.SAFETY_MONITOR_PLAN_ID;
monitorRecord.ASSESSMENT_CYCLE = detailP.Key.ASSESSMENT_CYCLE;
monitorRecords.Add(monitorRecord);
var details = monitorPlanDetails.Where(t => t.SAFETY_MONITOR_PLAN_ID == detailP.Key.SAFETY_MONITOR_PLAN_ID && t.ASSESSMENT_CYCLE == detailP.Key.ASSESSMENT_CYCLE && t.USER_ID == detailP.Key.USER_ID).ToList();
if (details != null && details.Any())
{
foreach (var detailR in details)
{
T_PE_SAFETY_MONITOR_RECORD_DETAIL detail = new T_PE_SAFETY_MONITOR_RECORD_DETAIL();
detail.ORG_ID = monitorRecord.ORG_ID;
detail.SAFETY_MONITOR_RECORD_ID = monitorRecord.ID;
detail.PROJECT_ID = detailR.PROJECT_ID;
detail.CONTENTS = detailR.CONTENTS;
detail.STANDARD = detailR.STANDARD;
detail.METHOD = detailR.METHOD;
detail.RESULT_DISCUSS = PTResultDiscussEnums.Unfinished;
monitorRecordDetails.Add(detail);
}
}
var sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("安全绩效监测记录表-" + detailP.Key.ASSESSMENT_CYCLE.GetDescription(), monitorRecord.ID, filter.GetOrgId(), userInfo.ID, userInfo.NAME, DateTime.Now, DateTime.Now.AddDays(30), (int)FMNoticeTypeEnum., "PE021");
sendNotices.Add(sendNotice);
}
}
UnifiedCommit(() =>
{
if (monitorPlanList != null && monitorPlanList.Any())
this.BantchUpdateEntityNoCommit(monitorPlanList);
if (monitorRecords != null && monitorRecords.Any())
this.BantchSaveEntityNoCommit(monitorRecords);
if (monitorRecordDetails != null && monitorRecordDetails.Any())
this.BantchSaveEntityNoCommit(monitorRecordDetails);
if (sendNotices != null && sendNotices.Any())
this.BantchSaveEntityNoCommit(sendNotices);
});
return true;
});
}
/// <summary>
/// 触发安全评价计划讨论会(今日提醒)
/// </summary>
/// <returns></returns>
[HttpPost, Route("SafetyEvaluationPlanSync")]
public JsonActionResult<bool> SafetyEvaluationPlanSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
var dtNow = DateTime.Now;
var month = dtNow.Month;
var day = dtNow.Day;
var time = dtNow.TimeOfDay;
var week = dtNow.DayOfWeek;
T_FM_NOTIFICATION_TASK sendNotice = null;
bool isSend = false;
var userInfo = this.GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部负责人" && t.ENABLE_STATUS == 0);
if (userInfo == null && filter.OrgId.ToString() == "3efd5276-632b-e379-9ff3-7a7546591fca")
{
userInfo = this.GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部安全员" && t.ENABLE_STATUS == 0);
}
if (userInfo != null)
{
var newFilter = new BaseFilter(filter.OrgId);
newFilter.SelectField = new List<string> { "PLANCHECKFREQUENCY", "MONTH", "DATA", "WEEKDATA" };
var timeSet = GetEntity<T_PT_TIME_SET>(i => i.SET_TYPE == PTSetTypeEnum.SafetyPlanMeetting, newFilter);
if (timeSet != null)
{
switch (timeSet.PLANCHECKFREQUENCY)
{
//case BSPLANCHECKFREQUENCYEnum.OneTime:
case BSPLANCHECKFREQUENCYEnum.Year:
if (timeSet.MONTH == month && timeSet.DATA == day)
{
isSend = true;
}
break;
case BSPLANCHECKFREQUENCYEnum.HalfYear:
if ((timeSet.MONTH == month && timeSet.DATA == day) || (timeSet.MONTH + 6 == month && timeSet.DATA + 183 == day))
{
isSend = true;
}
break;
case BSPLANCHECKFREQUENCYEnum.Date:
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Week:
if (timeSet.WEEKDATA != null && (int)timeSet.WEEKDATA.Value == (int)week)
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Month:
if (timeSet.DATA == day)
{
isSend = true;
//if (month == 1)
// year = year - 1;
}
break;
case BSPLANCHECKFREQUENCYEnum.Quarter:
if (timeSet.MONTH == 1)
{
if ((month == 1 || month == 4 || month == 7 || month == 10) && timeSet.DATA == day)
isSend = true;
}
if (timeSet.MONTH == 2)
{
if ((month == 2 || month == 5 || month == 8 || month == 11) && timeSet.DATA == day)
isSend = true;
}
if (timeSet.MONTH == 3)
{
if ((month == 3 || month == 6 || month == 9 || month == 12) && timeSet.DATA == day)
isSend = true;
}
//if ((month == 1 && day == timeSet.DATA) || (month == 4 && day == timeSet.DATA) || (month == 7 && day == timeSet.DATA) || (month == 10 && day == timeSet.DATA))
//{
// isSend = true;
// if (month == 1 && day == timeSet.DATA)
// year = year - 1;
//}
break;
default:
break;
}
}
}
if (isSend)
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("请召开安全标准化内部评价计划讨论会。", Guid.NewGuid(), filter.GetOrgId(), userInfo.ID, userInfo.NAME, DateTime.Now, DateTime.Now.AddDays(30), (int)FMNoticeTypeEnum., "PF135");
UnifiedCommit(() =>
{
if (sendNotice != null)
UpdateEntityNoCommit(sendNotice);
});
return true;
});
}
/// <summary>
/// 触发安全标准化内部评价记录表
/// </summary>
/// <param name="filter"></param>
[HttpPost, Route("SafetyEvaluationRecordSync")]
public JsonActionResult<bool> SafetyEvaluationRecordSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
var dtNow = DateTime.Now;
var year = dtNow.Year;
var month = dtNow.Month;
var day = dtNow.Day;
var time = dtNow.TimeOfDay;
var week = dtNow.DayOfWeek;
var newFilter = new BaseFilter(filter.OrgId);
var evaluationPlan = this.GetEntities<T_PE_SAFETY_EVALUATION_PLAN>(t => t.START_TIME.Value.Year == year && t.START_TIME.Value.Month == month && t.START_TIME.Value.Day == day && t.IS_RUN == DisableStatusEnum., new BaseFilter(filter.OrgId), "Nav_Details", "Nav_Details.Nav_EvaluationUser").ToList();
if (evaluationPlan.Count < 1)
return true;
List<T_PE_SAFETY_EVALUATION_RECORD> recordList = new List<T_PE_SAFETY_EVALUATION_RECORD>();
List<T_PE_SAFETY_EVALUATION_RECORD_DETAIL> recordDetailList = new List<T_PE_SAFETY_EVALUATION_RECORD_DETAIL>();
List<T_PE_SAFETY_EVALUATION_RECORD_USER> recordUserList = new List<T_PE_SAFETY_EVALUATION_RECORD_USER>();
List<T_FM_NOTIFICATION_TASK> notices = new List<T_FM_NOTIFICATION_TASK>();
newFilter.SelectField = new List<string> { "ID", "NAME" };
var userList = this.GetEntities<T_FM_USER>(t => !t.IS_DELETED && t.ENABLE_STATUS == 0, newFilter).ToList();
foreach (var item in evaluationPlan)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
List<Guid> userIds = new List<Guid>();
List<string> userNames = new List<string>();
T_PE_SAFETY_EVALUATION_RECORD record = new T_PE_SAFETY_EVALUATION_RECORD();
record.ORG_ID = filter.OrgId;
record.EVALUATION_PLAN_ID = item.ID;
record.STATUS = PFStandardStatus.Draft;
recordList.Add(record);
var group = 1;
var standardizedIds = item.Nav_Details.Select(t => t.STANDARDIZED_ID).Distinct().ToList();
var standardized = this.GetEntities<T_PE_STANDARDIZED_SCORE_IMPORT_DETAIL>(t => standardizedIds.Contains(t.PRIMARY_ELEMENTS_ID), new BaseFilter(filter.OrgId));
foreach (var itemDetail in item.Nav_Details)
{
var evaluationItem = standardized.Where(t => t.PRIMARY_ELEMENTS_ID == itemDetail.STANDARDIZED_ID).ToList();
if (evaluationItem != null && evaluationItem.Any())
{
evaluationItem.ForEach(t =>
{
T_PE_SAFETY_EVALUATION_RECORD_DETAIL detail = new T_PE_SAFETY_EVALUATION_RECORD_DETAIL();
detail.ORG_ID = t.ORG_ID;
detail.PRODUCTION_UNIT_ID = item.PRODUCTION_UNIT_ID;
detail.SAFETY_EVALUATION_RECORD_ID = record.ID;
detail.PRIMARY_ELEMENTS_ID = t.PRIMARY_ELEMENTS_ID;
detail.SECOND_ELEMENTS_ID = t.SECOND_ELEMENTS_ID;
detail.THREE_ELEMENTS_ID = t.THREE_ELEMENTS_ID;
detail.EVALUATION_ITEM = t.EVALUATION_ITEM;
detail.CONTENTS = t.CONTENTS;
detail.STANDARDIZED_SCORE = t.STANDARDIZED_SCORE;
detail.NON_STANDARDIZED_SCORE = t.NON_STANDARDIZED_SCORE;
detail.EVALUATION_RESULT = PEEvaluationResultEnum.Conform;
detail.NUM = t.NUM;
recordDetailList.Add(detail);
});
}
if (itemDetail.Nav_EvaluationUser != null && itemDetail.Nav_EvaluationUser.Any())
{
foreach (var userDetail in itemDetail.Nav_EvaluationUser)
{
T_PE_SAFETY_EVALUATION_RECORD_USER user = new T_PE_SAFETY_EVALUATION_RECORD_USER();
user.SAFETY_EVALUATION_RECORD_ID = record.ID;
user.ORG_ID = filter.OrgId;
user.USER_ID = userDetail.USER_ID;
user.DEAL_STATUS = FOUserShiftStatusEnum.;
user.GROUP_NO = group;
user.ROW_NO = userDetail.ROW_NO;
recordUserList.Add(user);
if (userDetail.ROW_NO == 1)
userIds.Add(userDetail.USER_ID.Value);
}
}
group++;
}
userIds = userIds.Distinct().ToList();
if (userIds != null && userIds.Any())
{
foreach (var user in userIds)
{
var userName = userList.FirstOrDefault(t => t.ID == user);
userNames.Add(userName?.NAME);
}
//发消息
var notice = NotificationTaskService.InsertUserNoticeTaskModels("安全标准化内部评价记录表", record.ID, filter.OrgId, userIds, userNames, DateTime.Now,
DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum., "PE029");
notices.AddRange(notice);
}
}
}
if (notices != null && notices.Any())
{
//recordUserList = recordUserList.Distinct(t => new { t.SAFETY_EVALUATION_RECORD_ID, t.USER_ID }).ToList();
}
else
{
recordList = null;
recordDetailList = null;
recordUserList = null;
}
UnifiedCommit(() =>
{
if (evaluationPlan != null && evaluationPlan.Any())
BantchSaveEntityNoCommit(evaluationPlan);
if (recordList != null && recordList.Any())
BantchSaveEntityNoCommit(recordList);
if (recordDetailList != null && recordDetailList.Any())
BantchAddEntityNoCommit(recordDetailList);
if (recordUserList != null && recordUserList.Any())
BantchAddEntityNoCommit(recordUserList);
if (notices != null && notices.Any())
BantchAddEntityNoCommit(notices);
});
return true;
});
}
/// <summary>
/// 同步考评项目导入子表到考评类目评分子表
/// </summary>
/// <param name="filter"></param>
[HttpPost, Route("StandardizedScoreSync")]
public JsonActionResult<bool> StandardizedScoreSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
List<T_PE_STANDARDIZED_SCORE_IMPORT_ITEM> standardScoreItems = new List<T_PE_STANDARDIZED_SCORE_IMPORT_ITEM>();
var standardScore = this.GetEntities<T_PE_STANDARDIZED_SCORE_IMPORT_DETAIL>(t => true, new BaseFilter(filter.OrgId)).ToList();
if (standardScore != null && standardScore.Any())
{
foreach (var item in standardScore)
{
T_PE_STANDARDIZED_SCORE_IMPORT_ITEM score = new T_PE_STANDARDIZED_SCORE_IMPORT_ITEM();
score.ORG_ID = item.ORG_ID;
score.NUM=item.NUM;
score.CONTENTS = item.CONTENTS;
score.STANDARDIZED_SCORE = item.STANDARDIZED_SCORE;
score.NON_STANDARDIZED_SCORE = item.NON_STANDARDIZED_SCORE;
score.EVALUATION_ITEM = item.EVALUATION_ITEM;
score.STANDARDIZED_SCORE_IMPORT_ID = item.THREE_ELEMENTS_ID != null ? item.THREE_ELEMENTS_ID : (item.SECOND_ELEMENTS_ID != null ? item.SECOND_ELEMENTS_ID : (item.PRIMARY_ELEMENTS_ID !=null ? item.PRIMARY_ELEMENTS_ID:item.PRODUCTION_UNIT_ID));
standardScoreItems.Add(score);
}
}
UnifiedCommit(() =>
{
if (standardScoreItems != null && standardScoreItems.Any())
BantchSaveEntityNoCommit(standardScoreItems);
});
return true;
});
}
/// <summary>
/// 触发安全标准化内部评价记录表
/// </summary>
/// <param name="filter"></param>
[HttpPost, Route("SafetyEvaluationRecordNewSync")]
public JsonActionResult<bool> SafetyEvaluationRecordNewSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
var dtNow = DateTime.Now;
var year = dtNow.Year;
var month = dtNow.Month;
var day = dtNow.Day;
var hour = dtNow.Hour;
var newFilter = new BaseFilter(filter.OrgId);
var evaluationPlan = this.GetEntities<T_PE_SAFETY_EVALUATION_PLAN>(t => t.START_TIME.Value.Year == year && t.START_TIME.Value.Month == month && t.START_TIME.Value.Day == day && t.START_TIME.Value.Hour == hour && t.IS_RUN == DisableStatusEnum., new BaseFilter(filter.OrgId), "Nav_Details.Nav_EvaluationMethod", "Nav_Details.Nav_EvaluationUser").ToList();
if (evaluationPlan.Count < 1)
return true;
List<T_PE_SAFETY_EVALUATION_RECORD> recordList = new List<T_PE_SAFETY_EVALUATION_RECORD>();
List<T_PE_SAFETY_EVALUATION_RECORD_DETAIL> recordDetailList = new List<T_PE_SAFETY_EVALUATION_RECORD_DETAIL>();
List<T_PE_SAFETY_EVALUATION_RECORD_USER> recordUserList = new List<T_PE_SAFETY_EVALUATION_RECORD_USER>();
List<T_PE_SAFETY_EVALUATION_RECORD_METHOD> recordMethodList = new List<T_PE_SAFETY_EVALUATION_RECORD_METHOD>();
List<T_FM_NOTIFICATION_TASK> notices = new List<T_FM_NOTIFICATION_TASK>();
newFilter.SelectField = new List<string> { "ID", "NAME" };
var userList = this.GetEntities<T_FM_USER>(t => !t.IS_DELETED && t.ENABLE_STATUS == 0, newFilter).ToList();
foreach (var item in evaluationPlan)
{
item.IS_RUN = DisableStatusEnum.;
if (item.Nav_Details != null && item.Nav_Details.Any())
{
List<Guid> userIds = new List<Guid>();
List<string> userNames = new List<string>();
var standardizedIds = item.Nav_Details.Select(t => t.STANDARDIZED_ID).Distinct().ToList();
var standardized = this.GetEntities<T_PE_STANDARDIZED_SCORE_IMPORT_DETAIL>(t => standardizedIds.Contains(t.PRIMARY_ELEMENTS_ID), new BaseFilter(filter.OrgId));
var group = 1;
foreach (var itemDetail in item.Nav_Details)
{
var firstDetail = item.Nav_Details.FirstOrDefault(t => t.ID == itemDetail.ID);
T_PE_SAFETY_EVALUATION_RECORD record = new T_PE_SAFETY_EVALUATION_RECORD();
record.ORG_ID = filter.OrgId;
record.EVALUATION_PLAN_ID = item.ID;
record.EVALUATION_PLAN_DETAIL_ID = itemDetail.ID;
record.STATUS = PFStandardStatus.Draft;
recordList.Add(record);
var evaluationItem = standardized.Where(t => t.PRIMARY_ELEMENTS_ID == itemDetail.STANDARDIZED_ID).ToList();
if (evaluationItem != null && evaluationItem.Any())
{
evaluationItem.ForEach(t =>
{
T_PE_SAFETY_EVALUATION_RECORD_DETAIL detail = new T_PE_SAFETY_EVALUATION_RECORD_DETAIL();
detail.ORG_ID = t.ORG_ID;
detail.PRODUCTION_UNIT_ID = item.PRODUCTION_UNIT_ID;
detail.SAFETY_EVALUATION_RECORD_ID = record.ID;
detail.PRIMARY_ELEMENTS_ID = t.PRIMARY_ELEMENTS_ID;
detail.SECOND_ELEMENTS_ID = t.SECOND_ELEMENTS_ID;
detail.THREE_ELEMENTS_ID = t.THREE_ELEMENTS_ID;
detail.EVALUATION_ITEM = t.EVALUATION_ITEM;
detail.CONTENTS = t.CONTENTS;
detail.STANDARDIZED_SCORE = t.STANDARDIZED_SCORE > 0 ? t.STANDARDIZED_SCORE : t.NON_STANDARDIZED_SCORE;
detail.NON_STANDARDIZED_SCORE = t.NON_STANDARDIZED_SCORE;
detail.RESULT_SCORE = t.STANDARDIZED_SCORE > 0 ? t.STANDARDIZED_SCORE : t.NON_STANDARDIZED_SCORE;
detail.EVALUATION_RESULT = PEEvaluationResultEnum.Conform;
detail.NUM = t.NUM;
detail.DESCRIPTION = t.DESCRIPTION;
recordDetailList.Add(detail);
if (firstDetail != null && firstDetail.Nav_EvaluationMethod != null && firstDetail.Nav_EvaluationMethod.Any())
{
firstDetail.Nav_EvaluationMethod.ForEach(t2 =>
{
T_PE_SAFETY_EVALUATION_RECORD_METHOD method = new T_PE_SAFETY_EVALUATION_RECORD_METHOD();
method.ORG_ID = detail.ORG_ID; method.SAFETY_EVALUATION_RECORD_DETAIL_ID = detail.ID;
method.METHOD_ID = t2.METHOD_ID;
recordMethodList.Add(method);
});
}
});
}
if (itemDetail.Nav_EvaluationUser != null && itemDetail.Nav_EvaluationUser.Any())
{
foreach (var userDetail in itemDetail.Nav_EvaluationUser)
{
T_PE_SAFETY_EVALUATION_RECORD_USER user = new T_PE_SAFETY_EVALUATION_RECORD_USER();
user.SAFETY_EVALUATION_RECORD_ID = record.ID;
user.ORG_ID = filter.OrgId;
user.USER_ID = userDetail.USER_ID;
user.DEAL_STATUS = FOUserShiftStatusEnum.;
user.GROUP_NO = group;
user.ROW_NO = userDetail.ROW_NO;
recordUserList.Add(user);
if (userDetail.ROW_NO == 1 && userDetail.USER_ID.HasValue)
{
//userIds.Add(userDetail.USER_ID.Value);
var userName = userList.FirstOrDefault(t => t.ID == userDetail.USER_ID.Value)?.NAME;
var notice = NotificationTaskService.InsertUserNoticeTaskModel("安全标准化内部评价记录表", record.ID, filter.OrgId, userDetail.USER_ID.Value, userName, item.START_TIME.Value,
item.END_TIME.Value, (int)FMNoticeTypeEnum., "PE029");
notices.Add(notice);
}
}
}
group++;
}
//userIds = userIds.Distinct().ToList();
//if (userIds != null && userIds.Any())
//{
// foreach (var user in userIds)
// {
// var userName = userList.FirstOrDefault(t => t.ID == user);
// userNames.Add(userName?.NAME);
// }
// //发消息
// var notice = NotificationTaskService.InsertUserNoticeTaskModels("安全标准化内部评价记录表", record.ID, filter.OrgId, userIds, userNames, DateTime.Now,
// DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "PE029");
// notices.AddRange(notice);
//}
}
}
if (notices != null && notices.Any())
{
//recordUserList = recordUserList.Distinct(t => new { t.SAFETY_EVALUATION_RECORD_ID, t.USER_ID }).ToList();
}
else
{
recordList = null;
recordDetailList = null;
recordUserList = null;
recordMethodList = null;
}
UnifiedCommit(() =>
{
if (evaluationPlan != null && evaluationPlan.Any())
BantchSaveEntityNoCommit(evaluationPlan);
if (recordList != null && recordList.Any())
BantchSaveEntityNoCommit(recordList);
if (recordDetailList != null && recordDetailList.Any())
BantchAddEntityNoCommit(recordDetailList);
if (recordUserList != null && recordUserList.Any())
BantchAddEntityNoCommit(recordUserList);
if (recordMethodList != null && recordMethodList.Any())
BantchAddEntityNoCommit(recordMethodList);
if (notices != null && notices.Any())
BantchAddEntityNoCommit(notices);
});
return true;
});
}
/// <summary>
/// 触发安全标准化内部评价计划表
/// </summary>
/// <returns></returns>
[HttpPost, Route("SafetyEvaluationRecordPlanSync")]
public JsonActionResult<bool> SafetyEvaluationRecordPlanSync([FromBody] KeywordFilter filter)
{
return SafeExecute<bool>(() =>
{
var dtNow = DateTime.Now;
var year = dtNow.Year;
var month = dtNow.Month;
var day = dtNow.Day;
var time = dtNow.TimeOfDay;
var week = dtNow.DayOfWeek;
List<T_FM_NOTIFICATION_TASK> sendNotices = new List<T_FM_NOTIFICATION_TASK>();
List<T_PE_SAFETY_EVALUATION_PLAN> monitorPlans = new List<T_PE_SAFETY_EVALUATION_PLAN>();
var newFilter = new BaseFilter(filter.OrgId);
newFilter.SelectField = new List<string> { "ID", "NAME" };
var userInfo = this.GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部负责人" && t.ENABLE_STATUS == 0, newFilter);
if (userInfo == null && filter.OrgId.ToString() == "3efd5276-632b-e379-9ff3-7a7546591fca")
{
userInfo = this.GetEntity<T_FM_USER>(t => t.Nav_ApproveRole != null && t.Nav_ApproveRole.NAME == "安环部安全员" && t.ENABLE_STATUS == 0);
}
if (userInfo != null)
{
bool isSend = false;
newFilter.SelectField = new List<string> { "PLANCHECKFREQUENCY", "MONTH", "DATA", "WEEKDATA" };
var timeSet = GetEntity<T_PT_TIME_SET>(i => i.SET_TYPE == PTSetTypeEnum.SafetyEvaluationPlan, newFilter);
if (timeSet != null)
{
switch (timeSet.PLANCHECKFREQUENCY)
{
//case BSPLANCHECKFREQUENCYEnum.OneTime:
case BSPLANCHECKFREQUENCYEnum.Year:
if (timeSet.MONTH == month && timeSet.DATA == day)
{
isSend = true;
}
break;
case BSPLANCHECKFREQUENCYEnum.HalfYear:
if ((timeSet.MONTH == month && timeSet.DATA == day) || ((timeSet.MONTH + 6) == month && (timeSet.DATA + 183) == day))
{
isSend = true;
}
break;
case BSPLANCHECKFREQUENCYEnum.Date:
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Week:
if (timeSet.WEEKDATA != null && (int)timeSet.WEEKDATA.Value == (int)week)
isSend = true;
break;
case BSPLANCHECKFREQUENCYEnum.Month:
if (timeSet.DATA == day)
{
isSend = true;
//if (month == 1)
// year = year - 1;
}
break;
case BSPLANCHECKFREQUENCYEnum.Quarter:
if (timeSet.MONTH == 1)
{
if ((month == 1 || month == 4 || month == 7 || month == 10) && timeSet.DATA == day)
isSend = true;
}
if (timeSet.MONTH == 2)
{
if ((month == 2 || month == 5 || month == 8 || month == 11) && timeSet.DATA == day)
isSend = true;
}
if (timeSet.MONTH == 3)
{
if ((month == 3 || month == 6 || month == 9 || month == 12) && timeSet.DATA == day)
isSend = true;
}
//if ((month == 1 && day == timeSet.DATA) || (month == 4 && day == timeSet.DATA) || (month == 7 && day == timeSet.DATA) || (month == 10 && day == timeSet.DATA))
//{
// isSend = true;
// if (month == 1 && day == timeSet.DATA)
// year = year - 1;
//}
break;
default:
break;
}
}
if (isSend)
{
if (!string.IsNullOrEmpty(filter.Parameter1))
{
if (DateTime.Now.Hour.ToString() == filter.Parameter1)
isSend = true;
else
isSend = false;
}
//newFilter.SelectField = new List<string> { "ID", "NAME" };
//var productUnit = this.GetEntities<T_PE_STANDARDIZED_SCORE_IMPORT>(t => t.PARENT_ID == null, newFilter).Distinct().ToList();
//if (productUnit != null && productUnit.Any())
//{
// foreach (var item in productUnit)
// {
// }
//}
var safe = this.GetEntity<T_PE_SAFETY_EVALUATION_PLAN>(t => t.CREATE_TIME.Value.Date == DateTime.Now.Date);
if (safe == null)
{
T_PE_SAFETY_EVALUATION_PLAN monitorPlan = new T_PE_SAFETY_EVALUATION_PLAN();
monitorPlan.ORG_ID = filter.GetOrgId();
monitorPlan.PRODUCTION_UNIT_ID = null;
monitorPlan.DEPARTMENT_ID = userInfo.DEPARTMENT_ID;
monitorPlan.STATUS = PFStandardStatus.Draft;
monitorPlan.YEAR = year.ToString();
monitorPlan.IS_RUN = DisableStatusEnum.;
monitorPlans.Add(monitorPlan);
T_FM_NOTIFICATION_TASK sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("安全标准化内部评价计划表", monitorPlan.ID, filter.GetOrgId(), userInfo.ID, userInfo.NAME, DateTime.Now, DateTime.Now.AddDays(30), (int)FMNoticeTypeEnum., "PE027");
sendNotices.Add(sendNotice);
}
}
}
UnifiedCommit(() =>
{
if (monitorPlans != null && monitorPlans.Any())
this.BantchSaveEntityNoCommit(monitorPlans);
if (sendNotices != null && sendNotices.Any())
this.BantchSaveEntityNoCommit(sendNotices);
});
return true;
});
}
}
}