using APT.BaseData.Domain.Entities; 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.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 { /// /// 变化管理任务落实表 /// [Route("api/PR/PRChangeTaskImplement")] public partial class ChangeTaskImplementController : AuthorizeApiController { IPFCodeRuleService CodeRuleService { get; set; } IFMNotificationTaskService NotificationTaskService { get; set; } IFMFlowPermitService MFlowPermitService { get; set; } IPFApproveCallBackService ApproveCallBackService { get; set; } /// /// 变化管理任务落实表 /// /// public ChangeTaskImplementController(IPFCodeRuleService codeRuleService, IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService) { CodeRuleService = codeRuleService; NotificationTaskService = notificationTaskService; MFlowPermitService = mFlowPermitService; ApproveCallBackService = approveCallBackService; } /// /// 落实人员获取 /// /// /// [HttpPost, Route("GetUserEdit")] public JsonActionResult 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(id, new string[] { "Nav_User", "Nav_Department","Nav_Task", "Nav_Users","Nav_Users.Nav_User","Nav_Files","Nav_Files.Nav_ImgFile.Nav_File","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; }); } /// /// 新增/编辑 /// /// /// [HttpPost, Route("FullUpdate")] public JsonActionResult FullUpdate([FromBody] T_PR_CHANGE_TASK_IMPLEMENT entity) { return SafeExecute(() => { entity.TIME = DateTime.Now; entity.STATUS = PFStandardStatus.Draft; var users = entity.Nav_Users.Where(t => !t.IS_DELETED).ToList(); var files = entity.Nav_Files.Where(t => !t.IS_DELETED).ToList(); if (files != null && files.Any()) { files.ForEach(t => { t.ORG_ID = entity.ORG_ID; t.CHANGE_TASK_IMPLEMENT_ID = entity.ID; }); } if (users != null && users.Any()) { users.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[] { ',' }); 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; }); } /// /// 回调函数 /// /// /// [HttpGet, Route("BackUpdate")] public JsonActionResult BackUpdate(string id) { return SafeExecute(() => { return ApproveCallBackService.CallBack("PR/PRChangeTaskImplement/BackUpdate", id); }); } } }