เพิ่มวันที่ยับยั่ง
This commit is contained in:
parent
f2a0b754b3
commit
64eb77674a
13 changed files with 41337 additions and 90 deletions
|
|
@ -184,7 +184,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task CommanderApproveRetirementResignEmployee(Guid id, string reason)
|
||||
public async Task CommanderApproveRetirementResignEmployee(Guid id, string reason, DateTime date)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
|
@ -250,6 +250,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
approver.RejectDate = date;
|
||||
|
||||
//await _dbContext.SaveChangesAsync();
|
||||
|
||||
|
|
@ -296,7 +297,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task CommanderRejectRetirementResignEmployee(Guid id, string reason)
|
||||
public async Task CommanderRejectRetirementResignEmployee(Guid id, string reason, DateTime date)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
|
@ -338,6 +339,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
approver.RejectDate = date;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
|
@ -383,7 +385,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
}
|
||||
|
||||
public async Task ApproveRetirementResignEmployee(Guid id, string reason)
|
||||
public async Task ApproveRetirementResignEmployee(Guid id, string reason, DateTime date)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
|
@ -424,6 +426,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
approver.RejectDate = date;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
|
@ -459,7 +462,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
}
|
||||
|
||||
public async Task RejectRetirementResignEmployee(Guid id, string reason)
|
||||
public async Task RejectRetirementResignEmployee(Guid id, string reason, DateTime date)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
|
@ -500,6 +503,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
approver.RejectDate = date;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -89,51 +89,6 @@ namespace BMA.EHR.Application.Repositories
|
|||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
//เกษียณอายุราชการ
|
||||
//public async Task ExecuteRetirement()
|
||||
//{
|
||||
// var retirePeriodOfficer = await _dbContext.Set<RetirementPeriod>()
|
||||
// .Include(x => x.RetirementRawProfiles.Where(y => y.Remove != "REMOVE"))
|
||||
// .Where(x => x.Year == DateTime.Now.Year)
|
||||
// .Where(x => x.Type.Trim().ToUpper().Contains("OFFICER"))
|
||||
// .FirstOrDefaultAsync();
|
||||
|
||||
// if (retirePeriodOfficer == null)
|
||||
// return;
|
||||
|
||||
// var body = new
|
||||
// {
|
||||
// data = retirePeriodOfficer.RetirementRawProfiles
|
||||
// .Select(x => new
|
||||
// {
|
||||
// profileId = x.profileId
|
||||
// })
|
||||
// .ToList()
|
||||
// };
|
||||
|
||||
// //ข้าราชการ
|
||||
// //var apiUrl = $"{_configuration["API"]}/org/unauthorize/retirement";
|
||||
// using (var client = new HttpClient())
|
||||
// {
|
||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
// client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
|
||||
// var jsonBody = JsonConvert.SerializeObject(body);
|
||||
// var content = new StringContent(jsonBody, Encoding.UTF8, "application/json");
|
||||
|
||||
// var _req = new HttpRequestMessage(HttpMethod.Patch, apiUrl)
|
||||
// {
|
||||
// Content = content
|
||||
// };
|
||||
// var response = await client.SendAsync(_req);
|
||||
// var responseContent = await response.Content.ReadAsStringAsync();
|
||||
// if (!response.IsSuccessStatusCode)
|
||||
// {
|
||||
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public void TestMethod()
|
||||
{
|
||||
return;
|
||||
|
|
@ -182,7 +137,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
public async Task CommanderApproveRetirementResign(Guid id, string reason)
|
||||
public async Task CommanderApproveRetirementResign(Guid id, string reason, DateTime date)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
|
@ -199,14 +154,6 @@ namespace BMA.EHR.Application.Repositories
|
|||
throw new Exception("คำขอนี้ยังไม่ได้อยู่ในขั้นตอนที่สามารถอนุมัติได้ ไม่สามารถทำรายการได้");
|
||||
}
|
||||
|
||||
// check commander approve
|
||||
//var approvers = await _dbContext.Set<RetirementResignApprover>()
|
||||
// //.AsNoTracking()
|
||||
// .Include(x => x.RetirementResign)
|
||||
// .Where(x => x.RetirementResign.Id == id && x.ApproveType == "COMMANDER")
|
||||
// .OrderBy(x => x.Seq)
|
||||
// .ToListAsync();
|
||||
|
||||
var approvers = rawData.Approvers.Where(x => x.ApproveType!.ToUpper() == "COMMANDER").OrderBy(x => x.Seq).ToList();
|
||||
|
||||
var approver = approvers.FirstOrDefault(x => x.KeycloakId == userId);
|
||||
|
|
@ -228,28 +175,9 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
var maxSeq = approvers.Max(x => x.Seq);
|
||||
|
||||
//var data = await _dbContext.Set<RetirementResignApprover>()
|
||||
// .AsNoTracking()
|
||||
// .Include(x => x.RetirementResign)
|
||||
// .Where(x => x.RetirementResign.Id == id && x.KeycloakId == userId && x.ApproveType == "COMMANDER")
|
||||
// .FirstOrDefaultAsync();
|
||||
|
||||
//if(data != null)
|
||||
//{
|
||||
// data.ApproveStatus = "APPROVE";
|
||||
// data.Comment = reason;
|
||||
|
||||
// data.LastUpdatedAt = DateTime.Now;
|
||||
// data.LastUpdateUserId = userId.ToString("D");
|
||||
// data.LastUpdateFullName = FullName ?? "";
|
||||
|
||||
// await _dbContext.SaveChangesAsync();
|
||||
//}
|
||||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
|
||||
//await _dbContext.SaveChangesAsync();
|
||||
approver.RejectDate = date;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
|
@ -271,7 +199,6 @@ namespace BMA.EHR.Application.Repositories
|
|||
else
|
||||
{
|
||||
rawData.Status = "PENDING";
|
||||
// rawData.LeaveComment = reason;
|
||||
rawData.ApproveStep = "st3";
|
||||
|
||||
// TODO: Send notification to 1st Approver
|
||||
|
|
@ -293,7 +220,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task CommanderRejectRetirementResign(Guid id, string reason)
|
||||
public async Task CommanderRejectRetirementResign(Guid id, string reason, DateTime date)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
|
@ -335,6 +262,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
approver.RejectDate = date;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
|
@ -379,7 +307,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
}
|
||||
|
||||
public async Task ApproveRetirementResign(Guid id, string reason)
|
||||
public async Task ApproveRetirementResign(Guid id, string reason, DateTime date)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
|
@ -420,6 +348,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
approver.ApproveStatus = "APPROVE";
|
||||
approver.Comment = reason;
|
||||
approver.RejectDate = date;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
|
@ -458,7 +387,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
}
|
||||
|
||||
public async Task RejectRetirementResign(Guid id, string reason)
|
||||
public async Task RejectRetirementResign(Guid id, string reason, DateTime date)
|
||||
{
|
||||
// Get UserId from token
|
||||
var userId = UserId == null ? Guid.Empty : Guid.Parse(UserId);
|
||||
|
|
@ -499,6 +428,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
|
||||
approver.ApproveStatus = "REJECT";
|
||||
approver.Comment = reason;
|
||||
approver.RejectDate = date;
|
||||
|
||||
if (approver.Seq != maxSeq)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
public string ApproveStatus { get; set; } = string.Empty;
|
||||
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
public string Org { get; set; } = string.Empty;
|
||||
public DateTime? RejectDate { get; set; }
|
||||
|
||||
public string? ApproveType { get; set; } = string.Empty; // ผู้บังคับบัญชา = commander, ผู้มีอำนาจอนุมัติ = Approver
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@ namespace BMA.EHR.Domain.Models.Retirement
|
|||
public string ApproveStatus { get; set; } = string.Empty;
|
||||
|
||||
public string Comment { get; set; } = string.Empty;
|
||||
public string Org { get; set; } = string.Empty;
|
||||
public DateTime? RejectDate { get; set; }
|
||||
|
||||
public string? ApproveType { get; set; } = string.Empty; // ผู้บังคับบัญชา = commander, ผู้มีอำนาจอนุมัติ = Approver
|
||||
}
|
||||
|
|
|
|||
20601
BMA.EHR.Infrastructure/Migrations/20250507095828_update_table_retirement_add_approver_date.Designer.cs
generated
Normal file
20601
BMA.EHR.Infrastructure/Migrations/20250507095828_update_table_retirement_add_approver_date.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class update_table_retirement_add_approver_date : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "RejectDate",
|
||||
table: "RetirementResignEmployeeApprovers",
|
||||
type: "datetime(6)",
|
||||
nullable: true);
|
||||
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "RejectDate",
|
||||
table: "RetirementResignApprovers",
|
||||
type: "datetime(6)",
|
||||
nullable: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RejectDate",
|
||||
table: "RetirementResignEmployeeApprovers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "RejectDate",
|
||||
table: "RetirementResignApprovers");
|
||||
}
|
||||
}
|
||||
}
|
||||
20609
BMA.EHR.Infrastructure/Migrations/20250507101317_update_table_retirement_add_approver_date1.Designer.cs
generated
Normal file
20609
BMA.EHR.Infrastructure/Migrations/20250507101317_update_table_retirement_add_approver_date1.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,40 @@
|
|||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class update_table_retirement_add_approver_date1 : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Org",
|
||||
table: "RetirementResignEmployeeApprovers",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Org",
|
||||
table: "RetirementResignApprovers",
|
||||
type: "longtext",
|
||||
nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Org",
|
||||
table: "RetirementResignEmployeeApprovers");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Org",
|
||||
table: "RetirementResignApprovers");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17132,6 +17132,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnOrder(102)
|
||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||
|
||||
b.Property<string>("Org")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PositionName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
|
@ -17143,6 +17147,9 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime?>("RejectDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("RetirementResignId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
|
|
@ -18051,6 +18058,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
.HasColumnOrder(102)
|
||||
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
|
||||
|
||||
b.Property<string>("Org")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PositionName")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
|
@ -18062,6 +18073,9 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Property<Guid>("ProfileId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime?>("RejectDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("RetirementResignEmployeeId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
|
|
|
|||
|
|
@ -2598,6 +2598,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
PositionName = r.PositionName,
|
||||
ProfileId = r.ProfileId,
|
||||
KeycloakId = r.KeycloakId,
|
||||
Org = r.Org,
|
||||
ApproveStatus = "PENDING",
|
||||
ApproveType = type.Trim().ToUpper()
|
||||
});
|
||||
|
|
@ -2662,7 +2663,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderApproveRetirementResign(id, req.Reason ?? "");
|
||||
await _repository.CommanderApproveRetirementResign(id, req.Reason ?? "", req.Date ?? DateTime.Now);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2696,7 +2697,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderRejectRetirementResign(id, req.Reason ?? "");
|
||||
await _repository.CommanderRejectRetirementResign(id, req.Reason ?? "", req.Date ?? DateTime.Now);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2730,7 +2731,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.ApproveRetirementResign(id, req.Reason ?? "");
|
||||
await _repository.ApproveRetirementResign(id, req.Reason ?? "", req.Date ?? DateTime.Now);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2764,7 +2765,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.RejectRetirementResign(id, req.Reason ?? "");
|
||||
await _repository.RejectRetirementResign(id, req.Reason ?? "", req.Date ?? DateTime.Now);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1994,6 +1994,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
PositionName = r.PositionName,
|
||||
ProfileId = r.ProfileId,
|
||||
KeycloakId = r.KeycloakId,
|
||||
Org = r.Org,
|
||||
ApproveStatus = "PENDING",
|
||||
ApproveType = type.Trim().ToUpper()
|
||||
});
|
||||
|
|
@ -2058,7 +2059,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderApproveRetirementResignEmployee(id, req.Reason ?? "");
|
||||
await _repository.CommanderApproveRetirementResignEmployee(id, req.Reason ?? "", req.Date ?? DateTime.Now);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2092,7 +2093,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.CommanderRejectRetirementResignEmployee(id, req.Reason ?? "");
|
||||
await _repository.CommanderRejectRetirementResignEmployee(id, req.Reason ?? "", req.Date ?? DateTime.Now);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2126,7 +2127,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.ApproveRetirementResignEmployee(id, req.Reason ?? "");
|
||||
await _repository.ApproveRetirementResignEmployee(id, req.Reason ?? "", req.Date ?? DateTime.Now);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
@ -2160,7 +2161,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
// {
|
||||
// return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
// }
|
||||
await _repository.RejectRetirementResignEmployee(id, req.Reason ?? "");
|
||||
await _repository.RejectRetirementResignEmployee(id, req.Reason ?? "", req.Date ?? DateTime.Now);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,5 +4,6 @@ namespace BMA.EHR.Retirement.Service.Requests
|
|||
public class RetirementRequestApproveDto
|
||||
{
|
||||
public string? Reason { get; set; }
|
||||
public DateTime? Date { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,5 +24,8 @@ namespace BMA.EHR.Retirement.Service.Requests
|
|||
|
||||
[JsonProperty("keycloakId")]
|
||||
public Guid KeycloakId { get; set; } = Guid.Empty;
|
||||
|
||||
[JsonProperty("org")]
|
||||
public string Org { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue