1307 lines
		
	
	
		
			71 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			1307 lines
		
	
	
		
			71 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.OH;
 | 
						||
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/OH")]
 | 
						||
    [TypeFilter(typeof(CustomActionFilterAttribute))]
 | 
						||
    public partial class OHController : AuthorizeApiController<T_OH_HEALTH_EXAM_NOTICE>
 | 
						||
    {
 | 
						||
 | 
						||
        IFMNotificationTaskService NotificationTaskService { get; set; }
 | 
						||
        IFMUserService UserService { get; set; }
 | 
						||
        //IBSSafeCheckService SafeCheckService { get; set; }, IBSSafeCheckService safeCheckService
 | 
						||
        IPFSysLogService SysLogService { get; set; }
 | 
						||
        IFMSyncLogDetailService SyncLogDetailService { get; set; }
 | 
						||
        public OHController(IFMNotificationTaskService notificationTaskService, IPFSysLogService sysLogService, IFMUserService userService, IFMSyncLogDetailService syncLogDetailService)
 | 
						||
        {
 | 
						||
            NotificationTaskService = notificationTaskService;
 | 
						||
            SysLogService = sysLogService;
 | 
						||
            UserService = userService;
 | 
						||
            SyncLogDetailService = syncLogDetailService;
 | 
						||
        }
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 给人事专员推送 体检计划表单 每天推送一次  参数需要加  PlanAddDate="03-01"
 | 
						||
        /// 每年8月1日(时间可设置)触发今日提醒给安环部负责人上传第三方检测报告;消息类型:文件上传;消息内容:请上传职业危害检测报告  UpLoadDate='08-01'
 | 
						||
        /// 
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="filter"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        [HttpPost, Route("ExamPlan")]
 | 
						||
        public JsonActionResult<bool> ExamPlan([FromBody] KeywordFilter filter)
 | 
						||
        {
 | 
						||
            //岗位 暂时没按配置的实现
 | 
						||
            return SafeExecute<bool>(() =>
 | 
						||
            {
 | 
						||
                try
 | 
						||
                {
 | 
						||
 | 
						||
                    DateTime dtNow = DateTime.Now;
 | 
						||
                    //DateTime? dtPlanAddDate = null;//设置3月1号推送体检计划表单
 | 
						||
                    //DateTime? dtUpLoadDate = null;//设置 8月1号 给安环部推送今日待办
 | 
						||
                    //DateTime? dtMonitorDate = null;//设置 12月15日 将监测结果进行统计后推送待办任务给监测阈值表中的记录人
 | 
						||
                    List<T_OH_RUNCONFIG> listConfig = null;
 | 
						||
                    if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
                    {
 | 
						||
                        try
 | 
						||
                        {
 | 
						||
                            DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
                            dtNow = deParm;
 | 
						||
                        }
 | 
						||
                        catch
 | 
						||
                        {
 | 
						||
                            dtNow = DateTime.Now;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    T_FM_SYNC_TASK task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);//跑批待办
 | 
						||
                    int min = 10;//10分钟以内
 | 
						||
                    DateTime dtMax = dtNow;
 | 
						||
                    if (task.SYNC_UNIT.HasValue)
 | 
						||
                    {
 | 
						||
                        switch (task.SYNC_UNIT.Value)//秒 = 0,  分 = 1,   时 = 2,  天 = 3,
 | 
						||
                        {
 | 
						||
                            case 1:
 | 
						||
                                min = task.PERIODIC_TIME;
 | 
						||
                                break;
 | 
						||
                            case 2:
 | 
						||
                                min = task.PERIODIC_TIME * 60;
 | 
						||
                                break;
 | 
						||
                            case 3:
 | 
						||
                                min = task.PERIODIC_TIME * 60 * 24;
 | 
						||
                                break;
 | 
						||
                            case 0:
 | 
						||
                            default:
 | 
						||
                                break;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    dtMax = dtMax.AddMinutes(min);
 | 
						||
                    listConfig = GetEntities<T_OH_RUNCONFIG>(e => !e.IS_DELETED, null, null).ToList();
 | 
						||
                    if (listConfig != null && listConfig.Any())
 | 
						||
                    {
 | 
						||
                        //string dtMD = dtNow.ToString("MM-dd");
 | 
						||
                        //for (int i = listConfig.Count - 1; i > -1; i--)
 | 
						||
                        //{
 | 
						||
                        //    if (listConfig[i].DATE.ToString("MM-dd") != dtMD)
 | 
						||
                        //    {
 | 
						||
                        //        listConfig.RemoveAt(i);
 | 
						||
                        //    }
 | 
						||
                        //}
 | 
						||
 | 
						||
                        DateTime dtRun = DateTime.Now;
 | 
						||
                        //按触发时间  
 | 
						||
                        for (int i = listConfig.Count - 1; i > -1; i--)
 | 
						||
                        {
 | 
						||
                            try
 | 
						||
                            {
 | 
						||
                                dtRun = Convert.ToDateTime(dtNow.Year + listConfig[i].DATE.ToString("-MM-dd HH:mm:ss"));
 | 
						||
                                if (dtNow <= dtRun && dtRun <= dtMax)
 | 
						||
                                {
 | 
						||
                                    //时间段内 往下执行
 | 
						||
                                }
 | 
						||
                                else
 | 
						||
                                {
 | 
						||
                                    listConfig.RemoveAt(i);
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            catch
 | 
						||
                            {
 | 
						||
                                listConfig.RemoveAt(i);
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    bool isPlanSend = false;//体检部门 到截止时间 汇总给人事专员
 | 
						||
 | 
						||
                    #region  判断是否有 待结束的体检计划
 | 
						||
 | 
						||
                    string Msg = string.Empty;
 | 
						||
                    T_FM_USER UserRS = null;
 | 
						||
                    List<Guid> listPlanIDTask = null;//需要创建 部门体检计划汇总  的PlanID
 | 
						||
                    DateTime dtPlanStart = dtNow.Date.AddSeconds(-1);
 | 
						||
                    var listExamPlan = GetEntities<T_OH_HEALTH_EXAM_PLAN>(e => e.DUE_TIME.HasValue && dtPlanStart <= e.DUE_TIME.Value && e.DUE_TIME.Value <= dtNow && !e.IS_DELETED && e.STATUS == PFStandardStatus.Sign, null, null);
 | 
						||
                    if (listExamPlan != null && listExamPlan.Any())
 | 
						||
                    {
 | 
						||
                        UserRS = UserService.GetPostUser(ref Msg, "人事专员");
 | 
						||
                        if (UserRS == null)
 | 
						||
                        {
 | 
						||
                            if (string.IsNullOrEmpty(Msg))
 | 
						||
                            {
 | 
						||
                                throw new Exception("未获取到人事专员!");
 | 
						||
                            }
 | 
						||
                            else
 | 
						||
                            {
 | 
						||
                                throw new Exception(Msg);
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        var listPlanID = listExamPlan.Select(x => x.ID).ToList();
 | 
						||
                        //再判断人事专员没有收到待办
 | 
						||
                        var listPlanTask = GetEntities<T_FM_NOTIFICATION_TASK>(e => !e.IS_DELETED && e.USER_ID == UserRS.ID && e.SOURCE_FORMCODE.StartsWith("OH006") && e.SOURCE_DATA_ID.HasValue && listPlanID.Contains(e.SOURCE_DATA_ID.Value), null, null);
 | 
						||
                        if (listPlanTask == null || listPlanTask.Count() != listExamPlan.Count())
 | 
						||
                        {
 | 
						||
                            isPlanSend = true;
 | 
						||
                            listPlanIDTask = new List<Guid>();
 | 
						||
                            if (listPlanTask == null || !listPlanTask.Any())
 | 
						||
                            {
 | 
						||
                                listPlanIDTask = listPlanID;
 | 
						||
                            }
 | 
						||
                            else
 | 
						||
                            {
 | 
						||
                                foreach (var item in listPlanTask)
 | 
						||
                                {
 | 
						||
                                    if (!listPlanID.Contains(item.SOURCE_DATA_ID.Value))
 | 
						||
                                    {
 | 
						||
                                        listPlanIDTask.Add(item.SOURCE_DATA_ID.Value);
 | 
						||
                                    }
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    bool isSendResultImport = false;//是否 体检结果录入
 | 
						||
                    #region     判断是否有体检结果录入
 | 
						||
 | 
						||
                    var listNotice = GetEntities<T_OH_HEALTH_EXAM_NOTICE>(e => e.NOTICEIMPORTSTATE == NoticeImportState.Draft && !e.IS_DELETED && e.END_TIME <= dtNow, null, null);
 | 
						||
                    if (listNotice != null && listNotice.Any())
 | 
						||
                    {
 | 
						||
                        isSendResultImport = true;
 | 
						||
                    }
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    if ((listConfig == null || !listConfig.Any()) && !isPlanSend && !isSendResultImport)
 | 
						||
                    {
 | 
						||
                        return true;
 | 
						||
                    }
 | 
						||
 | 
						||
                    bool isPlanAdd = false;//体检计划表
 | 
						||
                    bool isUpLoad = false;//职业危害检测报告
 | 
						||
                    bool isMonitorResult = false;//监测结果统计与分析汇总
 | 
						||
 | 
						||
                    foreach (var item in listConfig)
 | 
						||
                    {
 | 
						||
                        switch (item.CONFIGTYPE)
 | 
						||
                        {
 | 
						||
                            case ConfigType.EXAM_PLAN:
 | 
						||
                                isPlanAdd = true;
 | 
						||
                                break;
 | 
						||
                            case ConfigType.CHECK_REPORT:
 | 
						||
                                isUpLoad = true;
 | 
						||
                                break;
 | 
						||
                            case ConfigType.RESULT_SUM:
 | 
						||
                                isMonitorResult = true;
 | 
						||
                                break;
 | 
						||
                            default:
 | 
						||
                                break;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
 | 
						||
                    if (!isPlanAdd && !isUpLoad && !isMonitorResult && !isPlanSend && !isSendResultImport)
 | 
						||
                    {
 | 
						||
                        return true;
 | 
						||
                    }
 | 
						||
 | 
						||
                    //T_FM_SYNC_TASK task = null;//跑批待办
 | 
						||
                    T_FM_NOTIFICATION_TASK taskPlan = null;//人事专员创建体检计划(03-01)
 | 
						||
                    T_OH_HEALTH_EXAM_PLAN examPlan = null;//体检计划
 | 
						||
                    T_FM_NOTIFICATION_TASK taskUpLoad = null;//安环部上传职业危害报告(08-01)
 | 
						||
 | 
						||
                    T_OH_HAZARD_MONITOR_RESULT_SUM resultSum = null;
 | 
						||
                    List<T_OH_HAZARD_MONITOR_RESULT> resultList = null;
 | 
						||
                    List<T_FM_NOTIFICATION_TASK> listTaskMonitorResult = null;
 | 
						||
 | 
						||
                    //OH004
 | 
						||
                    if (isPlanAdd)
 | 
						||
                    {
 | 
						||
                        T_OH_HEALTH_EXAM_PLAN examPlanCheck = GetEntity<T_OH_HEALTH_EXAM_PLAN>(e => !e.IS_DELETED && e.CREATE_TIME.Value.Date == dtNow.Date && e.YEAR == dtNow.Year);
 | 
						||
                        if (examPlanCheck == null)
 | 
						||
                        {
 | 
						||
                            T_FM_USER userRS = null;
 | 
						||
                            var config = listConfig.FirstOrDefault(e => e.CONFIGTYPE == ConfigType.EXAM_PLAN && e.POST_ID.HasValue);
 | 
						||
                            if (config != null)
 | 
						||
                            {
 | 
						||
                                var person = GetEntity<T_FM_PERSON>(e => e.POST_ID.HasValue && e.POST_ID.Value == config.POST_ID.Value, "Nav_User");
 | 
						||
                                if (person == null)
 | 
						||
                                {
 | 
						||
                                    SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少岗位ID【" + config.POST_ID.Value + "】的配置", Msg + "  体检计划接口【PP/OH/ExamPlan】");
 | 
						||
                                }
 | 
						||
                                else
 | 
						||
                                {
 | 
						||
                                    userRS = person.Nav_User;
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
                            if (userRS == null)
 | 
						||
                            {
 | 
						||
                                userRS = UserService.GetPostUser(ref Msg);
 | 
						||
                            }
 | 
						||
                            if (userRS == null)
 | 
						||
                            {
 | 
						||
                                SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少【人事专员】岗位人员", Msg + "  体检计划接口【PP/OH/ExamPlan】");
 | 
						||
                            }
 | 
						||
                            else
 | 
						||
                            {
 | 
						||
                                examPlan = new T_OH_HEALTH_EXAM_PLAN();
 | 
						||
                                examPlan.ID = Guid.NewGuid();
 | 
						||
                                //examPlan.NAME =;
 | 
						||
                                examPlan.YEAR = DateTime.Now.Year;
 | 
						||
                                //examPlan.DUE_TIME =;
 | 
						||
                                //examPlan.[CONTENT] =;
 | 
						||
                                examPlan.STATAUSORDER = OHHealthExamPlanStatus.Draft;
 | 
						||
                                examPlan.STATUS = PFStandardStatus.Draft;
 | 
						||
                                //examPlan.APPROVE_ID =;
 | 
						||
                                examPlan.IS_DELETED = false;
 | 
						||
                                examPlan.ORG_ID = filter.OrgId;
 | 
						||
                                //examPlan.ENTITY_ORG_TPYE =;
 | 
						||
                                //examPlan.FORM_ID =;
 | 
						||
                                //examPlan.FLOW_STATUS =;
 | 
						||
                                //examPlan.FLOW_SEND_STATUS =;
 | 
						||
                                //examPlan.FLOW_ID =;
 | 
						||
                                examPlan.CREATE_TIME = DateTime.Now;
 | 
						||
                                //examPlan.MODIFY_TIME =;
 | 
						||
                                //examPlan.CREATER_ID =;
 | 
						||
                                //examPlan.MODIFIER_ID =;
 | 
						||
                                taskPlan = NotificationTaskService.InsertUserNoticeTaskModel("体检计划", examPlan.ID, examPlan.ORG_ID, userRS.ID, userRS.NAME, DateTime.Now, 0, "OH004", FMTASKTYPE.OH_EXAM_PLAN);
 | 
						||
                                //taskPlan = NotificationTaskService.InsertUserNoticeTaskModel("体检计划", examPlan.ID, examPlan.ORG_ID, userRS.ID, userRS.NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OH004");
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    if (isUpLoad)
 | 
						||
                    {
 | 
						||
                        //每年8月1日(时间可设置)触发今日提醒给安环部负责人上传第三方检测报告;消息类型:文件上传;消息内容:请上传职业危害检测报告
 | 
						||
                        T_FM_USER userSafeMaster = null;
 | 
						||
                        var config = listConfig.FirstOrDefault(e => e.CONFIGTYPE == ConfigType.CHECK_REPORT && e.POST_ID.HasValue);
 | 
						||
                        if (config != null)
 | 
						||
                        {
 | 
						||
                            var person = GetEntity<T_FM_PERSON>(e => e.POST_ID.HasValue && e.POST_ID.Value == config.POST_ID.Value, "Nav_User");
 | 
						||
                            if (person == null)
 | 
						||
                            {
 | 
						||
                                SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少岗位ID【" + config.POST_ID.Value + "】的配置", "体检计划接口【PP/OH/ExamPlan】");
 | 
						||
                            }
 | 
						||
                            else
 | 
						||
                            {
 | 
						||
                                userSafeMaster = person.Nav_User;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        if (userSafeMaster == null)
 | 
						||
                        {
 | 
						||
                            userSafeMaster = UserService.GetRoleUser(ref Msg, "安环部负责人", null, null);
 | 
						||
                        }
 | 
						||
 | 
						||
                        if (userSafeMaster == null)
 | 
						||
                        {
 | 
						||
                            SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少【安环部负责人】", Msg + "  体检计划接口【PP/OH/ExamPlan】");
 | 
						||
                        }
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            DateTime dtNowDate = dtNow.Date;
 | 
						||
                            var taskCheck = GetEntity<T_FM_NOTIFICATION_TASK>(e => e.SOURCE_DATA_ID == Guid.Empty && e.USER_ID == userSafeMaster.ID && e.NOTICE_TYPE == 0 && e.CREATE_TIME.Value.Date == dtNowDate && e.NOTICE_TITLE == "请上传职业危害检测报告");
 | 
						||
                            if (taskCheck == null || taskCheck.ID == Guid.Empty)
 | 
						||
                            {
 | 
						||
                                //taskUpLoad = NotificationTaskService.InsertUserNoticeTaskModel("请上传职业危害检测报告", Guid.Empty, userSafeMaster.ORG_ID, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, DateTime.Now.AddDays(1), (int)FMNoticeTypeEnum.消息, "OH034");
 | 
						||
                                taskUpLoad = NotificationTaskService.InsertUserNoticeTaskModel("请上传职业危害检测报告", Guid.Empty, userSafeMaster.ORG_ID, userSafeMaster.ID, userSafeMaster.NAME, DateTime.Now, (int)FMNoticeTypeEnum.消息, "OH034", FMTASKTYPE.OH_MONITOR_JOB_Report);
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
                    if (isMonitorResult)
 | 
						||
                    {
 | 
						||
                        var sum = GetEntity<T_OH_HAZARD_MONITOR_RESULT_SUM>(e => e.YEAR == dtNow.Year && !e.IS_DELETED);
 | 
						||
                        if (sum == null)
 | 
						||
                        {
 | 
						||
                            //今年没有添加过
 | 
						||
                            var listMonitorDetail = GetEntities<T_OH_HAZARD_MONITOR_JOB_DETAIL>(e => !e.IS_DELETED && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Year == dtNow.Year && e.OVER_LIMIT.HasValue && e.Nav_Job.STATUS == OHHazardMonitorJobStatusEnum.Finish, null, new string[] { "Nav_Job" });
 | 
						||
                            if (listMonitorDetail != null && listMonitorDetail.Any())
 | 
						||
                            {
 | 
						||
                                //有监测记录明细
 | 
						||
                                //每种职业危害类型 每个人 添加一条监测结果
 | 
						||
                                Dictionary<Guid, List<Guid>> dicListRuleUser = new Dictionary<Guid, List<Guid>>();
 | 
						||
                                List<Guid> listUserIDCheck = null;
 | 
						||
                                List<Guid> listUserID = new List<Guid>();
 | 
						||
                                foreach (var item in listMonitorDetail)
 | 
						||
                                {
 | 
						||
                                    if (!item.RULE_ID.HasValue || !item.USER_ID_GET.HasValue)
 | 
						||
                                    {
 | 
						||
                                        continue;
 | 
						||
                                    }
 | 
						||
                                    if (dicListRuleUser.ContainsKey(item.RULE_ID.Value))
 | 
						||
                                    {
 | 
						||
                                        listUserIDCheck = dicListRuleUser[item.RULE_ID.Value];
 | 
						||
                                        if (!listUserIDCheck.Contains(item.USER_ID_GET.Value))
 | 
						||
                                        {
 | 
						||
                                            dicListRuleUser[item.RULE_ID.Value].Add(item.USER_ID_GET.Value);
 | 
						||
                                            listUserID.Add(item.USER_ID_GET.Value);
 | 
						||
                                        }
 | 
						||
                                    }
 | 
						||
                                    else
 | 
						||
                                    {
 | 
						||
                                        dicListRuleUser.Add(item.RULE_ID.Value, new List<Guid>() { item.USER_ID_GET.Value });
 | 
						||
                                        listUserID.Add(item.USER_ID_GET.Value);
 | 
						||
                                    }
 | 
						||
                                }
 | 
						||
 | 
						||
                                if (dicListRuleUser.Count > 0)
 | 
						||
                                {
 | 
						||
                                    resultSum = new T_OH_HAZARD_MONITOR_RESULT_SUM();
 | 
						||
                                    resultSum.ID = Guid.NewGuid();
 | 
						||
                                    resultSum.YEAR = dtNow.Year;
 | 
						||
                                    resultSum.TIME = dtNow.Date;
 | 
						||
                                    //resultSum.RATIO =;
 | 
						||
                                    resultSum.STATUS = PFStandardStatus.Draft;
 | 
						||
                                    resultSum.IS_DELETED = false;
 | 
						||
                                    resultSum.ORG_ID = filter.OrgId;
 | 
						||
                                    //resultSum.ENTITY_ORG_TPYE =;
 | 
						||
                                    //resultSum.FORM_ID     =;
 | 
						||
                                    //resultSum.FLOW_STATUS =;
 | 
						||
                                    //resultSum.FLOW_SEND_STATUS  =;
 | 
						||
                                    //resultSum.FLOW_ID     =;
 | 
						||
                                    //resultSum.CREATE_TIME =;
 | 
						||
                                    //resultSum.MODIFY_TIME =;
 | 
						||
                                    //resultSum.CREATER_ID  =;
 | 
						||
                                    //resultSum.MODIFIER_ID =;
 | 
						||
                                    listTaskMonitorResult = new List<T_FM_NOTIFICATION_TASK>();
 | 
						||
                                    resultList = new List<T_OH_HAZARD_MONITOR_RESULT>();
 | 
						||
                                    foreach (var item in dicListRuleUser)
 | 
						||
                                    {
 | 
						||
                                        foreach (var itemV in item.Value)
 | 
						||
                                        {
 | 
						||
                                            resultList.Add(new T_OH_HAZARD_MONITOR_RESULT()
 | 
						||
                                            {
 | 
						||
                                                ID = Guid.NewGuid(),
 | 
						||
                                                RULE_ID = item.Key,
 | 
						||
                                                SUM_ID = resultSum.ID,
 | 
						||
                                                MONITOR_COUNT = listMonitorDetail.Where(e => e.RULE_ID == item.Key && e.USER_ID_GET == itemV).Count(),
 | 
						||
                                                OK_COUNT = listMonitorDetail.Where(e => e.RULE_ID == item.Key && e.USER_ID_GET == itemV && e.OVER_LIMIT.Value == YesNoEnum.No).Count(),
 | 
						||
                                                OK_PERCENT = 0,//默认最后计算
 | 
						||
                                                               //TREND =,
 | 
						||
                                                STATUS = PFStandardStatus.Draft,
 | 
						||
                                                IS_DELETED = false,
 | 
						||
                                                ORG_ID = filter.OrgId,
 | 
						||
                                                User_ID = itemV,
 | 
						||
                                                //ENTITY_ORG_TPYE
 | 
						||
                                                //FORM_ID
 | 
						||
                                                //FLOW_STATUS
 | 
						||
                                                //FLOW_SEND_STATUS
 | 
						||
                                                //FLOW_ID
 | 
						||
                                                //CREATE_TIME
 | 
						||
                                                //MODIFY_TIME
 | 
						||
                                                //CREATER_ID
 | 
						||
                                                //MODIFIER_ID
 | 
						||
                                            });
 | 
						||
                                        }
 | 
						||
                                    }
 | 
						||
 | 
						||
                                    foreach (var item in resultList)
 | 
						||
                                    {
 | 
						||
                                        if (item.MONITOR_COUNT != 0)
 | 
						||
                                        {
 | 
						||
                                            item.OK_PERCENT = item.OK_COUNT / item.MONITOR_COUNT;
 | 
						||
                                        }
 | 
						||
                                    }
 | 
						||
                                }
 | 
						||
 | 
						||
                                List<T_FM_USER> listUser = GetEntities<T_FM_USER>(e => listUserID.Contains(e.ID), null, null).ToList();
 | 
						||
                                List<Guid> listUserSendID = new List<Guid>();
 | 
						||
                                List<string> listUserSendName = new List<string>();
 | 
						||
                                foreach (var item in listUser)
 | 
						||
                                {
 | 
						||
                                    listUserSendID.Add(item.ID);
 | 
						||
                                    listUserSendName.Add(item.NAME);
 | 
						||
                                }
 | 
						||
                                //发送待办
 | 
						||
 | 
						||
                                listTaskMonitorResult = NotificationTaskService.InsertUserNoticeTaskModels("监测结果统计与分析表", resultSum.ID, resultSum.ORG_ID, listUserSendID, listUserSendName, DateTime.Now, 0, "OH028", FMTASKTYPE.OH_MONITOR_RESULT_SUM);
 | 
						||
                                //listTaskMonitorResult = NotificationTaskService.InsertUserNoticeTaskModels("监测结果统计与分析表", resultSum.ID, resultSum.ORG_ID, listUserSendID, listUserSendName, DateTime.Now, DateTime.Now.AddDays(1), 0, "OH028");
 | 
						||
                            }
 | 
						||
                            else
 | 
						||
                            {
 | 
						||
                                //没有信息 暂不处理
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    List<T_FM_NOTIFICATION_TASK> listNoticeImport = null; //体检导入通知
 | 
						||
                    List<T_OH_HEALTH_EXAM_RESULT_IMPORT> listImportOrder = new List<T_OH_HEALTH_EXAM_RESULT_IMPORT>();
 | 
						||
 | 
						||
                    if (isSendResultImport)
 | 
						||
                    {
 | 
						||
                        //体检结果录入  合并 PP/OH/SendResultImport
 | 
						||
                        T_FM_USER userRS = null;
 | 
						||
                        //找体检计划的配置
 | 
						||
                        var config = GetEntity<T_OH_RUNCONFIG>(e => !e.IS_DELETED && e.CONFIGTYPE == ConfigType.EXAM_PLAN);
 | 
						||
                        if (config != null)
 | 
						||
                        {
 | 
						||
                            var person = GetEntity<T_FM_PERSON>(e => e.POST_ID.HasValue && e.POST_ID.Value == config.POST_ID.Value, "Nav_User");
 | 
						||
                            if (person == null)
 | 
						||
                            {
 | 
						||
                                SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少岗位ID【" + config.POST_ID.Value + "】的配置", Msg + "  体检计划接口【PP/OH/ExamPlan】");
 | 
						||
                            }
 | 
						||
                            else
 | 
						||
                            {
 | 
						||
                                userRS = person.Nav_User;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
 | 
						||
                        if (userRS == null)
 | 
						||
                        {
 | 
						||
                            UserService.GetPostUser(ref Msg);
 | 
						||
                        }
 | 
						||
                        if (userRS == null)
 | 
						||
                        {
 | 
						||
                            if (string.IsNullOrEmpty(Msg))
 | 
						||
                            {
 | 
						||
                                SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少【人事专员】岗位人员", "体检结果录入【PP/OH/ExamPlan】");//体检计划接口
 | 
						||
                            }
 | 
						||
                            else
 | 
						||
                            {
 | 
						||
                                SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少【人事专员】岗位人员", Msg + "  体检结果录入【PP/OH/ExamPlan】");//体检计划接口
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            List<Guid> listPARENTID = new List<Guid>();
 | 
						||
                            List<Guid> listDataID = new List<Guid>();
 | 
						||
 | 
						||
                            List<Guid> listUserId = new List<Guid>();
 | 
						||
                            List<string> listUserName = new List<string>();
 | 
						||
                            //同一个 PARENTID 发送一个待办
 | 
						||
                            foreach (var item in listNotice)
 | 
						||
                            {
 | 
						||
                                item.NOTICEIMPORTSTATE = NoticeImportState.NoticeImport;
 | 
						||
 | 
						||
                                if (item.PARENTID.HasValue && !listPARENTID.Contains(item.PARENTID.Value))
 | 
						||
                                {
 | 
						||
                                    listPARENTID.Add(item.PARENTID.Value);
 | 
						||
                                    T_OH_HEALTH_EXAM_RESULT_IMPORT modelImport = new T_OH_HEALTH_EXAM_RESULT_IMPORT();
 | 
						||
                                    modelImport.ID = Guid.NewGuid();
 | 
						||
                                    modelImport.ORG_ID = item.ORG_ID.Value;
 | 
						||
                                    modelImport.NOTICE_ID = item.PARENTID.Value;
 | 
						||
                                    listDataID.Add(modelImport.ID);
 | 
						||
                                    listImportOrder.Add(modelImport);
 | 
						||
 | 
						||
                                    //Name.Add("体检通知结果导入");
 | 
						||
                                    listUserId.Add(userRS.ID);
 | 
						||
                                    listUserName.Add(userRS.NAME);
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
 | 
						||
                            listNoticeImport = NotificationTaskService.InsertUserNoticeTaskModels("体检结果导入", listDataID, filter.OrgId, listUserId, listUserName, DateTime.Now, 1, "OH017_IMPORT", FMTASKTYPE.OH_EXAM_RESULT_IMPORT);
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
 | 
						||
                    //部门级 体检计划表 待变成未处理 无需处理
 | 
						||
                    List<T_OH_HEALTH_EAXM_PLAN_DEPARTMENT> listPlanDepChange = null;
 | 
						||
                    IEnumerable<T_FM_NOTIFICATION_TASK> listTaskDepNeedEnd = null;
 | 
						||
                    //给人事专员发送 【部门体检计划汇总】待办
 | 
						||
                    List<T_FM_NOTIFICATION_TASK> listTaskDepSum = null;
 | 
						||
 | 
						||
                    if (isPlanSend && listPlanIDTask != null && listPlanIDTask.Count > 0)
 | 
						||
                    {
 | 
						||
                        IEnumerable<T_OH_HEALTH_EAXM_PLAN_DEPARTMENT> listPlanDep = null;
 | 
						||
                        var listPlanDepAll = GetEntities<T_OH_HEALTH_EAXM_PLAN_DEPARTMENT>(e => listPlanIDTask.Contains(e.PLAN_ID), null, null);
 | 
						||
                        if (listPlanDepAll != null && listPlanDepAll.Any())
 | 
						||
                        {
 | 
						||
                            listPlanDep = listPlanDepAll.Where(e => e.STATUS != PFStandardStatus.Draft);
 | 
						||
                        }
 | 
						||
 | 
						||
                        if (listPlanDep != null && listPlanDep.Any())//如果大家都没填写 不汇总
 | 
						||
                        {
 | 
						||
                            List<Guid> listPLANID = listPlanDep.Select(e => e.PLAN_ID).Distinct().ToList();
 | 
						||
                            List<Guid> listPlanDepID = new List<Guid>();// listPlanDep.Select(e => e.ID).Distinct().ToList();
 | 
						||
                            foreach (var item in listPlanDepAll)
 | 
						||
                            {
 | 
						||
                                if (listPLANID.Contains(item.PLAN_ID) && item.STATUS == PFStandardStatus.Draft)
 | 
						||
                                {
 | 
						||
                                    item.MODIFY_TIME = DateTime.Now;
 | 
						||
                                    item.STATUS = PFStandardStatus.Archived;
 | 
						||
                                    if (listPlanDepChange == null)
 | 
						||
                                    {
 | 
						||
                                        listPlanDepChange = new List<T_OH_HEALTH_EAXM_PLAN_DEPARTMENT>();
 | 
						||
                                    }
 | 
						||
                                    listPlanDepChange.Add(item);
 | 
						||
                                    listPlanDepID.Add(item.ID);
 | 
						||
                                }
 | 
						||
                            }
 | 
						||
 | 
						||
                            T_OH_HEALTH_EAXM_PLAN_DEPARTMENT planDepCheck = null;
 | 
						||
                            listTaskDepNeedEnd = GetEntities<T_FM_NOTIFICATION_TASK>(e => !e.IS_DELETED && e.SOURCE_FORMCODE == "OH005" && e.SOURCE_DATA_ID.HasValue && listPlanDepID.Contains(e.SOURCE_DATA_ID.Value), null, null);
 | 
						||
                            listTaskDepSum = new List<T_FM_NOTIFICATION_TASK>();
 | 
						||
                            foreach (var item in listTaskDepNeedEnd)
 | 
						||
                            {
 | 
						||
                                item.TASK_DT = dtNow;
 | 
						||
                                item.NOTICE_STATUS = 4;// FMNoticeStatusEnum.超时无需办理;
 | 
						||
                                item.SOURCE_FORMCODE = "OH005_SHOWPRINT";
 | 
						||
 | 
						||
                                #region     查找获取计划ID 给人事专员 发送待办
 | 
						||
 | 
						||
                                planDepCheck = listPlanDep.FirstOrDefault(e => e.ID == item.SOURCE_DATA_ID.Value);
 | 
						||
                                if (planDepCheck != null && listTaskDepSum.FirstOrDefault(e => e.SOURCE_DATA_ID == planDepCheck.PLAN_ID) == null)
 | 
						||
                                {
 | 
						||
                                    listTaskDepSum.Add(NotificationTaskService.InsertUserNoticeTaskModel("部门体检计划汇总", planDepCheck.PLAN_ID, planDepCheck.ORG_ID, UserRS.ID, UserRS.NAME, DateTime.Now, (int)FMNoticeTypeEnum.消息, "OH006", FMTASKTYPE.OH_EXAM_PLAN_SUM));
 | 
						||
                                    //listTaskDepSum.Add(NotificationTaskService.InsertUserNoticeTaskModel("部门体检计划汇总", planDepCheck.PLAN_ID, planDepCheck.ORG_ID, UserRS.ID, UserRS.NAME, DateTime.Now, DateTime.Now.AddDays(1), (int)FMNoticeTypeEnum.消息, "OH006"));
 | 
						||
                                }
 | 
						||
 | 
						||
                                #endregion
 | 
						||
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                        else
 | 
						||
                        {
 | 
						||
                            isPlanSend = false;
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    if (taskPlan != null || taskUpLoad != null || resultSum != null || (listNotice != null && listNotice.Any()) || (listTaskDepSum != null && listTaskDepSum.Any()))
 | 
						||
                    {
 | 
						||
                        //task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
 | 
						||
                        if (task != null)
 | 
						||
                        {
 | 
						||
                            task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
 | 
						||
                            task.SYNC_PARAM = "";
 | 
						||
                            //task.SYNC_PARAM = "PlanAddDate=" + strPlanAddDate + "|UpLoadDate=" + strUpLoadDate + "|MonitorDate=" + strMonitorDate;//清空参数
 | 
						||
                        }
 | 
						||
 | 
						||
                        this.UnifiedCommit(() =>
 | 
						||
                        {
 | 
						||
                            if (task != null)
 | 
						||
                                UpdateEntityNoCommit(task);//跑批信息
 | 
						||
                        if (examPlan != null)
 | 
						||
                                UpdateEntityNoCommit(examPlan);//体检计划
 | 
						||
                        if (taskPlan != null)
 | 
						||
                                UpdateEntityNoCommit(taskPlan);//体检计划待办
 | 
						||
                        if (taskUpLoad != null)
 | 
						||
                                UpdateEntityNoCommit(taskUpLoad);//职业危害检测报告
 | 
						||
 | 
						||
                        if (resultSum != null)
 | 
						||
                                UpdateEntityNoCommit(resultSum);//保存汇总信息
 | 
						||
                        if (resultList != null && resultList.Any())
 | 
						||
                                BantchAddEntityNoCommit(resultList);//保存汇总明细信息
 | 
						||
                        if (listTaskMonitorResult != null && listTaskMonitorResult.Any())
 | 
						||
                                BantchAddEntityNoCommit(listTaskMonitorResult);//给记录人发送待办
 | 
						||
 | 
						||
                        //体检截止日期已到 给人事专员 发送  部门体检计划汇总
 | 
						||
                        if (listPlanDepChange != null && listPlanDepChange.Any())//部门体检计划状态修改
 | 
						||
                            BantchSaveEntityNoCommit(listPlanDepChange);
 | 
						||
                            if (listTaskDepNeedEnd != null && listTaskDepNeedEnd.Any())//待办归档
 | 
						||
                            BantchSaveEntityNoCommit(listTaskDepNeedEnd);
 | 
						||
                            if (listTaskDepSum != null && listTaskDepSum.Any())//发送待办
 | 
						||
                            BantchAddEntityNoCommit(listTaskDepSum);
 | 
						||
 | 
						||
                        //体检结果录入表单
 | 
						||
                        if (listNotice != null && listNotice.Any())//修改状态
 | 
						||
                            BantchSaveEntityNoCommit(listNotice);
 | 
						||
                            if (listImportOrder != null && listImportOrder.Any())//添加导入Model
 | 
						||
                            BantchSaveEntityNoCommit(listImportOrder);
 | 
						||
                            if (listNoticeImport != null && listNoticeImport.Any())//添加待办
 | 
						||
                            BantchSaveEntityNoCommit(listNoticeImport);
 | 
						||
                        });
 | 
						||
 | 
						||
                        int Count = ((resultList != null && resultList.Any()) ? resultList.Count : 0) + ((listTaskMonitorResult != null && listTaskMonitorResult.Any()) ? listTaskMonitorResult.Count : 0) + ((listPlanDepChange != null && listPlanDepChange.Any()) ? listPlanDepChange.Count : 0) + ((listTaskDepNeedEnd != null && listTaskDepNeedEnd.Any()) ? listTaskDepNeedEnd.Count() : 0) + ((listTaskDepSum != null && listTaskDepSum.Any()) ? listTaskDepSum.Count() : 0) + ((listNotice != null && listNotice.Any()) ? listNotice.Count() : 0) + ((listImportOrder != null && listImportOrder.Any()) ? listImportOrder.Count() : 0) + ((listNoticeImport != null && listNoticeImport.Any()) ? listNoticeImport.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;
 | 
						||
            });
 | 
						||
        }
 | 
						||
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 体检结果录入表单
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="filter"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        [HttpPost, Route("SendResultImport")]
 | 
						||
        public JsonActionResult<bool> SendResultImport([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 listNotice = GetEntities<T_OH_HEALTH_EXAM_NOTICE>(e => e.NOTICEIMPORTSTATE == NoticeImportState.Draft && e.END_TIME <= dtNow && !e.IS_DELETED, null, null);
 | 
						||
                //if (listNotice == null || !listNotice.Any())
 | 
						||
                //{
 | 
						||
                //    return true;
 | 
						||
                //}
 | 
						||
                //string Msg = string.Empty;
 | 
						||
                //T_FM_USER userRS = UserService.GetPostUser(ref Msg);
 | 
						||
                //if (userRS == null)
 | 
						||
                //{
 | 
						||
                //    if (string.IsNullOrEmpty(Msg))
 | 
						||
                //    {
 | 
						||
                //        SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少【人事专员】岗位人员", "体检计划接口【PP/OH/SendResultImport】");
 | 
						||
                //    }
 | 
						||
                //    else
 | 
						||
                //    {
 | 
						||
                //        SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少【人事专员】岗位人员", Msg + "  体检计划接口【PP/OH/SendResultImport】");
 | 
						||
                //    }
 | 
						||
                //}
 | 
						||
                //else
 | 
						||
                //{
 | 
						||
 | 
						||
                //    T_FM_SYNC_TASK task = null;//跑批待办
 | 
						||
                //    List<T_FM_NOTIFICATION_TASK> listNoticeImport = new List<T_FM_NOTIFICATION_TASK>(); //体检导入通知
 | 
						||
                //    List<Guid> listPARENTID = new List<Guid>();
 | 
						||
                //    List<Guid> listDataID = new List<Guid>();
 | 
						||
                //    List<T_OH_HEALTH_EXAM_RESULT_IMPORT> listImportOrder = new List<T_OH_HEALTH_EXAM_RESULT_IMPORT>();
 | 
						||
 | 
						||
                //    List<string> Name = new List<string>();
 | 
						||
                //    List<Guid> UserId = new List<Guid>();
 | 
						||
                //    List<string> userName = new List<string>();
 | 
						||
                //    //同一个 PARENTID 发送一个待办
 | 
						||
                //    foreach (var item in listNotice)
 | 
						||
                //    {
 | 
						||
                //        item.NOTICEIMPORTSTATE = NoticeImportState.NoticeImport;
 | 
						||
 | 
						||
                //        if (item.PARENTID.HasValue && !listPARENTID.Contains(item.PARENTID.Value))
 | 
						||
                //        {
 | 
						||
                //            listPARENTID.Add(item.PARENTID.Value);
 | 
						||
 | 
						||
                //            T_OH_HEALTH_EXAM_RESULT_IMPORT modelImport = new T_OH_HEALTH_EXAM_RESULT_IMPORT();
 | 
						||
                //            modelImport.ID = Guid.NewGuid();
 | 
						||
                //            modelImport.ORG_ID = item.ORG_ID.Value;
 | 
						||
                //            modelImport.NOTICE_ID = item.PARENTID.Value;
 | 
						||
                //            listDataID.Add(modelImport.ID);
 | 
						||
                //            listImportOrder.Add(modelImport);
 | 
						||
 | 
						||
                //            //Name.Add("体检通知结果导入");
 | 
						||
                //            Name.Add("体检结果导入");
 | 
						||
                //            UserId.Add(userRS.ID);
 | 
						||
                //            userName.Add(userRS.NAME);
 | 
						||
                //        }
 | 
						||
                //    }
 | 
						||
 | 
						||
                //    List<T_FM_NOTIFICATION_TASK> listTaskImport = NotificationTaskService.InsertUserNoticeTaskModels(Name, listDataID, filter.OrgId, UserId, userName, DateTime.Now, DateTime.Now.AddDays(1), 1, "OH017_IMPORT");
 | 
						||
 | 
						||
                //    task = GetEntity<T_FM_SYNC_TASK>(filter.Keyword);
 | 
						||
                //    if (task != null)
 | 
						||
                //    {
 | 
						||
                //        task.UPDATE_SUCCES_TIME = DateTime.Now;//上次同步结束时间
 | 
						||
                //        task.SYNC_PARAM = "";//清空参数
 | 
						||
                //    }
 | 
						||
                //    this.UnifiedCommit(() =>
 | 
						||
                //    {
 | 
						||
                //        if (task != null)
 | 
						||
                //            UpdateEntityNoCommit(task);//跑批信息
 | 
						||
                //        if (listNotice != null && listNotice.Any())//修改状态
 | 
						||
                //            BantchSaveEntityNoCommit(listNotice);
 | 
						||
                //        if (listImportOrder != null && listImportOrder.Any())//添加导入Model
 | 
						||
                //            BantchSaveEntityNoCommit(listImportOrder);
 | 
						||
                //        if (listTaskImport != null && listTaskImport.Any())//添加待办
 | 
						||
                //            BantchSaveEntityNoCommit(listTaskImport);
 | 
						||
                //    });
 | 
						||
                //}
 | 
						||
                return true;
 | 
						||
            });
 | 
						||
        }
 | 
						||
 | 
						||
 | 
						||
        /// <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("NoticeCycle")]
 | 
						||
        public JsonActionResult<bool> NoticeCycle([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 { }
 | 
						||
                    }
 | 
						||
                    int WarmDay = 15;
 | 
						||
                    DateTime dtSearch = dtNow.AddDays(WarmDay);
 | 
						||
 | 
						||
                    //体检周期都是几个月的
 | 
						||
                    //所以半个月内有人需要体检就发送待办
 | 
						||
 | 
						||
                    //如果有最近的未完成的待办 直接做今日提醒
 | 
						||
                    var listNotice = GetEntities<T_OH_HEALTH_EXAM_NOTICE_REGISTER>(e => e.NEXTDATE.HasValue && e.NEXTDATE <= dtSearch, null, null);
 | 
						||
                    if (listNotice == null || !listNotice.Any())
 | 
						||
                    {
 | 
						||
                        return true;
 | 
						||
                    }
 | 
						||
                    string Msg = string.Empty;
 | 
						||
                    T_FM_USER userRS = UserService.GetPostUser(ref Msg);
 | 
						||
 | 
						||
                    if (userRS == null)
 | 
						||
                    {
 | 
						||
                        SysLogService.AddLog(filter.OrgId.Value, APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value, "系统缺少【人事专员】岗位人员", Msg + "  体检计划接口【PP/OH/ExamPlan】");
 | 
						||
                        return true;
 | 
						||
                    }
 | 
						||
 | 
						||
                    var taskNotice = GetEntity<T_FM_NOTIFICATION_TASK>(e => e.USER_ID == userRS.ID && e.SOURCE_FORMCODE == "OH026" && e.NOTICE_STATUS == 0);
 | 
						||
                    if (taskNotice != null)
 | 
						||
                    {
 | 
						||
                        //有没处理的待办
 | 
						||
                        //位置靠前
 | 
						||
                        taskNotice.MODIFY_TIME = DateTime.Now;
 | 
						||
                        this.UnifiedCommit(() =>
 | 
						||
                        {
 | 
						||
                            if (taskNotice != null)
 | 
						||
                                UpdateEntityNoCommit(taskNotice);
 | 
						||
                        });
 | 
						||
                    }
 | 
						||
                    else
 | 
						||
                    {
 | 
						||
                        T_OH_HEALTH_EXAM_NOTICE modelWarm = new T_OH_HEALTH_EXAM_NOTICE();
 | 
						||
                        modelWarm.ID = Guid.NewGuid();
 | 
						||
                        modelWarm.CODE = "XTTJTZ" + dtNow.ToString("yyyyMMddHHmmss");
 | 
						||
                        //modelWarm.NAME =;
 | 
						||
                        //modelWarm.OTHER_STUFF =;
 | 
						||
                        modelWarm.STATUS = PFStandardStatus.Draft;
 | 
						||
                        //modelWarm.APPROVE_ID =;
 | 
						||
                        modelWarm.IS_DELETED = false;
 | 
						||
                        modelWarm.ORG_ID = filter.OrgId;
 | 
						||
                        //modelWarm.ENTITY_ORG_TPYE =;
 | 
						||
                        //modelWarm.FORM_ID =;
 | 
						||
                        //modelWarm.FLOW_STATUS =;
 | 
						||
                        //modelWarm.FLOW_SEND_STATUS =;
 | 
						||
                        //modelWarm.FLOW_ID =;
 | 
						||
                        //modelWarm.CREATE_TIME =;
 | 
						||
                        //modelWarm.MODIFY_TIME =;
 | 
						||
                        //modelWarm.CREATER_ID =;
 | 
						||
                        //modelWarm.MODIFIER_ID =;
 | 
						||
                        //modelWarm.PARENTID =;
 | 
						||
                        modelWarm.ISSYSTEM = true;//根据这个值前端要自动加载有审批周期待体检的人
 | 
						||
 | 
						||
                        T_FM_NOTIFICATION_TASK taskNoticeRs = NotificationTaskService.InsertUserNoticeTaskModel("体检通知", modelWarm.ID, modelWarm.ORG_ID, userRS.ID, userRS.NAME,
 | 
						||
                    DateTime.Now, DateTime.Now.AddDays(1), 0, "OH026");
 | 
						||
 | 
						||
                        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 (task != null)
 | 
						||
                                UpdateEntityNoCommit(task);
 | 
						||
                            if (taskNoticeRs != null)
 | 
						||
                                UpdateEntityNoCommit(taskNoticeRs);
 | 
						||
                            if (modelWarm != null)
 | 
						||
                                UpdateEntityNoCommit(modelWarm);
 | 
						||
                        });
 | 
						||
                        int Count = (taskNoticeRs != null ? 1 : 0) + (modelWarm != null ? 1 : 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;
 | 
						||
            });
 | 
						||
        }
 | 
						||
 | 
						||
 | 
						||
 | 
						||
 | 
						||
        /// <summary>
 | 
						||
        /// 发送检测记录
 | 
						||
        /// </summary>
 | 
						||
        /// <param name="filter"></param>
 | 
						||
        /// <returns></returns>
 | 
						||
        [HttpPost, Route("SendMonitor")]
 | 
						||
        public JsonActionResult<bool> SendMonitor([FromBody] KeywordFilter filter)
 | 
						||
        {
 | 
						||
            return SafeExecute<bool>(() =>
 | 
						||
            {
 | 
						||
                try
 | 
						||
                {
 | 
						||
                    //根据  职业危害因素监测规则 T_OH_HAZARD_MONITOR_RULE 
 | 
						||
                    // 给 责任部门对应记录人 发送检测记录表
 | 
						||
                    DateTime dtNow = DateTime.Now;
 | 
						||
                    if (!string.IsNullOrEmpty(filter.Parameter1))
 | 
						||
                    {
 | 
						||
                        try
 | 
						||
                        {
 | 
						||
                            //接收来自页面的参数
 | 
						||
                            DateTime deParm = Convert.ToDateTime(filter.Parameter1);
 | 
						||
                            dtNow = deParm;
 | 
						||
                        }
 | 
						||
                        catch { }
 | 
						||
                    }
 | 
						||
                    int minLaster = 20;
 | 
						||
                    //30分钟
 | 
						||
                    DateTime dtEnd = dtNow.AddMinutes(minLaster);//
 | 
						||
 | 
						||
                    var listRule = GetEntities<T_OH_HAZARD_MONITOR_RULE>(e => !e.IS_DELETED && e.MONITOR_INTERVAL != BSPLANCHECKFREQUENCYEnum.None && e.TIME != DateTime.MinValue && e.DEPARTMENT_ID.HasValue && e.RECORD_POST_ID.HasValue && e.DEPARTMENT_ID_WORKSHOP.HasValue && e.WARN_POST_ID.HasValue, null, new string[] { "Nav_Type" }).OrderBy(e => e.TYPE_ID);//"Nav_RecordPost.Nav_Users.Nav_User",  //符合时间的 规则        .Nav_Type.MONITOR_TYPE
 | 
						||
                    List<T_OH_HAZARD_MONITOR_RULE> listRun = new List<T_OH_HAZARD_MONITOR_RULE>();
 | 
						||
 | 
						||
                    if (listRule != null && listRule.Any())
 | 
						||
                    {
 | 
						||
                        DateTime dtCombin = dtNow.Date;
 | 
						||
                        foreach (var item in listRule)
 | 
						||
                        {
 | 
						||
                            if (!ISTimeOK(item.TIME, dtNow, 0, minLaster))
 | 
						||
                            {
 | 
						||
                                //设置时间往前后各偏移 20 分钟 判断跑批
 | 
						||
                                continue;
 | 
						||
                            }
 | 
						||
                            switch (item.MONITOR_INTERVAL)
 | 
						||
                            {
 | 
						||
                                case BSPLANCHECKFREQUENCYEnum.Date://每天
 | 
						||
                                    listRun.Add(item);
 | 
						||
                                    break;
 | 
						||
                                case BSPLANCHECKFREQUENCYEnum.Week://每周
 | 
						||
                                    if (item.WEEKDATA != null && (int)dtNow.DayOfWeek == (int)item.WEEKDATA.Value)
 | 
						||
                                        //星期匹配   DateTime.Now.DayOfWeek Thursday    (int)DateTime.Now.DayOfWeek 4
 | 
						||
                                        listRun.Add(item);
 | 
						||
                                    break;
 | 
						||
                                case BSPLANCHECKFREQUENCYEnum.Month://每月
 | 
						||
                                    if (item.DAY == dtNow.Day)
 | 
						||
                                        listRun.Add(item);
 | 
						||
                                    break;
 | 
						||
                                case BSPLANCHECKFREQUENCYEnum.Quarter://每季度
 | 
						||
                                    if (item.DAY == dtNow.Day && (item.MONTH == dtNow.Month || item.MONTH == dtNow.Month - 3 || item.MONTH == dtNow.Month - 6 || item.MONTH == dtNow.Month - 9))//日相等 月相等 或者 月= 当前月-3n
 | 
						||
                                        listRun.Add(item);
 | 
						||
                                    break;
 | 
						||
                                case BSPLANCHECKFREQUENCYEnum.HalfYear://每半年
 | 
						||
                                    if (item.DAY == dtNow.Day && (item.MONTH == dtNow.Month || item.MONTH == dtNow.Month - 6))//日相等 月相等 或者 月= 当前月-6
 | 
						||
                                        listRun.Add(item);
 | 
						||
                                    break;
 | 
						||
                                case BSPLANCHECKFREQUENCYEnum.Year://每年
 | 
						||
                                    if (item.MONTH == dtNow.Month && item.DAY == dtNow.Day)
 | 
						||
                                        listRun.Add(item);
 | 
						||
                                    break;
 | 
						||
                                default:
 | 
						||
                                    break;
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
                    }
 | 
						||
 | 
						||
                    if (listRun.Count < 1)
 | 
						||
                    {
 | 
						||
                        return true;
 | 
						||
                    }
 | 
						||
 | 
						||
                    var listSendDetail = GetEntities<T_OH_HAZARD_MONITOR_JOB_DETAIL>(e => !e.IS_DELETED && e.RULE_ID.HasValue && e.CREATE_TIME.HasValue && e.CREATE_TIME.Value.Date == dtNow.Date, null, null);
 | 
						||
 | 
						||
                    //OH024
 | 
						||
                    //监测记录
 | 
						||
                    List<T_OH_HAZARD_MONITOR_JOB> listMonitorJob = new List<T_OH_HAZARD_MONITOR_JOB>();
 | 
						||
                    List<T_OH_HAZARD_MONITOR_JOB_DETAIL> listMonitorJobDetail = new List<T_OH_HAZARD_MONITOR_JOB_DETAIL>();
 | 
						||
 | 
						||
                    //责任部门 对应记录人 发送检测记录 单据
 | 
						||
                    List<T_FM_NOTIFICATION_TASK> listTask = new List<T_FM_NOTIFICATION_TASK>();
 | 
						||
                    T_OH_HAZARD_MONITOR_JOB_DETAIL modelCheckDetail = null;
 | 
						||
                    DateTime LAST_NOTIFY = DateTime.Now;
 | 
						||
                    List<T_OH_HAZARD_MONITOR_RULE> listRuleUpdate = new List<T_OH_HAZARD_MONITOR_RULE>();
 | 
						||
                    //责任部门 对应 记录人 
 | 
						||
                    IEnumerable<T_FM_USER> IListUser = null;
 | 
						||
 | 
						||
                    List<string> listName = null;
 | 
						||
                    List<Guid> listID = null;
 | 
						||
 | 
						||
                    #region     新版  同一个部门岗位都能收到待办 (后续,只要一个填写,另外的就不能填写了)
 | 
						||
 | 
						||
                    T_OH_HAZARD_MONITOR_JOB Job = null;
 | 
						||
                    foreach (var item in listRun)
 | 
						||
                    {
 | 
						||
                        //判断今天有没有 添加  e.USER_ID_GET == itemPost.USER_ID &&
 | 
						||
                        modelCheckDetail = listSendDetail.FirstOrDefault(e => e.RULE_ID == item.ID);
 | 
						||
                        if (modelCheckDetail != null)
 | 
						||
                        {
 | 
						||
                            continue; //今天有添加
 | 
						||
                        }
 | 
						||
 | 
						||
                        #region      检测单
 | 
						||
 | 
						||
                        Job = listMonitorJob.FirstOrDefault(e => e.MONITOR_TYPE == item.Nav_Type.MONITOR_TYPE);//itemPost.USER_ID
 | 
						||
                        if (Job == null)
 | 
						||
                        {
 | 
						||
 | 
						||
                            #region     通知人员
 | 
						||
                            IListUser = GetEntities<T_FM_USER>(e => e.DEPARTMENT_ID.HasValue && e.ENABLE_STATUS == 0 && !e.IS_DELETED && e.PERSON_ID.HasValue && e.Nav_Person.POST_ID.HasValue && e.DEPARTMENT_ID.Value == item.DEPARTMENT_ID && e.Nav_Person.POST_ID == item.RECORD_POST_ID, null, "Nav_Person");
 | 
						||
                            if (IListUser == null || !IListUser.Any())
 | 
						||
                            {
 | 
						||
                                continue;
 | 
						||
                            }
 | 
						||
 | 
						||
                            listName = new List<string>();
 | 
						||
                            listID = new List<Guid>();
 | 
						||
                            foreach (var itemU in IListUser)
 | 
						||
                            {
 | 
						||
                                listName.Add(itemU.NAME);
 | 
						||
                                listID.Add(itemU.ID);
 | 
						||
                            }
 | 
						||
                            #endregion
 | 
						||
 | 
						||
                            Job = new T_OH_HAZARD_MONITOR_JOB();
 | 
						||
                            Job.ID = Guid.NewGuid();
 | 
						||
                            //Job.RULE_ID = item.ID;
 | 
						||
                            //Job.MONITOR_TIME =;
 | 
						||
                            //Job.USER_ID = itemPost.USER_ID;
 | 
						||
                            //Job.DEVICE_NAME =;
 | 
						||
                            //Job.DEVICE_SPEC =;
 | 
						||
                            //Job.MONITOR_METHOD =;
 | 
						||
                            //Job.SAMPLE_PEOPLE =;
 | 
						||
                            Job.STATUS = OHHazardMonitorJobStatusEnum.WaitSign;
 | 
						||
                            Job.IS_DELETED = false;
 | 
						||
                            Job.ORG_ID = item.ORG_ID;
 | 
						||
                            //Job.ENTITY_ORG_TPYE =;
 | 
						||
                            //Job.FORM_ID =;
 | 
						||
                            //Job.FLOW_STATUS =;
 | 
						||
                            //Job.FLOW_SEND_STATUS =;
 | 
						||
                            //Job.FLOW_ID =;
 | 
						||
                            //Job.CREATE_TIME = dtNow;
 | 
						||
                            //Job.MODIFY_TIME = dtNow;
 | 
						||
                            //Job.CREATER_ID = itemPost.USER_ID;
 | 
						||
                            //Job.MODIFIER_ID = itemPost.USER_ID;
 | 
						||
                            //Job.USER_ID_GET = itemPost.ID;// itemPost.USER_ID;
 | 
						||
                            if (listID.Count == 1)
 | 
						||
                            {
 | 
						||
                                Job.USER_ID_GET = listID[0];
 | 
						||
                            }
 | 
						||
 | 
						||
                            Job.TYPE_ID = item.TYPE_ID;
 | 
						||
                            Job.MONITOR_TYPE = item.Nav_Type.MONITOR_TYPE;
 | 
						||
 | 
						||
                            //添加监测记录单
 | 
						||
                            listMonitorJob.Add(Job);
 | 
						||
 | 
						||
                            DateTime dtTaskEnd = NotificationTaskService.GetTaskEndTime(FMTASKTYPE.OH_MonitorJob, item.ORG_ID.Value, DateTime.Now, (int)item.MONITOR_INTERVAL, null);
 | 
						||
 | 
						||
                            //添加待办
 | 
						||
                            listTask.AddRange(NotificationTaskService.InsertUserNoticeTaskModels(item.Nav_Type.MONITOR_TYPE.GetDescription(), Job.ID, Job.ORG_ID, listID, listName, dtNow, dtTaskEnd, 0, "OH024"));
 | 
						||
 | 
						||
                            //最后修改时间
 | 
						||
                            item.LAST_NOTIFY = DateTime.Now;//最后推送日期
 | 
						||
                            if (!listRuleUpdate.Contains(item))
 | 
						||
                            {
 | 
						||
                                listRuleUpdate.Add(item);
 | 
						||
                            }
 | 
						||
                        }
 | 
						||
 | 
						||
                        #endregion
 | 
						||
 | 
						||
 | 
						||
                        #region     监测明细
 | 
						||
 | 
						||
                        T_OH_HAZARD_MONITOR_JOB_DETAIL JobDetail = new T_OH_HAZARD_MONITOR_JOB_DETAIL();
 | 
						||
                        JobDetail.ID = Guid.NewGuid();
 | 
						||
                        JobDetail.JOB_ID = Job.ID;
 | 
						||
                        JobDetail.RULE_ID = item.ID;
 | 
						||
                        //JobDetail.USER_ID_GET = itemPost.ID; // itemPost.USER_ID;
 | 
						||
                        //JobDetail.SAMPLE_SOURCE      =;
 | 
						||
                        //JobDetail.JOB_STATUS         =;
 | 
						||
                        //JobDetail.PROTECT_STATUS     =;
 | 
						||
                        //JobDetail.MONITOR_RESULT_LOW =;
 | 
						||
                        //JobDetail.MONITOR_RESULT_HIGH=;
 | 
						||
                        //JobDetail.OVER_LIMIT         =;
 | 
						||
                        //JobDetail.MONITOR_RESULT_05  =;
 | 
						||
                        //JobDetail.MONITOR_RESULT_10  =;
 | 
						||
                        //JobDetail.MONITOR_RESULT_AROUND=;
 | 
						||
                        //JobDetail.SAMPLE_TIME    =;
 | 
						||
                        //JobDetail.TEST_TIME      =;
 | 
						||
                        //JobDetail.MONITOR_RESULT =;
 | 
						||
                        //JobDetail.TEST_DEPARTMENT=;
 | 
						||
                        //JobDetail.TESTER         =;
 | 
						||
                        JobDetail.IS_DELETED = false;
 | 
						||
                        JobDetail.ORG_ID = item.ORG_ID;
 | 
						||
                        //JobDetail.ENTITY_ORG_TPYE =;
 | 
						||
                        //JobDetail.FORM_ID         =;
 | 
						||
                        //JobDetail.FLOW_STATUS     =;
 | 
						||
                        //JobDetail.FLOW_SEND_STATUS=;
 | 
						||
                        //JobDetail.FLOW_ID         =;
 | 
						||
                        //JobDetail.CREATE_TIME     =;
 | 
						||
                        //JobDetail.MODIFY_TIME     =;
 | 
						||
                        //JobDetail.CREATER_ID      =;
 | 
						||
                        //JobDetail.MODIFIER_ID     =;
 | 
						||
                        listMonitorJobDetail.Add(JobDetail);
 | 
						||
 | 
						||
                        #endregion
 | 
						||
 | 
						||
                    }
 | 
						||
 | 
						||
                    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 (task != null)
 | 
						||
                            UpdateEntityNoCommit(task);
 | 
						||
                        if (listMonitorJob != null && listMonitorJob.Any())
 | 
						||
                            BantchSaveEntityNoCommit(listMonitorJob);
 | 
						||
                        if (listTask != null && listTask.Any())
 | 
						||
                            BantchSaveEntityNoCommit(listTask);
 | 
						||
                        if (listMonitorJobDetail != null && listMonitorJobDetail.Any())
 | 
						||
                            BantchSaveEntityNoCommit(listMonitorJobDetail);
 | 
						||
                        if (listRuleUpdate != null && listRuleUpdate.Any())
 | 
						||
                            BantchSaveEntityNoCommit(listRuleUpdate);
 | 
						||
                    });
 | 
						||
 | 
						||
                    int Count = ((listMonitorJob != null && listMonitorJob.Any()) ? listMonitorJob.Count : 0) + ((listTask != null && listTask.Any()) ? listTask.Count : 0) + ((listMonitorJobDetail != null && listMonitorJobDetail.Any()) ? listMonitorJobDetail.Count : 0) + ((listRuleUpdate != null && listRuleUpdate.Any()) ? listRuleUpdate.Count : 0);
 | 
						||
                    SyncLogDetailService.InsertSyncLogDetail(HttpContext.Items, HttpContext.TraceIdentifier, filter.OrgId, Count, filter.Parameter1, SyncLogType.BSCreateCheckPlanSet);
 | 
						||
 | 
						||
                    #endregion
 | 
						||
 | 
						||
                    #region     旧版 检测单只发给某个人
 | 
						||
 | 
						||
                    //foreach (var item in listRun)
 | 
						||
                    //{
 | 
						||
                    //    //判断今天有没有 添加  e.USER_ID_GET == itemPost.USER_ID &&
 | 
						||
                    //    modelCheckDetail = listSendDetail.FirstOrDefault(e => e.RULE_ID == item.ID);
 | 
						||
                    //    if (modelCheckDetail != null)
 | 
						||
                    //    {
 | 
						||
                    //        //今天有添加
 | 
						||
                    //        continue;
 | 
						||
                    //    }
 | 
						||
 | 
						||
                    //    IListUser = GetEntities<T_FM_USER>(e => e.DEPARTMENT_ID.HasValue && e.DEPARTMENT_ID.Value == item.DEPARTMENT_ID && e.Nav_Person.POST_ID == item.RECORD_POST_ID, null, "Nav_Person");
 | 
						||
 | 
						||
                    //    // item.Nav_RecordPost.Nav_Users
 | 
						||
                    //    foreach (var itemPost in IListUser)
 | 
						||
                    //    {
 | 
						||
                    //        if (item.DEPARTMENT_ID != itemPost.DEPARTMENT_ID)
 | 
						||
                    //        {
 | 
						||
                    //            continue;
 | 
						||
                    //        }
 | 
						||
                    //        modelCheckDetail = listMonitorJobDetail.FirstOrDefault(e => e.RULE_ID == item.ID);
 | 
						||
                    //        if (modelCheckDetail != null)
 | 
						||
                    //        {
 | 
						||
                    //            //有加过(虽然人不一样)
 | 
						||
                    //            continue;
 | 
						||
                    //        }
 | 
						||
 | 
						||
                    //        #region      检测单
 | 
						||
 | 
						||
                    //        T_OH_HAZARD_MONITOR_JOB Job = listMonitorJob.FirstOrDefault(e => e.MONITOR_TYPE == item.Nav_Type.MONITOR_TYPE && e.USER_ID_GET == itemPost.ID);//itemPost.USER_ID
 | 
						||
 | 
						||
                    //        if (Job == null)
 | 
						||
                    //        {
 | 
						||
                    //            Job = new T_OH_HAZARD_MONITOR_JOB();
 | 
						||
                    //            Job.ID = Guid.NewGuid();
 | 
						||
                    //            //Job.RULE_ID = item.ID;
 | 
						||
                    //            //Job.MONITOR_TIME =;
 | 
						||
                    //            //Job.USER_ID = itemPost.USER_ID;
 | 
						||
                    //            //Job.DEVICE_NAME =;
 | 
						||
                    //            //Job.DEVICE_SPEC =;
 | 
						||
                    //            //Job.MONITOR_METHOD =;
 | 
						||
                    //            //Job.SAMPLE_PEOPLE =;
 | 
						||
                    //            Job.STATUS = OHHazardMonitorJobStatusEnum.WaitSign;
 | 
						||
                    //            Job.IS_DELETED = false;
 | 
						||
                    //            Job.ORG_ID = item.ORG_ID;
 | 
						||
                    //            //Job.ENTITY_ORG_TPYE =;
 | 
						||
                    //            //Job.FORM_ID =;
 | 
						||
                    //            //Job.FLOW_STATUS =;
 | 
						||
                    //            //Job.FLOW_SEND_STATUS =;
 | 
						||
                    //            //Job.FLOW_ID =;
 | 
						||
                    //            //Job.CREATE_TIME = dtNow;
 | 
						||
                    //            //Job.MODIFY_TIME = dtNow;
 | 
						||
                    //            //Job.CREATER_ID = itemPost.USER_ID;
 | 
						||
                    //            //Job.MODIFIER_ID = itemPost.USER_ID;
 | 
						||
                    //            Job.USER_ID_GET = itemPost.ID;// itemPost.USER_ID;
 | 
						||
                    //            Job.TYPE_ID = item.TYPE_ID;
 | 
						||
                    //            Job.MONITOR_TYPE = item.Nav_Type.MONITOR_TYPE;
 | 
						||
 | 
						||
                    //            //添加监测记录单
 | 
						||
                    //            listMonitorJob.Add(Job);
 | 
						||
 | 
						||
                    //            //添加待办
 | 
						||
                    //            T_FM_NOTIFICATION_TASK taskAdd = NotificationTaskService.InsertUserNoticeTaskModel(item.Nav_Type.MONITOR_TYPE.GetDescription(), Job.ID, Job.ORG_ID, itemPost.ID, itemPost.NAME, dtNow, dtNow.AddDays(1), 0, "OH024");//itemPost.USER_ID, itemPost.Nav_User.NAME
 | 
						||
                    //            listTask.Add(taskAdd);
 | 
						||
 | 
						||
                    //            //最后修改时间
 | 
						||
                    //            item.LAST_NOTIFY = DateTime.Now;//最后推送日期
 | 
						||
                    //            if (!listRuleUpdate.Contains(item))
 | 
						||
                    //            {
 | 
						||
                    //                listRuleUpdate.Add(item);
 | 
						||
                    //            }
 | 
						||
                    //        }
 | 
						||
 | 
						||
                    //        #region     监测明细
 | 
						||
 | 
						||
                    //        T_OH_HAZARD_MONITOR_JOB_DETAIL JobDetail = new T_OH_HAZARD_MONITOR_JOB_DETAIL();
 | 
						||
                    //        JobDetail.ID = Guid.NewGuid();
 | 
						||
                    //        JobDetail.JOB_ID = Job.ID;
 | 
						||
                    //        JobDetail.RULE_ID = item.ID;
 | 
						||
                    //        JobDetail.USER_ID_GET = itemPost.ID; // itemPost.USER_ID;
 | 
						||
 | 
						||
                    //        //JobDetail.SAMPLE_SOURCE      =;
 | 
						||
                    //        //JobDetail.JOB_STATUS         =;
 | 
						||
                    //        //JobDetail.PROTECT_STATUS     =;
 | 
						||
                    //        //JobDetail.MONITOR_RESULT_LOW =;
 | 
						||
                    //        //JobDetail.MONITOR_RESULT_HIGH=;
 | 
						||
                    //        //JobDetail.OVER_LIMIT         =;
 | 
						||
                    //        //JobDetail.MONITOR_RESULT_05  =;
 | 
						||
                    //        //JobDetail.MONITOR_RESULT_10  =;
 | 
						||
                    //        //JobDetail.MONITOR_RESULT_AROUND=;
 | 
						||
                    //        //JobDetail.SAMPLE_TIME    =;
 | 
						||
                    //        //JobDetail.TEST_TIME      =;
 | 
						||
                    //        //JobDetail.MONITOR_RESULT =;
 | 
						||
                    //        //JobDetail.TEST_DEPARTMENT=;
 | 
						||
                    //        //JobDetail.TESTER         =;
 | 
						||
                    //        JobDetail.IS_DELETED = false;
 | 
						||
                    //        JobDetail.ORG_ID = item.ORG_ID;
 | 
						||
                    //        //JobDetail.ENTITY_ORG_TPYE =;
 | 
						||
                    //        //JobDetail.FORM_ID         =;
 | 
						||
                    //        //JobDetail.FLOW_STATUS     =;
 | 
						||
                    //        //JobDetail.FLOW_SEND_STATUS=;
 | 
						||
                    //        //JobDetail.FLOW_ID         =;
 | 
						||
                    //        //JobDetail.CREATE_TIME     =;
 | 
						||
                    //        //JobDetail.MODIFY_TIME     =;
 | 
						||
                    //        //JobDetail.CREATER_ID      =;
 | 
						||
                    //        //JobDetail.MODIFIER_ID     =;
 | 
						||
 | 
						||
                    //        listMonitorJobDetail.Add(JobDetail);
 | 
						||
 | 
						||
                    //        #endregion
 | 
						||
 | 
						||
                    //        #endregion
 | 
						||
                    //    }
 | 
						||
                    //}
 | 
						||
 | 
						||
                    //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 (task != null)
 | 
						||
                    //        UpdateEntityNoCommit(task);
 | 
						||
                    //    if (listMonitorJob != null && listMonitorJob.Any())
 | 
						||
                    //        BantchSaveEntityNoCommit(listMonitorJob);
 | 
						||
                    //    if (listTask != null && listTask.Any())
 | 
						||
                    //        BantchSaveEntityNoCommit(listTask);
 | 
						||
                    //    if (listMonitorJobDetail != null && listMonitorJobDetail.Any())
 | 
						||
                    //        BantchSaveEntityNoCommit(listMonitorJobDetail);
 | 
						||
                    //    if (listRuleUpdate != null && listRuleUpdate.Any())
 | 
						||
                    //        BantchSaveEntityNoCommit(listRuleUpdate);
 | 
						||
                    //}); 
 | 
						||
                    #endregion
 | 
						||
                }
 | 
						||
                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;
 | 
						||
            });
 | 
						||
        }
 | 
						||
 | 
						||
    }
 | 
						||
}
 |