695 lines
		
	
	
		
			43 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			695 lines
		
	
	
		
			43 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using APT.BaseData.Domain.IServices.FM;
 | 
						|
using APT.BaseData.Domain.IServices;
 | 
						|
using APT.MS.Domain.Entities.SK;
 | 
						|
using APT.Utility;
 | 
						|
using Microsoft.AspNetCore.Mvc;
 | 
						|
using APT.BaseData.Domain.Entities.FM;
 | 
						|
using APT.BaseData.Domain.Entities;
 | 
						|
using APT.BaseData.Domain.Enums.PF;
 | 
						|
using APT.BaseData.Domain.Enums;
 | 
						|
using APT.Infrastructure.Core;
 | 
						|
using APT.MS.Domain.Enums.SK;
 | 
						|
using APT.MS.Domain.Enums;
 | 
						|
using NPOI.SS.Formula.Functions;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System;
 | 
						|
using System.Linq;
 | 
						|
using APT.BaseData.Services.Services.FM;
 | 
						|
using APT.MS.Domain.Entities.FO;
 | 
						|
using Org.BouncyCastle.Crypto;
 | 
						|
 | 
						|
namespace APT.SK.WebApi.Controllers.Api
 | 
						|
{
 | 
						|
    [Route("api/SK/SKHiddenDangerRectifyNotice")]
 | 
						|
    public partial class HiddenDangerRectifyNoticeController : AuthorizeApiController<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE>
 | 
						|
    {
 | 
						|
        IPFApproveCallBackService ApproveCallBackService { get; set; }
 | 
						|
        IFMNotificationTaskService NotificationTaskService { get; set; }
 | 
						|
        IPFCodeRuleService CodeRuleService { get; set; }
 | 
						|
        IFMFlowPermitService MFlowPermitService { get; set; }
 | 
						|
        public HiddenDangerRectifyNoticeController(IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFCodeRuleService codeRuleService, IPFApproveCallBackService approveCallBackService)
 | 
						|
        {
 | 
						|
            NotificationTaskService = notificationTaskService;
 | 
						|
            MFlowPermitService = mFlowPermitService;
 | 
						|
            CodeRuleService = codeRuleService;
 | 
						|
            ApproveCallBackService = approveCallBackService;
 | 
						|
        }
 | 
						|
        [HttpPost, Route("FullUpdate")]
 | 
						|
        public JsonActionResult<bool> FullUpdate([FromBody] T_SK_HIDDEN_DANGER_RECTIFY_NOTICE entity)
 | 
						|
        {
 | 
						|
            return SafeExecute<bool>(() =>
 | 
						|
            {
 | 
						|
                var userId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                var departId = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
 | 
						|
                if (entity.APPLY_USER_ID == null)
 | 
						|
                    entity.APPLY_USER_ID = userId;
 | 
						|
                if (entity.APPLY_DEPARTMENT_ID == null)
 | 
						|
                    entity.APPLY_DEPARTMENT_ID = departId;
 | 
						|
                var details = entity.Nav_RectifyDetails;
 | 
						|
                entity.Nav_RectifyDetails = null;
 | 
						|
                var files = entity.Nav_RectifyFiles;
 | 
						|
                entity.Nav_RectifyFiles = null;
 | 
						|
                entity.ApplyDepartmentName = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == departId).NAME;
 | 
						|
                entity.ApplyPostName = this.GetEntity<T_FM_USER>(t => t.ID == userId, "Nav_Person.Nav_Post")?.Nav_Person?.Nav_Post?.NAME;
 | 
						|
                List<Guid> deleteFileIds = new List<Guid>();
 | 
						|
                List<Guid> deleteBasicIds = new List<Guid>();
 | 
						|
                List<Guid> deleteReasonIds = new List<Guid>();
 | 
						|
                List<Guid> deleteDetailIds = new List<Guid>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE> fileList = new List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC> basicList = new List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_REASON> reasonList = new List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_REASON>();
 | 
						|
                if (details != null && details.Any())
 | 
						|
                {
 | 
						|
                    var evaluationIsExist = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE>(t => t.ID == entity.ID, new string[] { "Nav_RectifyDetails", "Nav_RectifyDetails.Nav_RectifyDetailFiles", "Nav_RectifyDetails.Nav_RectifyDetailBasics" });
 | 
						|
                    if (evaluationIsExist != null && evaluationIsExist.Nav_RectifyDetails != null && evaluationIsExist.Nav_RectifyDetails.Any())
 | 
						|
                    {
 | 
						|
                        evaluationIsExist.Nav_RectifyDetails.ForEach(t =>
 | 
						|
                        {
 | 
						|
                            if (t.Nav_RectifyDetailFiles != null && t.Nav_RectifyDetailFiles.Any())
 | 
						|
                            {
 | 
						|
                                var tempIds = t.Nav_RectifyDetailFiles.Select(m => m.ID).ToList();
 | 
						|
                                deleteFileIds.AddRange(tempIds);
 | 
						|
                            }
 | 
						|
                            if (t.Nav_RectifyDetailBasics != null && t.Nav_RectifyDetailBasics.Any())
 | 
						|
                            {
 | 
						|
                                var tempIds = t.Nav_RectifyDetailBasics.Select(m => m.ID).ToList();
 | 
						|
                                deleteBasicIds.AddRange(tempIds);
 | 
						|
                            }
 | 
						|
                            if (t.Nav_RectifyDetailReasons != null && t.Nav_RectifyDetailReasons.Any())
 | 
						|
                            {
 | 
						|
                                var tempIds = t.Nav_RectifyDetailReasons.Select(m => m.ID).ToList();
 | 
						|
                                deleteReasonIds.AddRange(tempIds);
 | 
						|
                            }
 | 
						|
                            deleteDetailIds.Add(t.ID);
 | 
						|
                        });
 | 
						|
                    }
 | 
						|
                    foreach (var item in details)
 | 
						|
                    {
 | 
						|
                        item.ORG_ID = entity.ORG_ID;
 | 
						|
                        item.HIDDEN_DANGER_RECTIFY_NOTICE_ID = entity.ID;
 | 
						|
                        if (item.RECITIFY_USER_ID == null)
 | 
						|
                            throw new Exception("整改责任人丢失,请联系管理员排查");
 | 
						|
                        if (item.IMPLEMENT_USER_ID == item.ACCEPT_USER_ID)
 | 
						|
                            throw new Exception("验收人与整改落实人不能为同一人");
 | 
						|
                        if (item.Nav_RectifyDetailFiles != null && item.Nav_RectifyDetailFiles.Any())
 | 
						|
                        {
 | 
						|
                            foreach (var item2 in item.Nav_RectifyDetailFiles)
 | 
						|
                            {
 | 
						|
                                if (!item2.IS_DELETED)
 | 
						|
                                {
 | 
						|
                                    T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE file = new T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE();
 | 
						|
                                    file.ORG_ID = entity.ORG_ID;
 | 
						|
                                    file.HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_ID = item.ID;
 | 
						|
                                    file.IMG_FILE_ID = item2.IMG_FILE_ID;
 | 
						|
                                    file.Nav_ImgFile = null;
 | 
						|
                                    fileList.Add(file);
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        if (item.Nav_RectifyDetailBasics != null && item.Nav_RectifyDetailBasics.Any())
 | 
						|
                        {
 | 
						|
                            foreach (var item2 in item.Nav_RectifyDetailBasics)
 | 
						|
                            {
 | 
						|
                                if (!item2.IS_DELETED)
 | 
						|
                                {
 | 
						|
                                    T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC basic = new T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC();
 | 
						|
                                    basic.ORG_ID = entity.ORG_ID;
 | 
						|
                                    basic.HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_ID = item.ID;
 | 
						|
                                    basic.LAW_ID = item2.LAW_ID;
 | 
						|
                                    basic.Nav_Law = null;
 | 
						|
                                    basicList.Add(basic);
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        if (item.Nav_RectifyDetailReasons != null && item.Nav_RectifyDetailReasons.Any())
 | 
						|
                        {
 | 
						|
                            foreach (var item2 in item.Nav_RectifyDetailReasons)
 | 
						|
                            {
 | 
						|
                                if (!item2.IS_DELETED)
 | 
						|
                                {
 | 
						|
                                    T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_REASON basic = new T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_REASON();
 | 
						|
                                    basic.ORG_ID = entity.ORG_ID;
 | 
						|
                                    basic.HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_ID = item.ID;
 | 
						|
                                    basic.REASON_ID = item2.REASON_ID;
 | 
						|
                                    basic.Nav_Reason = null;
 | 
						|
                                    reasonList.Add(basic);
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        item.Nav_RectifyDetailBasics = null;
 | 
						|
                        item.Nav_RectifyDetailFiles = null;
 | 
						|
                        item.Nav_RectifyDetailReasons = null;
 | 
						|
                        item.Nav_Contents = null;
 | 
						|
                        item.Nav_RecitifyUser = null;
 | 
						|
                        item.Nav_AcceptUser = null;
 | 
						|
                        item.Nav_ImplementUser = null;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if (files != null && files.Any())
 | 
						|
                {
 | 
						|
                    foreach (var item in files)
 | 
						|
                    {
 | 
						|
                        item.ORG_ID = entity.ORG_ID;
 | 
						|
                        item.HIDDEN_DANGER_RECTIFY_NOTICE_ID = entity.ID;
 | 
						|
                        item.Nav_ImgFile = null;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                T_FM_NOTIFICATION_TASK task = null;
 | 
						|
                List<T_FM_NOTIFICATION_TASK> notices = new List<T_FM_NOTIFICATION_TASK>();
 | 
						|
                if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
 | 
						|
                {
 | 
						|
                    entity.STATUS = PFStandardStatus.Sign;
 | 
						|
                    var userIds = details == null ? null : details.Where(m => m.ACCEPT_USER_ID != null).Select(t => (Guid)t.ACCEPT_USER_ID).Distinct().ToList();
 | 
						|
                    if (userIds != null && userIds.Any())
 | 
						|
                    {
 | 
						|
                        var departName = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == entity.APPLY_DEPARTMENT_ID && t.ENABLE_STATUS == 0)?.NAME;
 | 
						|
                        var UserNames = new List<string>();
 | 
						|
                        var user = this.GetEntities<T_FM_USER>(t => t.ENABLE_STATUS == (int)FMEnableStatusEnum.启用 && userIds.Contains(t.ID), new BaseFilter(entity.ORG_ID));
 | 
						|
                        foreach (var u in userIds)
 | 
						|
                        {
 | 
						|
                            var current = user.FirstOrDefault(t => t.ID == u);
 | 
						|
                            UserNames.Add(current?.NAME);
 | 
						|
                        }
 | 
						|
                        //发消息
 | 
						|
                        notices = NotificationTaskService.InsertUserNoticeTaskModels("隐患整改通知(" + departName + DateTime.Now.ToShortDateString().Replace("/", "") + ")-确认", entity.ID, entity.ORG_ID, userIds, UserNames, DateTime.Now,
 | 
						|
                         DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "SK020_SHOWPRINT");
 | 
						|
                    }
 | 
						|
 | 
						|
                    if (entity.TaskID != Guid.Empty)
 | 
						|
                    {
 | 
						|
                        task = NotificationTaskService.GetTaskFinishModel(entity.TaskID);
 | 
						|
                        task.SOURCE_FORMCODE = "SK020_SHOWPRINT";
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                this.UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    if (deleteReasonIds != null && deleteReasonIds.Any())
 | 
						|
                        this.BantchDeleteEntityNoCommit<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_REASON>(deleteReasonIds);
 | 
						|
                    if (deleteBasicIds != null && deleteBasicIds.Any())
 | 
						|
                        this.BantchDeleteEntityNoCommit<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC>(deleteBasicIds);
 | 
						|
                    if (deleteFileIds != null && deleteFileIds.Any())
 | 
						|
                        this.BantchDeleteEntityNoCommit<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE>(deleteFileIds);
 | 
						|
                    if (deleteDetailIds != null && deleteDetailIds.Any())
 | 
						|
                        this.BantchDeleteEntityNoCommit<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL>(deleteDetailIds);
 | 
						|
                    if (entity != null)
 | 
						|
                        UpdateEntityNoCommit(entity);
 | 
						|
                    if (task != null)
 | 
						|
                        UpdateEntityNoCommit(task);
 | 
						|
                    if (details != null && details.Any())
 | 
						|
                        BantchSaveEntityNoCommit(details);
 | 
						|
                    if (files != null && files.Any())
 | 
						|
                        BantchSaveEntityNoCommit(files);
 | 
						|
                    if (notices != null && notices.Any())
 | 
						|
                        BantchSaveEntityNoCommit(notices);
 | 
						|
                    if (fileList != null && fileList.Any())
 | 
						|
                        BantchSaveEntityNoCommit(fileList);
 | 
						|
                    if (basicList != null && basicList.Any())
 | 
						|
                        BantchSaveEntityNoCommit(basicList);
 | 
						|
                    if (reasonList != null && reasonList.Any())
 | 
						|
                        BantchSaveEntityNoCommit(reasonList);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        [HttpPost, Route("FullUpdateYL")]
 | 
						|
        public JsonActionResult<bool> FullUpdateYL([FromBody] T_SK_HIDDEN_DANGER_RECTIFY_NOTICE entity)
 | 
						|
        {
 | 
						|
            return SafeExecute<bool>(() =>
 | 
						|
            {
 | 
						|
                var userId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                var departId = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
 | 
						|
                if (entity.APPLY_USER_ID == null)
 | 
						|
                    entity.APPLY_USER_ID = userId;
 | 
						|
                if (entity.APPLY_DEPARTMENT_ID == null)
 | 
						|
                    entity.APPLY_DEPARTMENT_ID = departId;
 | 
						|
                var details = entity.Nav_RectifyDetails;
 | 
						|
                entity.Nav_RectifyDetails = null;
 | 
						|
                var files = entity.Nav_RectifyFiles;
 | 
						|
                entity.Nav_RectifyFiles = null;
 | 
						|
                List<Guid> deleteFileIds = new List<Guid>();
 | 
						|
                List<Guid> deleteBasicIds = new List<Guid>();
 | 
						|
                List<Guid> deleteDetailIds = new List<Guid>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE> fileList = new List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC> basicList = new List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC>();
 | 
						|
                if (details != null && details.Any())
 | 
						|
                {
 | 
						|
                    var evaluationIsExist = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE>(t => t.ID == entity.ID, new string[] { "Nav_RectifyDetails", "Nav_RectifyDetails.Nav_RectifyDetailFiles", "Nav_RectifyDetails.Nav_RectifyDetailBasics" });
 | 
						|
                    if (evaluationIsExist != null && evaluationIsExist.Nav_RectifyDetails != null && evaluationIsExist.Nav_RectifyDetails.Any())
 | 
						|
                    {
 | 
						|
                        evaluationIsExist.Nav_RectifyDetails.ForEach(t =>
 | 
						|
                        {
 | 
						|
                            if (t.Nav_RectifyDetailFiles != null && t.Nav_RectifyDetailFiles.Any())
 | 
						|
                            {
 | 
						|
                                var tempIds = t.Nav_RectifyDetailFiles.Select(m => m.ID).ToList();
 | 
						|
                                deleteFileIds.AddRange(tempIds);
 | 
						|
                            }
 | 
						|
                            if (t.Nav_RectifyDetailBasics != null && t.Nav_RectifyDetailBasics.Any())
 | 
						|
                            {
 | 
						|
                                var tempIds = t.Nav_RectifyDetailBasics.Select(m => m.ID).ToList();
 | 
						|
                                deleteBasicIds.AddRange(tempIds);
 | 
						|
                            }
 | 
						|
                            deleteDetailIds.Add(t.ID);
 | 
						|
                        });
 | 
						|
                    }
 | 
						|
                    foreach (var item in details)
 | 
						|
                    {
 | 
						|
                        item.ORG_ID = entity.ORG_ID;
 | 
						|
                        item.HIDDEN_DANGER_RECTIFY_NOTICE_ID = entity.ID;
 | 
						|
                        if (item.RECITIFY_USER_ID == null)
 | 
						|
                            throw new Exception("整改责任人丢失,请联系管理员排查");
 | 
						|
                        if (item.IMPLEMENT_USER_ID == item.ACCEPT_USER_ID)
 | 
						|
                            throw new Exception("验收人与整改落实人不能为同一人");
 | 
						|
                        if (item.Nav_RectifyDetailFiles != null && item.Nav_RectifyDetailFiles.Any())
 | 
						|
                        {
 | 
						|
                            foreach (var item2 in item.Nav_RectifyDetailFiles)
 | 
						|
                            {
 | 
						|
                                if (!item2.IS_DELETED)
 | 
						|
                                {
 | 
						|
                                    T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE file = new T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE();
 | 
						|
                                    file.ORG_ID = entity.ORG_ID;
 | 
						|
                                    file.HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_ID = item.ID;
 | 
						|
                                    file.IMG_FILE_ID = item2.IMG_FILE_ID;
 | 
						|
                                    file.Nav_ImgFile = null;
 | 
						|
                                    fileList.Add(file);
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        if (item.Nav_RectifyDetailBasics != null && item.Nav_RectifyDetailBasics.Any())
 | 
						|
                        {
 | 
						|
                            foreach (var item2 in item.Nav_RectifyDetailBasics)
 | 
						|
                            {
 | 
						|
                                if (!item2.IS_DELETED)
 | 
						|
                                {
 | 
						|
                                    T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC basic = new T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC();
 | 
						|
                                    basic.ORG_ID = entity.ORG_ID;
 | 
						|
                                    basic.HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_ID = item.ID;
 | 
						|
                                    basic.LAW_ID = item2.LAW_ID;
 | 
						|
                                    basic.Nav_Law = null;
 | 
						|
                                    basicList.Add(basic);
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        item.Nav_RectifyDetailBasics = null;
 | 
						|
                        item.Nav_RectifyDetailFiles = null;
 | 
						|
                        item.Nav_Contents = null;
 | 
						|
                        item.Nav_RecitifyUser = null;
 | 
						|
                        item.Nav_AcceptUser = null;
 | 
						|
                        item.Nav_ImplementUser = null;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if (files != null && files.Any())
 | 
						|
                {
 | 
						|
                    foreach (var item in files)
 | 
						|
                    {
 | 
						|
                        item.ORG_ID = entity.ORG_ID;
 | 
						|
                        item.HIDDEN_DANGER_RECTIFY_NOTICE_ID = entity.ID;
 | 
						|
                        item.Nav_ImgFile = null;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                T_FM_NOTIFICATION_TASK task = null;
 | 
						|
                List<T_FM_NOTIFICATION_TASK> notices = new List<T_FM_NOTIFICATION_TASK>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD> records = new List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD_PHOTOA> photoList = new List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD_PHOTOA>();
 | 
						|
                if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
 | 
						|
                {
 | 
						|
                    entity.STATUS = PFStandardStatus.Archived;
 | 
						|
                    if (details != null && details.Any())
 | 
						|
                    {
 | 
						|
                        var users = this.GetEntities<T_FM_USER>(t => t.ENABLE_STATUS == (int)FMEnableStatusEnum.启用, new BaseFilter(entity.ORG_ID));
 | 
						|
                        foreach (var detail in details)
 | 
						|
                        {
 | 
						|
                            if (detail.IMPLEMENT_USER_ID != null)
 | 
						|
                            {
 | 
						|
                                var user = users.FirstOrDefault(t => t.ID == detail.IMPLEMENT_USER_ID);
 | 
						|
                                if (user != null)
 | 
						|
                                {
 | 
						|
                                    //发消息
 | 
						|
                                    T_SK_HIDDEN_DANGER_RECTIFY_RECORD record = new T_SK_HIDDEN_DANGER_RECTIFY_RECORD();
 | 
						|
                                    record.APPLY_DEPARTMENT_ID = entity.APPLY_DEPARTMENT_ID;
 | 
						|
                                    record.APPLY_USER_ID = entity.APPLY_USER_ID;
 | 
						|
                                    record.ORG_ID = entity.ORG_ID;
 | 
						|
                                    record.HIDDEN_DANGER_REPORT_ID = entity.HIDDEN_DANGER_REPORT_ID;
 | 
						|
                                    record.HIDDEN_DANGER_REPORT_DETAIL_ID = entity.HIDDEN_DANGER_REPORT_DETAIL_ID;
 | 
						|
                                    record.HIDDEN_DANGER_CONFIRM_ID = entity.HIDDEN_DANGER_CONFIRM_ID;
 | 
						|
                                    record.HIDDEN_DANGER_RECTIFY_NOTICE_ID = entity.ID;
 | 
						|
                                    record.HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_ID = detail.ID;
 | 
						|
                                    record.CODE = "YHZG" + DateTime.Now.ToShortDateString().Replace("/", "") + new Random().Next(1, 999);
 | 
						|
                                    record.MineType = entity.MineType;
 | 
						|
                                    record.RISK_AREA_ID = detail.RISK_AREA_ID;
 | 
						|
                                    record.CHECK_CONTENTS_ID = detail.CHECK_CONTENTS_ID;
 | 
						|
                                    record.CHECK_QUESTION_ID = detail.CHECK_QUESTION_ID;
 | 
						|
                                    record.CHECKCONTENT = detail.CHECKCONTENT;
 | 
						|
                                    record.CHECKPROOF = detail.CHECKPROOF;
 | 
						|
                                    record.CHECKSTANDARD = detail.CHECKSTANDARD;
 | 
						|
                                    record.HIDDEN_PLACE = detail.HIDDEN_PLACE;
 | 
						|
                                    record.HIDDEN_DESCRIPTION = detail.HIDDEN_DESCRIPTION;
 | 
						|
                                    record.HIDDEN_LEVEL = detail.HIDDEN_LEVEL;
 | 
						|
                                    record.RECTIFICATION_MEASURES = detail.RECTIFICATION_MEASURES;
 | 
						|
                                    record.RECITIFY_TIME = detail.RECITIFY_TIME;
 | 
						|
                                    record.RECITIFY_USER_ID = detail.RECITIFY_USER_ID;
 | 
						|
                                    record.ACCEPT_USER_ID = detail.ACCEPT_USER_ID;
 | 
						|
                                    record.IMPLEMENT_USER_ID = detail.IMPLEMENT_USER_ID;
 | 
						|
                                    record.STATUS = PFStandardStatus.Draft;
 | 
						|
                                    record.CHECK_TYPE_ID = entity.CHECK_TYPE_ID;
 | 
						|
                                    record.CHECK_TIME = entity.CHECK_TIME;
 | 
						|
                                    records.Add(record);
 | 
						|
                                    if (detail.Nav_RectifyDetailFiles != null && detail.Nav_RectifyDetailFiles.Any())
 | 
						|
                                    {
 | 
						|
                                        foreach (var item in detail.Nav_RectifyDetailFiles)
 | 
						|
                                        {
 | 
						|
                                            T_SK_HIDDEN_DANGER_RECTIFY_RECORD_PHOTOA file = new T_SK_HIDDEN_DANGER_RECTIFY_RECORD_PHOTOA();
 | 
						|
                                            file.ORG_ID = item.ORG_ID;
 | 
						|
                                            file.IMG_FILE_ID = item.IMG_FILE_ID;
 | 
						|
                                            file.HIDDEN_DANGER_RECTIFY_RECORD_ID = record.ID;
 | 
						|
                                            photoList.Add(file);
 | 
						|
                                        }
 | 
						|
                                    }
 | 
						|
                                    var endtime = DateTime.Now.AddDays(3);
 | 
						|
                                    if (record.RECITIFY_TIME != null && record.RECITIFY_TIME != DateTime.MinValue)
 | 
						|
                                    {
 | 
						|
                                        endtime = DateTime.Parse(record.RECITIFY_TIME.Value.ToShortDateString() + " 23:59:59");
 | 
						|
                                    }
 | 
						|
                                    var sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("隐患整改记录表(" + detail.HIDDEN_LEVEL.GetDescription() + ")", record.ID, record.ORG_ID, user.ID, user.NAME, DateTime.Now,
 | 
						|
                                                  endtime, (int)FMNoticeTypeEnum.消息, "SK022");
 | 
						|
                                    notices.Add(sendNotice);
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
 | 
						|
                    if (entity.TaskID != Guid.Empty)
 | 
						|
                    {
 | 
						|
                        task = NotificationTaskService.GetTaskFinishModel(entity.TaskID);
 | 
						|
                        task.SOURCE_FORMCODE = "SK020_SHOWPRINT";
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                this.UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    if (deleteBasicIds != null && deleteBasicIds.Any())
 | 
						|
                        this.BantchDeleteEntityNoCommit<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_BASIC>(deleteBasicIds);
 | 
						|
                    if (deleteFileIds != null && deleteFileIds.Any())
 | 
						|
                        this.BantchDeleteEntityNoCommit<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_FILE>(deleteFileIds);
 | 
						|
                    if (deleteDetailIds != null && deleteDetailIds.Any())
 | 
						|
                        this.BantchDeleteEntityNoCommit<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL>(deleteDetailIds);
 | 
						|
                    if (entity != null)
 | 
						|
                        UpdateEntityNoCommit(entity);
 | 
						|
                    if (task != null)
 | 
						|
                        UpdateEntityNoCommit(task);
 | 
						|
                    if (details != null && details.Any())
 | 
						|
                        BantchSaveEntityNoCommit(details);
 | 
						|
                    if (files != null && files.Any())
 | 
						|
                        BantchSaveEntityNoCommit(files);
 | 
						|
                    if (notices != null && notices.Any())
 | 
						|
                        BantchSaveEntityNoCommit(notices);
 | 
						|
                    if (fileList != null && fileList.Any())
 | 
						|
                        BantchSaveEntityNoCommit(fileList);
 | 
						|
                    if (basicList != null && basicList.Any())
 | 
						|
                        BantchSaveEntityNoCommit(basicList);
 | 
						|
                    if (records != null && records.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(records);
 | 
						|
                    if (photoList != null && photoList.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(photoList);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 获得单条实体数据
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="filter">过滤实体</param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("SKGet")]
 | 
						|
        public JsonActionResult<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE> SKGet([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute(() =>
 | 
						|
            {
 | 
						|
                var id = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID").Value.ToString();
 | 
						|
                if (string.IsNullOrEmpty(id))
 | 
						|
                    this.ThrowError("060010");
 | 
						|
                filter.IgnoreDataRule = true;
 | 
						|
                var result = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE>(id, new string[] { "Nav_ApplyUser", "Nav_ApplyDepartment","Nav_CheckType",
 | 
						|
           "Nav_RectifyFiles.Nav_ImgFile","Nav_ProductionUnit"});
 | 
						|
                if (result != null)
 | 
						|
                {
 | 
						|
                    var details = this.GetEntities<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL>(t => t.HIDDEN_DANGER_RECTIFY_NOTICE_ID == result.ID, new BaseFilter(filter.OrgId), "Nav_RiskArea", "Nav_Contents", "Nav_Question", "Nav_RecitifyUser", "Nav_ImplementUser", "Nav_AcceptUser", "Nav_RectifyDetailFiles.Nav_ImgFile", "Nav_RectifyDetailBasics.Nav_Law");
 | 
						|
                    result.Nav_RectifyDetails = details.OrderBy(m => m.RISK_AREA_ID).ToList();
 | 
						|
                }
 | 
						|
                return result;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 签字人员获取
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="filter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("GetIdentityUserEdit")]
 | 
						|
        public JsonActionResult<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE> GetIdentityUserEdit([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute(() => {
 | 
						|
                var id = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID").Value.ToString();
 | 
						|
                if (string.IsNullOrEmpty(id))
 | 
						|
                    this.ThrowError("030017");
 | 
						|
                var loginUserId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                filter.IgnoreDataRule = true;
 | 
						|
                var result = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE>(id, new string[] {"Nav_ApplyUser","Nav_ApplyDepartment","Nav_CheckType",
 | 
						|
            "Nav_RectifyDetails","Nav_RectifyDetails.Nav_RiskArea","Nav_RectifyDetails.Nav_Contents","Nav_RectifyDetails.Nav_Question","Nav_RectifyDetails.Nav_RectifyDetailBasics.Nav_Law",
 | 
						|
                    "Nav_RectifyDetails.Nav_AcceptUser", "Nav_RectifyDetails.Nav_ImplementUser","Nav_RectifyDetails.Nav_RectifyDetailFiles.Nav_ImgFile",
 | 
						|
                    "Nav_RectifyFiles","Nav_RectifyFiles.Nav_ImgFile","Nav_ProductionUnit"});
 | 
						|
                //var taskId = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "TASK_ID").Value;
 | 
						|
                if (result != null && result.Nav_RectifyDetails != null && result.Nav_RectifyDetails.Any())//&& taskId != null
 | 
						|
                {
 | 
						|
                    result.Nav_RectifyDetails = result.Nav_RectifyDetails.ToList();// Where(c => c.Nav_AcceptUser != null && c.ACCEPT_USER_ID == loginUserId).OrderBy(t=>t.RISK_AREA_ID).ToList();
 | 
						|
                }
 | 
						|
                return result;
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 签字人员获取
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="filter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("GetIdentityUserEditApp")]
 | 
						|
        public JsonActionResult<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE> GetIdentityUserEditApp([FromBody] KeywordFilter filter)
 | 
						|
        {
 | 
						|
            return SafeExecute(() => {
 | 
						|
                var id = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID").Value.ToString();
 | 
						|
                if (string.IsNullOrEmpty(id))
 | 
						|
                    this.ThrowError("030017");
 | 
						|
                var loginUserId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                filter.IgnoreDataRule = true;
 | 
						|
                var result = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE>(id, new string[] {"Nav_ApplyUser","Nav_ApplyDepartment","Nav_CheckType",
 | 
						|
            "Nav_RectifyDetails","Nav_RectifyDetails.Nav_RiskArea","Nav_RectifyDetails.Nav_Contents","Nav_RectifyDetails.Nav_Question","Nav_RectifyDetails.Nav_RectifyDetailBasics.Nav_Law",
 | 
						|
                    "Nav_RectifyDetails.Nav_AcceptUser", "Nav_RectifyDetails.Nav_ImplementUser","Nav_RectifyDetails.Nav_RectifyDetailFiles.Nav_ImgFile",
 | 
						|
                    "Nav_RectifyFiles","Nav_RectifyFiles.Nav_ImgFile", "Nav_ProductionUnit"});
 | 
						|
                //var taskId = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "TASK_ID").Value;
 | 
						|
                if (result != null && result.Nav_RectifyDetails != null && result.Nav_RectifyDetails.Any())// && taskId != null
 | 
						|
                {
 | 
						|
                    result.CHECK_PERSON = string.IsNullOrEmpty(result.CHECK_PERSON) ? "" : result.CHECK_PERSON;
 | 
						|
                    var details = result.Nav_RectifyDetails.GroupBy(t => t.RISK_AREA_ID).Select(g => g.First()).ToList();
 | 
						|
                    if (details != null && details.Any())
 | 
						|
                    {
 | 
						|
                        foreach (var item in details)
 | 
						|
                        {
 | 
						|
                            item.Nav_DetailContents = new List<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL>();
 | 
						|
                            var safeCheck1 = result.Nav_RectifyDetails.Where(t => t.RISK_AREA_ID == item.RISK_AREA_ID).ToList();
 | 
						|
                            if (safeCheck1 != null && safeCheck1.Any())
 | 
						|
                            {
 | 
						|
                                foreach (var item2 in safeCheck1)
 | 
						|
                                {
 | 
						|
                                    T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL ddd = new T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL();
 | 
						|
                                    ddd.RISK_AREA_ID = item2.RISK_AREA_ID;
 | 
						|
                                    ddd.Nav_RiskArea = item2.Nav_RiskArea;
 | 
						|
                                    ddd.CHECK_CONTENTS_ID = item2.CHECK_CONTENTS_ID;
 | 
						|
                                    ddd.Nav_Contents = item2.Nav_Contents;
 | 
						|
                                    ddd.CHECK_QUESTION_ID = item2.CHECK_QUESTION_ID;
 | 
						|
                                    ddd.Nav_Question = item2.Nav_Question;
 | 
						|
                                    ddd.CHECKCONTENT = item2.CHECKCONTENT;
 | 
						|
                                    ddd.CHECKPROOF = item2.CHECKPROOF;
 | 
						|
                                    ddd.CHECKSTANDARD = item2.CHECKSTANDARD;
 | 
						|
                                    ddd.HIDDEN_DESCRIPTION = string.IsNullOrEmpty(item2.HIDDEN_DESCRIPTION) ? "" : item2.HIDDEN_DESCRIPTION;
 | 
						|
                                    ddd.HIDDEN_LEVEL = item2.HIDDEN_LEVEL;
 | 
						|
                                    ddd.HIDDEN_PLACE = string.IsNullOrEmpty(item2.HIDDEN_PLACE) ? "" : item2.HIDDEN_PLACE;
 | 
						|
                                    ddd.RECITIFY_USER_ID = item2.RECITIFY_USER_ID;
 | 
						|
                                    ddd.Nav_RecitifyUser = item2.Nav_RecitifyUser;
 | 
						|
                                    ddd.RECTIFICATION_MEASURES = string.IsNullOrEmpty(item2.RECTIFICATION_MEASURES) ? "" : item2.RECTIFICATION_MEASURES;
 | 
						|
                                    ddd.RECITIFY_TIME = item2.RECITIFY_TIME;
 | 
						|
                                    ddd.IMPLEMENT_USER_ID = item2.IMPLEMENT_USER_ID;
 | 
						|
                                    ddd.Nav_ImplementUser = item2.Nav_ImplementUser;
 | 
						|
                                    ddd.ACCEPT_USER_ID = item2.ACCEPT_USER_ID;
 | 
						|
                                    ddd.Nav_AcceptUser = item2.Nav_AcceptUser;
 | 
						|
                                    ddd.Nav_RectifyDetailFiles = item2.Nav_RectifyDetailFiles;
 | 
						|
                                    item.Nav_DetailContents.Add(ddd);
 | 
						|
                                }
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        result.Nav_RectifyDetails = details;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                return result;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 识别人确认
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="entity"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("IdentityUpdate")]
 | 
						|
        public JsonActionResult<bool> IdentityUpdate([FromBody] T_SK_HIDDEN_DANGER_RECTIFY_NOTICE entity)
 | 
						|
        {
 | 
						|
            return SafeExecute(() =>
 | 
						|
            {
 | 
						|
                T_FM_NOTIFICATION_TASK task = null;
 | 
						|
                var notice = this.GetEntity<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE>(entity.ID, "Nav_RectifyDetails.Nav_RectifyDetailFiles", "Nav_RectifyDetails.Nav_ImplementUser");
 | 
						|
                var userId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                if (entity.TaskID != Guid.Empty)
 | 
						|
                {
 | 
						|
                    var currTask = GetEntity<T_FM_NOTIFICATION_TASK>(t => t.ID == entity.TaskID);
 | 
						|
                    if (currTask != null)
 | 
						|
                    {
 | 
						|
                        userId = currTask.USER_ID;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                var details = this.GetEntities<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL>(t => t.HIDDEN_DANGER_RECTIFY_NOTICE_ID == notice.ID && t.ACCEPT_USER_ID == userId, new BaseFilter(notice.ORG_ID), "Nav_RectifyDetailFiles", "Nav_RectifyDetailReasons").ToList();
 | 
						|
                details.ForEach(t =>
 | 
						|
                {
 | 
						|
                    t.ISCHECK = true;
 | 
						|
                    t.CHECKTIME = DateTime.Now;
 | 
						|
                });
 | 
						|
                List<T_FM_NOTIFICATION_TASK> sendNotices = new List<T_FM_NOTIFICATION_TASK>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD> records = new List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD_PHOTOA> photoList = new List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD_PHOTOA>();
 | 
						|
                List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD_REASON> reasonList = new List<T_SK_HIDDEN_DANGER_RECTIFY_RECORD_REASON>();
 | 
						|
                var todoCount = this.GetCount<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL>(t => notice.ID == t.HIDDEN_DANGER_RECTIFY_NOTICE_ID && t.ACCEPT_USER_ID != userId && t.ISCHECK == false, new BaseFilter(notice.ORG_ID));
 | 
						|
                if (todoCount == 0)
 | 
						|
                {
 | 
						|
                    notice.STATUS = PFStandardStatus.Archived;
 | 
						|
                    var random = new Random();
 | 
						|
                    if (notice.Nav_RectifyDetails != null && notice.Nav_RectifyDetails.Any())
 | 
						|
                    {
 | 
						|
                        foreach (var detail in notice.Nav_RectifyDetails)
 | 
						|
                        {
 | 
						|
                            //触发隐患整改记录
 | 
						|
                            if (detail.IMPLEMENT_USER_ID != null)
 | 
						|
                            {
 | 
						|
                                T_SK_HIDDEN_DANGER_RECTIFY_RECORD record = new T_SK_HIDDEN_DANGER_RECTIFY_RECORD();
 | 
						|
                                record.APPLY_DEPARTMENT_ID = notice.APPLY_DEPARTMENT_ID;
 | 
						|
                                record.APPLY_USER_ID = notice.APPLY_USER_ID;
 | 
						|
                                record.ORG_ID = detail.ORG_ID;
 | 
						|
                                record.HIDDEN_DANGER_REPORT_ID = notice.HIDDEN_DANGER_REPORT_ID;
 | 
						|
                                record.HIDDEN_DANGER_REPORT_DETAIL_ID = notice.HIDDEN_DANGER_REPORT_DETAIL_ID;
 | 
						|
                                record.HIDDEN_DANGER_CONFIRM_ID = notice.HIDDEN_DANGER_CONFIRM_ID;
 | 
						|
                                record.HIDDEN_DANGER_RECTIFY_NOTICE_ID = notice.ID;
 | 
						|
                                record.HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL_ID = detail.ID;
 | 
						|
                                record.CODE = "YHZG" + DateTime.Now.ToShortDateString().Replace("/", "") + random.Next(1, 999);
 | 
						|
                                record.MineType = notice.MineType;
 | 
						|
                                record.PRODUCTION_UNIT_ID = notice.PRODUCTION_UNIT_ID;
 | 
						|
                                record.RISK_AREA_ID = detail.RISK_AREA_ID;
 | 
						|
                                record.CHECK_CONTENTS_ID = detail.CHECK_CONTENTS_ID;
 | 
						|
                                record.CHECK_QUESTION_ID = detail.CHECK_QUESTION_ID;
 | 
						|
                                record.CHECKCONTENT = detail.CHECKCONTENT;
 | 
						|
                                record.CHECKPROOF = detail.CHECKPROOF;
 | 
						|
                                record.CHECKSTANDARD = detail.CHECKSTANDARD;
 | 
						|
                                record.HIDDEN_PLACE = detail.HIDDEN_PLACE;
 | 
						|
                                record.HIDDEN_DESCRIPTION = detail.HIDDEN_DESCRIPTION;
 | 
						|
                                record.HIDDEN_LEVEL = detail.HIDDEN_LEVEL;
 | 
						|
                                record.RECTIFICATION_MEASURES = detail.RECTIFICATION_MEASURES;
 | 
						|
                                record.RECITIFY_TIME = detail.RECITIFY_TIME;
 | 
						|
                                record.RECITIFY_USER_ID = detail.RECITIFY_USER_ID;
 | 
						|
                                record.ACCEPT_USER_ID = detail.ACCEPT_USER_ID;
 | 
						|
                                record.IMPLEMENT_USER_ID = detail.IMPLEMENT_USER_ID;
 | 
						|
                                record.STATUS = PFStandardStatus.Draft;
 | 
						|
                                record.CHECK_TYPE_ID = notice.CHECK_TYPE_ID;
 | 
						|
                                record.CHECK_TIME = notice.CHECK_TIME;
 | 
						|
                                records.Add(record);
 | 
						|
                                if (detail.Nav_RectifyDetailFiles != null && detail.Nav_RectifyDetailFiles.Any())
 | 
						|
                                {
 | 
						|
                                    foreach (var item in detail.Nav_RectifyDetailFiles)
 | 
						|
                                    {
 | 
						|
                                        T_SK_HIDDEN_DANGER_RECTIFY_RECORD_PHOTOA file = new T_SK_HIDDEN_DANGER_RECTIFY_RECORD_PHOTOA();
 | 
						|
                                        file.ORG_ID = item.ORG_ID;
 | 
						|
                                        file.IMG_FILE_ID = item.IMG_FILE_ID;
 | 
						|
                                        file.HIDDEN_DANGER_RECTIFY_RECORD_ID = record.ID;
 | 
						|
                                        photoList.Add(file);
 | 
						|
                                    }
 | 
						|
                                }
 | 
						|
                                if (detail.Nav_RectifyDetailReasons != null && detail.Nav_RectifyDetailReasons.Any())
 | 
						|
                                {
 | 
						|
                                    foreach (var item in detail.Nav_RectifyDetailReasons)
 | 
						|
                                    {
 | 
						|
                                        T_SK_HIDDEN_DANGER_RECTIFY_RECORD_REASON file = new T_SK_HIDDEN_DANGER_RECTIFY_RECORD_REASON();
 | 
						|
                                        file.ORG_ID = item.ORG_ID;
 | 
						|
                                        file.REASON_ID = item.REASON_ID;
 | 
						|
                                        file.HIDDEN_DANGER_RECTIFY_RECORD_ID = record.ID;
 | 
						|
                                        reasonList.Add(file);
 | 
						|
                                    }
 | 
						|
                                }
 | 
						|
                                var endtime = DateTime.Now.AddDays(3);
 | 
						|
                                if (record.RECITIFY_TIME != null && record.RECITIFY_TIME != DateTime.MinValue)
 | 
						|
                                {
 | 
						|
                                    endtime = DateTime.Parse(record.RECITIFY_TIME.Value.ToShortDateString() + " 23:59:59");
 | 
						|
                                }
 | 
						|
                                var sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("隐患整改记录表", record.ID, record.ORG_ID, (Guid)detail.IMPLEMENT_USER_ID, detail?.Nav_ImplementUser?.NAME, DateTime.Now,
 | 
						|
                                              endtime, (int)FMNoticeTypeEnum.消息, "SK022");
 | 
						|
                                sendNotices.Add(sendNotice);
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if (entity.TaskID != Guid.Empty)
 | 
						|
                {
 | 
						|
                    task = NotificationTaskService.GetTaskFinishModel(entity.TaskID);
 | 
						|
                    task.SOURCE_FORMCODE = "SK020_SHOWPRINT";
 | 
						|
                }
 | 
						|
                UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    if (notice != null)
 | 
						|
                        this.UpdateEntityNoCommit(notice);
 | 
						|
                    if (details != null && details.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(details);
 | 
						|
                    if (task != null)
 | 
						|
                        this.UpdateEntityNoCommit(task);
 | 
						|
                    if (records != null && records.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(records);
 | 
						|
                    if (photoList != null && photoList.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(photoList);
 | 
						|
                    if (reasonList != null && reasonList.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(reasonList);
 | 
						|
                    if (sendNotices != null && sendNotices.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(sendNotices);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        [HttpPost, Route("FullOrderPaged")]
 | 
						|
        public PagedActionResult<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE> FullOrderPaged([FromBody] KeywordPageFilter pageFilter)
 | 
						|
        {
 | 
						|
            var result = this.GetOrderPageEntities<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE>(null, pageFilter);
 | 
						|
            if (result != null && result.Data != null && result.Data.Any())
 | 
						|
            {
 | 
						|
                var ids = result.Data.Select(t => t.ID).ToList();
 | 
						|
                var details = this.GetEntities<T_SK_HIDDEN_DANGER_RECTIFY_NOTICE_DETAIL>(t => ids.Contains(t.HIDDEN_DANGER_RECTIFY_NOTICE_ID), new BaseFilter(pageFilter.OrgId), "Nav_RiskArea", "Nav_Contents", "Nav_Question", "Nav_RecitifyUser", "Nav_ImplementUser", "Nav_AcceptUser").ToList();
 | 
						|
                result.Data.ForEach(t =>
 | 
						|
                {
 | 
						|
                    var detail = details.FirstOrDefault(m => m.HIDDEN_DANGER_RECTIFY_NOTICE_ID == t.ID);
 | 
						|
                    if (detail != null)
 | 
						|
                    {
 | 
						|
                        t.AREA_NAME = detail.Nav_RiskArea?.NAME;
 | 
						|
                        t.CHECK_CONTENT = detail.Nav_Contents?.CHECKCONTENT;
 | 
						|
                        t.HIDDEN_DESCRIPTION = detail.Nav_Question?.DESCREPTION;
 | 
						|
                        t.HIDDEN_LEVEL = detail.HIDDEN_LEVEL.GetDescription();
 | 
						|
                        t.HIDDEN_PLACE = detail.HIDDEN_PLACE;
 | 
						|
                        t.RECTIFICATION_MEASURES = detail.RECTIFICATION_MEASURES;
 | 
						|
                        t.RECITIFY_TIME = detail.RECITIFY_TIME;
 | 
						|
                        t.RecitifyUser = detail.Nav_RecitifyUser?.NAME;
 | 
						|
                        t.ImplementUser = detail.Nav_ImplementUser?.NAME;
 | 
						|
                        t.AcceptUser = detail.Nav_AcceptUser?.NAME;
 | 
						|
                    }
 | 
						|
                });
 | 
						|
            }
 | 
						|
            return result;
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |