using APT.BaseData.Domain.Entities.FM; using APT.BaseData.Domain.Enums; using APT.BaseData.Domain.Enums.PF; using APT.BaseData.Domain.IServices.FM; using APT.BaseData.Domain.IServices; using APT.BaseData.Services.DomainServices; using APT.Infrastructure.Core; using APT.MS.Domain.Entities.OG; using APT.MS.Domain.Enums; using APT.Utility; using Microsoft.AspNetCore.Mvc; using System; namespace APT.SC.WebApi.Controllers.Api.OG { [Route("api/OG/OGApproveRewardPunishmentReport")] public class OGApproveRewardPunishmentReportController : AuthorizeApiController { IFMNotificationTaskService NotificationTaskService { get; set; } IFMFlowPermitService MFlowPermitService { get; set; } IPFApproveCallBackService ApproveCallBackService { get; set; } public OGApproveRewardPunishmentReportController(IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService) { NotificationTaskService = notificationTaskService; MFlowPermitService = mFlowPermitService; ApproveCallBackService = approveCallBackService; } /// /// 保存 /// /// /// [HttpPost, Route("FullUpdate")] public JsonActionResult FullUpdate([FromBody] T_OG_APPROVE_REWARD_PUNISHMENT_REPORT entity) { return SafeExecute(() => { if (entity.START_TIME == null) { entity.START_TIME = DateTime.Now; } var userID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID; if (entity.USER_ID == null) { entity.USER_ID = userID; } if (entity.DEPARTMENT_ID == null) { entity.DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID; } if (entity.STATUS != PFStandardStatus.Draft) { throw new Exception("当前表单不可重复提交"); } var punishmentDetail = entity.Nav_ApproveRewardPunishmentDetail; entity.Nav_ApproveRewardPunishmentDetail = null; entity.Nav_Department = null; entity.Nav_User = null; punishmentDetail.ForEach(t => { if (t.OBJECT == OGRewardPunishmentObject.部门) { if (t.DEPARTMENT_ID == null) { throw new Exception("奖惩对象为部门时,需选择奖惩部门"); } t.USER_ID = null; } if (t.OBJECT == OGRewardPunishmentObject.员工) { if (t.USER_ID == null) { throw new Exception("奖惩对象为员工时,需选择奖惩人员"); } } }); if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify")) { if (entity.IDENTIFY_APPROVE == OGIdentifyApprove.录入) { entity.STATUS = PFStandardStatus.Archived; } else { var AHUser = GetEntity(t => t.Nav_ApproveRole.NAME == "安环部负责人"); var department = GetEntity(t => t.ID == entity.DEPARTMENT_ID, new string[] { "Nav_User" }); if (department.DEPARTMENT_TYPE == (int)FMDepartmentType.公司) { entity.STATUS = PFStandardStatus.Archived; } else { entity.STATUS = PFStandardStatus.Approving; } string type = ""; switch (department.DEPARTMENT_TYPE) { case (int)FMDepartmentType.部门: // 安环部 if (department.ID == AHUser.DEPARTMENT_ID) { type = "AH"; } else { type = "BM"; } break; case (int)FMDepartmentType.车间: type = "CJ"; break; case (int)FMDepartmentType.班组: type = "BZ"; break; } if (type != "") { MFlowPermitService.InsertApprove(DateTime.Now.ToString("yyyyMMddHHmmss"), "OG027", type, entity.ID, "OG027_SHOWPRINT", entity.TaskID, true, () => { UpdateEntityNoCommit(entity); if (punishmentDetail != null) BantchSaveEntityNoCommit(punishmentDetail); }, null); return true; } } } UnifiedCommit(() => { UpdateEntityNoCommit(entity); if (punishmentDetail != null) BantchSaveEntityNoCommit(punishmentDetail); }); return true; }); } /// /// 隐患上报 审核通过 给每个通知负责人发送通知 /// /// /// [HttpGet, Route("approveAndRewardAgree")] public JsonActionResult approveAndRewardAgree(string id) { return SafeExecute(() => { return ApproveCallBackService.CallBack("OG/OGApproveRewardPunishmentReport/approveAndRewardAgree", id); }); } } }