mh_sms/APT.MicroApi/APT.SC.WebApi/Controllers/Api/OGController/16OGApproveRewardPunishmentReportController.cs

155 lines
6.5 KiB
C#
Raw Normal View History

2024-01-22 09:17:01 +08:00
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<T_OG_APPROVE_REWARD_PUNISHMENT_REPORT>
{
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;
}
/// <summary>
/// 保存
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpPost, Route("FullUpdate")]
public JsonActionResult<bool> 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_FM_USER>(t => t.Nav_ApproveRole.NAME == "安环部负责人");
var department = GetEntity<T_FM_DEPARTMENT>(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;
});
}
/// <summary>
/// 隐患上报 审核通过 给每个通知负责人发送通知
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
[HttpGet, Route("approveAndRewardAgree")]
public JsonActionResult<bool> approveAndRewardAgree(string id)
{
return SafeExecute<bool>(() =>
{
return ApproveCallBackService.CallBack("OG/OGApproveRewardPunishmentReport/approveAndRewardAgree", id);
});
}
}
}