2375 lines
		
	
	
		
			141 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			2375 lines
		
	
	
		
			141 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using APT.BaseData.Domain.Entities;
 | 
						||
using APT.BaseData.Domain.Entities.FM;
 | 
						||
using APT.BaseData.Domain.Enums;
 | 
						||
using APT.BaseData.Domain.Enums.PF;
 | 
						||
using APT.BaseData.Domain.IServices;
 | 
						||
using APT.BaseData.Domain.IServices.FM;
 | 
						||
using APT.Infrastructure.Core;
 | 
						||
using APT.MS.Domain.Entities.BS;
 | 
						||
using APT.MS.Domain.Entities.HM;
 | 
						||
using APT.MS.Domain.Entities.PF;
 | 
						||
using APT.MS.Domain.Entities.SC;
 | 
						||
using APT.MS.Domain.Enums;
 | 
						||
using APT.Utility;
 | 
						||
using APT.WebApi.Models;
 | 
						||
using Microsoft.AspNetCore.Mvc;
 | 
						||
using System;
 | 
						||
using System.Collections.Generic;
 | 
						||
using System.Linq;
 | 
						||
using System.Linq.Expressions;
 | 
						||
using System.Text;
 | 
						||
using System.Text.RegularExpressions;
 | 
						||
 | 
						||
namespace APT.PP.WebApi.Controllers.Api.PP
 | 
						||
{
 | 
						||
    [Route("api/PP/SC")]
 | 
						||
    [TypeFilter(typeof(CustomActionFilterAttribute))]
 | 
						||
    public partial class SCController : AuthorizeApiController<T_SC_MT_PLAN_SET>
 | 
						||
    {
 | 
						||
 | 
						||
        IFMNotificationTaskService NotificationTaskService { get; set; }
 | 
						||
        //IBSSafeCheckService SafeCheckService { get; set; }, IBSSafeCheckService safeCheckService
 | 
						||
        IFMUserService UserService { get; set; }
 | 
						||
        IPFSysLogService SysLogService { get; set; }
 | 
						||
        ISCMTMeetingService SCMTMeetingService { get; set; }
 | 
						||
        IFMSyncLogDetailService SyncLogDetailService { get; set; }
 | 
						||
        public SCController(IFMNotificationTaskService notificationTaskService, IPFSysLogService sysLogService, IFMUserService userService, ISCMTMeetingService scMTMeetingService, IFMSyncLogDetailService syncLogDetailService)
 | 
						||
        {
 | 
						||
            NotificationTaskService = notificationTaskService;
 | 
						||
            UserService = userService;
 | 
						||
            SysLogService = sysLogService;
 | 
						||
            SCMTMeetingService = scMTMeetingService;
 | 
						||
            SyncLogDetailService = syncLogDetailService;
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 判断跑批时间是否符合
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="RUNSETTIME"></param>
 | 
						||
        /// <param name="dtNow"></param>
 | 
						||
        /// <param name="minAdvance"></param>
 | 
						||
        /// <param name="minLaster"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        private bool ISTimeOK(DateTime? RUNSETTIME, DateTime dtNow, int minAdvance, int minLaster)
 | 
						||
        {
 | 
						||
            if (RUNSETTIME == null)
 | 
						||
            {
 | 
						||
                return false;
 | 
						||
            }
 | 
						||
 | 
						||
            if (RUNSETTIME != null)
 | 
						||
            {
 | 
						||
                if (minAdvance != 0 || minLaster != 0)
 | 
						||
                {
 | 
						||
                    //DateTime dtSetTime = Convert.ToDateTime(dtNow.ToString("yyyy") + RUNSETTIME.Value.ToString("-MM-dd HH:mm:ss"));
 | 
						||
                    DateTime dtSetTime = Convert.ToDateTime(dtNow.ToString("yyyy-MM-dd") + RUNSETTIME.Value.ToString(" HH:mm:ss"));
 | 
						||
                    if (minAdvance > 0 && minLaster > 0)
 | 
						||
                    {
 | 
						||
                        if (dtNow.AddMinutes(-1 * minAdvance) <= dtSetTime && dtSetTime <= dtNow.AddMinutes(minLaster))
 | 
						||
                        {
 | 
						||
                            return true;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    else if (minAdvance > 0)
 | 
						||
                    {
 | 
						||
                        if (dtNow.AddMinutes(-1 * minAdvance) <= dtSetTime && dtSetTime <= dtNow)
 | 
						||
                        {
 | 
						||
                            //如果设置时间小于当前时间  并且 设置使劲按大于 当前时间大于当前时间往前偏移分钟数
 | 
						||
                            return true;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        if (dtNow <= dtSetTime && dtSetTime <= dtNow.AddMinutes(minLaster))
 | 
						||
                        {
 | 
						||
                            //如果 设置时间大于当前时间 并且设置时间小于当前时间往后偏移分钟数
 | 
						||
                            return true;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                else
 | 
						||
                {
 | 
						||
                    if (RUNSETTIME.Value.ToString("HH:mm") == dtNow.ToString("HH:mm"))
 | 
						||
                    {
 | 
						||
                        return true;
 | 
						||
                    }
 | 
						||
                }
 | 
						||
            }
 | 
						||
            return false;
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 根据 会议召开计划
 | 
						||
        /// 给触发人 添加会议召开待办
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="filter"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        [HttpPost, Route("CreateMeetingPlanSet")]
 | 
						||
        public JsonActionResult<bool> CreatePreShiftMeeting([FromBody] KeywordFilter filter)
 | 
						||
        {
 | 
						||
            return SafeExecute<bool>(() =>
 | 
						||
            {
 | 
						||
                DateTime dtNow = DateTime.Now;
 | 
						||
                if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
                {
 | 
						||
                    try
 | 
						||
                    {
 | 
						||
                        //接收来自页面的参数
 | 
						||
                        DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
                        dtNow = deParm;
 | 
						||
                    }
 | 
						||
                    catch { }
 | 
						||
                }
 | 
						||
 | 
						||
                filter.Parameter1 = " ENABLE_STATUS = false ";
 | 
						||
                Expression<Func<T_SC_MT_PLAN_SET, bool>> expression = e => e.IS_DELETED == false && e.ENABLE_STATUS == 0;
 | 
						||
 | 
						||
                List<T_SC_MT_PLAN_SET> listPlanSet = this.GetOrderEntities<T_SC_MT_PLAN_SET>(expression, filter, new string[] { "Nav_ContentName" }).ToList();
 | 
						||
 | 
						||
                List<T_SC_MT_PLAN_SET> listPlanSetRund = new List<T_SC_MT_PLAN_SET>();
 | 
						||
 | 
						||
                if (listPlanSet.Count < 1)
 | 
						||
                    return true;//没找到审批信息
 | 
						||
 | 
						||
                T_FM_USER User = GetEntity<T_FM_USER>(e => e.CODE.StartsWith("admin") && e.ENABLE_STATUS == 0);
 | 
						||
                if (User == null)
 | 
						||
                {
 | 
						||
                    User = GetEntity<T_FM_USER>(e => e.ID == listPlanSet[0].CREATER_ID.Value && e.ENABLE_STATUS == 0);//随便取一个不影响信息
 | 
						||
                }
 | 
						||
                int min = 5;//按设置时间 可以提前5分钟执行跑批生成代办任务
 | 
						||
 | 
						||
                #region   获取时间符合的设置
 | 
						||
                List<int> listQuarter = new List<int> { 1, 4, 7, 10 };
 | 
						||
                //5 单次 每天10,  每周20,  每月30, 每季40,
 | 
						||
                for (int i = 0; i < listPlanSet.Count; i++)
 | 
						||
                {
 | 
						||
                    if (!ISTimeOK(listPlanSet[i].RUNSETTIME, dtNow, min, min))//设置时间往前后各偏移 5 分钟 判断跑批
 | 
						||
                    { continue; }
 | 
						||
 | 
						||
                    switch (listPlanSet[i].PLANCHECKFREQUENCY)
 | 
						||
                    {
 | 
						||
                        //case BSPLANCHECKFREQUENCYEnum.OneTime:
 | 
						||
                        case BSPLANCHECKFREQUENCYEnum.Year:
 | 
						||
                            #region    单次检查 时间对   月 日对才加入
 | 
						||
 | 
						||
                            if (!string.IsNullOrEmpty(listPlanSet[i].RUNDATA))//05-01,10-01
 | 
						||
                            {
 | 
						||
                                List<string> listMMdd = listPlanSet[i].RUNDATA.Split(",").ToList();
 | 
						||
                                if (listPlanSet[i].RUNDATA.Contains("-"))
 | 
						||
                                {
 | 
						||
                                    for (int j = 0; j < listMMdd.Count; j++)
 | 
						||
                                    {
 | 
						||
                                        try
 | 
						||
                                        {
 | 
						||
                                            if (!string.IsNullOrEmpty(listMMdd[j]) && (Convert.ToDateTime(dtNow.Year.ToString() + ("-") + listMMdd[j]) == Convert.ToDateTime(dtNow.ToString("yyyy-MM-dd")) || Convert.ToDateTime(dtNow.Year.ToString() + "-" + listMMdd[j]) == Convert.ToDateTime(dtNow.ToString("yyyy-M-d"))))
 | 
						||
                                            {
 | 
						||
                                                listPlanSetRund.Add(listPlanSet[i]);
 | 
						||
                                                break;
 | 
						||
                                            }
 | 
						||
                                        }
 | 
						||
                                        catch { }
 | 
						||
                                    }
 | 
						||
                                }
 | 
						||
                                else if (listPlanSet[i].RUNDATA.Contains("/"))
 | 
						||
                                {
 | 
						||
                                    for (int j = 0; j < listMMdd.Count; j++)
 | 
						||
                                    {
 | 
						||
                                        try
 | 
						||
                                        {
 | 
						||
                                            if (!string.IsNullOrEmpty(listMMdd[j]) && (Convert.ToDateTime(dtNow.Year.ToString("yyyy/") + listMMdd[j]) == Convert.ToDateTime(dtNow.ToString("yyyy/MM/dd")) || Convert.ToDateTime(dtNow.Year.ToString("yyyy/") + listMMdd[j]) == Convert.ToDateTime(dtNow.ToString("yyyy/M/d"))))
 | 
						||
                                            {
 | 
						||
                                                listPlanSetRund.Add(listPlanSet[i]);
 | 
						||
                                                break;
 | 
						||
                                            }
 | 
						||
                                        }
 | 
						||
                                        catch { }
 | 
						||
                                    }
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            #endregion
 | 
						||
                            break;
 | 
						||
                        case BSPLANCHECKFREQUENCYEnum.Date:
 | 
						||
                            //每日天执行 时间匹配就添加
 | 
						||
                            listPlanSetRund.Add(listPlanSet[i]);
 | 
						||
                            break;
 | 
						||
                        case BSPLANCHECKFREQUENCYEnum.Week:
 | 
						||
                            if (listPlanSet[i].WEEKDATA != null && (int)dtNow.DayOfWeek == (int)listPlanSet[i].WEEKDATA.Value)
 | 
						||
                            {
 | 
						||
                                //星期匹配   DateTime.Now.DayOfWeek Thursday    (int)DateTime.Now.DayOfWeek 4
 | 
						||
                                listPlanSetRund.Add(listPlanSet[i]);
 | 
						||
                            }
 | 
						||
                            break;
 | 
						||
                        case BSPLANCHECKFREQUENCYEnum.Month:
 | 
						||
                            if (listPlanSet[i].DATA != null && listPlanSet[i].DATA.Value == dtNow.Day)
 | 
						||
                            {
 | 
						||
                                //日匹配  (季度是季度第一月的某日 刚好也符合)
 | 
						||
                                listPlanSetRund.Add(listPlanSet[i]);
 | 
						||
                            }
 | 
						||
                            break;
 | 
						||
                        case BSPLANCHECKFREQUENCYEnum.Quarter:
 | 
						||
                            if (listPlanSet[i].DATA != null && listPlanSet[i].DATA.Value == dtNow.Day && listQuarter.Contains(dtNow.Month))
 | 
						||
                            {
 | 
						||
                                //日匹配  (季度是季度第一月的某日 刚好也符合)
 | 
						||
                                listPlanSetRund.Add(listPlanSet[i]);
 | 
						||
                            }
 | 
						||
                            break;
 | 
						||
                        default:
 | 
						||
                            break;
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
                #endregion
 | 
						||
 | 
						||
                if (listPlanSetRund.Count < 1)//未获取到数据 直接返回
 | 
						||
                    return true;
 | 
						||
 | 
						||
                #region    跑批添加数据前 
 | 
						||
 | 
						||
                DateTime dtFirst = dtNow.Date;
 | 
						||
                List<Guid> listPlansetId = listPlanSetRund.Select(e => e.ID).ToList();
 | 
						||
 | 
						||
                // 系统生成10  用户主动创建20   今天 生成的
 | 
						||
                //List<T_SC_MT_MEETING> listMeeting = this.GetOrderEntities<T_SC_MT_MEETING>(e => e.CREACTTYPE == CREACTTYPEEnum.System && e.CREATE_TIME >= dtFirst && e.CREATE_TIME <= dtFirst.AddDays(1) && listPlansetId.Contains(e.ID), filter).ToList();
 | 
						||
 | 
						||
                DateTime dtCheckMin = dtFirst.AddMinutes(-30);
 | 
						||
                List<T_SC_MT_MEETING> listMeeting = this.GetOrderEntities<T_SC_MT_MEETING>(e => e.CREACTTYPE == CREACTTYPEEnum.System && e.CREATE_TIME >= dtCheckMin && e.CREATE_TIME <= dtFirst.AddDays(1) && e.PLANSET_ID.HasValue && listPlansetId.Contains(e.PLANSET_ID.Value), null).ToList();
 | 
						||
 | 
						||
                Guid PLANSET_ID = Guid.Empty;
 | 
						||
                T_SC_MT_MEETING modelCheck = null;
 | 
						||
 | 
						||
                List<T_SC_MT_MEETING> listSafeCheckAdd = new List<T_SC_MT_MEETING>(); //需要插入数据库的安检记录
 | 
						||
                List<T_SC_MT_MEETING_CONTENT> listcont = new List<T_SC_MT_MEETING_CONTENT>();
 | 
						||
                List<T_FM_USER> listFMUserNotice = null;//每项设置的通知人员(中间表)
 | 
						||
                List<T_FM_DEPARTMENT> listDepartment = null;
 | 
						||
 | 
						||
                //KeywordFilter filterDepart = new KeywordFilter();
 | 
						||
                int DEPARTMENT_TYPE = 0;//部门类型 用于linq相接时存放 (中间值:防错)
 | 
						||
                DateTime ChcekDateTime = dtFirst;
 | 
						||
                DateTime dtTimeOut = DateTime.Now;
 | 
						||
 | 
						||
                T_PF_APPROVAL_ROLE modelRoleSafe = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("安环部"));
 | 
						||
                if (modelRoleSafe == null || modelRoleSafe.ID == new Guid())
 | 
						||
                {
 | 
						||
                    try
 | 
						||
                    {
 | 
						||
                        //没有找到安全员
 | 
						||
                        SysLogService.AddLog(listPlanSetRund[0].ORG_ID.Value, User.ID, PFSysLogTypeEnum.SafeChecker, "SC024", "未找到审批角色【安环部】", null, null);
 | 
						||
                        //return true;//没有找到安全员 没用往下继续执行的必要 
 | 
						||
                        // 班组给班长发送待办 需要继续执行
 | 
						||
                    }
 | 
						||
                    catch { }
 | 
						||
                }
 | 
						||
 | 
						||
                #endregion
 | 
						||
 | 
						||
                #region 按逐条设置 查询信息  添加数据
 | 
						||
                var listPlanSetID = listPlanSetRund.Select(e => e.ID);
 | 
						||
                var listPlanSetDep = GetEntities<T_SC_MT_PLAN_SET_DEPARTMENT>(e => listPlanSetID.Contains(e.PLAN_SET_ID), null, null);
 | 
						||
                IEnumerable<T_SC_MT_PLAN_SET_DEPARTMENT> IListPlanSetDep = null;
 | 
						||
                T_SC_MT_PLAN_SET_DEPARTMENT depTemp = null;
 | 
						||
                List<T_FM_DEPARTMENT> listDepAdd = new List<T_FM_DEPARTMENT>();
 | 
						||
                T_FM_DEPARTMENT depCheck = null;
 | 
						||
                bool isUserContent = false;
 | 
						||
                T_FM_SYNC_TASK task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
 | 
						||
                if (task != null)
 | 
						||
                {
 | 
						||
                    task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
 | 
						||
                    task.SYNC_PARAM = "";//清空参数
 | 
						||
                }
 | 
						||
                string FormCode = "";
 | 
						||
                List<T_FM_NOTIFICATION_TASK> listTask = null;//接收会议召开计划的待办
 | 
						||
                for (int i = 0; i < listPlanSetRund.Count; i++)
 | 
						||
                {
 | 
						||
                    listSafeCheckAdd = new List<T_SC_MT_MEETING>();
 | 
						||
                    listcont = new List<T_SC_MT_MEETING_CONTENT>();
 | 
						||
                    var noticeTitles = new List<string>();
 | 
						||
                    var noticeDataIds = new List<Guid>();
 | 
						||
                    var noticeUserIds = new List<Guid>();
 | 
						||
                    var noticeUserNames = new List<string>();
 | 
						||
 | 
						||
                    PLANSET_ID = listPlanSetRund[i].ID;
 | 
						||
                    modelCheck = listMeeting.FirstOrDefault(e => e.PLANSET_ID == PLANSET_ID);
 | 
						||
                    if (modelCheck != null)
 | 
						||
                    {
 | 
						||
                        //有添加会议通知 返回 查找下一个
 | 
						||
                        continue;
 | 
						||
                    }
 | 
						||
 | 
						||
                    listDepartment = new List<T_FM_DEPARTMENT>();
 | 
						||
 | 
						||
                    listFMUserNotice = new List<T_FM_USER>();
 | 
						||
                    List<DateTime> listEndTime = new List<DateTime>();
 | 
						||
                    #region    获取通知触发人员
 | 
						||
 | 
						||
                    if (listPlanSetRund[i].APPROVE_ROLE_ID.HasValue)
 | 
						||
                    {
 | 
						||
                        var roleUser = GetEntities<T_FM_USER>(e => e.APPROVE_ROLE_ID == listPlanSetRund[i].APPROVE_ROLE_ID && e.ENABLE_STATUS == 0, null, new string[] { "Nav_Department" });
 | 
						||
                        if (roleUser != null && roleUser.Any())
 | 
						||
                        {
 | 
						||
                            listFMUserNotice = roleUser.ToList();
 | 
						||
 | 
						||
                            IListPlanSetDep = listPlanSetDep.Where(e => e.PLAN_SET_ID == listPlanSetRund[i].ID);
 | 
						||
                            if (IListPlanSetDep != null && IListPlanSetDep.Any())
 | 
						||
                            {
 | 
						||
                                for (int k = 0; k < listFMUserNotice.Count; k++)
 | 
						||
                                {
 | 
						||
                                    isUserContent = false;
 | 
						||
                                    #region    判断 部门限制 //FMDepartmentType 部门 = 0, 车间 = 1, 班组 = 2, 公司 = 3
 | 
						||
 | 
						||
                                    switch (listFMUserNotice[k].Nav_Department.DEPARTMENT_TYPE)
 | 
						||
                                    {
 | 
						||
                                        case 0:
 | 
						||
                                            if (listFMUserNotice[k].DEPARTMENT_ID.HasValue)
 | 
						||
                                            {
 | 
						||
                                                depTemp = IListPlanSetDep.FirstOrDefault(e => e.DEPARTMENT_ID == listFMUserNotice[k].DEPARTMENT_ID.Value);
 | 
						||
                                                if (depTemp != null)
 | 
						||
                                                    isUserContent = true;
 | 
						||
                                            }
 | 
						||
                                            break;
 | 
						||
                                        case 1:
 | 
						||
                                            if (listFMUserNotice[k].Nav_Department.PARENT_ID.HasValue)
 | 
						||
                                            {
 | 
						||
                                                depTemp = IListPlanSetDep.FirstOrDefault(e => e.DEPARTMENT_ID == listFMUserNotice[k].Nav_Department.PARENT_ID.Value);
 | 
						||
                                                if (depTemp != null)
 | 
						||
                                                    isUserContent = true;
 | 
						||
                                            }
 | 
						||
                                            break;
 | 
						||
                                        case 2:
 | 
						||
                                            if (listFMUserNotice[k].Nav_Department.PARENT_ID.HasValue)
 | 
						||
                                            {
 | 
						||
                                                depCheck = listDepAdd.FirstOrDefault(e => e.ID == listFMUserNotice[k].Nav_Department.PARENT_ID.Value);
 | 
						||
                                                if (depCheck == null)
 | 
						||
                                                {
 | 
						||
                                                    depCheck = GetEntity<T_FM_DEPARTMENT>(listFMUserNotice[k].Nav_Department.PARENT_ID.Value);
 | 
						||
                                                    listDepAdd.Add(depCheck);
 | 
						||
                                                }
 | 
						||
                                                if (depCheck != null)
 | 
						||
                                                {
 | 
						||
                                                    depTemp = IListPlanSetDep.FirstOrDefault(e => e.DEPARTMENT_ID == depCheck.PARENT_ID.Value);
 | 
						||
                                                    if (depTemp != null)
 | 
						||
                                                        isUserContent = true;
 | 
						||
                                                }
 | 
						||
                                            }
 | 
						||
                                            break;
 | 
						||
                                        case 3:
 | 
						||
                                            isUserContent = true;
 | 
						||
                                            break;
 | 
						||
                                        default:
 | 
						||
                                            break;
 | 
						||
                                    }
 | 
						||
 | 
						||
                                    #endregion
 | 
						||
                                    if (isUserContent)
 | 
						||
                                        continue;
 | 
						||
 | 
						||
                                    listFMUserNotice.Remove(listFMUserNotice[k]);
 | 
						||
                                    k--;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
 | 
						||
                            for (int k = 0; k < listFMUserNotice.Count; k++)
 | 
						||
                            {
 | 
						||
                                listDepartment.Add(listFMUserNotice[k].Nav_Department);
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        //标准化创建小组组长  看看怎么取值
 | 
						||
                    }
 | 
						||
 | 
						||
                    if (listFMUserNotice.Count < 1)
 | 
						||
                    {
 | 
						||
                        //没有找到通知人员信息
 | 
						||
                        continue;
 | 
						||
                    }
 | 
						||
 | 
						||
                    #endregion
 | 
						||
                    FormCode = (listPlanSetRund[i].MEETINGTYPE == SCMEETINGTYPE.BasicSecurity || listPlanSetRund[i].MEETINGTYPE == SCMEETINGTYPE.SafetyBoard) ? "SC028" : "SC032";
 | 
						||
                    for (int j = 0; j < listFMUserNotice.Count; j++)
 | 
						||
                    {
 | 
						||
                        //添加代办 
 | 
						||
                        T_SC_MT_MEETING modelRun = new T_SC_MT_MEETING();
 | 
						||
                        modelRun.ID = Guid.NewGuid();
 | 
						||
                        modelRun.ORG_ID = filter.GetOrgId();
 | 
						||
                        modelRun.NAME = listPlanSetRund[i]?.Nav_ContentName?.NAME;
 | 
						||
                        modelRun.CODE = "HY" + dtNow.ToString("yyyyMMddHH") + i.ToString() + j.ToString();//mmss 因为审批流 CODE 长度20 减少长度
 | 
						||
                        modelRun.CREATER_ID = listFMUserNotice[j].ID;//安全检查的创建人 就是通知人
 | 
						||
                        modelRun.MEETINGTYPE = listPlanSetRund[i].MEETINGTYPE;
 | 
						||
                        modelRun.PLANSET_ID = listPlanSetRund[i].ID;
 | 
						||
                        modelRun.CREACTTYPE = CREACTTYPEEnum.System;//系统生成
 | 
						||
                        modelRun.STATUS = PFStandardStatus.Draft;
 | 
						||
                        modelRun.USER_ID_ORIGINATOR = listFMUserNotice[j].ID;//制表人
 | 
						||
                        modelRun.LEVELVALUE = listDepartment[j].DEPARTMENT_TYPE;
 | 
						||
                        if (modelRun.MEETINGTYPE == SCMEETINGTYPE.SafetyBoard)
 | 
						||
                        {
 | 
						||
                            modelRun.LEVELVALUE = (int)FMDepartmentType.公司;
 | 
						||
                        }
 | 
						||
                        modelRun.DEPARTMENT_ID = listDepartment[j].ID;//检查部门(公司/部门/车间/班组 ID)
 | 
						||
                        modelRun.CREATE_TIME = dtNow;
 | 
						||
                        //会议内容
 | 
						||
                        if (listPlanSetRund[i].CONTENTNAME_ID.HasValue)
 | 
						||
                        {
 | 
						||
                            listcont.Add(new T_SC_MT_MEETING_CONTENT()
 | 
						||
                            {
 | 
						||
                                ID = Guid.NewGuid(),
 | 
						||
                                ORG_ID = modelRun.ORG_ID,
 | 
						||
                                MEETING_ID = modelRun.ID,
 | 
						||
                                CONTENTNAME_ID = listPlanSetRund[i].CONTENTNAME_ID.Value//变成非必填了
 | 
						||
                            });
 | 
						||
                        }
 | 
						||
 | 
						||
                        listSafeCheckAdd.Add(modelRun);
 | 
						||
                        noticeDataIds.Add(modelRun.ID);
 | 
						||
                        noticeUserIds.Add(listFMUserNotice[j].ID);
 | 
						||
                        noticeUserNames.Add(listFMUserNotice[j].NAME);
 | 
						||
 | 
						||
                        //请召开+“会议内容”+会议
 | 
						||
                        //手动发起
 | 
						||
                        //在应急模块中的具体表单中已说明
 | 
						||
                        if (modelRun.MEETINGTYPE == SCMEETINGTYPE.BasicSecurity || modelRun.MEETINGTYPE == SCMEETINGTYPE.SafetyBoard)
 | 
						||
                        {
 | 
						||
                            noticeTitles.Add("请召开" + modelRun.MEETINGTYPE.GetDescription());
 | 
						||
                        }
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            noticeTitles.Add("请召开" + modelRun.MEETINGTYPE.GetDescription() + "-" + listPlanSetRund[i]?.Nav_ContentName?.NAME + "会议");
 | 
						||
                            if (listPlanSetRund[i]?.Nav_ContentName?.NAME == "潜在紧急事件讨论")
 | 
						||
                            {
 | 
						||
                                modelRun.CREACTTYPE = CREACTTYPEEnum.ToCM018;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    if (noticeTitles.Count > 0)
 | 
						||
                    {
 | 
						||
                        listTask = NotificationTaskService.InsertUserNoticeTaskModels(noticeTitles[0], noticeDataIds, filter.OrgId, noticeUserIds, noticeUserNames, DateTime.Now, 0, FormCode, FMTASKTYPE.MT_PLAN_Make, (int)listPlanSetRund[i].PLANCHECKFREQUENCY);
 | 
						||
                        this.UnifiedCommit(() =>
 | 
						||
                        {
 | 
						||
                            if (listSafeCheckAdd != null && listSafeCheckAdd.Any())
 | 
						||
                                BantchAddEntityNoCommit(listSafeCheckAdd);
 | 
						||
                            if (listcont != null && listcont.Any())
 | 
						||
                                BantchAddEntityNoCommit(listcont);
 | 
						||
                            if (task != null)
 | 
						||
                                UpdateEntityNoCommit(task);
 | 
						||
                            if (listTask != null && listTask.Any())
 | 
						||
                                this.BantchAddEntityNoCommit(listTask);
 | 
						||
                        });
 | 
						||
 | 
						||
                        int Count = ((listSafeCheckAdd != null && listSafeCheckAdd.Any()) ? listSafeCheckAdd.Count : 0) + ((listcont != null && listcont.Any()) ? listcont.Count : 0) + ((listTask != null && listTask.Any()) ? listTask.Count : 0);
 | 
						||
                        SyncLogDetailService.InsertSyncLogDetail(HttpContext.Items, HttpContext.TraceIdentifier, filter.OrgId, Count, filter.Parameter1, SyncLogType.BSCreateCheckPlanSet);
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
                #endregion
 | 
						||
 | 
						||
                return true;
 | 
						||
            });
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 会议开始
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="filter"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        [HttpPost, Route("MeetingBegin")]
 | 
						||
        public JsonActionResult<bool> MeetingBegin([FromBody] KeywordFilter filter)
 | 
						||
        {
 | 
						||
            return SafeExecute<bool>(() =>
 | 
						||
            {
 | 
						||
                DateTime dtNow = DateTime.Now;
 | 
						||
                if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
                {
 | 
						||
                    try
 | 
						||
                    {
 | 
						||
                        //接收来自页面的参数
 | 
						||
                        DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
                        dtNow = deParm;
 | 
						||
                    }
 | 
						||
                    catch { }
 | 
						||
                }
 | 
						||
 | 
						||
                //查找符合条件的会议信息   今天 已经审批过  开始时间小于当前时间 的会议
 | 
						||
                var listMeeting = GetEntities<T_SC_MT_MEETING>(e => !e.ISBEGIN && (e.STATUS == PFStandardStatus.Approving || e.STATUS == PFStandardStatus.Archived) && e.BEGIN_TIME.HasValue && e.BEGIN_TIME.Value.Date == dtNow.Date && e.BEGIN_TIME <= dtNow && !e.IS_DELETED && !e.ISCANCEL, null, new string[] { "Nav_ListMeetingContent.Nav_ContentName.Nav_ListContent.Nav_ListContentDeal" });//"Nav_ListPAll.Nav_User" => Nav_ListPAll, "Nav_ListPAll"  "Nav_ListPReView", "Nav_UserRecorder", 
 | 
						||
                //IS_DELETED 取消
 | 
						||
 | 
						||
                if (listMeeting == null || !listMeeting.Any())
 | 
						||
                {
 | 
						||
                    //没有符合条件的会议
 | 
						||
                    return true;
 | 
						||
                }
 | 
						||
                List<T_FM_NOTIFICATION_TASK> listTask = new List<T_FM_NOTIFICATION_TASK>();
 | 
						||
                List<T_SC_MT_MEETING_MINUTES> listMeetMinutes = new List<T_SC_MT_MEETING_MINUTES>();
 | 
						||
                List<T_SC_MT_MEETING_PALL> listAllChange = new List<T_SC_MT_MEETING_PALL>();
 | 
						||
                List<T_SC_MT_MINUTES_PREVIEW> listMeetMinutesPreview = new List<T_SC_MT_MINUTES_PREVIEW>();
 | 
						||
                DateTime dtOperate = DateTime.Now; //实际时间 不随传参改变
 | 
						||
                int NoticeNotDeal = (int)FMNoticeStatusEnum.未处理;
 | 
						||
                List<T_FM_NOTIFICATION_TASK> listTaskEnd = new List<T_FM_NOTIFICATION_TASK>();
 | 
						||
 | 
						||
 | 
						||
                List<T_SC_MT_MEETING_PJOIN> listJoin = new List<T_SC_MT_MEETING_PJOIN>();//参会
 | 
						||
                List<T_SC_MT_MEETING_PASKFORLEAVE> listAskLevel = new List<T_SC_MT_MEETING_PASKFORLEAVE>();//请假
 | 
						||
                List<T_SC_MT_MEETING_MINUTES_CONTENT> listMinutesContent = new List<T_SC_MT_MEETING_MINUTES_CONTENT>();
 | 
						||
                List<T_SC_MT_MEETING_MINUTES_CONTENT_DEAL> listMinutesContentDeal = new List<T_SC_MT_MEETING_MINUTES_CONTENT_DEAL>();
 | 
						||
 | 
						||
                //跑批 会议开始时 1、给 记录人 发送 会议纪要 待办  2、判断 参会人员 的状态   (未完成 默认参会)
 | 
						||
                foreach (var item in listMeeting)
 | 
						||
                {
 | 
						||
                    item.ISBEGIN = true;//修改是否开始
 | 
						||
 | 
						||
                    T_SC_MT_MEETING_MINUTES meetMinutes = new T_SC_MT_MEETING_MINUTES();
 | 
						||
                    meetMinutes.MEETINGTYPE = item.MEETINGTYPE;
 | 
						||
                    meetMinutes.ID = Guid.NewGuid();
 | 
						||
                    meetMinutes.MEETING_ID = item.ID;
 | 
						||
                    meetMinutes.STATUS = PFStandardStatus.Draft;
 | 
						||
                    meetMinutes.CREATER_ID = item.USER_ID_RECORDER;
 | 
						||
                    meetMinutes.CREATE_TIME = dtOperate;
 | 
						||
                    meetMinutes.ORG_ID = item.ORG_ID;
 | 
						||
                    meetMinutes.DEPARTMENT_ID = item.DEPARTMENT_ID;
 | 
						||
                    listMeetMinutes.Add(meetMinutes);
 | 
						||
                    //给记录人 添加待办
 | 
						||
 | 
						||
                    //判断有几个题目 
 | 
						||
                    foreach (var itemTitle in item.Nav_ListMeetingContent)
 | 
						||
                    {
 | 
						||
                        if (itemTitle.Nav_ContentName.Nav_ListContent == null || !itemTitle.Nav_ContentName.Nav_ListContent.Any())
 | 
						||
                        {
 | 
						||
                            continue;
 | 
						||
                        }
 | 
						||
                        foreach (var itemNAME in itemTitle.Nav_ContentName.Nav_ListContent)
 | 
						||
                        {
 | 
						||
                            //itemNAME.TITLE
 | 
						||
                            T_SC_MT_MEETING_MINUTES_CONTENT modelContent = new T_SC_MT_MEETING_MINUTES_CONTENT();
 | 
						||
                            modelContent.ID = Guid.NewGuid();
 | 
						||
                            modelContent.ORG_ID = item.ORG_ID;
 | 
						||
                            modelContent.MEETING_MINUTES_ID = meetMinutes.ID;
 | 
						||
                            modelContent.CONTENT_ID = itemNAME.ID;
 | 
						||
                            modelContent.CREATER_ID = item.USER_ID_RECORDER;
 | 
						||
                            modelContent.CREATE_TIME = dtOperate;
 | 
						||
                            listMinutesContent.Add(modelContent);
 | 
						||
                            if (itemNAME.Nav_ListContentDeal == null || !itemNAME.Nav_ListContentDeal.Any())
 | 
						||
                            {
 | 
						||
                                continue;
 | 
						||
                            }
 | 
						||
 | 
						||
                            foreach (var itemDetail in itemNAME.Nav_ListContentDeal)
 | 
						||
                            {
 | 
						||
                                //选项内容
 | 
						||
                                //itemDetail.CONTENTDETAIL
 | 
						||
                                T_SC_MT_MEETING_MINUTES_CONTENT_DEAL modelContentDetail = new T_SC_MT_MEETING_MINUTES_CONTENT_DEAL();
 | 
						||
                                modelContentDetail.ID = Guid.NewGuid();
 | 
						||
                                modelContentDetail.ORG_ID = item.ORG_ID;
 | 
						||
                                modelContentDetail.CONTENT_ID = modelContent.ID;
 | 
						||
                                modelContentDetail.CONTENT_DEAL_ID = itemDetail.ID;
 | 
						||
                                modelContentDetail.ISCHECK = false;
 | 
						||
                                modelContentDetail.GETPOINT = 0;
 | 
						||
                                modelContentDetail.CREATER_ID = item.USER_ID_RECORDER;
 | 
						||
                                modelContentDetail.CREATE_TIME = dtOperate;
 | 
						||
                                listMinutesContentDeal.Add(modelContentDetail);
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    //SC034 普通会议纪要编辑
 | 
						||
                    //SC030 安委会纪要编辑
 | 
						||
                    var Nav_UserRecorder = GetEntity<T_FM_USER>(e => e.ID == item.USER_ID_RECORDER && e.ENABLE_STATUS == 0);
 | 
						||
 | 
						||
                    var taskAdd = NotificationTaskService.InsertUserNoticeTaskModel(item.MEETINGTYPE.GetDescription() + "会议纪要", meetMinutes.ID, meetMinutes.ORG_ID, item.USER_ID_RECORDER.Value, Nav_UserRecorder.NAME, DateTime.Now, (int)FMNoticeTypeEnum.消息, (int)item.MEETINGTYPE >= 40 ? "SC030" : "SC034", FMTASKTYPE.MT_MINUTES);
 | 
						||
                    listTask.Add(taskAdd);
 | 
						||
 | 
						||
                    var Nav_ListPAll = GetEntities<T_SC_MT_MEETING_PALL>(e => e.MEETING_ID == item.ID, null, null);
 | 
						||
                    var Nav_ListPReView = GetEntities<T_SC_MT_MEETING_PREVIEW>(e => e.MEETING_ID == item.ID, null, null);
 | 
						||
 | 
						||
                    if (Nav_ListPAll != null && Nav_ListPAll.Any())
 | 
						||
                    {
 | 
						||
                        foreach (var itemAll in Nav_ListPAll)
 | 
						||
                        {
 | 
						||
                            if (itemAll.JOINRESULT == null)//参会情况未反馈
 | 
						||
                            {
 | 
						||
                                //如果未反馈  直接 修改状态为未完成  默认参加会议
 | 
						||
                                itemAll.JOINRESULT = JoinTaskResult.UnCheck;//系统设置未完成
 | 
						||
                                                                            //itemAll.PERSONTYPE = SCMEETINGPERSONTYPE.JOIN; //未反馈的默认参会
 | 
						||
                                listAllChange.Add(itemAll);
 | 
						||
                            }
 | 
						||
 | 
						||
                            if (itemAll.PERSONNATURE == PersonNature.HOST || itemAll.PERSONNATURE == PersonNature.RECORDER)
 | 
						||
                            {
 | 
						||
                                //如果是主持人或者 记录人 不加信息
 | 
						||
                                continue;
 | 
						||
                            }
 | 
						||
                            switch (itemAll.JOINRESULT)
 | 
						||
                            {
 | 
						||
                                case JoinTaskResult.Join:
 | 
						||
                                case JoinTaskResult.UnCheck:
 | 
						||
                                    //参加 未完成 默认 参会
 | 
						||
                                    T_SC_MT_MEETING_PJOIN join = new T_SC_MT_MEETING_PJOIN();
 | 
						||
                                    join.ID = Guid.NewGuid();
 | 
						||
                                    join.MEETING_MINUTES_ID = meetMinutes.ID;
 | 
						||
 | 
						||
 | 
						||
                                    if (itemAll.PERSONTYPE == SCMEETINGPERSONTYPE.ALL || itemAll.PERSONTYPE == SCMEETINGPERSONTYPE.JOIN)// || itemAll.PERSONTYPE == SCMEETINGPERSONTYPE.JOIN 应该不要
 | 
						||
                                    {
 | 
						||
                                        if (Nav_ListPReView != null && Nav_ListPReView.Any())
 | 
						||
                                        {
 | 
						||
                                            var rep = Nav_ListPReView.Where(e => e.USER_ID == itemAll.USER_ID);
 | 
						||
                                            if (rep != null && rep.Any())
 | 
						||
                                            {
 | 
						||
                                                join.PERSONTYPE = SCMEETINGPERSONTYPE.REVIEW;
 | 
						||
                                            }
 | 
						||
                                            else
 | 
						||
                                            {
 | 
						||
                                                join.PERSONTYPE = SCMEETINGPERSONTYPE.JOIN;
 | 
						||
                                            }
 | 
						||
                                        }
 | 
						||
                                        else
 | 
						||
                                        {
 | 
						||
                                            join.PERSONTYPE = SCMEETINGPERSONTYPE.JOIN;
 | 
						||
                                        }
 | 
						||
                                    }
 | 
						||
                                    else if (itemAll.PERSONTYPE == SCMEETINGPERSONTYPE.REVIEW)
 | 
						||
                                    {
 | 
						||
                                        join.PERSONTYPE = SCMEETINGPERSONTYPE.REVIEW;
 | 
						||
                                    }
 | 
						||
                                    join.USER_ID = itemAll.USER_ID;
 | 
						||
                                    join.IS_DELETED = false;
 | 
						||
                                    join.ORG_ID = itemAll.ORG_ID;
 | 
						||
                                    join.ISRECORDRED = false;
 | 
						||
                                    listJoin.Add(join);
 | 
						||
                                    break;
 | 
						||
                                case JoinTaskResult.AskForLeave:
 | 
						||
                                    //请假
 | 
						||
                                    T_SC_MT_MEETING_PASKFORLEAVE asklevel = new T_SC_MT_MEETING_PASKFORLEAVE();
 | 
						||
                                    asklevel.ID = Guid.NewGuid();
 | 
						||
                                    asklevel.MEETING_MINUTES_ID = meetMinutes.ID;
 | 
						||
                                    asklevel.PERSONTYPE = SCMEETINGPERSONTYPE.JOIN;
 | 
						||
                                    asklevel.USER_ID = itemAll.USER_ID;
 | 
						||
                                    asklevel.IS_DELETED = false;
 | 
						||
                                    asklevel.ORG_ID = itemAll.ORG_ID;
 | 
						||
                                    listAskLevel.Add(asklevel);
 | 
						||
                                    break;
 | 
						||
                                default:
 | 
						||
                                    break;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    //item.Nav_ListPAll = null; 这样会把ID清空 
 | 
						||
 | 
						||
                    var thisNotDeal = GetEntities<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_FORMCODE == "SC028_SHOWPRINT" && e.SOURCE_DATA_ID == item.ID && e.NOTICE_STATUS == NoticeNotDeal, null, null);//这边应该不会有重复数据  (这个会议 未处理的 待办)
 | 
						||
 | 
						||
                    if (thisNotDeal != null && thisNotDeal.Any())
 | 
						||
                    {
 | 
						||
                        listTaskEnd.AddRange(thisNotDeal);
 | 
						||
                    }
 | 
						||
 | 
						||
                    if (Nav_ListPReView != null && Nav_ListPReView.Any())
 | 
						||
                    {
 | 
						||
                        //评审 人员
 | 
						||
                        foreach (var itemP in Nav_ListPReView)
 | 
						||
                        {
 | 
						||
                            listMeetMinutesPreview.Add(new T_SC_MT_MINUTES_PREVIEW()
 | 
						||
                            {
 | 
						||
                                ID = Guid.NewGuid(),
 | 
						||
                                ORG_ID = itemP.ORG_ID,
 | 
						||
                                MEETING_MINUTES_ID = meetMinutes.ID,
 | 
						||
                                PERSONTYPE = SCMEETINGPERSONTYPE.REVIEW,
 | 
						||
                                USER_ID = itemP.USER_ID,
 | 
						||
                                ISRECORDRED = false
 | 
						||
                            });
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
                //对未处理的待办 做系统超期处理
 | 
						||
                if (listTaskEnd != null && listTaskEnd.Count > 0)
 | 
						||
                {
 | 
						||
                    foreach (var item in listTaskEnd)
 | 
						||
                    {
 | 
						||
                        item.NOTICE_STATUS = (int)FMNoticeStatusEnum.超期办理;
 | 
						||
                        item.MODIFY_TIME = dtOperate;
 | 
						||
                    }
 | 
						||
                }
 | 
						||
 | 
						||
                T_FM_SYNC_TASK task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
 | 
						||
                if (task != null)
 | 
						||
                {
 | 
						||
                    task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
 | 
						||
                    task.SYNC_PARAM = "";//清空参数
 | 
						||
                }
 | 
						||
                foreach (var item in listMeeting)
 | 
						||
                {
 | 
						||
                    if (item.Nav_ListMeetingContent != null && item.Nav_ListMeetingContent.Any())
 | 
						||
                    {
 | 
						||
                        foreach (var itemT in item.Nav_ListMeetingContent)
 | 
						||
                        {
 | 
						||
                            itemT.Nav_ContentName = null;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                this.UnifiedCommit(() =>
 | 
						||
                {
 | 
						||
                    if (listMeeting != null && listMeeting.Any()) //会议状态【是否开始】修改
 | 
						||
                        BantchUpdateEntityNoCommit(listMeeting);
 | 
						||
                    if (listMeetMinutes != null && listMeetMinutes.Any()) //添加会议纪要
 | 
						||
                        BantchSaveEntityNoCommit(listMeetMinutes);
 | 
						||
                    if (listJoin != null && listJoin.Any()) //参会人员
 | 
						||
                        BantchSaveEntityNoCommit(listJoin);
 | 
						||
                    if (listAskLevel != null && listAskLevel.Any()) //请假人员
 | 
						||
                        BantchSaveEntityNoCommit(listAskLevel);
 | 
						||
                    if (listTask != null && listTask.Any()) //给记录人发送会议纪要待办
 | 
						||
                        BantchSaveEntityNoCommit(listTask);
 | 
						||
                    if (listAllChange != null && listAllChange.Any()) //参会人员未反馈 状态修改
 | 
						||
                        BantchUpdateEntityNoCommit(listAllChange);
 | 
						||
                    if (listTaskEnd != null && listTaskEnd.Count > 0) //未完成对应待办处理
 | 
						||
                        BantchUpdateEntityNoCommit(listTaskEnd);
 | 
						||
                    if (listMinutesContent != null && listMinutesContent.Any()) //会议意见
 | 
						||
                        BantchSaveEntityNoCommit(listMinutesContent);
 | 
						||
                    if (listMinutesContentDeal != null && listMinutesContentDeal.Any()) //会议意见详情
 | 
						||
                        BantchSaveEntityNoCommit(listMinutesContentDeal);
 | 
						||
                    if (listMeetMinutesPreview != null && listMeetMinutesPreview.Count > 0)//审批人员
 | 
						||
                        BantchSaveEntityNoCommit(listMeetMinutesPreview);
 | 
						||
                    if (task != null)
 | 
						||
                        UpdateEntityNoCommit(task);
 | 
						||
                });
 | 
						||
 | 
						||
                int Count = ((listMeetMinutes != null && listMeetMinutes.Any()) ? listMeetMinutes.Count : 0) + ((listJoin != null && listJoin.Any()) ? listJoin.Count : 0) + ((listAskLevel != null && listAskLevel.Any()) ? listAskLevel.Count : 0) + ((listTask != null && listTask.Any()) ? listTask.Count : 0) + ((listAllChange != null && listAllChange.Any()) ? listAllChange.Count : 0) + ((listTaskEnd != null && listTaskEnd.Any()) ? listTaskEnd.Count : 0) + ((listMinutesContent != null && listMinutesContent.Any()) ? listMinutesContent.Count : 0) + ((listMinutesContentDeal != null && listMinutesContentDeal.Any()) ? listMinutesContentDeal.Count : 0) + ((listMeetMinutesPreview != null && listMeetMinutesPreview.Any()) ? listMeetMinutesPreview.Count : 0);
 | 
						||
                SyncLogDetailService.InsertSyncLogDetail(HttpContext.Items, HttpContext.TraceIdentifier, filter.OrgId, Count, filter.Parameter1, SyncLogType.BSCreateCheckPlanSet);
 | 
						||
 | 
						||
                return true;
 | 
						||
            });
 | 
						||
        }
 | 
						||
 | 
						||
        ///// <summary>
 | 
						||
        ///// 会议结束 链接到别的模块
 | 
						||
        ///// </summary>
 | 
						||
        ///// <param name="filter"></param>
 | 
						||
        ///// <returns></returns>
 | 
						||
        //[HttpPost, Route("MeetingEndToOther")]
 | 
						||
        //public JsonActionResult<bool> MeetingEndToOther([FromBody] KeywordFilter filter)
 | 
						||
        //{
 | 
						||
        //    return SafeExecute<bool>(() =>
 | 
						||
        //    {
 | 
						||
        //        DateTime dtNow = DateTime.Now;
 | 
						||
        //        if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
        //        {
 | 
						||
        //            try
 | 
						||
        //            {
 | 
						||
        //                //接收来自页面的参数
 | 
						||
        //                DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
        //                dtNow = deParm;
 | 
						||
        //            }
 | 
						||
        //            catch { }
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        var listMtEnd = GetEntities<T_SC_MT_MEETING_END>(e => !e.IS_DELETED && !e.ISEND && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Date <= dtNow.Date, null, null);
 | 
						||
        //        if (listMtEnd == null && !listMtEnd.Any())
 | 
						||
        //        {
 | 
						||
        //            return true;
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        var listMTID = listMtEnd.Select(e => e.MEETING_ID);
 | 
						||
        //        var listMT = GetEntities<T_SC_MT_MEETING>(e => !e.IS_DELETED && listMTID.Contains(e.ID), null, null);
 | 
						||
        //        if (listMT == null || !listMT.Any())
 | 
						||
        //        {
 | 
						||
        //            return true;
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        listMT = listMT.ToList();
 | 
						||
 | 
						||
        //        List<T_FM_NOTIFICATION_TASK> listTaskSend = null;//需要添加的所有待办
 | 
						||
        //        T_FM_USER userSafeMaster = null; //安环部负责人
 | 
						||
 | 
						||
        //        T_FM_SYNC_TASK taskSync = null;
 | 
						||
        //        #region     各处理逻辑  代码块区分 不直接 return 因为有数据要处理
 | 
						||
 | 
						||
        //        //数据挨个判断处理
 | 
						||
        //        listMtEnd.ForEach(e =>
 | 
						||
        //        {
 | 
						||
        //            e.RUN_COUNT++;
 | 
						||
        //            e.ISEND = true;
 | 
						||
        //            e.MODIFY_TIME = DateTime.Now;
 | 
						||
        //        });
 | 
						||
 | 
						||
 | 
						||
 | 
						||
        //        #region     3、CM 潜在紧急事件讨论 
 | 
						||
 | 
						||
        //        var listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToCM018);
 | 
						||
        //        if (listMTFA != null && listMTFA.Any())
 | 
						||
        //        {
 | 
						||
        //            var userIDs = listMTFA.Where(e => e.USER_ID_RECORDER.HasValue && !e.ISCANCEL && !e.IS_DELETED).Select(e => e.USER_ID_RECORDER.Value);
 | 
						||
        //            if (userIDs != null && userIDs.Any())
 | 
						||
        //            {
 | 
						||
        //                var listUser = GetEntities<T_FM_USER>(e => userIDs.Contains(e.ID), null);
 | 
						||
        //                if (listTaskSend == null)
 | 
						||
        //                    listTaskSend = new List<T_FM_NOTIFICATION_TASK>();
 | 
						||
        //                foreach (var item in listUser)
 | 
						||
        //                {
 | 
						||
        //                    listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("潜在紧急事件", Guid.Empty, filter.OrgId, item.ID, item.NAME, DateTime.Now, 0, "CM018", FMTASKTYPE.Default));
 | 
						||
        //                }
 | 
						||
        //            }
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        #endregion
 | 
						||
 | 
						||
 | 
						||
        //        #endregion
 | 
						||
 | 
						||
        //        taskSync = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);//跑批待办
 | 
						||
        //        if (taskSync.SYNC_PARAM != null)
 | 
						||
        //        {
 | 
						||
        //            taskSync.SYNC_PARAM = "";
 | 
						||
        //        }
 | 
						||
        //        taskSync.TASK_END_TIME = DateTime.Now;
 | 
						||
        //        taskSync.UPDATE_SUCCES_TIME = DateTime.Now;
 | 
						||
 | 
						||
        //        this.UnifiedCommit(() =>
 | 
						||
        //        {
 | 
						||
        //            if (taskSync != null) //跑批信息
 | 
						||
        //                UpdateEntityNoCommit(taskSync);
 | 
						||
        //            BantchUpdateEntityNoCommit(listMtEnd);
 | 
						||
 | 
						||
        //            if (listTaskSend != null && listTaskSend.Any()) //添加待办 公共
 | 
						||
        //                BantchSaveEntityNoCommit(listTaskSend);
 | 
						||
        //        });
 | 
						||
 | 
						||
        //        int Count = ((listMtEnd != null && listMtEnd.Any()) ? listMtEnd.Count() : 0) + ((listTaskSend != null && listTaskSend.Any()) ? listTaskSend.Count : 0);
 | 
						||
        //        SyncLogDetailService.InsertSyncLogDetail(HttpContext.Items, HttpContext.TraceIdentifier, filter.OrgId, Count, filter.Parameter1, SyncLogType.BSCreateCheckPlanSet);
 | 
						||
        //        return true;
 | 
						||
        //    });
 | 
						||
        //}
 | 
						||
 | 
						||
        ///// <summary>
 | 
						||
        ///// 其他模块 对接到会议开始
 | 
						||
        ///// </summary>
 | 
						||
        ///// <param name="filter"></param>
 | 
						||
        ///// <returns></returns>
 | 
						||
        //[HttpPost, Route("OtherToMeetingBegin")]
 | 
						||
        //public JsonActionResult<bool> OtherToMeetingBegin([FromBody] KeywordFilter filter)
 | 
						||
        //{
 | 
						||
        //    return SafeExecute<bool>(() =>
 | 
						||
        //    {
 | 
						||
        //        DateTime dtNow = DateTime.Now;
 | 
						||
        //        if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
        //        {
 | 
						||
        //            try
 | 
						||
        //            {
 | 
						||
        //                //接收来自页面的参数
 | 
						||
        //                DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
        //                dtNow = deParm;
 | 
						||
        //            }
 | 
						||
        //            catch { }
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        var listMtBegin = GetEntities<T_SC_MT_MEETING_BEGIN>(e => !e.IS_DELETED && !e.ISBEGIN && (!e.END_IGNORE.HasValue || e.END_IGNORE.Value > dtNow), null, null).OrderBy(e => e.CREATE_TIME.Value);
 | 
						||
        //        //&& e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Date == dtNow.Date  只要没触发 就会触发
 | 
						||
 | 
						||
        //        if (listMtBegin == null && !listMtBegin.Any())
 | 
						||
        //        {
 | 
						||
        //            return true;
 | 
						||
        //        }
 | 
						||
 | 
						||
 | 
						||
        //        #region    业务代码 扩展 每条一个事务处理 加强健壮性 但是性能低一些
 | 
						||
 | 
						||
 | 
						||
        //        bool isChange = false;
 | 
						||
        //        //foreach (var item in listMtBegin)
 | 
						||
        //        //{
 | 
						||
        //        //    switch (item.SOURCETYPE)
 | 
						||
        //        //    {
 | 
						||
        //        //        case SOURCETYPE.EventReport:
 | 
						||
 | 
						||
        //        //            if (!isChange)
 | 
						||
        //        //                isChange = true;
 | 
						||
        //        //            break;
 | 
						||
        //        //        default:
 | 
						||
        //        //            break;
 | 
						||
        //        //    }
 | 
						||
        //        //}
 | 
						||
 | 
						||
        //        #endregion
 | 
						||
 | 
						||
        //        if (isChange)
 | 
						||
        //        {
 | 
						||
        //            T_FM_SYNC_TASK taskSync = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);//跑批待办
 | 
						||
        //            if (taskSync.SYNC_PARAM != null)
 | 
						||
        //            {
 | 
						||
        //                taskSync.SYNC_PARAM = "";
 | 
						||
        //            }
 | 
						||
        //            taskSync.TASK_END_TIME = DateTime.Now;
 | 
						||
        //            taskSync.UPDATE_SUCCES_TIME = DateTime.Now;
 | 
						||
        //            this.UnifiedCommit(() =>
 | 
						||
        //            {
 | 
						||
        //                if (taskSync != null) //跑批信息
 | 
						||
        //                    UpdateEntityNoCommit(taskSync);
 | 
						||
        //            });
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        return true;
 | 
						||
        //    });
 | 
						||
        //}
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 会议结束 链接到别的模块
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="filter"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        [HttpPost, Route("MeetingEndToOther")]
 | 
						||
        public JsonActionResult<bool> MeetingEndToOther([FromBody] KeywordFilter filter)
 | 
						||
        {
 | 
						||
            return SafeExecute<bool>(() =>
 | 
						||
            {
 | 
						||
                try
 | 
						||
                {
 | 
						||
                    //如果 会议内容 需要匹配多个 触发 现在只有一个 (应急处理方案 待会议登记的类型触发后,修改信息,修改会议结束 数据为未触发 重新跑一下)
 | 
						||
                    DateTime dtNow = DateTime.Now;
 | 
						||
                    if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
                    {
 | 
						||
                        try
 | 
						||
                        {
 | 
						||
                            //接收来自页面的参数
 | 
						||
                            DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
                            dtNow = deParm;
 | 
						||
                        }
 | 
						||
                        catch { }
 | 
						||
                    }
 | 
						||
 | 
						||
                    var listMtEnd = GetEntities<T_SC_MT_MEETING_END>(e => !e.IS_DELETED && !e.ISEND && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Date <= dtNow.Date, null, null);
 | 
						||
                    if (listMtEnd == null && !listMtEnd.Any())
 | 
						||
                    {
 | 
						||
                        return true;
 | 
						||
                    }
 | 
						||
 | 
						||
                    var listMTID = listMtEnd.Select(e => e.MEETING_ID);
 | 
						||
                    var listMT = GetEntities<T_SC_MT_MEETING>(e => !e.IS_DELETED && listMTID.Contains(e.ID), null, null);
 | 
						||
                    if (listMT == null || !listMT.Any())
 | 
						||
                    {
 | 
						||
                        return true;
 | 
						||
                    }
 | 
						||
 | 
						||
                    listMT = listMT.ToList();
 | 
						||
 | 
						||
                    List<T_FM_NOTIFICATION_TASK> listTaskSend = new List<T_FM_NOTIFICATION_TASK>(); //需要添加的所有待办
 | 
						||
                    T_FM_USER userSafeMaster = null;  //安环负责人/安全员
 | 
						||
 | 
						||
                    //List<T_AE_INVESTIGATION_RECORD_INVESTIGATION_USERS> listInvestigationUsers = null;//需要添加的所有待办
 | 
						||
                    T_FM_SYNC_TASK taskSync = null;
 | 
						||
 | 
						||
                    #region  公共需求  userSafeMaster  安环负责人/安全员  如果有需要 缺没有 就不执行了
 | 
						||
 | 
						||
                    List<CREACTTYPEEnum> listEnum = new List<CREACTTYPEEnum>() { CREACTTYPEEnum.ToPT014, CREACTTYPEEnum.ToHM134, CREACTTYPEEnum.ToOG010, CREACTTYPEEnum.ToCM018, CREACTTYPEEnum.ToCM002, CREACTTYPEEnum.ToLR010, CREACTTYPEEnum.ToPR002, CREACTTYPEEnum.ToSC067, CREACTTYPEEnum.ToPR002_2, CREACTTYPEEnum.ToPR002_3, CREACTTYPEEnum.ToPR002_4 };
 | 
						||
 | 
						||
                    var checkUserT = listMT.FirstOrDefault(e => e.CREACTTYPE.HasValue && listEnum.Contains(e.CREACTTYPE.Value));
 | 
						||
                    if (checkUserT != null)
 | 
						||
                    {
 | 
						||
                        string Msg = string.Empty;
 | 
						||
                        userSafeMaster = UserService.GetRoleUser(ref Msg, "安环部负责人", null, null);
 | 
						||
                        if (userSafeMaster == null)
 | 
						||
                            userSafeMaster = UserService.GetRoleUser(ref Msg, "安环部安全员", null, null);
 | 
						||
                        if (userSafeMaster == null)
 | 
						||
                            return true;
 | 
						||
                    }
 | 
						||
 | 
						||
                    //默认时间
 | 
						||
                    DateTime dtEndDefault = NotificationTaskService.GetTaskEndTime(FMTASKTYPE.Default, filter.OrgId.Value, DateTime.Now, null, null);
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region     各处理逻辑  代码块区分 不直接 return 因为有数据要处理
 | 
						||
 | 
						||
                    //数据挨个判断处理
 | 
						||
                    listMtEnd.ForEach(e =>
 | 
						||
                    {
 | 
						||
                        e.RUN_COUNT++;
 | 
						||
                        e.ISEND = true;
 | 
						||
                        e.MODIFY_TIME = DateTime.Now;
 | 
						||
                    });
 | 
						||
                    IEnumerable<T_SC_MT_MEETING> listMTFA = null;
 | 
						||
                    //后续扩展
 | 
						||
                    #region    1、AE 事故事件 会议小组     //ToAE008《事故调查小组成员表》的触发对象  
 | 
						||
                    //事故事件上报[AE006] => 审批 => 触发【事故调查小组成立】会议 => 【事故调查小组成员AE008】表单=> 触发【事故调查讨论】会议 => 【勘察记录表 AE018】表单  => 触发【调查报告讨论】会议 => 【事故事件调查结果填报表AE010】
 | 
						||
 | 
						||
                    #region   ToAE006   《事故事件上报表》的触发对象       转到 事后触发会议    //不需要
 | 
						||
                    //List<T_AE_ACCIDENT_SURVEY_TEAM_MEMBER> listMember = null;
 | 
						||
                    //listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToAE006);
 | 
						||
                    //if (listMTFA != null && listMTFA.Any())
 | 
						||
                    //{
 | 
						||
                    //    listMember = new List<T_AE_ACCIDENT_SURVEY_TEAM_MEMBER>();
 | 
						||
                    //    T_AE_ACCIDENT_SURVEY_TEAM_MEMBER member = null;
 | 
						||
                    //    var listMTID006 = listMT.Select(e => e.ID);
 | 
						||
                    //    var listBegin = GetEntities<T_SC_MT_MEETING_BEGIN>(e => e.MEETING_ID.HasValue && listMTID006.Contains(e.MEETING_ID.Value), null, null);
 | 
						||
                    //    var listUserID = listBegin.Select(e => e.USER_ID);
 | 
						||
                    //    var listUserBegin = GetEntities<T_FM_USER>(e => listUserID.Contains(e.ID), null, null);
 | 
						||
                    //    //《事故调查小组成员表》的触发对象 
 | 
						||
                    //    foreach (var item in listMTFA)
 | 
						||
                    //    {
 | 
						||
                    //        var begin = listBegin.FirstOrDefault(e => e.MEETING_ID == item.ID);
 | 
						||
                    //        if (begin == null)
 | 
						||
                    //            continue;
 | 
						||
                    //        var userThis = listUserBegin.FirstOrDefault(e => e.ID == begin.USER_ID);
 | 
						||
                    //        if (userThis == null)
 | 
						||
                    //            continue;
 | 
						||
                    //        member = new T_AE_ACCIDENT_SURVEY_TEAM_MEMBER();
 | 
						||
                    //        member.ID = Guid.NewGuid();
 | 
						||
                    //        member.REPORT_ID = begin.DATA_ID;
 | 
						||
                    //        member.STATUS = PFStandardStatus.Draft;
 | 
						||
                    //        member.IS_DELETED = false;
 | 
						||
                    //        member.ORG_ID = filter.OrgId;
 | 
						||
                    //        member.CREATE_TIME = DateTime.Now;
 | 
						||
                    //        member.CREATER_ID = begin.USER_ID;
 | 
						||
                    //        //member.LEADER_USER_ID = ;
 | 
						||
                    //        //member.SURVEY_USER_ID = ;
 | 
						||
                    //        //member.ENTITY_ORG_TPYE = ;
 | 
						||
                    //        //member.FORM_ID = ;
 | 
						||
                    //        //member.FLOW_STATUS = ;
 | 
						||
                    //        //member.FLOW_SEND_STATUS = ;
 | 
						||
                    //        //member.FLOW_ID = ;
 | 
						||
                    //        //member.MODIFY_TIME = ;
 | 
						||
                    //        member.MODIFIER_ID = begin.USER_ID;
 | 
						||
                    //        listMember.Add(member);
 | 
						||
                    //        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("事故调查小组成员", member.ID, filter.OrgId, begin.USER_ID, userThis.NAME, DateTime.Now, DateTime.Now.AddDays(1), (int)FMNoticeTypeEnum.消息, "AE008"));
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region   ToAE008   《事故调查小组成员表》的触发对象   转到 事后触发会议
 | 
						||
                    //List<T_AE_ACCIDENT_SURVEY_TEAM_MEMBER> listMember = null;
 | 
						||
                    //listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToAE006);//事故事件上报AE006  触发的 会议 触发 事故调查小组成员 会议 AE008
 | 
						||
                    //if (listMTFA != null && listMTFA.Any())
 | 
						||
                    //{
 | 
						||
                    //    listMember = new List<T_AE_ACCIDENT_SURVEY_TEAM_MEMBER>();
 | 
						||
                    //    T_AE_ACCIDENT_SURVEY_TEAM_MEMBER member = null;
 | 
						||
                    //    var listMTID006 = listMT.Select(e => e.ID);
 | 
						||
                    //    var listBegin = GetEntities<T_SC_MT_MEETING_BEGIN>(e => e.MEETING_ID.HasValue && listMTID006.Contains(e.MEETING_ID.Value), null, null);
 | 
						||
                    //    var listUserID = listBegin.Select(e => e.USER_ID);
 | 
						||
                    //    var listUserBegin = GetEntities<T_FM_USER>(e => listUserID.Contains(e.ID), null, null);
 | 
						||
                    //    //《事故调查小组成员表》的触发对象 
 | 
						||
                    //    foreach (var item in listMTFA)
 | 
						||
                    //    {
 | 
						||
                    //        var begin = listBegin.FirstOrDefault(e => e.MEETING_ID == item.ID);
 | 
						||
                    //        if (begin == null)
 | 
						||
                    //            continue;
 | 
						||
                    //        var userThis = listUserBegin.FirstOrDefault(e => e.ID == begin.USER_ID);
 | 
						||
                    //        if (userThis == null)
 | 
						||
                    //            continue;
 | 
						||
                    //        member = new T_AE_ACCIDENT_SURVEY_TEAM_MEMBER();
 | 
						||
                    //        member.ID = Guid.NewGuid();
 | 
						||
                    //        member.REPORT_ID = begin.DATA_ID;
 | 
						||
                    //        member.STATUS = PFStandardStatus.Draft;
 | 
						||
                    //        member.IS_DELETED = false;
 | 
						||
                    //        member.ORG_ID = filter.OrgId;
 | 
						||
                    //        member.CREATE_TIME = DateTime.Now;
 | 
						||
                    //        member.CREATER_ID = begin.USER_ID;
 | 
						||
                    //        //member.LEADER_USER_ID = ;
 | 
						||
                    //        //member.SURVEY_USER_ID = ;
 | 
						||
                    //        //member.ENTITY_ORG_TPYE = ;
 | 
						||
                    //        //member.FORM_ID = ;
 | 
						||
                    //        //member.FLOW_STATUS = ;
 | 
						||
                    //        //member.FLOW_SEND_STATUS = ;
 | 
						||
                    //        //member.FLOW_ID = ;
 | 
						||
                    //        //member.MODIFY_TIME = ;
 | 
						||
                    //        member.MODIFIER_ID = begin.USER_ID;
 | 
						||
                    //        listMember.Add(member);
 | 
						||
                    //        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("事故调查小组成员", member.ID, filter.OrgId, begin.USER_ID, userThis.NAME, DateTime.Now, DateTime.Now.AddDays(1), (int)FMNoticeTypeEnum.消息, "AE008"));
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
 | 
						||
                    #endregion
 | 
						||
                    //#region     ToAE010
 | 
						||
                    //listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToAE010);
 | 
						||
                    //List<T_AE_ACCIDENT_EVENT_SURVEY_RESULT> listResult = null;
 | 
						||
                    //if (listMTFA != null && listMTFA.Any())
 | 
						||
                    //{
 | 
						||
                    //    var listMTIDAE010 = listMTFA.Select(e => e.ID);
 | 
						||
                    //    var listBegin = GetEntities<T_SC_MT_MEETING_BEGIN>(e => e.MEETING_ID.HasValue && listMTIDAE010.Contains(e.MEETING_ID.Value), null, null);
 | 
						||
                    //    if (listBegin != null && listBegin.Any())
 | 
						||
                    //    {
 | 
						||
                    //        var listRecordID = listBegin.Select(e => e.DATA_ID);
 | 
						||
                    //        var listRecord = GetEntities<T_AE_INVESTIGATION_RECORD>(e => listRecordID.Contains(e.ID), null, null);
 | 
						||
                    //        var listUserID = listBegin.Select(e => e.USER_ID).Distinct();
 | 
						||
                    //        var listUser = GetEntities<T_FM_USER>(e => listUserID.Contains(e.ID), null, null);
 | 
						||
 | 
						||
                    //        if (listRecord != null && listRecord.Any())
 | 
						||
                    //        {
 | 
						||
                    //            listResult = new List<T_AE_ACCIDENT_EVENT_SURVEY_RESULT>();
 | 
						||
                    //            T_AE_INVESTIGATION_RECORD modelRec = null;
 | 
						||
                    //            T_FM_USER modelUser = null;
 | 
						||
                    //            T_SC_MT_MEETING_BEGIN modelBegin = null;
 | 
						||
                    //            foreach (var item in listMTFA)
 | 
						||
                    //            {
 | 
						||
                    //                modelBegin = listBegin.FirstOrDefault(e => e.MEETING_ID.HasValue && e.MEETING_ID.Value == item.ID);
 | 
						||
                    //                if (modelBegin == null)
 | 
						||
                    //                    continue;
 | 
						||
                    //                modelRec = listRecord.First(e => e.ID == modelBegin.DATA_ID);
 | 
						||
                    //                if (modelRec == null)
 | 
						||
                    //                    continue;
 | 
						||
                    //                modelUser = listUser.FirstOrDefault(e => e.ID == modelBegin.USER_ID);
 | 
						||
                    //                if (modelUser == null)
 | 
						||
                    //                    continue;
 | 
						||
 | 
						||
                    //                T_AE_ACCIDENT_EVENT_SURVEY_RESULT modelResult = new T_AE_ACCIDENT_EVENT_SURVEY_RESULT();
 | 
						||
                    //                modelResult.ID = Guid.NewGuid();
 | 
						||
                    //                modelResult.REPORT_ID = modelRec.ACCIDENT_ID;
 | 
						||
                    //                modelResult.STATUS = PFStandardStatus.Draft;
 | 
						||
                    //                modelResult.IS_DELETED = false;
 | 
						||
                    //                modelResult.ORG_ID = filter.OrgId;
 | 
						||
 | 
						||
                    //                //modelResult.CASUALTY_COUNT = "";
 | 
						||
                    //                //modelResult.ECONOMIC_LOSSES = "";
 | 
						||
                    //                //modelResult.ACCIDENT_COURSE = "";
 | 
						||
                    //                //modelResult.TIME = "";
 | 
						||
                    //                //modelResult.RISK_SUBMIT_ID = "";
 | 
						||
                    //                //modelResult.ENTITY_ORG_TPYE = "";
 | 
						||
                    //                //modelResult.FORM_ID = "";
 | 
						||
                    //                //modelResult.FLOW_STATUS = "";
 | 
						||
                    //                //modelResult.FLOW_SEND_STATUS = "";
 | 
						||
                    //                //modelResult.FLOW_ID = "";
 | 
						||
                    //                //modelResult.CREATE_TIME = "";
 | 
						||
                    //                //modelResult.MODIFY_TIME = "";
 | 
						||
                    //                //modelResult.CREATER_ID = "";
 | 
						||
                    //                //modelResult.MODIFIER_ID = ""; 
 | 
						||
                    //                listResult.Add(modelResult);
 | 
						||
 | 
						||
                    //                listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("事故事件调查结果填报", modelResult.ID, filter.OrgId, modelUser.ID, modelUser.NAME, DateTime.Now, DateTime.Now.AddDays(1), (int)FMNoticeTypeEnum.消息, "AE010"));
 | 
						||
                    //            }
 | 
						||
                    //        }
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
                    //#endregion
 | 
						||
                    //#region ToAE018  AEToMTAfterTeamMember
 | 
						||
                    //List<T_AE_INVESTIGATION_RECORD> listSurveyResult = null;
 | 
						||
                    //listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && (e.CREACTTYPE == CREACTTYPEEnum.AEToMTAfterTeamMember || e.CREACTTYPE == CREACTTYPEEnum.ToAE018));//
 | 
						||
                    //if (listMTFA != null && listMTFA.Any())
 | 
						||
                    //{
 | 
						||
                    //    var listMTIDAE = listMTFA.Select(e => e.ID);
 | 
						||
                    //    var begins = GetEntities<T_SC_MT_MEETING_BEGIN>(e => e.MEETING_ID.HasValue && e.ISBEGIN && listMTIDAE.Contains(e.MEETING_ID.Value), null, null);
 | 
						||
 | 
						||
                    //    var listJoinAll = GetEntities<T_SC_MT_MEETING_PALL>(e => listMTIDAE.Contains(e.MEETING_ID), null);
 | 
						||
 | 
						||
                    //    //listSurveyResult = new List<T_AE_ACCIDENT_EVENT_SURVEY_RESULT>();
 | 
						||
                    //    listSurveyResult = new List<T_AE_INVESTIGATION_RECORD>();
 | 
						||
                    //    if (listInvestigationUsers == null)
 | 
						||
                    //        listInvestigationUsers = new List<T_AE_INVESTIGATION_RECORD_INVESTIGATION_USERS>();
 | 
						||
                    //    IEnumerable<Guid> listUserID = null;
 | 
						||
                    //    foreach (var item in listMTFA)
 | 
						||
                    //    {
 | 
						||
                    //        var begin = begins.FirstOrDefault(e => e.MEETING_ID == item.ID);
 | 
						||
                    //        if (begin == null)
 | 
						||
                    //        {
 | 
						||
                    //            continue;
 | 
						||
                    //        }
 | 
						||
 | 
						||
                    //        #region   事故事件调查结果填报  => 勘察记录()
 | 
						||
 | 
						||
                    //        T_AE_ACCIDENT_SURVEY_TEAM_MEMBER entityM = GetEntity<T_AE_ACCIDENT_SURVEY_TEAM_MEMBER>(e => e.REPORT_ID.HasValue && e.SURVEY_USER_ID.HasValue && e.REPORT_ID.Value == begin.DATA_ID, "Nav_SurveyUser");
 | 
						||
                    //        if (entityM == null)
 | 
						||
                    //        {
 | 
						||
                    //            continue;
 | 
						||
                    //        }
 | 
						||
 | 
						||
                    //        DateTime dtEndLevel = DateTime.Now;
 | 
						||
                    //        #region   获取 限制结案时间  dtEnd
 | 
						||
 | 
						||
                    //        AEAccidentLevel level = GetEntity<T_AE_ACCIDENT_EVENT_REPORT>(entityM.REPORT_ID.Value).ACCIDENT_LEVEL.Value;
 | 
						||
                    //        var days = GetEntity<T_AE_ACCIDENT_LEVEL_DAYS>(e => e.ACCIDENT_LEVEL == level);
 | 
						||
                    //        if (days == null)
 | 
						||
                    //        {
 | 
						||
                    //            switch (level)
 | 
						||
                    //            {
 | 
						||
                    //                case AEAccidentLevel.Jumbo:
 | 
						||
                    //                case AEAccidentLevel.Major:
 | 
						||
                    //                case AEAccidentLevel.Larger:
 | 
						||
                    //                case AEAccidentLevel.General:
 | 
						||
                    //                    dtEndLevel = DateTime.Now.Date.AddDays(32).AddSeconds(-1);
 | 
						||
                    //                    break;
 | 
						||
                    //                case AEAccidentLevel.SeriouslyInjured:
 | 
						||
                    //                    dtEndLevel = DateTime.Now.Date.AddDays(17).AddSeconds(-1);
 | 
						||
                    //                    break;
 | 
						||
                    //                case AEAccidentLevel.MinorJuries:
 | 
						||
                    //                case AEAccidentLevel.Aminor:
 | 
						||
                    //                case AEAccidentLevel.Risk:
 | 
						||
                    //                    dtEndLevel = DateTime.Now.Date.AddDays(12).AddSeconds(-1);
 | 
						||
                    //                    break;
 | 
						||
                    //                default:
 | 
						||
                    //                    break;
 | 
						||
                    //            }
 | 
						||
                    //        }
 | 
						||
                    //        else
 | 
						||
                    //        {
 | 
						||
                    //            dtEndLevel = DateTime.Now.Date.AddDays(2 + days.DAYS).AddSeconds(-1);
 | 
						||
                    //        }
 | 
						||
                    //        #endregion
 | 
						||
 | 
						||
 | 
						||
                    //        T_AE_INVESTIGATION_RECORD modelResult = new T_AE_INVESTIGATION_RECORD();
 | 
						||
                    //        modelResult.ID = Guid.NewGuid();
 | 
						||
                    //        //modelResult.LAUNCH_TIME =;
 | 
						||
 | 
						||
                    //        modelResult.DEPARTMENT_ID = item.DEPARTMENT_ID;
 | 
						||
 | 
						||
                    //        modelResult.USER_ID = entityM.SURVEY_USER_ID;
 | 
						||
                    //        modelResult.ACCIDENT_ID = entityM.REPORT_ID; ;
 | 
						||
                    //        modelResult.TEAM_MEMBER_ID = entityM.ID;
 | 
						||
 | 
						||
                    //        //modelResult.INVESTIGATION_TIME =;
 | 
						||
                    //        //modelResult.INVESTIGATION_LOCATION =;
 | 
						||
                    //        //modelResult.INVESTIGATION_REASON =;
 | 
						||
                    //        //modelResult.SCENE_ENV_DESC =;
 | 
						||
                    //        //modelResult.SCENE_DESC =;
 | 
						||
                    //        //modelResult.SCENE_EVIDENCE_DESC =;
 | 
						||
                    //        modelResult.STATUS = PFStandardStatus.Draft;
 | 
						||
                    //        //modelResult.REVIEW_OK =;
 | 
						||
                    //        //modelResult.REVIEW_COMMENT =;
 | 
						||
                    //        modelResult.IS_DELETED = false;
 | 
						||
                    //        modelResult.ORG_ID = item.ORG_ID;
 | 
						||
                    //        //modelResult.ENTITY_ORG_TPYE =;
 | 
						||
                    //        //modelResult.FORM_ID =;
 | 
						||
                    //        //modelResult.FLOW_STATUS =;
 | 
						||
                    //        //modelResult.FLOW_SEND_STATUS =;
 | 
						||
                    //        //modelResult.FLOW_ID =;
 | 
						||
                    //        //modelResult.CREATE_TIME =;
 | 
						||
                    //        //modelResult.MODIFY_TIME =;
 | 
						||
                    //        //modelResult.CREATER_ID =;
 | 
						||
                    //        //modelResult.MODIFIER_ID =;
 | 
						||
                    //        //modelResult.LEADER_USER_ID =;
 | 
						||
                    //        //modelResult.APPROVE_ID =;
 | 
						||
 | 
						||
 | 
						||
                    //        //勘察人员 默认 参会人员 24 0226
 | 
						||
                    //        //T_AE_INVESTIGATION_RECORD_INVESTIGATION_USERS 
 | 
						||
                    //        listUserID = listJoinAll.Select(e => e.USER_ID).Distinct();
 | 
						||
                    //        if (item.USER_ID_HOST.HasValue && !listUserID.Contains(item.USER_ID_HOST.Value))
 | 
						||
                    //            listUserID.Append(item.USER_ID_HOST.Value);
 | 
						||
                    //        if (!listUserID.Contains(item.USER_ID_ORIGINATOR))
 | 
						||
                    //            listUserID.Append(item.USER_ID_ORIGINATOR);
 | 
						||
                    //        if (item.USER_ID_RECORDER.HasValue && !listUserID.Contains(item.USER_ID_RECORDER.Value))
 | 
						||
                    //            listUserID.Append(item.USER_ID_RECORDER.Value);
 | 
						||
                    //        foreach (var itemUser in listUserID)
 | 
						||
                    //        {
 | 
						||
                    //            listInvestigationUsers.Add(new T_AE_INVESTIGATION_RECORD_INVESTIGATION_USERS()
 | 
						||
                    //            {
 | 
						||
                    //                ID = Guid.NewGuid(),
 | 
						||
                    //                ORG_ID = modelResult.ORG_ID,
 | 
						||
                    //                RECORD_ID = modelResult.ID,
 | 
						||
                    //                USER_ID = itemUser,
 | 
						||
                    //                STATUS = AEInvestigationUserStatusEnum.未审阅
 | 
						||
                    //            });
 | 
						||
                    //        }
 | 
						||
                    //        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("勘察记录表", modelResult.ID, item.ORG_ID, entityM.SURVEY_USER_ID.Value, entityM.Nav_SurveyUser.NAME, DateTime.Now, dtEndLevel, (int)FMNoticeTypeEnum.消息, "AE018"));
 | 
						||
                    //        listSurveyResult.Add(modelResult);
 | 
						||
 | 
						||
                    //        #endregion
 | 
						||
                    //        #region //事故事件调查结果填报
 | 
						||
 | 
						||
                    //        //T_AE_ACCIDENT_EVENT_SURVEY_RESULT modelResult = new T_AE_ACCIDENT_EVENT_SURVEY_RESULT();
 | 
						||
                    //        //var begin = begins.FirstOrDefault(e => e.MEETING_ID == item.ID);
 | 
						||
                    //        //if (begin == null)
 | 
						||
                    //        //{
 | 
						||
                    //        //    continue;
 | 
						||
                    //        //}
 | 
						||
                    //        //modelResult.ID = Guid.NewGuid();
 | 
						||
                    //        //modelResult.REPORT_ID = begin.DATA_ID;
 | 
						||
                    //        //modelResult.STATUS = PFStandardStatus.Draft;
 | 
						||
                    //        //modelResult.IS_DELETED = false;
 | 
						||
                    //        //modelResult.ORG_ID = item.ORG_ID;
 | 
						||
 | 
						||
                    //        ////modelResult.CASUALTY_COUNT = "";
 | 
						||
                    //        ////modelResult.ECONOMIC_LOSSES = "";
 | 
						||
                    //        ////modelResult.ACCIDENT_COURSE = "";
 | 
						||
                    //        ////modelResult.TIME = "";
 | 
						||
                    //        ////modelResult.RISK_SUBMIT_ID = "";
 | 
						||
                    //        ////modelResult.ENTITY_ORG_TPYE = "";
 | 
						||
                    //        ////modelResult.FORM_ID = "";
 | 
						||
                    //        ////modelResult.FLOW_STATUS = "";
 | 
						||
                    //        ////modelResult.FLOW_SEND_STATUS = "";
 | 
						||
                    //        ////modelResult.FLOW_ID = "";
 | 
						||
                    //        ////modelResult.CREATE_TIME = "";
 | 
						||
                    //        ////modelResult.MODIFY_TIME = "";
 | 
						||
                    //        ////modelResult.CREATER_ID = "";
 | 
						||
                    //        ////modelResult.MODIFIER_ID = "";
 | 
						||
 | 
						||
                    //        //string SURVEYNAME = GetEntity<T_FM_USER>(item.USER_ID_ORIGINATOR).NAME;
 | 
						||
                    //        //T_FM_NOTIFICATION_TASK taskAdd = NotificationTaskService.InsertUserNoticeTaskModel("事故事件调查结果填报", modelResult.ID, item.ORG_ID, item.USER_ID_ORIGINATOR, SURVEYNAME, DateTime.Now, 0, "AE010", FMTASKTYPE.Default);
 | 
						||
 | 
						||
                    //        #endregion
 | 
						||
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
                    //#endregion
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region  2、BS  ToBS032  
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToBS032);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        //各层级负责人
 | 
						||
                        //wyw 班组 车间  安环 负责人
 | 
						||
                        //wyw有多个也就触发一个
 | 
						||
                        var listDep = GetEntities<T_FM_DEPARTMENT>(e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && e.DEPARTMENT_TYPE != 3, null, null);//&&(e.DEPARTMENT_TYPE== FMDepartmentType.班组|| e.DEPARTMENT_TYPE == FMDepartmentType.车间|| e.DEPARTMENT_TYPE == FMDepartmentType.部门
 | 
						||
                        var listUserID = listDep.Where(e => e.USER_ID.HasValue && (e.DEPARTMENT_TYPE == 1 || e.DEPARTMENT_TYPE == 2 || (e.DEPARTMENT_TYPE == 0 && e.DEPARTMENT_STATUS != 0))).Select(e => e.USER_ID.Value).Distinct();
 | 
						||
                        if (listUserID != null && listUserID.Any())
 | 
						||
                        {
 | 
						||
                            var users = GetEntities<T_FM_USER>(e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && listUserID.Contains(e.ID), null, null);
 | 
						||
                            List<Guid> listUserIDTask = new List<Guid>();
 | 
						||
                            List<string> listUserNameTask = new List<string>();
 | 
						||
                            users.ForEach(e =>
 | 
						||
                            {
 | 
						||
                                if (!listUserIDTask.Contains(e.ID))
 | 
						||
                                {
 | 
						||
                                    listUserIDTask.Add(e.ID); listUserNameTask.Add(e.NAME);
 | 
						||
                                }
 | 
						||
                            });
 | 
						||
                            var listTaskBS032 = NotificationTaskService.InsertUserNoticeTaskModels("检查任务制定", null, filter.OrgId, listUserIDTask, listUserNameTask, DateTime.Now, dtEndDefault, 0, "BS032");
 | 
						||
                            listTaskSend.AddRange(listTaskBS032);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region     3、CM 潜在紧急事件讨论 
 | 
						||
                    #region ToCM002 安环部负责人/安全员
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToCM026);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("年度应急演练计划", null, filter.OrgId, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, 0, "CM002", FMTASKTYPE.Default));
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #region ToCM018 记录人
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToCM018);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        var userIDs = listMTFA.Where(e => e.USER_ID_RECORDER.HasValue && !e.ISCANCEL && !e.IS_DELETED).Select(e => e.USER_ID_RECORDER.Value);
 | 
						||
                        if (userIDs != null && userIDs.Any())
 | 
						||
                        {
 | 
						||
                            var listUser = GetEntities<T_FM_USER>(e => userIDs.Contains(e.ID), null);
 | 
						||
                            foreach (var item in listUser)
 | 
						||
                            {
 | 
						||
                                listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("潜在紧急事件", Guid.Empty, filter.OrgId, item.ID, item.NAME, DateTime.Now, 0, "CM018", FMTASKTYPE.Default));
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #region ToCM026 记录人
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToCM026);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        //会议记录人
 | 
						||
                        var userIDs = listMTFA.Where(e => e.USER_ID_RECORDER.HasValue && !e.ISCANCEL && !e.IS_DELETED).Select(e => e.USER_ID_RECORDER.Value).Distinct();
 | 
						||
                        if (userIDs != null && userIDs.Any())
 | 
						||
                        {
 | 
						||
                            var listUser = GetEntities<T_FM_USER>(e => userIDs.Contains(e.ID), null);
 | 
						||
                            foreach (var item in listUser)
 | 
						||
                            {
 | 
						||
                                listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("应急能力评估", null, filter.OrgId, item.ID, item.NAME, DateTime.Now, 0, "CM026", FMTASKTYPE.Default));
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region   4、HM  
 | 
						||
                    #region   ToHM076  各部门负责人
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToHM104);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        var deps = GetEntities<T_FM_DEPARTMENT>(e => !e.IS_DELETED && e.DEPARTMENT_STATUS == 0 && e.USER_ID.HasValue && e.DEPARTMENT_TYPE == (int)FMDepartmentType.部门, null, null);
 | 
						||
                        var listUsers = deps.Select(e => e.USER_ID.Value);
 | 
						||
                        var listUser = GetEntities<T_FM_USER>(e => listUsers.Contains(e.ID), null, null);
 | 
						||
                        List<Guid> listUserIDdep = new List<Guid>();
 | 
						||
                        List<string> listUserNamedep = new List<string>();
 | 
						||
                        listUser.ForEach(e => { if (!listUserIDdep.Contains(e.ID)) { listUserIDdep.Add(e.ID); listUserNamedep.Add(e.NAME); } });
 | 
						||
 | 
						||
                        listTaskSend.AddRange(NotificationTaskService.InsertUserNoticeTaskModels("作业任务识别", null, filter.OrgId, listUserIDdep, listUserNamedep, DateTime.Now, 0, "HM104", FMTASKTYPE.Default));
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #region   ToHM134  
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToHM134);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("年度风险评价计划", null, filter.OrgId, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, 0, "HM134", FMTASKTYPE.Default));
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #region   ToHM062_HM102   对应会议的触发对象
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToHM062_HM102);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        //谁创建的会议给谁
 | 
						||
                        var listUserID = listMTFA.Where(e => e.CREATER_ID.HasValue).Select(e => e.CREATER_ID.Value).Distinct();
 | 
						||
                        if (listUserID != null && listUserID.Any())
 | 
						||
                        {
 | 
						||
                            var listUser = GetEntities<T_FM_USER>(e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && listUserID.Contains(e.ID), null, null);
 | 
						||
                            foreach (var item in listMTFA)
 | 
						||
                            {
 | 
						||
                                if (!item.CREATER_ID.HasValue)
 | 
						||
                                    continue;
 | 
						||
                                var userSend = listUser.FirstOrDefault(e => e.ID == item.CREATER_ID.Value);
 | 
						||
                                if (userSend == null)
 | 
						||
                                    continue;
 | 
						||
                                listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("危险源/风险辨识任务", null, filter.OrgId, userSend.ID, userSend.NAME, DateTime.Now, 0, "HM062", FMTASKTYPE.Default));
 | 
						||
                                listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("职业危害辨识任务", null, filter.OrgId, userSend.ID, userSend.NAME, DateTime.Now, 0, "HM102", FMTASKTYPE.Default));
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region   5、LR   ToLR010
 | 
						||
                    //发起人
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToSC067);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        var listUserID = listMTFA.Where(e => e.CREATER_ID.HasValue).Select(e => e.CREATER_ID);
 | 
						||
                        var listUser = GetEntities<T_FM_USER>(e => listUserID.Contains(e.ID), null, null);
 | 
						||
                        List<Guid> listUserIDU = new List<Guid>();
 | 
						||
                        List<string> listUserName = new List<string>();
 | 
						||
                        listTaskSend.AddRange(NotificationTaskService.InsertUserNoticeTaskModels("法律法规更新与融入", null, filter.OrgId, listUserIDU, listUserName, DateTime.Now, 0, "LR010", FMTASKTYPE.Default));
 | 
						||
                    }
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region   6、OG 组织保障(OG002 给全部员工发送代办?)
 | 
						||
                    //标准化系统评审意见  会议内容为安全生产标准化评审会的会议纪要完成后触发待办任务 (此表单) 给会议记录人
 | 
						||
                    #region //OG002  全体员工???什么是员工?总经理要吗? 讨论后 暂时不要
 | 
						||
                    //listMTFA = listMT.Where(e => e.CREACTTYPE == CREACTTYPEEnum.ToOG002);
 | 
						||
                    //if (listMTFA != null && listMTFA.Any())
 | 
						||
                    //{
 | 
						||
                    //    IEnumerable<T_FM_USER> listUser = null;
 | 
						||
                    //    try
 | 
						||
                    //    {
 | 
						||
                    //        BaseFilter filt = new BaseFilter();
 | 
						||
                    //        filt.OrgId = filter.OrgId;
 | 
						||
                    //        filt.IgnoreDataRule = true;
 | 
						||
                    //        filt.SelectField = new List<string> { "IS_DELETED", "ENABLE_STATUS", "ID", "NAME" };
 | 
						||
                    //        listUser = GetEntities<T_FM_USER>(e => !e.IS_DELETED && e.ENABLE_STATUS == 0, null, null);
 | 
						||
                    //    }
 | 
						||
                    //    catch { }
 | 
						||
 | 
						||
                    //    if (listUser != null)
 | 
						||
                    //    {
 | 
						||
                    //        List<Guid> listUserIDTask = new List<Guid>();
 | 
						||
                    //        List<string> listUserNameTask = new List<string>();
 | 
						||
                    //        listUser.ForEach(e =>
 | 
						||
                    //        {
 | 
						||
                    //            if (!listUserIDTask.Contains(e.ID))
 | 
						||
                    //            {
 | 
						||
                    //                listUserIDTask.Add(e.ID); listUserNameTask.Add(e.NAME);
 | 
						||
                    //            }
 | 
						||
                    //        });
 | 
						||
                    //        listTaskSend.AddRange(NotificationTaskService.InsertUserNoticeTaskModels("安全生产责任制签订", null, filter.OrgId, listUserIDTask, listUserNameTask, DateTime.Now, dtEndDefault, 0, "OG002"));
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
 | 
						||
                    #endregion
 | 
						||
                    #region ToOG034Edit
 | 
						||
                    listMTFA = listMT.Where(e => e.CREACTTYPE == CREACTTYPEEnum.ToOG034Edit);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        var userIDs = listMTFA.Where(e => e.USER_ID_RECORDER.HasValue && !e.ISCANCEL && !e.IS_DELETED).Select(e => e.USER_ID_RECORDER.Value);
 | 
						||
                        if (userIDs != null && userIDs.Any())
 | 
						||
                        {
 | 
						||
                            var listUser = GetEntities<T_FM_USER>(e => userIDs.Contains(e.ID), null);
 | 
						||
                            foreach (var item in listUser)
 | 
						||
                            {
 | 
						||
                                listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("标准化系统评审意见", null, filter.OrgId, item.ID, item.NAME, DateTime.Now, 0, "OG034_EDIT", FMTASKTYPE.Default));
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #region ToOG010  安环部负责人/安全员
 | 
						||
 | 
						||
                    listMTFA = listMT.Where(e => e.CREACTTYPE == CREACTTYPEEnum.ToOG010);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("人员任命书", null, filter.OrgId, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, 0, "OG010", FMTASKTYPE.Default));
 | 
						||
                    }
 | 
						||
 | 
						||
                    #endregion
 | 
						||
                    #region   ToOG028    安环部安全员
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToOG028);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        var depSafe = GetEntity<T_FM_DEPARTMENT>(e => !e.IS_DELETED && e.DEPARTMENT_TYPE == (int)FMDepartmentType.部门 && e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.安全部门);
 | 
						||
                        if (depSafe != null)
 | 
						||
                        {
 | 
						||
                            var role = GetEntity<T_PF_APPROVAL_ROLE>(e => e.NAME.Contains("安环部安全员"));
 | 
						||
                            var UserSafe = GetEntity<T_FM_USER>(e => e.DEPARTMENT_ID.HasValue && e.DEPARTMENT_ID.Value == depSafe.ID && e.APPROVE_ROLE_ID.HasValue && e.APPROVE_ROLE_ID.Value == role.ID);
 | 
						||
                            if (UserSafe != null)
 | 
						||
                            {
 | 
						||
                                listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("认可与奖励上报", null, filter.OrgId, UserSafe.ID, UserSafe.NAME, DateTime.Now, 0, "OG028", FMTASKTYPE.Default));
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #region ToOG060  各部门安全员(生产部门 安全员)
 | 
						||
 | 
						||
                    listMTFA = listMT.Where(e => e.CREACTTYPE == CREACTTYPEEnum.ToOG060);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        var deps = GetEntities<T_FM_DEPARTMENT>(e => e.ENABLE_STATUS == 0 && !e.IS_DELETED && e.DEPARTMENT_TYPE == 0 && e.DEPARTMENT_STATUS == (int)FMDepartmentStatus.生产部门, null, null);
 | 
						||
                        if (deps != null && deps.Any())
 | 
						||
                        {
 | 
						||
                            var listDepID = deps.Select(e => e.ID);
 | 
						||
                            var approveRole = GetEntity<T_PF_APPROVAL_ROLE>(e => !e.IS_DELETED && e.NAME.Contains("部门安全员"));
 | 
						||
                            if (approveRole != null)
 | 
						||
                            {
 | 
						||
                                var listUser = GetEntities<T_FM_USER>(e => e.APPROVE_ROLE_ID.HasValue && e.APPROVE_ROLE_ID.Value == approveRole.ID && listDepID.Contains(e.ID), null, null);
 | 
						||
                                foreach (var item in listUser)
 | 
						||
                                {
 | 
						||
                                    listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("员工意见征集", null, filter.OrgId, item.ID, item.NAME, DateTime.Now, 0, "OG060", FMTASKTYPE.Default));
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region   7、PE   ToPE027
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToSC067);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("安全标准化内部评价计划录入", null, filter.OrgId, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, 0, "PE027", FMTASKTYPE.Default));
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region   8、PT安全生产方针调查
 | 
						||
                    #region ToPT014
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToPT014);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("安全生产方针调查", null, filter.OrgId, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, 0, "PT014", FMTASKTYPE.Default));
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region   9、 PR
 | 
						||
                    #region   ToPR023  
 | 
						||
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToPR023);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        var listUserID = listMTFA.Where(e => e.CREATER_ID.HasValue).Select(e => e.CREATER_ID.Value).Distinct().ToList();
 | 
						||
                        if (listUserID != null && listUserID.Any())
 | 
						||
                        {
 | 
						||
                            var users = GetEntities<T_FM_USER>(e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && listUserID.Contains(e.ID), null, null);
 | 
						||
                            List<Guid> listUserIDTask = new List<Guid>();
 | 
						||
                            List<string> listUserNameTask = new List<string>();
 | 
						||
                            users.ForEach(e =>
 | 
						||
                            {
 | 
						||
                                if (!listUserIDTask.Contains(e.ID))
 | 
						||
                                {
 | 
						||
                                    listUserIDTask.Add(e.ID); listUserNameTask.Add(e.NAME);
 | 
						||
                                }
 | 
						||
                            });
 | 
						||
                            var listTaskPR023 = NotificationTaskService.InsertUserNoticeTaskModels("变化识别评估表", null, filter.OrgId, listUserIDTask, listUserNameTask, DateTime.Now, dtEndDefault, 0, "PR023");
 | 
						||
                            listTaskSend.AddRange(listTaskPR023);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #region   ToPR002  
 | 
						||
                    //安环部负责人 / 安全员 多个也触发一次会议
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && (e.CREACTTYPE == CREACTTYPEEnum.ToPR002 || e.CREACTTYPE == CREACTTYPEEnum.ToPR002_2 || e.CREACTTYPE == CREACTTYPEEnum.ToPR002_3 || e.CREACTTYPE == CREACTTYPEEnum.ToPR002_4));
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        T_FM_NOTIFICATION_TASK taskAdd = NotificationTaskService.InsertUserNoticeTaskModel("内部设计文件审核表", null, filter.OrgId, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, 0, "PR002", FMTASKTYPE.Default);
 | 
						||
                        listTaskSend.Add(taskAdd);
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region   10、SC   ToSC067
 | 
						||
                    listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.Ordinary && e.CREACTTYPE == CREACTTYPEEnum.ToSC067);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("应急预案修订记录", null, filter.OrgId, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, 0, "SC067", FMTASKTYPE.Default));
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region    11、TL 尾矿库 
 | 
						||
                    //#region    FileAudit
 | 
						||
                    //T_TL_FILE_SUM modelFileSum = null;
 | 
						||
                    //listMTFA = listMT.Where(e => e.MEETINGTYPE == SCMEETINGTYPE.FileAudit);
 | 
						||
                    //if (listMTFA != null && listMTFA.Any())
 | 
						||
                    //{
 | 
						||
                    //    var MeetID = listMTFA.Select(e => e.ID);
 | 
						||
                    //    var listMeetContent = GetEntities<T_SC_MT_MEETING_CONTENT>(e => MeetID.Contains(e.MEETING_ID) && e.Nav_ContentName.NAME.Contains("尾矿") && e.Nav_ContentName.NAME.Contains("设计文件审核"), null, "Nav_ContentName");
 | 
						||
 | 
						||
                    //    string Msg = string.Empty;
 | 
						||
                    //    if (listMeetContent != null && listMeetContent.Any())
 | 
						||
                    //    {
 | 
						||
                    //        var listMeetID = listMeetContent.Select(e => e.MEETING_ID).Distinct();
 | 
						||
 | 
						||
                    //        //不管几条 符合 尾矿库 建设 【设计文件专家评审意见】
 | 
						||
                    //        //1、只添加 一个待办 
 | 
						||
                    //        //2、对应会议结束  完善信息
 | 
						||
                    //        //TL004
 | 
						||
                    //        string FormCode = "TL004";
 | 
						||
                    //        modelFileSum = new T_TL_FILE_SUM();
 | 
						||
                    //        modelFileSum.ID = Guid.NewGuid();
 | 
						||
                    //        modelFileSum.ORG_ID = filter.OrgId;
 | 
						||
                    //        modelFileSum.CONTENT = "请提交经安全生产监督管理部门审查批准的专家审查意见";
 | 
						||
                    //        modelFileSum.DEPARTMENT_ID = userSafeMaster.DEPARTMENT_ID;
 | 
						||
                    //        modelFileSum.USER_ID = userSafeMaster.ID;
 | 
						||
                    //        modelFileSum.FILETYPE = FILETYPE.SJWJZJPSYJ;
 | 
						||
                    //        modelFileSum.STATUS = PFStandardStatus.Draft;
 | 
						||
                    //        var task = NotificationTaskService.InsertUserNoticeTaskModel("请提交经安全生产监督管理部门审查批准的专家审查意见", modelFileSum.ID, modelFileSum.ORG_ID, modelFileSum.USER_ID, userSafeMaster.NAME, System.DateTime.Now, 0, FormCode, FMTASKTYPE.Default);
 | 
						||
                    //        listTaskSend.Add(task);
 | 
						||
 | 
						||
                    //        foreach (var item in listMtEnd)
 | 
						||
                    //        {
 | 
						||
                    //            if (listMeetID.Contains(item.MEETING_ID))
 | 
						||
                    //            {
 | 
						||
                    //                if (!item.DATA_ID.HasValue)
 | 
						||
                    //                {
 | 
						||
                    //                    item.DATA_ID = modelFileSum.ID;
 | 
						||
                    //                    item.USER_ID = modelFileSum.USER_ID;
 | 
						||
                    //                    item.CODE = FormCode;
 | 
						||
                    //                }
 | 
						||
                    //                else
 | 
						||
                    //                {
 | 
						||
                    //                    item.CODE += ";TL004 DATA_ID:" + modelFileSum.ID + " USER_ID:" + modelFileSum.USER_ID;
 | 
						||
                    //                }
 | 
						||
                    //            }
 | 
						||
                    //        }
 | 
						||
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
                    //#endregion
 | 
						||
                    #region ToTL014
 | 
						||
                    listMTFA = listMT.Where(e => e.CREACTTYPE == CREACTTYPEEnum.ToTL014);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        //尾矿库部门负责人
 | 
						||
                        var wkEnum = GetEntity<T_FM_ENUMS>(e => e.CODE == "BSMineTypeEnum" && e.VALUE == 20);
 | 
						||
                        var listDep = GetEntities<T_FM_DEPARTMENT_PRODUCTION_UNIT>(e => e.ENUMS_ID == wkEnum.ID && e.Nav_Department.USER_ID.HasValue && e.Nav_Department.DEPARTMENT_TYPE == (int)FMDepartmentType.部门, null, "Nav_Department");
 | 
						||
                        if (listDep != null && listDep.Any())
 | 
						||
                        {
 | 
						||
                            var listUserID = listDep.Select(e => e.Nav_Department.USER_ID.Value);
 | 
						||
                            var listUser = GetEntities<T_FM_USER>(e => listUserID.Contains(e.ID), null, null);
 | 
						||
                            List<Guid> listUserIDD = new List<Guid>();
 | 
						||
                            List<string> listUserNAMED = new List<string>();
 | 
						||
                            listUser.ForEach(e => { if (!listUserIDD.Contains(e.ID)) { listUserIDD.Add(e.ID); listUserNAMED.Add(e.NAME); } });
 | 
						||
                            listTaskSend.AddRange(NotificationTaskService.InsertUserNoticeTaskModels("回采计划", null, filter.OrgId, listUserIDD, listUserNAMED, DateTime.Now, dtEndDefault, 0, "TL014"));
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region    12、今日提醒 
 | 
						||
 | 
						||
                    #region ToNotice 今日提醒
 | 
						||
                    //触发对象 根据公司实际指派  //触发今日提醒:消息类型:文件上传;消息内容:请上传下年度生产作业计划至文件库。 
 | 
						||
                    //谁发起的会议给谁触发今日提醒
 | 
						||
                    listMTFA = listMT.Where(e => e.CREACTTYPE == CREACTTYPEEnum.ToNotice);
 | 
						||
                    if (listMTFA != null && listMTFA.Any())
 | 
						||
                    {
 | 
						||
                        var listUserID = listMTFA.Where(e => e.CREATER_ID.HasValue).Select(e => e.CREATER_ID.Value).Distinct();
 | 
						||
                        if (listUserID != null && listUserID.Any())
 | 
						||
                        {
 | 
						||
                            var listUser = GetEntities<T_FM_USER>(e => !e.IS_DELETED && e.ENABLE_STATUS == 0 && listUserID.Contains(e.ID), null, null);
 | 
						||
                            foreach (var item in listMTFA)
 | 
						||
                            {
 | 
						||
                                if (!item.CREATER_ID.HasValue)
 | 
						||
                                    continue;
 | 
						||
                                var userSend = listUser.FirstOrDefault(e => e.ID == item.CREATER_ID.Value);
 | 
						||
                                if (userSend == null)
 | 
						||
                                    continue;
 | 
						||
                                listTaskSend.Add(NotificationTaskService.InsertUserNoticeTaskModel("请上传下年度生产作业计划至文件库", null, filter.OrgId, userSend.ID, userSend.NAME, DateTime.Now, (int)FMNoticeTypeEnum.今日提醒, "", FMTASKTYPE.Default));
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    taskSync = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);//跑批待办
 | 
						||
                    if (taskSync.SYNC_PARAM != null)
 | 
						||
                    {
 | 
						||
                        taskSync.SYNC_PARAM = "";
 | 
						||
                    }
 | 
						||
                    taskSync.TASK_END_TIME = DateTime.Now;
 | 
						||
                    taskSync.UPDATE_SUCCES_TIME = DateTime.Now;
 | 
						||
 | 
						||
                    this.UnifiedCommit(() =>
 | 
						||
                    {
 | 
						||
                        if (taskSync != null) //跑批信息
 | 
						||
                            UpdateEntityNoCommit(taskSync);
 | 
						||
                        BantchUpdateEntityNoCommit(listMtEnd);
 | 
						||
 | 
						||
                        if (listTaskSend != null && listTaskSend.Any()) //添加待办 公共
 | 
						||
                            BantchSaveEntityNoCommit(listTaskSend);
 | 
						||
 | 
						||
                        //if (modelFileSum != null) //TL 尾矿库建设  设计文件专家评审意见  
 | 
						||
                        //    UpdateEntityNoCommit(modelFileSum);
 | 
						||
 | 
						||
                        //if (listSurveyResult != null && listSurveyResult.Any()) //AE 添加调查结果填报 
 | 
						||
                        //    BantchSaveEntityNoCommit(listSurveyResult);
 | 
						||
                        //if (listInvestigationUsers != null && listInvestigationUsers.Any()) //勘察人员 
 | 
						||
                        //    BantchSaveEntityNoCommit(listInvestigationUsers);
 | 
						||
 | 
						||
                        //if (listMember != null && listMember.Any())//需要数据关联
 | 
						||
                        //    BantchSaveEntityNoCommit(listMember);
 | 
						||
                        //if (listResult != null && listResult.Any())//需要数据关联
 | 
						||
                        //    BantchSaveEntityNoCommit(listResult);
 | 
						||
                    });
 | 
						||
 | 
						||
                    int Count = ((listMtEnd != null && listMtEnd.Any()) ? listMtEnd.Count() : 0) + ((listTaskSend != null && listTaskSend.Any()) ? listTaskSend.Count : 0);// + ((listSurveyResult != null && listSurveyResult.Any()) ? listSurveyResult.Count : 0)
 | 
						||
                    SyncLogDetailService.InsertSyncLogDetail(HttpContext.Items, HttpContext.TraceIdentifier, filter.OrgId, Count, filter.Parameter1, SyncLogType.BSCreateCheckPlanSet);
 | 
						||
                }
 | 
						||
                catch (Exception ex)
 | 
						||
                {
 | 
						||
                    if (!string.IsNullOrEmpty(ex.StackTrace))
 | 
						||
                        throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
 | 
						||
                    else
 | 
						||
                        throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
 | 
						||
                }
 | 
						||
                return true;
 | 
						||
            });
 | 
						||
        }
 | 
						||
 | 
						||
        //事故事件与会议关联总体流程
 | 
						||
        //事故事件上报[AE006] => 审批 => 触发【事故调查小组成立】会议 => 【事故调查小组成员AE008】表单=> 触发【事故调查讨论】会议 => 【勘察记录表 AE018】表单  => 触发【调查报告讨论】会议 => 【事故事件调查结果填报表AE010】
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 其他模块 对接到会议开始
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="filter"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        [HttpPost, Route("OtherToMeetingBegin")]
 | 
						||
        public JsonActionResult<bool> OtherToMeetingBegin([FromBody] KeywordFilter filter)
 | 
						||
        {
 | 
						||
            return SafeExecute<bool>(() =>
 | 
						||
            {
 | 
						||
                try
 | 
						||
                {
 | 
						||
                    DateTime dtNow = DateTime.Now;
 | 
						||
                    if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
                    {
 | 
						||
                        try
 | 
						||
                        {
 | 
						||
                            //接收来自页面的参数
 | 
						||
                            DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
                            dtNow = deParm;
 | 
						||
                        }
 | 
						||
                        catch { }
 | 
						||
                    }
 | 
						||
 | 
						||
                    //ToWJSH 暂时没有表单 所以暂时只做了基础的处理
 | 
						||
                    var listMtBegin = GetEntities<T_SC_MT_MEETING_BEGIN>(e => !e.IS_DELETED && !e.ISBEGIN && (!e.END_IGNORE.HasValue || e.END_IGNORE.Value > dtNow), null, null).OrderBy(e => e.CREATE_TIME.Value);
 | 
						||
                    //&& e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Date == dtNow.Date  只要没触发 就会触发
 | 
						||
 | 
						||
                    if (listMtBegin == null || !listMtBegin.Any())
 | 
						||
                        return true;
 | 
						||
 | 
						||
                    #region    业务代码 扩展 每条一个事务处理 加强健壮性 但是性能低一些
 | 
						||
 | 
						||
                    int Count = 0;
 | 
						||
                    T_SC_MT_MEETING entityMT = null;
 | 
						||
                    List<T_SC_MT_MEETING_PALL> listMTAllUser = null;
 | 
						||
                    List<T_SC_MT_MEETING_CONTENT> listMTContent = null;
 | 
						||
                    T_FM_NOTIFICATION_TASK taskNotice = null;
 | 
						||
                    //T_AE_ACCIDENT_SURVEY_TEAM_MEMBER member = null;
 | 
						||
                    //IEnumerable<T_AE_ACCIDENT_SURVEY_TEAM_DEPUTY_LEADER> listUserLeadre = null;
 | 
						||
                    //IEnumerable<T_AE_ACCIDENT_SURVEY_TEAM_MEMBERS> listMember = null;
 | 
						||
                    T_FM_USER userSurvey = null;
 | 
						||
                    IEnumerable<Guid> listUserID = null;
 | 
						||
                    foreach (var item in listMtBegin)
 | 
						||
                    {
 | 
						||
                        switch (item.SOURCETYPE)
 | 
						||
                        {
 | 
						||
                            case SOURCETYPE.AE006ToMeet:
 | 
						||
                                #region //《事故事件上报表》归档后    触发   会议类型:普通会议    会议内容:事故调查小组成立
 | 
						||
                                userSurvey = GetEntity<T_FM_USER>(item.USER_ID, "Nav_Department");
 | 
						||
                                entityMT = new T_SC_MT_MEETING();
 | 
						||
                                entityMT.ID = Guid.NewGuid();
 | 
						||
                                entityMT.MEETINGTYPE = SCMEETINGTYPE.Ordinary;
 | 
						||
                                entityMT.CREACTTYPE = CREACTTYPEEnum.ToAE006;
 | 
						||
                                entityMT.DEPARTMENT_ID = userSurvey.DEPARTMENT_ID.Value;
 | 
						||
                                entityMT.LEVELVALUE = userSurvey.Nav_Department.DEPARTMENT_TYPE;
 | 
						||
                                entityMT.ORG_ID = item.ORG_ID;
 | 
						||
                                entityMT.USER_ID_ORIGINATOR = item.USER_ID;
 | 
						||
                                entityMT.STATUS = PFStandardStatus.Draft;
 | 
						||
                                entityMT.PERSCORE = 0;
 | 
						||
                                entityMT.IS_DELETED = false;
 | 
						||
                                entityMT.CREATE_TIME = DateTime.Now;
 | 
						||
 | 
						||
                                var modelContent = GetEntity<T_SC_MT_CONTENT_NAME>(e => e.NAME == "事故调查小组成立");
 | 
						||
                                if (modelContent != null)
 | 
						||
                                {
 | 
						||
                                    listMTContent = new List<T_SC_MT_MEETING_CONTENT>();
 | 
						||
                                    listMTContent.Add(new T_SC_MT_MEETING_CONTENT()
 | 
						||
                                    {
 | 
						||
                                        ID = Guid.NewGuid(),
 | 
						||
                                        ORG_ID = item.ORG_ID,
 | 
						||
                                        MEETING_ID = entityMT.ID,
 | 
						||
                                        CONTENTNAME_ID = modelContent.ID,
 | 
						||
                                    });
 | 
						||
                                }
 | 
						||
                                taskNotice = NotificationTaskService.InsertUserNoticeTaskModel("请召开事故调查小组成立会议", entityMT.ID, entityMT.ORG_ID, userSurvey.ID, userSurvey.NAME, dtNow, 0, "SC032", FMTASKTYPE.MT_PLAN_Make);
 | 
						||
                                item.RUN_COUNT++;
 | 
						||
                                item.ISBEGIN = true;
 | 
						||
                                item.MODIFY_TIME = DateTime.Now;
 | 
						||
                                item.MEETING_ID = entityMT.ID;
 | 
						||
                                this.UnifiedCommit(() =>
 | 
						||
                                {
 | 
						||
                                    UpdateEntityNoCommit(item);
 | 
						||
                                    UpdateEntityNoCommit(taskNotice);
 | 
						||
                                    UpdateEntityNoCommit(entityMT);//多次触发 人员可能会重复 
 | 
						||
                                    if (listMTContent != null && listMTContent.Any())//会议内容
 | 
						||
                                        BantchSaveEntityNoCommit(listMTContent);
 | 
						||
                                });
 | 
						||
                                Count += 4;
 | 
						||
                                #endregion
 | 
						||
                                break;
 | 
						||
                            case SOURCETYPE.AE008ToMeet:
 | 
						||
                                #region     流程描述 事故调查小组 =>会议 => 勘察记录 
 | 
						||
                                //member = GetEntity<T_AE_ACCIDENT_SURVEY_TEAM_MEMBER>(e => e.REPORT_ID.HasValue && e.REPORT_ID.Value == item.DATA_ID && e.STATUS == PFStandardStatus.Archived, "Nav_AccidentEventReport");
 | 
						||
                                //listUserLeadre = GetEntities<T_AE_ACCIDENT_SURVEY_TEAM_DEPUTY_LEADER>(e => !e.IS_DELETED && e.TEAM_MEMBER_ID == member.ID, null, null);//副组长
 | 
						||
                                //listMember = GetEntities<T_AE_ACCIDENT_SURVEY_TEAM_MEMBERS>(e => !e.IS_DELETED && e.TEAM_MEMBER_ID == member.ID, null, null);//组员 
 | 
						||
                                //if (listMember == null)
 | 
						||
                                //    continue;
 | 
						||
                                //entityMT = new T_SC_MT_MEETING();
 | 
						||
                                //listMTAllUser = new List<T_SC_MT_MEETING_PALL>();
 | 
						||
                                //listUserID = new List<Guid>();
 | 
						||
                                //if (listUserLeadre != null && listUserLeadre.Any())
 | 
						||
                                //{
 | 
						||
                                //    listUserID = listUserLeadre.Where(e => e.USER_ID.HasValue).Select(e => e.USER_ID.Value);
 | 
						||
                                //}
 | 
						||
                                //if (listMember != null && listMember.Any())
 | 
						||
                                //{
 | 
						||
                                //    listUserID = listUserID.Concat(listMember.Where(e => e.USER_ID.HasValue).Select(e => e.USER_ID.Value));
 | 
						||
                                //}
 | 
						||
                                //if (member.LEADER_USER_ID.HasValue && !listUserID.Contains(member.LEADER_USER_ID.Value))
 | 
						||
                                //{
 | 
						||
                                //    listUserID.Append(member.LEADER_USER_ID.Value);
 | 
						||
                                //}
 | 
						||
                                //if (member.SURVEY_USER_ID.HasValue && !listUserID.Contains(member.SURVEY_USER_ID.Value))
 | 
						||
                                //{
 | 
						||
                                //    listUserID.Append(member.SURVEY_USER_ID.Value);
 | 
						||
                                //}
 | 
						||
                                //listUserID = listUserID.Distinct();
 | 
						||
 | 
						||
                                //if (!item.MEETING_ID.HasValue || item.MEETING_ID == Guid.Empty)
 | 
						||
                                //{
 | 
						||
                                //    item.MEETING_ID = Guid.NewGuid();
 | 
						||
                                //}
 | 
						||
                                //userSurvey = GetEntity<T_FM_USER>(member.SURVEY_USER_ID.Value, "Nav_Department");
 | 
						||
                                //listMTAllUser = SCMTMeetingService.GetEntityInfo(item.MEETING_ID.Value, "事故调查小组成立 " + DateTime.Now.ToString("yyMMdd"), "事故调查小组成立", member.Nav_AccidentEventReport.CODE, item.ORG_ID, userSurvey.DEPARTMENT_ID.Value, userSurvey.Nav_Department.DEPARTMENT_TYPE, member.SURVEY_USER_ID.Value, CREACTTYPEEnum.AEToMTAfterTeamMember, SCMEETINGTYPE.Ordinary, listUserID, out entityMT);
 | 
						||
                                //taskNotice = NotificationTaskService.InsertUserNoticeTaskModel("请召开事故调查讨论会议", entityMT.ID, entityMT.ORG_ID, entityMT.USER_ID_ORIGINATOR, userSurvey.NAME, dtNow, 0, "SC032", FMTASKTYPE.MT_PLAN_Make);//+ entityMT.MEETINGTYPE.GetDescription()
 | 
						||
 | 
						||
                                //item.RUN_COUNT++;
 | 
						||
                                //item.ISBEGIN = true;
 | 
						||
                                //item.MODIFY_TIME = DateTime.Now;
 | 
						||
                                ////item.MEETING_ID = entityMT.ID;
 | 
						||
                                //var modelContent008 = GetEntity<T_SC_MT_CONTENT_NAME>(e => e.NAME == "事故调查讨论");
 | 
						||
                                //if (modelContent008 != null)
 | 
						||
                                //{
 | 
						||
                                //    listMTContent = new List<T_SC_MT_MEETING_CONTENT>();
 | 
						||
                                //    listMTContent.Add(new T_SC_MT_MEETING_CONTENT()
 | 
						||
                                //    {
 | 
						||
                                //        ID = Guid.NewGuid(),
 | 
						||
                                //        ORG_ID = item.ORG_ID,
 | 
						||
                                //        MEETING_ID = entityMT.ID,
 | 
						||
                                //        CONTENTNAME_ID = modelContent008.ID,
 | 
						||
                                //    });
 | 
						||
                                //}
 | 
						||
 | 
						||
                                ////var userLeader = GetEntity<T_FM_USER>(member.LEADER_USER_ID.Value, "Nav_Department");
 | 
						||
                                //////SCMTMeetingService.GetEntityInfo(item.MEETING_ID.Value, "事故事件关联 " + DateTime.Now.ToString("yyMMdd"), "事故事件关联 " + member.Nav_AccidentEventReport.NAME, member.Nav_AccidentEventReport.CODE, item.ORG_ID, userLeader.DEPARTMENT_ID.Value, userLeader.Nav_Department.DEPARTMENT_TYPE, member.LEADER_USER_ID.Value, CREACTTYPEEnum.AEToMTAfterTeamMember, SCMEETINGTYPE.Ordinary, listUserID, out entityMT, out listMTAllUser);
 | 
						||
                                ////SCMTMeetingService.GetEntityInfo(item.MEETING_ID.Value, "事故调查小组成立 " + DateTime.Now.ToString("yyMMdd"), "事故调查小组成立", member.Nav_AccidentEventReport.CODE, item.ORG_ID, userLeader.DEPARTMENT_ID.Value, userLeader.Nav_Department.DEPARTMENT_TYPE, member.LEADER_USER_ID.Value, CREACTTYPEEnum.AEToMTAfterTeamMember, SCMEETINGTYPE.Ordinary, listUserID, out entityMT, out listMTAllUser);
 | 
						||
                                //////listTask = NotificationTaskService.InsertUserNoticeTaskModels(noticeTitles[0], noticeDataIds, filter.OrgId, noticeUserIds, noticeUserNames, DateTime.Now, 0, FormCode, FMTASKTYPE.MT_PLAN_Make, (int)listPlanSetRund[i].PLANCHECKFREQUENCY);
 | 
						||
                                ////T_FM_NOTIFICATION_TASK taskNotice = NotificationTaskService.InsertUserNoticeTaskModel("请召开" + entityMT.MEETINGTYPE.GetDescription(), entityMT.ID, entityMT.ORG_ID, entityMT.USER_ID_ORIGINATOR, userLeader.NAME, dtNow, 0, "SC032", FMTASKTYPE.MT_PLAN_Make);
 | 
						||
 | 
						||
                                ////信息修改
 | 
						||
                                //this.UnifiedCommit(() =>
 | 
						||
                                //{
 | 
						||
                                //    UpdateEntityNoCommit(item);
 | 
						||
                                //    UpdateEntityNoCommit(entityMT);//多次触发 人员可能会重复 
 | 
						||
                                //    if (listMTAllUser != null && listMTAllUser.Any())
 | 
						||
                                //        BantchSaveEntityNoCommit(listMTAllUser);
 | 
						||
                                //    if (listMTContent != null && listMTContent.Any())
 | 
						||
                                //        BantchSaveEntityNoCommit(listMTContent);
 | 
						||
                                //    UpdateEntityNoCommit(taskNotice);
 | 
						||
                                //});
 | 
						||
                                //Count += ((listMTAllUser != null && listMTAllUser.Any()) ? listMTAllUser.Count() : 0);
 | 
						||
                                #endregion
 | 
						||
                                break;
 | 
						||
                            case SOURCETYPE.AE018ToMeet:
 | 
						||
                                #region     //调查报告讨论   //《勘察记录表》归档后          触发   会议类型:普通会议    会议内容:调查报告讨论
 | 
						||
                                //var recordModel = GetEntity<T_AE_INVESTIGATION_RECORD>(item.DATA_ID);
 | 
						||
                                //if (recordModel == null || !recordModel.ACCIDENT_ID.HasValue)
 | 
						||
                                //    continue;
 | 
						||
                                //member = GetEntity<T_AE_ACCIDENT_SURVEY_TEAM_MEMBER>(e => e.REPORT_ID.HasValue && e.REPORT_ID.Value == recordModel.ACCIDENT_ID.Value && e.STATUS == PFStandardStatus.Archived, "Nav_AccidentEventReport");
 | 
						||
                                //if (member == null)
 | 
						||
                                //    continue;
 | 
						||
                                ////member = GetEntity<T_AE_ACCIDENT_SURVEY_TEAM_MEMBER>(e => e.REPORT_ID.HasValue && e.REPORT_ID.Value == item.DATA_ID && e.STATUS == PFStandardStatus.Archived, "Nav_AccidentEventReport");
 | 
						||
                                //listUserLeadre = GetEntities<T_AE_ACCIDENT_SURVEY_TEAM_DEPUTY_LEADER>(e => !e.IS_DELETED && e.TEAM_MEMBER_ID == member.ID, null, null);//副组长
 | 
						||
                                //listMember = GetEntities<T_AE_ACCIDENT_SURVEY_TEAM_MEMBERS>(e => !e.IS_DELETED && e.TEAM_MEMBER_ID == member.ID, null, null);//组员 
 | 
						||
                                //if (listUserLeadre == null || listMember == null)
 | 
						||
                                //    continue;
 | 
						||
                                //entityMT = new T_SC_MT_MEETING();
 | 
						||
                                //listMTAllUser = new List<T_SC_MT_MEETING_PALL>();
 | 
						||
                                //listUserID = new List<Guid>();
 | 
						||
                                //if (listUserLeadre != null && listUserLeadre.Any())
 | 
						||
                                //{
 | 
						||
                                //    listUserID = listUserLeadre.Where(e => e.USER_ID.HasValue).Select(e => e.USER_ID.Value);
 | 
						||
                                //}
 | 
						||
                                //if (listMember != null && listMember.Any())
 | 
						||
                                //{
 | 
						||
                                //    listUserID = listUserID.Concat(listMember.Where(e => e.USER_ID.HasValue).Select(e => e.USER_ID.Value));
 | 
						||
                                //}
 | 
						||
                                //if (member.LEADER_USER_ID.HasValue && !listUserID.Contains(member.LEADER_USER_ID.Value))
 | 
						||
                                //{
 | 
						||
                                //    listUserID.Append(member.LEADER_USER_ID.Value);
 | 
						||
                                //}
 | 
						||
                                //if (member.SURVEY_USER_ID.HasValue && !listUserID.Contains(member.SURVEY_USER_ID.Value))
 | 
						||
                                //{
 | 
						||
                                //    listUserID.Append(member.SURVEY_USER_ID.Value);
 | 
						||
                                //}
 | 
						||
                                //listUserID = listUserID.Distinct();
 | 
						||
 | 
						||
                                //if (!item.MEETING_ID.HasValue || item.MEETING_ID == Guid.Empty)
 | 
						||
                                //{
 | 
						||
                                //    item.MEETING_ID = Guid.NewGuid();
 | 
						||
                                //}
 | 
						||
                                //userSurvey = GetEntity<T_FM_USER>(member.SURVEY_USER_ID.Value, "Nav_Department");
 | 
						||
 | 
						||
                                //listMTAllUser = SCMTMeetingService.GetEntityInfo(item.MEETING_ID.Value, "调查报告讨论" + DateTime.Now.ToString("yyMMdd"), "调查报告讨论", member.Nav_AccidentEventReport.CODE, item.ORG_ID, userSurvey.DEPARTMENT_ID.Value, userSurvey.Nav_Department.DEPARTMENT_TYPE, member.SURVEY_USER_ID.Value, CREACTTYPEEnum.ToAE010, SCMEETINGTYPE.Ordinary, listUserID, out entityMT);
 | 
						||
 | 
						||
                                //taskNotice = NotificationTaskService.InsertUserNoticeTaskModel("请召开调查报告讨论会议", entityMT.ID, entityMT.ORG_ID, entityMT.USER_ID_ORIGINATOR, userSurvey.NAME, dtNow, 0, "SC032", FMTASKTYPE.MT_PLAN_Make);
 | 
						||
 | 
						||
                                //var modelContent018 = GetEntity<T_SC_MT_CONTENT_NAME>(e => e.NAME == "调查报告讨论");
 | 
						||
                                //if (modelContent018 != null)
 | 
						||
                                //{
 | 
						||
                                //    listMTContent = new List<T_SC_MT_MEETING_CONTENT>();
 | 
						||
                                //    listMTContent.Add(new T_SC_MT_MEETING_CONTENT()
 | 
						||
                                //    {
 | 
						||
                                //        ID = Guid.NewGuid(),
 | 
						||
                                //        ORG_ID = item.ORG_ID,
 | 
						||
                                //        MEETING_ID = entityMT.ID,
 | 
						||
                                //        CONTENTNAME_ID = modelContent018.ID,
 | 
						||
                                //    });
 | 
						||
                                //}
 | 
						||
 | 
						||
                                //item.RUN_COUNT++;
 | 
						||
                                //item.ISBEGIN = true;
 | 
						||
                                //item.MODIFY_TIME = DateTime.Now;
 | 
						||
                                //item.MEETING_ID = entityMT.ID;
 | 
						||
                                ////信息修改
 | 
						||
                                //this.UnifiedCommit(() =>
 | 
						||
                                //{
 | 
						||
                                //    UpdateEntityNoCommit(item);
 | 
						||
                                //    UpdateEntityNoCommit(entityMT);//多次触发 人员可能会重复 
 | 
						||
                                //    UpdateEntityNoCommit(taskNotice);
 | 
						||
                                //    if (listMTAllUser != null && listMTAllUser.Any())
 | 
						||
                                //        BantchSaveEntityNoCommit(listMTAllUser);
 | 
						||
                                //    if (listMTContent != null && listMTContent.Any())
 | 
						||
                                //        BantchSaveEntityNoCommit(listMTContent);
 | 
						||
                                //});
 | 
						||
                                //Count += (2 + ((listMTAllUser != null && listMTAllUser.Any()) ? listMTAllUser.Count() : 0) + (listMTContent != null ? listMTContent.Count : 0));
 | 
						||
                                #endregion
 | 
						||
                                break;
 | 
						||
                            case SOURCETYPE.PR023ToMeet:
 | 
						||
                                #region      //《变化识别评估表》提交后      触发   会议类型:普通会议    会议内容:变化管理讨论     触发对象: item.USER_ID
 | 
						||
 | 
						||
                                var modelUser = GetEntity<T_FM_USER>(item.USER_ID, "Nav_Department");
 | 
						||
                                entityMT = new T_SC_MT_MEETING();
 | 
						||
                                entityMT.ID = Guid.NewGuid();
 | 
						||
                                entityMT.MEETINGTYPE = SCMEETINGTYPE.Ordinary;
 | 
						||
                                entityMT.CREACTTYPE = CREACTTYPEEnum.PR023ToMeet;
 | 
						||
                                if (!modelUser.DEPARTMENT_ID.HasValue)
 | 
						||
                                {
 | 
						||
                                    throw new Exception(HttpContext.Request.Path + " 1834 " + modelUser.ID.ToString());
 | 
						||
                                }
 | 
						||
                                entityMT.DEPARTMENT_ID = modelUser.DEPARTMENT_ID.Value;
 | 
						||
                                if (userSurvey != null && userSurvey.Nav_Department != null)
 | 
						||
                                {
 | 
						||
                                    entityMT.LEVELVALUE = userSurvey.Nav_Department.DEPARTMENT_TYPE;
 | 
						||
                                }
 | 
						||
                                entityMT.ORG_ID = item.ORG_ID;
 | 
						||
                                entityMT.USER_ID_ORIGINATOR = item.USER_ID;
 | 
						||
                                entityMT.STATUS = PFStandardStatus.Draft;
 | 
						||
                                entityMT.PERSCORE = 0;
 | 
						||
                                entityMT.IS_DELETED = false;
 | 
						||
                                entityMT.CREATE_TIME = DateTime.Now;
 | 
						||
 | 
						||
                                modelContent = GetEntity<T_SC_MT_CONTENT_NAME>(e => e.NAME == "变化管理讨论");
 | 
						||
                                if (modelContent != null)
 | 
						||
                                {
 | 
						||
                                    listMTContent = new List<T_SC_MT_MEETING_CONTENT>();
 | 
						||
                                    listMTContent.Add(new T_SC_MT_MEETING_CONTENT()
 | 
						||
                                    {
 | 
						||
                                        ID = Guid.NewGuid(),
 | 
						||
                                        ORG_ID = item.ORG_ID,
 | 
						||
                                        MEETING_ID = entityMT.ID,
 | 
						||
                                        CONTENTNAME_ID = modelContent.ID,
 | 
						||
                                    });
 | 
						||
                                }
 | 
						||
 | 
						||
                                taskNotice = NotificationTaskService.InsertUserNoticeTaskModel("请召开变化管理讨论会议", entityMT.ID, entityMT.ORG_ID, modelUser.ID, modelUser.NAME, dtNow, 0, "SC032", FMTASKTYPE.MT_PLAN_Make);
 | 
						||
 | 
						||
                                item.RUN_COUNT++;
 | 
						||
                                item.ISBEGIN = true;
 | 
						||
                                item.MODIFY_TIME = DateTime.Now;
 | 
						||
                                item.MEETING_ID = entityMT.ID;
 | 
						||
 | 
						||
                                this.UnifiedCommit(() =>
 | 
						||
                                {
 | 
						||
                                    UpdateEntityNoCommit(item);
 | 
						||
                                    UpdateEntityNoCommit(entityMT);//多次触发 人员可能会重复 
 | 
						||
                                    if (listMTContent != null && listMTContent.Any())//会议内容
 | 
						||
                                        BantchSaveEntityNoCommit(listMTContent);
 | 
						||
                                    UpdateEntityNoCommit(taskNotice);
 | 
						||
                                });
 | 
						||
                                Count += (2 + (listMTContent != null ? listMTContent.Count : 0));
 | 
						||
                                #endregion
 | 
						||
                                break;
 | 
						||
                            case SOURCETYPE.PT014ToMeet:
 | 
						||
                                #region      //《安全生产方针征集表》归档后  触发   会议类型:普通会议    会议内容:安全生产方针讨论   触发对象:安环部负责人 / 安全员
 | 
						||
                                string Msg = string.Empty;
 | 
						||
                                var userSafeMaster = UserService.GetRoleUser(ref Msg, "安环部负责人", null, null);
 | 
						||
                                if (userSafeMaster == null)
 | 
						||
                                    userSafeMaster = UserService.GetRoleUser(ref Msg, "安环部安全员", null, null);
 | 
						||
                                if (userSafeMaster != null)
 | 
						||
                                {
 | 
						||
                                    entityMT = new T_SC_MT_MEETING();
 | 
						||
                                    entityMT.ID = Guid.NewGuid();
 | 
						||
                                    entityMT.MEETINGTYPE = SCMEETINGTYPE.Ordinary;
 | 
						||
                                    entityMT.DEPARTMENT_ID = userSafeMaster.DEPARTMENT_ID.Value;
 | 
						||
                                    entityMT.LEVELVALUE = (int)FMDepartmentType.部门;
 | 
						||
                                    entityMT.ORG_ID = item.ORG_ID;
 | 
						||
                                    entityMT.USER_ID_ORIGINATOR = userSafeMaster.ID;
 | 
						||
                                    entityMT.STATUS = PFStandardStatus.Draft;
 | 
						||
                                    entityMT.PERSCORE = 0;
 | 
						||
                                    entityMT.IS_DELETED = false;
 | 
						||
                                    entityMT.CREATE_TIME = DateTime.Now;
 | 
						||
 | 
						||
                                    var modelContent014 = GetEntity<T_SC_MT_CONTENT_NAME>(e => e.NAME == "安全生产方针讨论");
 | 
						||
                                    if (modelContent014 != null)
 | 
						||
                                    {
 | 
						||
                                        listMTContent = new List<T_SC_MT_MEETING_CONTENT>();
 | 
						||
                                        listMTContent.Add(new T_SC_MT_MEETING_CONTENT()
 | 
						||
                                        {
 | 
						||
                                            ID = Guid.NewGuid(),
 | 
						||
                                            ORG_ID = item.ORG_ID,
 | 
						||
                                            MEETING_ID = entityMT.ID,
 | 
						||
                                            CONTENTNAME_ID = modelContent014.ID,
 | 
						||
                                        });
 | 
						||
                                    }
 | 
						||
                                    taskNotice = NotificationTaskService.InsertUserNoticeTaskModel("请召开安全生产方针讨论会议", entityMT.ID, entityMT.ORG_ID, userSafeMaster.ID, userSafeMaster.NAME, dtNow, 0, "SC032", FMTASKTYPE.MT_PLAN_Make);
 | 
						||
                                    item.RUN_COUNT++;
 | 
						||
                                    item.ISBEGIN = true;
 | 
						||
                                    item.MODIFY_TIME = DateTime.Now;
 | 
						||
                                    item.MEETING_ID = entityMT.ID;
 | 
						||
                                    this.UnifiedCommit(() =>
 | 
						||
                                    {
 | 
						||
                                        UpdateEntityNoCommit(item);
 | 
						||
                                        UpdateEntityNoCommit(entityMT);//多次触发 人员可能会重复 
 | 
						||
                                        if (listMTContent != null && listMTContent.Any())//会议内容
 | 
						||
                                            BantchSaveEntityNoCommit(listMTContent);
 | 
						||
                                        UpdateEntityNoCommit(taskNotice);
 | 
						||
                                    });
 | 
						||
                                    Count += (2 + (listMTContent != null ? listMTContent.Count : 0));
 | 
						||
                                }
 | 
						||
                                #endregion
 | 
						||
                                break;
 | 
						||
                            default:
 | 
						||
                                break;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    SyncLogDetailService.InsertSyncLogDetail(HttpContext.Items, HttpContext.TraceIdentifier, filter.OrgId, Count, filter.Parameter1, SyncLogType.BSCreateCheckPlanSet);
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    if (Count > 0)
 | 
						||
                    {
 | 
						||
                        T_FM_SYNC_TASK taskSync = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);//跑批待办
 | 
						||
                        if (taskSync.SYNC_PARAM != null)
 | 
						||
                        {
 | 
						||
                            taskSync.SYNC_PARAM = "";
 | 
						||
                        }
 | 
						||
                        taskSync.TASK_END_TIME = DateTime.Now;
 | 
						||
                        taskSync.UPDATE_SUCCES_TIME = DateTime.Now;
 | 
						||
                        this.UnifiedCommit(() =>
 | 
						||
                        {
 | 
						||
                            if (taskSync != null) //跑批信息
 | 
						||
                                UpdateEntityNoCommit(taskSync);
 | 
						||
                        });
 | 
						||
                    }
 | 
						||
                }
 | 
						||
                catch (Exception ex)
 | 
						||
                {
 | 
						||
                    if (!string.IsNullOrEmpty(ex.StackTrace))
 | 
						||
                        throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
 | 
						||
                    else
 | 
						||
                        throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
 | 
						||
                }
 | 
						||
                return true;
 | 
						||
            });
 | 
						||
        }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
        ///// <summary>
 | 
						||
        ///// 会议开始   原方法 如果有多个可能会报错
 | 
						||
        ///// 现在按每个单独处理(从数据库获取的model 不能设置导航属性为空)
 | 
						||
        ///// </summary>
 | 
						||
        ///// <param name="filter"></param>
 | 
						||
        ///// <returns></returns>
 | 
						||
        //[HttpPost, Route("MeetingBegin")]
 | 
						||
        //public JsonActionResult<bool> MeetingBegin([FromBody] KeywordFilter filter)
 | 
						||
        //{
 | 
						||
        //    return SafeExecute<bool>(() =>
 | 
						||
        //    {
 | 
						||
        //        DateTime dtNow = DateTime.Now;
 | 
						||
        //        if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
        //        {
 | 
						||
        //            try
 | 
						||
        //            {
 | 
						||
        //                //接收来自页面的参数
 | 
						||
        //                DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
        //                dtNow = deParm;
 | 
						||
        //            }
 | 
						||
        //            catch { }
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        //查找符合条件的会议信息   今天 已经审批过  开始时间小于当前时间 的会议
 | 
						||
        //        var listMeeting = GetEntities<T_SC_MT_MEETING>(e => !e.ISBEGIN && e.STATUS == PFStandardStatus.Archived && e.BEGIN_TIME.HasValue && e.BEGIN_TIME.Value.Date == dtNow.Date && e.BEGIN_TIME <= dtNow, null, new string[] { "Nav_UserRecorder", "Nav_ListPAll.Nav_User", "Nav_ListPReView", "Nav_ListMeetingContent.Nav_ContentName.Nav_ListContent.Nav_ListContentDeal" });
 | 
						||
        //        if (listMeeting == null || !listMeeting.Any())
 | 
						||
        //        {
 | 
						||
        //            //没有符合条件的会议
 | 
						||
        //            return true;
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        //跑批 会议开始时 1、给 记录人 发送 会议纪要 待办  2、判断 参会人员 的状态   (未完成 默认参会)
 | 
						||
        //        foreach (var item in listMeeting)
 | 
						||
        //        {
 | 
						||
        //            List<T_FM_NOTIFICATION_TASK> listTask = new List<T_FM_NOTIFICATION_TASK>();
 | 
						||
        //            List<T_SC_MT_MEETING_MINUTES> listMeetMinutes = new List<T_SC_MT_MEETING_MINUTES>();
 | 
						||
        //            List<T_SC_MT_MEETING_PALL> listAllChange = new List<T_SC_MT_MEETING_PALL>();
 | 
						||
        //            List<T_SC_MT_MINUTES_PREVIEW> listMeetMinutesPreview = new List<T_SC_MT_MINUTES_PREVIEW>();
 | 
						||
        //            DateTime dtOperate = DateTime.Now; //实际时间 不随传参改变
 | 
						||
        //            int NoticeNotDeal = (int)FMNoticeStatusEnum.未处理;
 | 
						||
        //            List<T_FM_NOTIFICATION_TASK> listTaskEnd = new List<T_FM_NOTIFICATION_TASK>();
 | 
						||
 | 
						||
 | 
						||
        //            List<T_SC_MT_MEETING_PJOIN> listJoin = new List<T_SC_MT_MEETING_PJOIN>();//参会
 | 
						||
        //            List<T_SC_MT_MEETING_PASKFORLEAVE> listAskLevel = new List<T_SC_MT_MEETING_PASKFORLEAVE>();//请假
 | 
						||
        //            List<T_SC_MT_MEETING_MINUTES_CONTENT> listMinutesContent = new List<T_SC_MT_MEETING_MINUTES_CONTENT>();
 | 
						||
        //            List<T_SC_MT_MEETING_MINUTES_CONTENT_DEAL> listMinutesContentDeal = new List<T_SC_MT_MEETING_MINUTES_CONTENT_DEAL>();
 | 
						||
 | 
						||
 | 
						||
        //            item.ISBEGIN = true;//修改是否开始
 | 
						||
 | 
						||
        //            T_SC_MT_MEETING_MINUTES meetMinutes = new T_SC_MT_MEETING_MINUTES();
 | 
						||
        //            meetMinutes.MEETINGTYPE = item.MEETINGTYPE;
 | 
						||
        //            meetMinutes.ID = Guid.NewGuid();
 | 
						||
        //            meetMinutes.MEETING_ID = item.ID;
 | 
						||
        //            meetMinutes.STATUS = PFStandardStatus.Draft;
 | 
						||
        //            meetMinutes.CREATER_ID = item.USER_ID_RECORDER;
 | 
						||
        //            meetMinutes.CREATE_TIME = dtOperate;
 | 
						||
        //            meetMinutes.ORG_ID = item.ORG_ID;
 | 
						||
        //            listMeetMinutes.Add(meetMinutes);
 | 
						||
        //            //给记录人 添加待办
 | 
						||
 | 
						||
        //            //判断有几个题目 
 | 
						||
        //            foreach (var itemTitle in item.Nav_ListMeetingContent)
 | 
						||
        //            {
 | 
						||
        //                if (itemTitle.Nav_ContentName.Nav_ListContent == null || !itemTitle.Nav_ContentName.Nav_ListContent.Any())
 | 
						||
        //                {
 | 
						||
        //                    continue;
 | 
						||
        //                }
 | 
						||
        //                foreach (var itemNAME in itemTitle.Nav_ContentName.Nav_ListContent)
 | 
						||
        //                {
 | 
						||
        //                    //itemNAME.TITLE
 | 
						||
        //                    T_SC_MT_MEETING_MINUTES_CONTENT modelContent = new T_SC_MT_MEETING_MINUTES_CONTENT();
 | 
						||
        //                    modelContent.ID = Guid.NewGuid();
 | 
						||
        //                    modelContent.ORG_ID = item.ORG_ID;
 | 
						||
        //                    modelContent.MEETING_MINUTES_ID = meetMinutes.ID;
 | 
						||
        //                    modelContent.CONTENT_ID = itemNAME.ID;
 | 
						||
        //                    modelContent.CREATER_ID = item.USER_ID_RECORDER;
 | 
						||
        //                    modelContent.CREATE_TIME = dtOperate;
 | 
						||
        //                    listMinutesContent.Add(modelContent);
 | 
						||
        //                    if (itemNAME.Nav_ListContentDeal == null || !itemNAME.Nav_ListContentDeal.Any())
 | 
						||
        //                    {
 | 
						||
        //                        continue;
 | 
						||
        //                    }
 | 
						||
 | 
						||
        //                    foreach (var itemDetail in itemNAME.Nav_ListContentDeal)
 | 
						||
        //                    {
 | 
						||
        //                        //选项内容
 | 
						||
        //                        //itemDetail.CONTENTDETAIL
 | 
						||
        //                        T_SC_MT_MEETING_MINUTES_CONTENT_DEAL modelContentDetail = new T_SC_MT_MEETING_MINUTES_CONTENT_DEAL();
 | 
						||
        //                        modelContentDetail.ID = Guid.NewGuid();
 | 
						||
        //                        modelContentDetail.ORG_ID = item.ORG_ID;
 | 
						||
        //                        modelContentDetail.CONTENT_ID = modelContent.ID;
 | 
						||
        //                        modelContentDetail.CONTENT_DEAL_ID = itemDetail.ID;
 | 
						||
        //                        modelContentDetail.ISCHECK = false;
 | 
						||
        //                        modelContentDetail.GETPOINT = 0;
 | 
						||
        //                        modelContentDetail.CREATER_ID = item.USER_ID_RECORDER;
 | 
						||
        //                        modelContentDetail.CREATE_TIME = dtOperate;
 | 
						||
        //                        listMinutesContentDeal.Add(modelContentDetail);
 | 
						||
        //                    }
 | 
						||
        //                }
 | 
						||
        //            }
 | 
						||
        //            //SC034 普通会议纪要编辑
 | 
						||
        //            //SC030 安委会纪要编辑
 | 
						||
 | 
						||
        //            var taskAdd = NotificationTaskService.InsertUserNoticeTaskModel(item.MEETINGTYPE.GetDescription() + "会议纪要", meetMinutes.ID, meetMinutes.ORG_ID, item.USER_ID_RECORDER.Value, item.Nav_UserRecorder.NAME, DateTime.Now, DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, (int)item.MEETINGTYPE >= 40 ? "SC030" : "SC034");
 | 
						||
        //            listTask.Add(taskAdd);
 | 
						||
 | 
						||
        //            foreach (var itemAll in item.Nav_ListPAll)
 | 
						||
        //            {
 | 
						||
        //                if (itemAll.JOINRESULT == null)//参会情况未反馈
 | 
						||
        //                {
 | 
						||
        //                    //如果未反馈  直接 修改状态为未完成  默认参加会议
 | 
						||
        //                    itemAll.JOINRESULT = JoinTaskResult.UnCheck;//系统设置未完成
 | 
						||
        //                    //itemAll.PERSONTYPE = SCMEETINGPERSONTYPE.JOIN; //未反馈的默认参会
 | 
						||
        //                    listAllChange.Add(itemAll);
 | 
						||
        //                }
 | 
						||
 | 
						||
        //                switch (itemAll.JOINRESULT)
 | 
						||
        //                {
 | 
						||
        //                    case JoinTaskResult.Join:
 | 
						||
        //                    case JoinTaskResult.UnCheck:
 | 
						||
        //                        //参加 未完成 默认 参会
 | 
						||
        //                        T_SC_MT_MEETING_PJOIN join = new T_SC_MT_MEETING_PJOIN();
 | 
						||
        //                        join.ID = Guid.NewGuid();
 | 
						||
        //                        join.MEETING_MINUTES_ID = meetMinutes.ID;
 | 
						||
        //                        if (itemAll.PERSONTYPE == SCMEETINGPERSONTYPE.ALL || itemAll.PERSONTYPE == SCMEETINGPERSONTYPE.JOIN)// || itemAll.PERSONTYPE == SCMEETINGPERSONTYPE.JOIN 应该不要
 | 
						||
        //                        {
 | 
						||
        //                            if (item.Nav_ListPReView != null && item.Nav_ListPReView.Any())
 | 
						||
        //                            {
 | 
						||
        //                                var rep = item.Nav_ListPReView.Where(e => e.USER_ID == itemAll.USER_ID);
 | 
						||
        //                                if (rep != null && rep.Any())
 | 
						||
        //                                {
 | 
						||
        //                                    join.PERSONTYPE = SCMEETINGPERSONTYPE.REVIEW;
 | 
						||
        //                                }
 | 
						||
        //                                else
 | 
						||
        //                                {
 | 
						||
        //                                    join.PERSONTYPE = SCMEETINGPERSONTYPE.JOIN;
 | 
						||
        //                                }
 | 
						||
        //                            }
 | 
						||
        //                            else
 | 
						||
        //                            {
 | 
						||
        //                                join.PERSONTYPE = SCMEETINGPERSONTYPE.JOIN;
 | 
						||
        //                            }
 | 
						||
        //                        }
 | 
						||
        //                        else if (itemAll.PERSONTYPE == SCMEETINGPERSONTYPE.REVIEW)
 | 
						||
        //                        {
 | 
						||
        //                            join.PERSONTYPE = SCMEETINGPERSONTYPE.REVIEW;
 | 
						||
        //                        }
 | 
						||
        //                        join.USER_ID = itemAll.USER_ID;
 | 
						||
        //                        join.IS_DELETED = false;
 | 
						||
        //                        join.ORG_ID = itemAll.ORG_ID;
 | 
						||
        //                        join.ISRECORDRED = false;
 | 
						||
        //                        listJoin.Add(join);
 | 
						||
        //                        break;
 | 
						||
        //                    case JoinTaskResult.AskForLeave:
 | 
						||
        //                        //请假
 | 
						||
        //                        T_SC_MT_MEETING_PASKFORLEAVE asklevel = new T_SC_MT_MEETING_PASKFORLEAVE();
 | 
						||
        //                        asklevel.ID = Guid.NewGuid();
 | 
						||
        //                        asklevel.MEETING_MINUTES_ID = meetMinutes.ID;
 | 
						||
        //                        asklevel.PERSONTYPE = SCMEETINGPERSONTYPE.JOIN;
 | 
						||
        //                        asklevel.USER_ID = itemAll.USER_ID;
 | 
						||
        //                        asklevel.IS_DELETED = false;
 | 
						||
        //                        asklevel.ORG_ID = itemAll.ORG_ID;
 | 
						||
        //                        listAskLevel.Add(asklevel);
 | 
						||
        //                        break;
 | 
						||
        //                    default:
 | 
						||
        //                        break;
 | 
						||
        //                }
 | 
						||
        //            }
 | 
						||
 | 
						||
        //            //item.Nav_ListPAll = null; 这样会把ID清空 
 | 
						||
 | 
						||
        //            var thisNotDeal = GetEntities<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_FORMCODE == "SC028_SHOWPRINT" && e.SOURCE_DATA_ID == item.ID && e.NOTICE_STATUS == NoticeNotDeal, null, null);//这边应该不会有重复数据  (这个会议 未处理的 待办)
 | 
						||
 | 
						||
        //            if (thisNotDeal != null && thisNotDeal.Any())
 | 
						||
        //            {
 | 
						||
        //                listTaskEnd.AddRange(thisNotDeal);
 | 
						||
        //            }
 | 
						||
 | 
						||
        //            if (item.Nav_ListPReView != null && item.Nav_ListPReView.Any())
 | 
						||
        //            {
 | 
						||
        //                //评审 人员
 | 
						||
        //                foreach (var itemP in item.Nav_ListPReView)
 | 
						||
        //                {
 | 
						||
        //                    listMeetMinutesPreview.Add(new T_SC_MT_MINUTES_PREVIEW()
 | 
						||
        //                    {
 | 
						||
        //                        ID = Guid.NewGuid(),
 | 
						||
        //                        ORG_ID = itemP.ORG_ID,
 | 
						||
        //                        MEETING_MINUTES_ID = meetMinutes.ID,
 | 
						||
        //                        PERSONTYPE = SCMEETINGPERSONTYPE.REVIEW,
 | 
						||
        //                        USER_ID = itemP.USER_ID,
 | 
						||
        //                        ISRECORDRED = false
 | 
						||
        //                    });
 | 
						||
        //                }
 | 
						||
        //            }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
        //            //对未处理的待办 做系统超期处理
 | 
						||
        //            if (listTaskEnd != null && listTaskEnd.Count > 0)
 | 
						||
        //            {
 | 
						||
        //                foreach (var itemT in listTaskEnd)
 | 
						||
        //                {
 | 
						||
        //                    itemT.NOTICE_STATUS = (int)FMNoticeStatusEnum.超期办理;
 | 
						||
        //                    itemT.MODIFY_TIME = dtOperate;
 | 
						||
        //                }
 | 
						||
        //            }
 | 
						||
 | 
						||
        //            T_FM_SYNC_TASK task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
 | 
						||
        //            if (task != null)
 | 
						||
        //            {
 | 
						||
        //                task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
 | 
						||
        //                task.SYNC_PARAM = "";//清空参数
 | 
						||
        //            }
 | 
						||
 | 
						||
        //            this.UnifiedCommit(() =>
 | 
						||
        //            {
 | 
						||
        //                if (listMeeting != null && listMeeting.Any()) //会议状态【是否开始】修改
 | 
						||
        //                    BantchUpdateEntityNoCommit(listMeeting);
 | 
						||
        //                if (listMeetMinutes != null && listMeetMinutes.Any()) //添加会议纪要
 | 
						||
        //                    BantchSaveEntityNoCommit(listMeetMinutes);
 | 
						||
        //                if (listJoin != null && listJoin.Any()) //参会人员
 | 
						||
        //                    BantchSaveEntityNoCommit(listJoin);
 | 
						||
        //                if (listAskLevel != null && listAskLevel.Any()) //请假人员
 | 
						||
        //                    BantchSaveEntityNoCommit(listAskLevel);
 | 
						||
        //                if (listTask != null && listTask.Any()) //给记录人发送会议纪要待办
 | 
						||
        //                    BantchSaveEntityNoCommit(listTask);
 | 
						||
        //                if (listAllChange != null && listAllChange.Any()) //参会人员未反馈 状态修改
 | 
						||
        //                    BantchUpdateEntityNoCommit(listAllChange);
 | 
						||
        //                if (listTaskEnd != null && listTaskEnd.Count > 0) //未完成对应待办处理
 | 
						||
        //                    BantchUpdateEntityNoCommit(listTaskEnd);
 | 
						||
        //                if (listMinutesContent != null && listMinutesContent.Any()) //会议意见
 | 
						||
        //                    BantchSaveEntityNoCommit(listMinutesContent);
 | 
						||
        //                if (listMinutesContentDeal != null && listMinutesContentDeal.Any()) //会议意见详情
 | 
						||
        //                    BantchSaveEntityNoCommit(listMinutesContentDeal);
 | 
						||
        //                if (listMeetMinutesPreview != null && listMeetMinutesPreview.Count > 0)//审批人员
 | 
						||
        //                    BantchSaveEntityNoCommit(listMeetMinutesPreview);
 | 
						||
        //                if (task != null)
 | 
						||
        //                    UpdateEntityNoCommit(task);
 | 
						||
        //            });
 | 
						||
 | 
						||
        //        }
 | 
						||
 | 
						||
        //        return true;
 | 
						||
        //    });
 | 
						||
        //}
 | 
						||
 | 
						||
 | 
						||
    }
 | 
						||
}
 |