diff --git a/APT.BaseData.Services/Services/PF/PFApproveCallBackService.cs b/APT.BaseData.Services/Services/PF/PFApproveCallBackService.cs index dd84630..a3dbca6 100644 --- a/APT.BaseData.Services/Services/PF/PFApproveCallBackService.cs +++ b/APT.BaseData.Services/Services/PF/PFApproveCallBackService.cs @@ -2452,6 +2452,55 @@ namespace APT.BaseData.Services.DomainServices }); } return true; + } + private bool BackUpdateNew_FOFireJob(T_PF_APPROVE entityInt, T_PF_APPROVE modelApp, List listAppDetail, T_FM_NOTIFICATION_TASK taskFinish, List listTaskNext, bool isLast = false) + { + #region 审批公用 + + if (modelApp == null) + { + string taskCodeCheck = String.Empty; + bool result = GetApproject2(entityInt, ref modelApp, ref listAppDetail, ref taskFinish, ref taskCodeCheck, ref isLast, ref listTaskNext); + if (!result) + { + throw new Exception("审批失败!"); + } + } + + #endregion + if (!isLast) + { + this.UnifiedCommit(() => + { + if (modelApp != null) + UpdateEntityNoCommit(modelApp); //保存主表 + if (listAppDetail != null && listAppDetail.Count > 0)//添加组合数据 修改的安全库、隐患库 + BantchSaveEntityNoCommit(listAppDetail); + if (taskFinish != null) + UpdateEntityNoCommit(taskFinish); + if (listTaskNext != null && listTaskNext.Count > 0) + BantchSaveEntityNoCommit(listTaskNext); + }); + } + else + { + var entity = this.GetEntity(modelApp.DATA_ID); + entity.STATUS = PFStandardStatus.Archived; + UnifiedCommit(() => + { + if (modelApp != null) + UpdateEntityNoCommit(modelApp); //保存主表 + if (listAppDetail != null && listAppDetail.Count > 0)//添加组合数据 修改的安全库、隐患库 + BantchSaveEntityNoCommit(listAppDetail); + if (taskFinish != null) + UpdateEntityNoCommit(taskFinish); + if (listTaskNext != null && listTaskNext.Count > 0) + BantchSaveEntityNoCommit(listTaskNext); + if (entity != null) + this.UpdateEntityNoCommit(entity); + }); + } + return true; } /// /// 关键许可工作票外包 @@ -7453,6 +7502,9 @@ namespace APT.BaseData.Services.DomainServices break; case "FO/FOCrucialLicenseJob/BackUpdateNew": result = BackUpdateNew_FOCrucialLicenseJob(entityInt, modelApp, listAppDetail, taskFinish, listTaskNext, isLast); + break; + case "FO/FOFireJob/BackUpdateNew": + result = BackUpdateNew_FOFireJob(entityInt, modelApp, listAppDetail, taskFinish, listTaskNext, isLast); break; case "FO/FOJobEventRecord/BackUpdateNew": result = BackUpdateNew_FOJobEventRecord(entityInt, modelApp, listAppDetail, taskFinish, listTaskNext, isLast); diff --git a/APT.MicroApi/APT.FO.WebApi/Controllers/FireJobController.cs b/APT.MicroApi/APT.FO.WebApi/Controllers/FireJobController.cs index 9a599e5..e00ed10 100644 --- a/APT.MicroApi/APT.FO.WebApi/Controllers/FireJobController.cs +++ b/APT.MicroApi/APT.FO.WebApi/Controllers/FireJobController.cs @@ -1,5 +1,13 @@ -using APT.Infrastructure.Core; +using APT.BaseData.Domain.Entities; +using APT.BaseData.Domain.Entities.FM; +using APT.BaseData.Domain.Enums; +using APT.BaseData.Domain.IServices; +using APT.BaseData.Domain.IServices.FM; +using APT.BaseData.Services.DomainServices; +using APT.BaseData.Services.Services.FM; +using APT.Infrastructure.Core; using APT.MS.Domain.Entities.FO; +using APT.MS.Domain.Enums; using APT.Utility; using Microsoft.AspNetCore.Mvc; using System; @@ -14,6 +22,21 @@ namespace APT.FO.WebApi.Controllers [Route("api/FO/FOFireJob")] public partial class FireJobController : AuthorizeApiController { + IFMFlowPermitService MFlowPermitService { get; set; } + IPFCodeRuleService CodeRuleService { get; set; } + IPFApproveCallBackService ApproveCallBackService { get; set; } + IFMNotificationTaskService NotificationTaskService { get; set; } + /// + /// FOPreOperSch + /// + /// + public FireJobController(IPFCodeRuleService codeRuleService, IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService, IFMNotificationTaskService notificationTaskService) + { + CodeRuleService = codeRuleService; + MFlowPermitService = mFlowPermitService; + ApproveCallBackService = approveCallBackService; + NotificationTaskService = notificationTaskService; + } [HttpPost, Route("GetEdit")] public JsonActionResult GetEdit([FromBody] KeywordFilter filter) { @@ -124,6 +147,47 @@ namespace APT.FO.WebApi.Controllers var userList = new List(); if (users != null && users.Any()) { + var userTypes = this.GetEntities(t => t.NAME == "动火操作人员" || t.NAME == "瓦检员" || t.NAME == "喷水人员", new BaseFilter(entity.ORG_ID)); + var userTypeIds = userTypes.Select(m => m.ID).ToList(); + var dhUser = userTypes.FirstOrDefault(t => t.NAME == "动火操作人员"); + if (dhUser == null) + { + throw new Exception("人员类别未维护动火操作人员,请到系统管理添加名称为动火操作人员的人员类别"); + } + else + { + var dhUserHas = users.FirstOrDefault(t => t.USER_TYPE_ID == dhUser.ID); + if (dhUserHas == null) + { + throw new Exception("作业人员必须要有动火操作人员,请到用户列表配置对应人员类型"); + } + } + var wjUser = userTypes.FirstOrDefault(t => t.NAME == "瓦检员"); + if (wjUser == null) + { + throw new Exception("人员类别未维护瓦检员,请到系统管理添加名称为瓦检员的人员类别"); + } + else + { + var wjUserHas = users.FirstOrDefault(t => t.USER_TYPE_ID == wjUser.ID); + if (wjUserHas == null) + { + throw new Exception("作业人员必须要有瓦检员,请到用户列表配置对应人员类型"); + } + } + var psUser = userTypes.FirstOrDefault(t => t.NAME == "喷水人员"); + if (psUser == null) + { + throw new Exception("人员类别未维护喷水人员,请到系统管理添加名称为喷水人员的人员类别"); + } + else + { + var psUserHas = users.FirstOrDefault(t => t.USER_TYPE_ID == psUser.ID); + if (psUserHas == null) + { + throw new Exception("作业人员必须要有喷水人员,请到用户列表配置对应人员类型"); + } + } foreach (var item in users) { item.ORG_ID = entity.ORG_ID; @@ -144,6 +208,10 @@ namespace APT.FO.WebApi.Controllers userList.Add(item); } } + else + { + throw new Exception("作业人员不能为空"); + } var fireFiles = entity.Nav_FireFiles; if (fireFiles != null && fireFiles.Any()) { @@ -180,6 +248,62 @@ namespace APT.FO.WebApi.Controllers monitorFileList.Add(item); } } + if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify")) + { + //触发审批 + entity.STATUS = BaseData.Domain.Enums.PF.PFStandardStatus.Approving; + //取审批流水码 + 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 department = this.GetEntity(t => t.ID == departmentId); + var param = Enum.GetName(typeof(FMDepartmentType), department.DEPARTMENT_TYPE); + if (department.DEPARTMENT_STATUS == 2) + { + param = "公司"; + } + MFlowPermitService.InsertApprove(serialCode[0], "FO038", param, entity.ID, "FO039_SHOWPRINT", entity.TaskID, true, () => + { + if (detailFileIds != null && detailFileIds.Any()) + this.BantchDeleteEntityNoCommit(detailFileIds); + if (detailIds != null && detailIds.Any()) + this.BantchDeleteEntityNoCommit(detailIds); + if (userFileIds != null && userFileIds.Any()) + this.BantchDeleteEntityNoCommit(userFileIds); + if (userIds != null && userIds.Any()) + this.BantchDeleteEntityNoCommit(userIds); + if (fileIds != null && fileIds.Any()) + this.BantchDeleteEntityNoCommit(fileIds); + if (fireFileIds != null && fireFileIds.Any()) + this.BantchDeleteEntityNoCommit(fireFileIds); + if (monitorFileIds != null && monitorFileIds.Any()) + this.BantchDeleteEntityNoCommit(monitorFileIds); + if (riskIds != null && riskIds.Any()) + this.BantchDeleteEntityNoCommit(riskIds); + if (entity != null) + UpdateEntityNoCommit(entity); + if (detailList != null && detailList.Any()) + this.BantchSaveEntityNoCommit(detailList); + if (detailFileList != null && detailFileList.Any()) + this.BantchSaveEntityNoCommit(detailFileList); + if (userList != null && userList.Any()) + this.BantchSaveEntityNoCommit(userList); + if (userFileList != null && userFileList.Any()) + this.BantchSaveEntityNoCommit(userFileList); + if (riskList != null && riskList.Any()) + this.BantchSaveEntityNoCommit(riskList); + if (monitorFileList != null && monitorFileList.Any()) + this.BantchSaveEntityNoCommit(monitorFileList); + if (fireFileList != null && fireFileList.Any()) + this.BantchSaveEntityNoCommit(fireFileList); + if (fileList != null && fileList.Any()) + this.BantchSaveEntityNoCommit(fileList); + }, null, null, null, null, null, "FO039_SHOWPRINT", null, "动火作业工作票", FMTASKTYPE.JobSite); + return true; + } this.UnifiedCommit(() => { if (detailFileIds != null && detailFileIds.Any()) @@ -220,5 +344,69 @@ namespace APT.FO.WebApi.Controllers return true; }); } + /// + /// 回调函数 + /// + /// + /// + [HttpPost, Route("BackUpdateNew")] + public JsonActionResult BackUpdateNew([FromBody] T_PF_APPROVE entity) + { + return SafeExecute(() => + { + return ApproveCallBackService.CallBackNew("FO/FOFireJob/BackUpdateNew", entity); + }); + } + /// + /// 驳回 + /// + /// + /// + [HttpPost, Route("RejectUpdate")] + public JsonActionResult RejectUpdate([FromBody] T_PF_APPROVE model) + { + return SafeExecute(() => + { + //公共 获取审批流信息 + T_PF_APPROVE modelApp = null; + List 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(model.DATA_ID, new string[] { "Nav_ApplyUser" }); + entity.STATUS = BaseData.Domain.Enums.PF.PFStandardStatus.Rejected; + var persons = this.GetEntities(t => t.FIRE_JOB_ID == model.DATA_ID, new BaseFilter(entity.ORG_ID)); + if (persons.Any()) + persons.ForEach(t => { t.DEAL_STATUS = 0; t.Nav_User = null; }); + //直接驳回给申请人 + T_FM_NOTIFICATION_TASK notice = NotificationTaskService.InsertUserNoticeTaskModel("动火作业工作票已被驳回", entity.ID, entity.ORG_ID, (Guid)entity.APPLY_USER_ID, entity.Nav_ApplyUser.NAME, DateTime.Now, + DateTime.Now.AddHours(24), (int)FMNoticeTypeEnum.消息, "FO038"); + //当前节点其他审核人待办消除 + var taskOtherIds = this.GetEntities(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(taskOtherIds); + if (taskFinish != null) + UpdateEntityNoCommit(taskFinish); + }); + return true; + }); + } } }