217 lines
		
	
	
		
			10 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			217 lines
		
	
	
		
			10 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.FO;
 | 
						|
using APT.MS.Domain.Entities.SC.PE;
 | 
						|
using APT.MS.Domain.Entities.SC.PR;
 | 
						|
using APT.MS.Domain.Enums;
 | 
						|
using APT.Utility;
 | 
						|
using Microsoft.AspNetCore.Mvc;
 | 
						|
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using System.Linq;
 | 
						|
 | 
						|
namespace APT.SC.WebApi.Controllers.Api.PRController
 | 
						|
{
 | 
						|
    /// <summary>
 | 
						|
    ///  变化管理任务落实表
 | 
						|
    /// </summary>
 | 
						|
    [Route("api/PR/PRChangeTaskImplement")]
 | 
						|
    public partial class ChangeTaskImplementController : AuthorizeApiController<T_PR_CHANGE_TASK_IMPLEMENT>
 | 
						|
    {
 | 
						|
        IPFCodeRuleService CodeRuleService { get; set; }
 | 
						|
        IFMNotificationTaskService NotificationTaskService { get; set; }
 | 
						|
        IFMFlowPermitService MFlowPermitService { get; set; }
 | 
						|
        IPFApproveCallBackService ApproveCallBackService { get; set; }
 | 
						|
        /// <summary>
 | 
						|
        /// 变化管理任务落实表
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="notificationTaskService"></param>
 | 
						|
        public ChangeTaskImplementController(IPFCodeRuleService codeRuleService, IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService)
 | 
						|
        {
 | 
						|
            CodeRuleService = codeRuleService;
 | 
						|
            NotificationTaskService = notificationTaskService;
 | 
						|
            MFlowPermitService = mFlowPermitService;
 | 
						|
            ApproveCallBackService = approveCallBackService;
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 落实人员获取
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="filter"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("GetUserEdit")]
 | 
						|
        public JsonActionResult<T_PR_CHANGE_TASK_IMPLEMENT> GetUserEdit([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 result = this.GetEntity<T_PR_CHANGE_TASK_IMPLEMENT>(id, new string[] { "Nav_User", "Nav_Department","Nav_Task",
 | 
						|
            "Nav_Users","Nav_Users.Nav_User","Nav_Files","Nav_Files.Nav_ImgFile","Nav_Change","Nav_Change.Nav_Types.Nav_Type"});
 | 
						|
                if (result != null && result.Nav_Change!=null)
 | 
						|
                {
 | 
						|
                    result.CODE = result.Nav_Change.CODE;
 | 
						|
                    result.DESCRIPTION = result.Nav_Change.DESCRIPTION;
 | 
						|
                    if (result.Nav_Change.Nav_Types != null && result.Nav_Change.Nav_Types.Any())
 | 
						|
                    {
 | 
						|
                        result.Nav_Types = result.Nav_Change.Nav_Types;
 | 
						|
                    }
 | 
						|
                    //if (result.Nav_Change.Nav_Tasks != null && result.Nav_Change.Nav_Tasks.Any())
 | 
						|
                    //{
 | 
						|
                    //    result.Nav_Tasks = result.Nav_Change.Nav_Tasks;
 | 
						|
                    //    var loginUserId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
 | 
						|
                    //    result.Nav_Tasks = result.Nav_Tasks.Where(t => t.USER_ID == loginUserId).ToList();
 | 
						|
                    //}
 | 
						|
                }
 | 
						|
                return result;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 新增/编辑
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="entity"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("FullUpdate")]
 | 
						|
        public JsonActionResult<bool> FullUpdate([FromBody] T_PR_CHANGE_TASK_IMPLEMENT entity)
 | 
						|
        {
 | 
						|
            return SafeExecute(() =>
 | 
						|
            {
 | 
						|
                entity.TIME = DateTime.Now;
 | 
						|
                entity.STATUS = PFStandardStatus.Draft;
 | 
						|
                var users = entity.Nav_Users;
 | 
						|
                var files = entity.Nav_Files;
 | 
						|
                if (files != null && files.Any())
 | 
						|
                {
 | 
						|
                    files.Where(t => !t.IS_DELETED).ForEach(t =>
 | 
						|
                    {
 | 
						|
                        t.ORG_ID = entity.ORG_ID; t.CHANGE_TASK_IMPLEMENT_ID = entity.ID;
 | 
						|
                    });
 | 
						|
                }
 | 
						|
                if (users != null && users.Any())
 | 
						|
                {
 | 
						|
                    users.Where(t => !t.IS_DELETED).ForEach(t =>
 | 
						|
                    {
 | 
						|
                        t.ORG_ID = entity.ORG_ID; t.CHANGE_TASK_IMPLEMENT_ID = entity.ID;
 | 
						|
                        t.Nav_User = null;
 | 
						|
                    });
 | 
						|
                }
 | 
						|
                else
 | 
						|
                {
 | 
						|
                    if (entity.PERFORM_STATUS == PRPerformStatusEnum.OK)
 | 
						|
                        this.ThrowError("040052");
 | 
						|
                }
 | 
						|
                if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
 | 
						|
                {
 | 
						|
                    entity.STATUS = PFStandardStatus.Approving;
 | 
						|
                    entity.Nav_Types = null;
 | 
						|
                    entity.Nav_Files = null;
 | 
						|
                    entity.Nav_Users = null;
 | 
						|
                    //取审批流水码
 | 
						|
                    var sysFilter = new SystemCodeFilter();
 | 
						|
                    sysFilter.CodeType = (int)PFCodeRuleType.审批流编码;
 | 
						|
                    sysFilter.Count = 1;
 | 
						|
                    sysFilter.OrgId = entity.ORG_ID;
 | 
						|
                    var codes = CodeRuleService.NewGenSerial(sysFilter);
 | 
						|
                    var serialCode = codes.Split(new char[] { ',' });
 | 
						|
                    //var idetity = this.GetEntity<T_PR_CHANGE_IDENTIFY_EVALUATION>(t => t.ID == entity.CHANGE_IDENTIFY_EVALUATION_ID);
 | 
						|
                    MFlowPermitService.InsertApprove(serialCode[0], "PR026", "", entity.ID, "PR026_SHOWPRINT", entity.TaskID, true, () =>
 | 
						|
                    {
 | 
						|
                        if (entity != null)
 | 
						|
                            this.UpdateEntityNoCommit(entity);
 | 
						|
                        if (files != null && files.Any())
 | 
						|
                            this.BantchSaveEntityNoCommit(files);
 | 
						|
                        if (users != null && users.Any())
 | 
						|
                            this.BantchSaveEntityNoCommit(users);
 | 
						|
                    }, null, null, null, null, null, "PR026_SHOWPRINT", null);
 | 
						|
                    return true;
 | 
						|
                }
 | 
						|
                entity.Nav_Types = null;
 | 
						|
                entity.Nav_Files = null;
 | 
						|
                entity.Nav_Users = null;
 | 
						|
                UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    if (entity != null)
 | 
						|
                        this.UpdateEntityNoCommit(entity);
 | 
						|
                    if (files != null && files.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(files);
 | 
						|
                    if (users != null && users.Any())
 | 
						|
                        this.BantchSaveEntityNoCommit(users);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
            });
 | 
						|
        }
 | 
						|
        /// <summary>
 | 
						|
        /// 回调函数
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="id"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpGet, Route("BackUpdate")]
 | 
						|
        public JsonActionResult<bool> BackUpdate(string id)
 | 
						|
        {
 | 
						|
            return SafeExecute(() =>
 | 
						|
            {
 | 
						|
                return ApproveCallBackService.CallBack("PR/PRChangeTaskImplement/BackUpdate", id);
 | 
						|
            });
 | 
						|
        }
 | 
						|
 | 
						|
        /// <summary>
 | 
						|
        /// 驳回
 | 
						|
        /// </summary>
 | 
						|
        /// <param name="id"></param>
 | 
						|
        /// <returns></returns>
 | 
						|
        [HttpPost, Route("RejectUpdate")]
 | 
						|
        public JsonActionResult<bool> RejectUpdate([FromBody] T_PF_APPROVE model)
 | 
						|
        {
 | 
						|
            return SafeExecute(() =>
 | 
						|
            {
 | 
						|
                //公共 获取审批流信息
 | 
						|
                T_PF_APPROVE modelApp = null;
 | 
						|
                List<T_PF_APPROVE_DETAIL> listAppDetail = null;
 | 
						|
                T_FM_NOTIFICATION_TASK taskFinish = null;
 | 
						|
                string Msg = string.Empty;
 | 
						|
                bool ResultGetInfo = ApproveCallBackService.GetApproject(model, ref modelApp, ref listAppDetail, ref taskFinish, ref Msg);
 | 
						|
                if (!ResultGetInfo)
 | 
						|
                    throw new Exception("驳回失败!");
 | 
						|
 | 
						|
                if (modelApp == null || listAppDetail == null)
 | 
						|
                    throw new Exception("获取驳回信息失败!");
 | 
						|
                var entity = this.GetEntity<T_PR_CHANGE_TASK_IMPLEMENT>(model.DATA_ID);
 | 
						|
                entity.STATUS = PFStandardStatus.Rejected;
 | 
						|
                var persons = this.GetEntities<T_PR_CHANGE_TASK_IMPLEMENT_USER>(t => t.CHANGE_TASK_IMPLEMENT_ID == model.DATA_ID, new BaseFilter(entity.ORG_ID));
 | 
						|
                if (persons.Any())
 | 
						|
                    persons.ForEach(t => { t.DEAL_STATUS = 0; t.Nav_User = null; });
 | 
						|
                //直接驳回给申请人
 | 
						|
                var user = this.GetEntity<T_FM_USER>(t => t.ID == entity.USER_ID && t.ENABLE_STATUS == 0);
 | 
						|
                T_FM_NOTIFICATION_TASK notice = NotificationTaskService.InsertUserNoticeTaskModel("变化管理任务落实表已被驳回", entity.ID, entity.ORG_ID, (Guid)user.ID, user.NAME, DateTime.Now,
 | 
						|
                DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "PR026");
 | 
						|
                //当前节点其他审核人待办消除
 | 
						|
                var taskOtherIds = this.GetEntities<T_FM_NOTIFICATION_TASK>(t => t.SOURCE_DATA_ID == model.ID && t.NOTICE_STATUS == 0, new BaseFilter(entity.ORG_ID)).Select(t => t.ID).ToList();
 | 
						|
 | 
						|
                UnifiedCommit(() =>
 | 
						|
                {
 | 
						|
                    if (entity != null)
 | 
						|
                        this.UpdateEntityNoCommit(entity);
 | 
						|
                    if (notice != null)
 | 
						|
                        this.UpdateEntityNoCommit(notice);
 | 
						|
                    if (modelApp != null)
 | 
						|
                        UpdateEntityNoCommit(modelApp);
 | 
						|
                    if (listAppDetail != null && listAppDetail.Count > 0)
 | 
						|
                        BantchUpdateEntityNoCommit(listAppDetail);
 | 
						|
                    if (persons != null && persons.Any())
 | 
						|
                        BantchUpdateEntityNoCommit(persons);
 | 
						|
                    if (taskOtherIds != null && taskOtherIds.Any())
 | 
						|
                        BantchDeleteEntityNoCommit<T_FM_NOTIFICATION_TASK>(taskOtherIds);
 | 
						|
                    if (taskFinish != null)
 | 
						|
                        UpdateEntityNoCommit(taskFinish);
 | 
						|
                });
 | 
						|
                return true;
 | 
						|
                //return ApproveCallBackService.CallReject("FO/FOCrucialLicenseJob/RejectUpdate", id);
 | 
						|
            });
 | 
						|
        }
 | 
						|
    }
 | 
						|
}
 |