147 lines
		
	
	
		
			6.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			147 lines
		
	
	
		
			6.8 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using APT.BaseData.Domain.Entities;
 | 
						|
using APT.BaseData.Domain.Entities.FM;
 | 
						|
using APT.BaseData.Domain.IServices.FM;
 | 
						|
using APT.BaseData.Domain.IServices;
 | 
						|
using APT.Infrastructure.Core;
 | 
						|
using APT.MS.Domain.Entities.OG;
 | 
						|
using APT.MS.Domain.Enums;
 | 
						|
using APT.Utility;
 | 
						|
using Microsoft.AspNetCore.Mvc;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
using InfluxData.Net.InfluxDb.Models.Responses;
 | 
						|
 | 
						|
namespace APT.SC.WebApi.Controllers.Api.OG
 | 
						|
{
 | 
						|
    [Route("api/OG/OGExternalComplainAdvise")]
 | 
						|
    public class OGExternalComplainAdviseController : AuthorizeApiController<T_OG_EXTERNAL_COMPLAIN_ADVISE>
 | 
						|
    {
 | 
						|
        IFMNotificationTaskService NotificationTaskService { get; set; }
 | 
						|
        public OGExternalComplainAdviseController(IFMNotificationTaskService notificationTaskService, IPFCodeRuleService codeRuleService)
 | 
						|
        {
 | 
						|
            NotificationTaskService = notificationTaskService;
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 更新
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="id"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("FullUpdate")]
 | 
						|
        public JsonActionResult<bool> FullUpdate([FromBody]T_OG_EXTERNAL_COMPLAIN_ADVISE entity)
 | 
						|
        {
 | 
						|
            return SafeExecute<bool>(() =>
 | 
						|
            {
 | 
						|
                var Nav_FileList = entity.Nav_FileList;
 | 
						|
                var Nav_SurveyFileList = entity.Nav_SurveyFileList;
 | 
						|
 | 
						|
                if (entity.START_TIME == null)
 | 
						|
                {
 | 
						|
                    entity.START_TIME = DateTime.Now;
 | 
						|
                }
 | 
						|
                if (entity.USER_ID == null)
 | 
						|
                {
 | 
						|
                    if (entity.STATUS == OGExternalComplainAdviseStatus.草稿)
 | 
						|
                    {
 | 
						|
                        entity.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                if (entity.USER_ID == null)
 | 
						|
                {
 | 
						|
                    throw new Exception("用户信息错误");
 | 
						|
                }
 | 
						|
                if (entity.EXTERNAL_COMPANY_ID == null)
 | 
						|
                {
 | 
						|
                    throw new Exception("请选择外部单位");
 | 
						|
                }
 | 
						|
                
 | 
						|
                T_FM_NOTIFICATION_TASK sendNotice = null;
 | 
						|
                T_FM_NOTIFICATION_TASK finishNotice = null;
 | 
						|
                if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
 | 
						|
                {
 | 
						|
                    if (entity.TaskID != Guid.Empty)
 | 
						|
                    {
 | 
						|
                        finishNotice = NotificationTaskService.GetTaskFinishModel(entity.TaskID, "OG025_SHOWPRINT");
 | 
						|
                    }
 | 
						|
                    if (entity.STATUS == (int)OGExternalComplainAdviseStatus.草稿)
 | 
						|
                    {
 | 
						|
                        if (string.IsNullOrEmpty(entity.NAME))
 | 
						|
                        {
 | 
						|
                            throw new Exception("请填写建议事项名称");
 | 
						|
                        }
 | 
						|
                        if (string.IsNullOrEmpty(entity.DESCRIPTION))
 | 
						|
                        {
 | 
						|
                            throw new Exception("请填写建议事项描述");
 | 
						|
                        }
 | 
						|
 | 
						|
                        //安环部
 | 
						|
                        var AHUser = GetEntity<T_FM_USER>(t => t.Nav_ApproveRole.NAME == "安环部负责人");
 | 
						|
                        entity.DEPARTMENT_ID = AHUser.DEPARTMENT_ID;
 | 
						|
                        entity.ASSIGNEE_ID = AHUser.ID;
 | 
						|
                        entity.STATUS = OGExternalComplainAdviseStatus.受理中;
 | 
						|
                        sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("外部单位投诉建议受理", entity.ID, entity.ORG_ID, AHUser.ID, AHUser.NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OG026");
 | 
						|
                    }
 | 
						|
                    else if (entity.STATUS == OGExternalComplainAdviseStatus.受理中)
 | 
						|
                    {
 | 
						|
                        if (string.IsNullOrEmpty(entity.ASSIGNEE_DESCRIPTION))
 | 
						|
                        {
 | 
						|
                            throw new Exception("请填写受理意见描述");
 | 
						|
                        }
 | 
						|
                        if (entity.SURVEY_DEPARTMENT_ID == null)
 | 
						|
                        {
 | 
						|
                            throw new Exception("请选择调查部门");
 | 
						|
                        }
 | 
						|
                        if (entity.SURVEY_USER_ID == null)
 | 
						|
                        {
 | 
						|
                            throw new Exception("请选择调查人员");
 | 
						|
                        }
 | 
						|
                        var u = GetEntity<T_FM_USER>(entity.SURVEY_USER_ID.Value);
 | 
						|
                        entity.STATUS = OGExternalComplainAdviseStatus.调查中;
 | 
						|
                        sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("外部单位投诉建议调查", entity.ID, entity.ORG_ID, entity.SURVEY_USER_ID.Value, u.NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OG026");
 | 
						|
                    }
 | 
						|
                    else if (entity.STATUS == OGExternalComplainAdviseStatus.调查中)
 | 
						|
                    {
 | 
						|
                        if (string.IsNullOrEmpty(entity.SURVEY_DESCRIPTION))
 | 
						|
                        {
 | 
						|
                            throw new Exception("请填写调查情况描述");
 | 
						|
                        }
 | 
						|
                        var u = GetEntity<T_FM_USER>(entity.USER_ID.Value);
 | 
						|
                        entity.STATUS = OGExternalComplainAdviseStatus.评价中;
 | 
						|
                        sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("外部单位投诉建议评价", entity.ID, entity.ORG_ID, entity.USER_ID.Value, u.NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OG026");
 | 
						|
                    }
 | 
						|
                    else if (entity.STATUS == OGExternalComplainAdviseStatus.评价中)
 | 
						|
                    {
 | 
						|
                        entity.STATUS = OGExternalComplainAdviseStatus.归档;
 | 
						|
                    }
 | 
						|
                    else
 | 
						|
                    {
 | 
						|
                        throw new Exception("当前状态不可提交");
 | 
						|
                    }
 | 
						|
                }
 | 
						|
                entity.Nav_User = null;
 | 
						|
                entity.Nav_ExternalContactDetail = null;
 | 
						|
                entity.Nav_ItemEnum = null;
 | 
						|
                entity.Nav_Department = null;
 | 
						|
                entity.Nav_Assignee = null;
 | 
						|
                entity.Nav_SurveyDepartment = null;
 | 
						|
                entity.Nav_SurveyUser = null;
 | 
						|
                entity.Nav_FileList = null;
 | 
						|
                entity.Nav_SurveyFileList = null;
 | 
						|
                UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    UpdateEntityNoCommit(entity);
 | 
						|
                    if (Nav_FileList != null)
 | 
						|
                        BantchSaveEntityNoCommit(Nav_FileList);
 | 
						|
                    if (Nav_SurveyFileList != null)
 | 
						|
                        BantchSaveEntityNoCommit(Nav_SurveyFileList);
 | 
						|
                    if (finishNotice != null)
 | 
						|
                        UpdateEntityNoCommit(finishNotice);
 | 
						|
                    if (sendNotice != null)
 | 
						|
                        UpdateEntityNoCommit(sendNotice);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |