mh_sms/APT.MicroApi/APT.SC.WebApi/Controllers/Api/OGController/09OGEmployeeRefuseItemReportController.cs
2024-01-22 09:17:01 +08:00

189 lines
9.6 KiB
C#

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<T_OG_EMPLOYEE_REFUSE_ITEM_REPORT>
{
IFMNotificationTaskService NotificationTaskService { get; set; }
public OGEmployeeRefuseItemReportController(IFMNotificationTaskService notificationTaskService, IPFCodeRuleService codeRuleService)
{
NotificationTaskService = notificationTaskService;
}
/// <summary>
/// 更新
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost, Route("FullUpdate")]
public JsonActionResult<bool> FullUpdate([FromBody] T_OG_EMPLOYEE_REFUSE_ITEM_REPORT entity)
{
return SafeExecute<bool>(() =>
{
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_FM_USER>(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_FM_USER>(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.)
{
var fuzong = GetEntity<T_FM_USER>(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<T_FM_USER>(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<T_FM_USER>(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;
});
}
}
}