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 APT.BaseData.Domain.Enums; namespace APT.SC.WebApi.Controllers.Api.OG { [Route("api/OG/OGEmployeeRefuseItemReport")] public class OGEmployeeRefuseItemReportController : AuthorizeApiController { IFMNotificationTaskService NotificationTaskService { get; set; } public OGEmployeeRefuseItemReportController(IFMNotificationTaskService notificationTaskService, IPFCodeRuleService codeRuleService) { NotificationTaskService = notificationTaskService; } /// /// 更新 /// /// /// [HttpPost, Route("FullUpdate")] public JsonActionResult FullUpdate([FromBody] T_OG_EMPLOYEE_REFUSE_ITEM_REPORT entity) { return SafeExecute(() => { if (entity.START_TIME == null) { entity.START_TIME = DateTime.Now; } if (entity.USER_ID == null) { if (entity.STATUS == OGEmployeeOpinionReportStatus.草稿) { entity.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID; } } if (entity.LAUNCH_DEPARTMENT_ID == null) { if (entity.STATUS == (int)OGEmployeeOpinionReportStatus.草稿) { entity.LAUNCH_DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID; } } if (entity.LAUNCH_DEPARTMENT_ID == null) { throw new Exception("部门信息错误"); } var ASSIGNEE_NAME = ""; if (entity.ASSIGNEE_ID == null) { if (entity.STATUS == (int)OGEmployeeOpinionReportStatus.草稿) { var isNormal = GetEntity(t => t.ID == entity.USER_ID, new string[] { "Nav_Department.Nav_Parent.Nav_User", "Nav_Department.Nav_Parent.Nav_Parent.Nav_User", "Nav_ApproveRole" }); if (isNormal != null) { if (isNormal.Nav_ApproveRole != null && isNormal.Nav_ApproveRole.NAME.Equals("班组负责人"))//到车间负责人 { entity.ASSIGNEE_ID = isNormal.Nav_Department.Nav_Parent.Nav_Parent.Nav_User.ID; ASSIGNEE_NAME = isNormal.Nav_Department.Nav_Parent.Nav_Parent.Nav_User.NAME; } else if (isNormal.Nav_ApproveRole != null && isNormal.Nav_ApproveRole.NAME.Equals("车间负责人"))//到副总 { var fuzong = GetEntity(t => t.Nav_ApproveRole.NAME == "分管安全副总"); if(fuzong != null) { entity.ASSIGNEE_ID = fuzong.ID; ASSIGNEE_NAME = fuzong.NAME; } else { throw new Exception("未找到该部门副总!"); } } else if (isNormal.Nav_ApproveRole != null && isNormal.Nav_ApproveRole.NAME.Equals("部门负责人"))//到总经理 { entity.ASSIGNEE_ID = isNormal.Nav_Department.Nav_Parent.Nav_User.ID; ASSIGNEE_NAME = isNormal.Nav_Department.Nav_Parent.Nav_User.NAME; } else { if(isNormal.Nav_Department.DEPARTMENT_TYPE==(int)FMDepartmentType.Department) { var fuzong = GetEntity(t => t.Nav_ApproveRole.NAME == "分管安全副总"); if (fuzong != null) { entity.ASSIGNEE_ID = fuzong.ID; ASSIGNEE_NAME = fuzong.NAME; } else { throw new Exception("未找到该部门副总!"); } } else { entity.ASSIGNEE_ID = isNormal.Nav_Department.Nav_Parent.Nav_User.ID; ASSIGNEE_NAME = isNormal.Nav_Department.Nav_Parent.Nav_User.NAME; } } } } } var Nav_FileList = entity.Nav_FileList; entity.Nav_FileList = null; var Nav_InvestigationFileList = entity.Nav_InvestigationFileList; entity.Nav_InvestigationFileList = null; 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.FOGetTaskFinishModel(entity.TaskID,entity.ID, "OG013_SHOWPRINT"); } if (entity.STATUS == (int)OGEmployeeOpinionReportStatus.草稿) { if (string.IsNullOrEmpty(entity.NAME)) { throw new Exception("请填写事项名称"); } if (string.IsNullOrEmpty(entity.DESCRIPTION)) { throw new Exception("请填写事项描述"); } entity.STATUS = OGEmployeeOpinionReportStatus.确认中; sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("员工拒绝事项受理", entity.ID, entity.ORG_ID, entity.ASSIGNEE_ID.Value, ASSIGNEE_NAME, DateTime.Now, DateTime.Now.AddHours(12), 0, "OG014_EDIT1"); } else if (entity.STATUS == OGEmployeeOpinionReportStatus.确认中) { if (string.IsNullOrEmpty(entity.ASSIGNEE_DESCRIPTION)) { throw new Exception("请填写受理状况描述"); } if (entity.IMPLEMENT_USER_ID == null) { throw new Exception("请选择调查人"); } entity.STATUS = OGEmployeeOpinionReportStatus.审核中; var implementUser = GetEntity(entity.IMPLEMENT_USER_ID.Value); entity.IMPLEMENT_DEPARTMENT_ID = implementUser.DEPARTMENT_ID; sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("员工拒绝事项调查", entity.ID, entity.ORG_ID, entity.IMPLEMENT_USER_ID.Value, implementUser.NAME, DateTime.Now, DateTime.Now.AddHours(12), 0, "OG014_EDIT2"); } else if (entity.STATUS == OGEmployeeOpinionReportStatus.审核中) { if (string.IsNullOrEmpty(entity.IMPLEMENT_DESCRIPTION)) { throw new Exception("请填写落实情况描述"); } entity.STATUS = OGEmployeeOpinionReportStatus.评价中; var sendUser = GetEntity(entity.USER_ID.Value); sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("员工拒绝事项评价", entity.ID, entity.ORG_ID, entity.USER_ID.Value, sendUser.NAME, DateTime.Now, DateTime.Now.AddHours(12), 0, "OG014_EDIT3"); } else if (entity.STATUS == OGEmployeeOpinionReportStatus.评价中) { entity.STATUS = OGEmployeeOpinionReportStatus.归档; } else { throw new Exception("当前状态不可提交"); } } UnifiedCommit(() => { UpdateEntityNoCommit(entity); if (Nav_FileList != null) BantchSaveEntityNoCommit(Nav_FileList); if (Nav_InvestigationFileList != null) BantchSaveEntityNoCommit(Nav_InvestigationFileList); if (finishNotice != null) UpdateEntityNoCommit(finishNotice); if (sendNotice != null) UpdateEntityNoCommit(sendNotice); }); return true; }); } } }