129 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			129 lines
		
	
	
		
			6.3 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using APT.BaseData.Domain.Entities.FM;
 | 
						|
using APT.BaseData.Domain.Entities;
 | 
						|
using APT.BaseData.Domain.Enums.PF;
 | 
						|
using APT.BaseData.Domain.Enums;
 | 
						|
using APT.BaseData.Services.DomainServices;
 | 
						|
using APT.BaseData.Services.Services.FM;
 | 
						|
using APT.Infrastructure.Core;
 | 
						|
using APT.MS.Domain.Entities.SK;
 | 
						|
using APT.MS.Domain.Enums.SK;
 | 
						|
using APT.MS.Domain.Enums;
 | 
						|
using APT.Utility;
 | 
						|
using Microsoft.AspNetCore.Mvc;
 | 
						|
using APT.BaseData.Domain.IServices.FM;
 | 
						|
using APT.BaseData.Domain.IServices;
 | 
						|
using System.Linq;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System;
 | 
						|
 | 
						|
namespace APT.SK.WebApi.Controllers.Api
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    ///  手动隐患上报表
 | 
						|
    /// </summary>
 | 
						|
    [Route("api/SK/SKHiddenDangerHandReport")]
 | 
						|
    public partial class HiddenDangerHandReportController : AuthorizeApiController<T_SK_HIDDEN_DANGER_HAND_REPORT>
 | 
						|
    {
 | 
						|
        IPFApproveCallBackService ApproveCallBackService { get; set; }
 | 
						|
        IFMNotificationTaskService NotificationTaskService { get; set; }
 | 
						|
        IPFCodeRuleService CodeRuleService { get; set; }
 | 
						|
        IFMFlowPermitService MFlowPermitService { get; set; }
 | 
						|
        public HiddenDangerHandReportController(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_HAND_REPORT entity)
 | 
						|
        {
 | 
						|
            return SafeExecute<bool>(() =>
 | 
						|
            {
 | 
						|
                var userId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                var departId = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
 | 
						|
                var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
 | 
						|
                if(entity.ID == null)
 | 
						|
                    entity.ID = Guid.NewGuid();
 | 
						|
                if (entity.APPLY_USER_ID == null)
 | 
						|
                    entity.APPLY_USER_ID = userId;
 | 
						|
                if (entity.APPLY_DEPARTMENT_ID == null)
 | 
						|
                    entity.APPLY_DEPARTMENT_ID = departId;
 | 
						|
                if (entity.ORG_ID == null)
 | 
						|
                    entity.ORG_ID = orgId;
 | 
						|
                var files = entity.Nav_ReportFiles;
 | 
						|
                entity.Nav_ReportFiles = null;
 | 
						|
                entity.Nav_RiskArea = null;
 | 
						|
                if (files != null && files.Any())
 | 
						|
                {
 | 
						|
                    foreach (var item in files)
 | 
						|
                    {
 | 
						|
                        item.ORG_ID = entity.ORG_ID;
 | 
						|
                        item.HIDDEN_DANGER_HAND_REPORT_ID = entity.ID;
 | 
						|
                        item.Nav_ImgFile = null;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                List<T_FM_NOTIFICATION_TASK> notices = new List<T_FM_NOTIFICATION_TASK>();
 | 
						|
                T_SK_HIDDEN_DANGER_CONFIRM confirm = null;
 | 
						|
                List <T_SK_HIDDEN_DANGER_CONFIRM_PHOTO> photoList = new List<T_SK_HIDDEN_DANGER_CONFIRM_PHOTO>();
 | 
						|
                if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
 | 
						|
                {
 | 
						|
                    if (entity.APPLY_USER_ID != null)
 | 
						|
                    {
 | 
						|
                        var sendUser = entity.APPLY_USER_ID;
 | 
						|
                        var depart = this.GetEntity<T_FM_DEPARTMENT>(t => t.ID == entity.APPLY_DEPARTMENT_ID && t.ENABLE_STATUS == 0);
 | 
						|
                        entity.STATUS = PFStandardStatus.Archived;
 | 
						|
                        if (depart != null && depart.DEPARTMENT_TYPE == 2 && depart.USER_ID != null)
 | 
						|
                        {
 | 
						|
                            sendUser = depart.USER_ID;
 | 
						|
                        }
 | 
						|
                        var userName = this.GetEntity<T_FM_USER>(t => t.ENABLE_STATUS == (int)FMEnableStatusEnum.启用 && sendUser == t.ID)?.NAME;
 | 
						|
                        confirm = new T_SK_HIDDEN_DANGER_CONFIRM();
 | 
						|
                        confirm.HIDDEN_DANGER_HAND_REPORT_ID = entity.ID;
 | 
						|
                        confirm.ORG_ID = entity.ORG_ID;
 | 
						|
                        confirm.MineType = entity.MineType;
 | 
						|
                        confirm.APPLY_USER_ID = entity.APPLY_USER_ID;
 | 
						|
                        confirm.APPLY_DEPARTMENT_ID = entity.APPLY_DEPARTMENT_ID;
 | 
						|
                        confirm.RISK_AREA_ID = entity.RISK_AREA_ID;
 | 
						|
                        confirm.HIDDEN_PLACE = entity.HIDDEN_PLACE;
 | 
						|
                        confirm.HIDDEN_DESCRIPTION = entity.HIDDEN_DESCRIPTION;
 | 
						|
                        if (files != null && files.Any())
 | 
						|
                        {
 | 
						|
                            foreach (var file in files)
 | 
						|
                            {
 | 
						|
                                T_SK_HIDDEN_DANGER_CONFIRM_PHOTO photo = new T_SK_HIDDEN_DANGER_CONFIRM_PHOTO();
 | 
						|
                                photo.ORG_ID = file.ORG_ID;
 | 
						|
                                photo.IMG_FILE_ID = file.IMG_FILE_ID;
 | 
						|
                                photo.HIDDEN_DANGER_CONFIRM_ID = confirm.ID;
 | 
						|
                                photoList.Add(photo);
 | 
						|
                            }
 | 
						|
                        }
 | 
						|
                        //发消息
 | 
						|
                        var notice = NotificationTaskService.InsertUserNoticeTaskModel("隐患确认单(" + depart?.NAME + DateTime.Now.ToShortDateString().Replace("/", "") + ")", confirm.ID, entity.ORG_ID, (Guid)sendUser, userName, DateTime.Now,
 | 
						|
                         DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "SK018");
 | 
						|
                        notices.Add(notice);
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        entity.STATUS = PFStandardStatus.Archived;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                this.UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    if (entity != null)
 | 
						|
                        UpdateEntityNoCommit(entity);
 | 
						|
                    if (files != null && files.Any())
 | 
						|
                        BantchSaveEntityNoCommit(files);
 | 
						|
                    if (confirm != null)
 | 
						|
                        UpdateEntityNoCommit(confirm);
 | 
						|
                    if (photoList != null && photoList.Any())
 | 
						|
                        BantchSaveEntityNoCommit(photoList);
 | 
						|
                    if (notices != null && notices.Any())
 | 
						|
                        BantchSaveEntityNoCommit(notices);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |