api พ้นราชการ
This commit is contained in:
parent
b800b9e60d
commit
1c09aa8e23
8 changed files with 12002 additions and 30 deletions
|
|
@ -30,6 +30,10 @@ namespace BMA.EHR.Domain.Models.HR
|
||||||
[Comment("ชื่อเครื่องราชฯ")]
|
[Comment("ชื่อเครื่องราชฯ")]
|
||||||
// public string? Insignia { get; set; }
|
// public string? Insignia { get; set; }
|
||||||
public Insignia? Insignia { get; set; }
|
public Insignia? Insignia { get; set; }
|
||||||
|
[Comment("เอกสารอ้างอิง (เลขที่คำสั่ง)")]
|
||||||
|
public string? RefCommandNo { get; set; }
|
||||||
|
[Comment("เอกสารอ้างอิง (ลงวันที่)")]
|
||||||
|
public DateTime? RefCommandDate { get; set; }
|
||||||
public virtual List<ProfileInsigniaHistory> ProfileInsigniaHistorys { get; set; } = new List<ProfileInsigniaHistory>();
|
public virtual List<ProfileInsigniaHistory> ProfileInsigniaHistorys { get; set; } = new List<ProfileInsigniaHistory>();
|
||||||
public virtual Profile? Profile { get; set; }
|
public virtual Profile? Profile { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,8 @@ namespace BMA.EHR.Domain.Models.Retirement
|
||||||
{
|
{
|
||||||
[Comment("ครั้งที่")]
|
[Comment("ครั้งที่")]
|
||||||
public int Round { get; set; }
|
public int Round { get; set; }
|
||||||
|
[Comment("ปีงบประมาณ")]
|
||||||
|
public int Year { get; set; }
|
||||||
[Comment("ประเภท")]
|
[Comment("ประเภท")]
|
||||||
public string Type { get; set; } = string.Empty;
|
public string Type { get; set; } = string.Empty;
|
||||||
public virtual List<RetirementProfile> RetirementProfiles { get; set; } = new List<RetirementProfile>();
|
public virtual List<RetirementProfile> RetirementProfiles { get; set; } = new List<RetirementProfile>();
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ namespace BMA.EHR.Domain.Models.Retirement
|
||||||
[Required, Comment("เหตุผล")]
|
[Required, Comment("เหตุผล")]
|
||||||
public string Reason { get; set; } = string.Empty;
|
public string Reason { get; set; } = string.Empty;
|
||||||
[Comment("ลบออกจากเกษียญ")]
|
[Comment("ลบออกจากเกษียญ")]
|
||||||
public bool Remove { get; set; } = false;
|
public string Remove { get; set; } = "pending";
|
||||||
public RetirementPeriod RetirementPeriod { get; set; }
|
public RetirementPeriod RetirementPeriod { get; set; }
|
||||||
public Profile Profile { get; set; }
|
public Profile Profile { get; set; }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11796
BMA.EHR.Infrastructure/Migrations/20230724064919_update Table retire add year.Designer.cs
generated
Normal file
11796
BMA.EHR.Infrastructure/Migrations/20230724064919_update Table retire add year.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,76 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updateTableretireaddyear : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AlterColumn<string>(
|
||||||
|
name: "Remove",
|
||||||
|
table: "RetirementProfiles",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: false,
|
||||||
|
comment: "ลบออกจากเกษียญ",
|
||||||
|
oldClrType: typeof(bool),
|
||||||
|
oldType: "tinyint(1)",
|
||||||
|
oldComment: "ลบออกจากเกษียญ")
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "Year",
|
||||||
|
table: "RetirementPeriods",
|
||||||
|
type: "int",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: 0,
|
||||||
|
comment: "ปีงบประมาณ");
|
||||||
|
|
||||||
|
// migrationBuilder.AddColumn<DateTime>(
|
||||||
|
// name: "RefCommandDate",
|
||||||
|
// table: "ProfileInsignias",
|
||||||
|
// type: "datetime(6)",
|
||||||
|
// nullable: true,
|
||||||
|
// comment: "เอกสารอ้างอิง (ลงวันที่)");
|
||||||
|
|
||||||
|
// migrationBuilder.AddColumn<string>(
|
||||||
|
// name: "RefCommandNo",
|
||||||
|
// table: "ProfileInsignias",
|
||||||
|
// type: "longtext",
|
||||||
|
// nullable: true,
|
||||||
|
// comment: "เอกสารอ้างอิง (เลขที่คำสั่ง)")
|
||||||
|
// .Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Year",
|
||||||
|
table: "RetirementPeriods");
|
||||||
|
|
||||||
|
// migrationBuilder.DropColumn(
|
||||||
|
// name: "RefCommandDate",
|
||||||
|
// table: "ProfileInsignias");
|
||||||
|
|
||||||
|
// migrationBuilder.DropColumn(
|
||||||
|
// name: "RefCommandNo",
|
||||||
|
// table: "ProfileInsignias");
|
||||||
|
|
||||||
|
migrationBuilder.AlterColumn<bool>(
|
||||||
|
name: "Remove",
|
||||||
|
table: "RetirementProfiles",
|
||||||
|
type: "tinyint(1)",
|
||||||
|
nullable: false,
|
||||||
|
comment: "ลบออกจากเกษียญ",
|
||||||
|
oldClrType: typeof(string),
|
||||||
|
oldType: "longtext",
|
||||||
|
oldComment: "ลบออกจากเกษียญ")
|
||||||
|
.OldAnnotation("MySql:CharSet", "utf8mb4");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3364,6 +3364,14 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasColumnType("datetime(6)")
|
.HasColumnType("datetime(6)")
|
||||||
.HasComment("ลงวันที่");
|
.HasComment("ลงวันที่");
|
||||||
|
|
||||||
|
b.Property<DateTime?>("RefCommandDate")
|
||||||
|
.HasColumnType("datetime(6)")
|
||||||
|
.HasComment("เอกสารอ้างอิง (ลงวันที่)");
|
||||||
|
|
||||||
|
b.Property<string>("RefCommandNo")
|
||||||
|
.HasColumnType("longtext")
|
||||||
|
.HasComment("เอกสารอ้างอิง (เลขที่คำสั่ง)");
|
||||||
|
|
||||||
b.Property<string>("Section")
|
b.Property<string>("Section")
|
||||||
.HasMaxLength(30)
|
.HasMaxLength(30)
|
||||||
.HasColumnType("varchar(30)")
|
.HasColumnType("varchar(30)")
|
||||||
|
|
@ -10317,6 +10325,10 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("ประเภท");
|
.HasComment("ประเภท");
|
||||||
|
|
||||||
|
b.Property<int>("Year")
|
||||||
|
.HasColumnType("int")
|
||||||
|
.HasComment("ปีงบประมาณ");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("RetirementPeriods");
|
b.ToTable("RetirementPeriods");
|
||||||
|
|
@ -10381,8 +10393,9 @@ namespace BMA.EHR.Infrastructure.Migrations
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("เหตุผล");
|
.HasComment("เหตุผล");
|
||||||
|
|
||||||
b.Property<bool>("Remove")
|
b.Property<string>("Remove")
|
||||||
.HasColumnType("tinyint(1)")
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext")
|
||||||
.HasComment("ลบออกจากเกษียญ");
|
.HasComment("ลบออกจากเกษียญ");
|
||||||
|
|
||||||
b.Property<Guid>("RetirementPeriodId")
|
b.Property<Guid>("RetirementPeriodId")
|
||||||
|
|
|
||||||
|
|
@ -353,6 +353,63 @@ namespace BMA.EHR.OrganizationEmployee.Service.Controllers
|
||||||
|
|
||||||
var organizationEmployee = await _context.OrganizationEmployees
|
var organizationEmployee = await _context.OrganizationEmployees
|
||||||
.Where(x => x.Profile == null || (x.Profile != null && x.Profile == profile))
|
.Where(x => x.Profile == null || (x.Profile != null && x.Profile == profile))
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
Use = x.Profile == null ? false : (x.Profile == profile ? true : false),
|
||||||
|
Agency = x.Agency,
|
||||||
|
ConditionNote = x.ConditionNote,
|
||||||
|
Department = x.Department,
|
||||||
|
Government = x.Government,
|
||||||
|
IsActive = x.IsActive,
|
||||||
|
IsCondition = x.IsCondition,
|
||||||
|
IsDirector = x.IsDirector,
|
||||||
|
OrganizationUserNote = x.OrganizationUserNote,
|
||||||
|
Qualification = x.Qualification,
|
||||||
|
Pile = x.Pile,
|
||||||
|
PosNo = x.PosNo,
|
||||||
|
PositionCondition = x.PositionCondition,
|
||||||
|
PositionMasterUserNote = x.PositionMasterUserNote,
|
||||||
|
OrganizationOrder = x.OrganizationOrder,
|
||||||
|
|
||||||
|
OrganizationFaxId = x.OrganizationFax == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationFax.Id,
|
||||||
|
OrganizationLevelId = x.OrganizationLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationLevel.Id,
|
||||||
|
OrganizationOrganizationId = x.OrganizationOrganization == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationOrganization.Id,
|
||||||
|
OrganizationTelExternalId = x.OrganizationTelExternal == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationTelExternal.Id,
|
||||||
|
OrganizationTelInternalId = x.OrganizationTelInternal == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationTelInternal.Id,
|
||||||
|
OrganizationTypeId = x.OrganizationType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationType.Id,
|
||||||
|
PositionEmployeeStatusId = x.PositionEmployeeStatus == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionEmployeeStatus.Id,
|
||||||
|
PositionEmployeeLineId = x.PositionEmployeeLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionEmployeeLine.Id,
|
||||||
|
PositionEmployeePositionId = x.PositionEmployeePosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.PositionEmployeePosition.Id,
|
||||||
|
OrganizationAgencyId = x.OrganizationAgency == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationAgency.Id,
|
||||||
|
OrganizationGovernmentAgencyId = x.OrganizationGovernmentAgency == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationGovernmentAgency.Id,
|
||||||
|
OrganizationShortNameId = x.OrganizationShortName == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.OrganizationShortName.Id,
|
||||||
|
|
||||||
|
OrganizationFaxName = x.OrganizationFax == null ? null : x.OrganizationFax.Name,
|
||||||
|
OrganizationLevelName = x.OrganizationLevel == null ? null : x.OrganizationLevel.Name,
|
||||||
|
OrganizationOrganizationName = x.OrganizationOrganization == null ? null : x.OrganizationOrganization.Name,
|
||||||
|
OrganizationTelExternalName = x.OrganizationTelExternal == null ? null : x.OrganizationTelExternal.Name,
|
||||||
|
OrganizationTelInternalName = x.OrganizationTelInternal == null ? null : x.OrganizationTelInternal.Name,
|
||||||
|
OrganizationTypeName = x.OrganizationType == null ? null : x.OrganizationType.Name,
|
||||||
|
PositionEmployeeStatusName = x.PositionEmployeeStatus == null ? null : x.PositionEmployeeStatus.Name,
|
||||||
|
PositionEmployeeLineName = x.PositionEmployeeLine == null ? null : x.PositionEmployeeLine.Name,
|
||||||
|
PositionEmployeePositionName = x.PositionEmployeePosition == null ? null : x.PositionEmployeePosition.Name,
|
||||||
|
OrganizationAgencyName = x.OrganizationShortName == null ? null : x.OrganizationShortName.AgencyCode,
|
||||||
|
OrganizationGovernmentAgencyName = x.OrganizationShortName == null ? null : x.OrganizationShortName.GovernmentCode,
|
||||||
|
// OrganizationAgencyName = x.OrganizationAgency == null ? null : x.OrganizationAgency.Name,
|
||||||
|
// OrganizationGovernmentAgencyName = x.OrganizationGovernmentAgency == null ? null : x.OrganizationGovernmentAgency.Name,
|
||||||
|
OrganizationShortNameName = x.OrganizationShortName == null ? null : x.OrganizationShortName.Name,
|
||||||
|
PositionEmployeeLevels = x.OrganizationPositionEmployeeLevels.Select(y => new
|
||||||
|
{
|
||||||
|
Id = y.PositionEmployeeLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : y.PositionEmployeeLevel.Id,
|
||||||
|
Name = y.PositionEmployeeLevel == null ? null : y.PositionEmployeeLevel.Name,
|
||||||
|
}),
|
||||||
|
PositionEmployeePositionSides = x.OrganizationPositionEmployeePositionSides.Select(y => new
|
||||||
|
{
|
||||||
|
Id = y.PositionEmployeePositionSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : y.PositionEmployeePositionSide.Id,
|
||||||
|
Name = y.PositionEmployeePositionSide == null ? null : y.PositionEmployeePositionSide.Name,
|
||||||
|
}),
|
||||||
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
return Success(organizationEmployee);
|
return Success(organizationEmployee);
|
||||||
|
|
@ -370,6 +427,11 @@ namespace BMA.EHR.OrganizationEmployee.Service.Controllers
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.OrganizationEmployeeId);
|
.FirstOrDefaultAsync(x => x.Id == req.OrganizationEmployeeId);
|
||||||
if (organizationEmployee == null)
|
if (organizationEmployee == null)
|
||||||
return Error(GlobalMessages.OrganizationEmployeeNotFound, 404);
|
return Error(GlobalMessages.OrganizationEmployeeNotFound, 404);
|
||||||
|
var organizationEmployeeProfile = await _context.OrganizationEmployees
|
||||||
|
.Include(x => x.Profile)
|
||||||
|
.FirstOrDefaultAsync(x => x.Profile == profile);
|
||||||
|
if (organizationEmployeeProfile != null)
|
||||||
|
organizationEmployeeProfile.Profile = null;
|
||||||
organizationEmployee.Profile = profile;
|
organizationEmployee.Profile = profile;
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
if (type.Trim().ToUpper().Contains("OFFICER"))
|
if (type.Trim().ToUpper().Contains("OFFICER"))
|
||||||
{
|
{
|
||||||
var profiles = await _context.RetirementProfiles
|
var profiles = await _context.RetirementProfiles
|
||||||
.Where(x => x.CreatedAt.Year == year)
|
.Where(x => x.RetirementPeriod.Year == year)
|
||||||
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||||
.OrderBy(x => x.Profile.OrganizationOrganization)
|
.OrderBy(x => x.Profile.OrganizationOrganization)
|
||||||
.ThenBy(x => x.Profile.PositionType == null ? null : x.Profile.PositionType.Name)
|
.ThenBy(x => x.Profile.PositionType == null ? null : x.Profile.PositionType.Name)
|
||||||
|
|
@ -75,7 +75,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
if (type.Trim().ToUpper().Contains("EMPLOYEE"))
|
if (type.Trim().ToUpper().Contains("EMPLOYEE"))
|
||||||
{
|
{
|
||||||
var profiles = await _context.RetirementProfiles
|
var profiles = await _context.RetirementProfiles
|
||||||
.Where(x => x.CreatedAt.Year == year)
|
.Where(x => x.RetirementPeriod.Year == year)
|
||||||
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||||
.OrderBy(x => x.Profile.OrganizationOrganization)
|
.OrderBy(x => x.Profile.OrganizationOrganization)
|
||||||
.ThenBy(x => x.Profile.EmployeeType)
|
.ThenBy(x => x.Profile.EmployeeType)
|
||||||
|
|
@ -112,7 +112,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
var retire_old = await _context.RetirementPeriods
|
var retire_old = await _context.RetirementPeriods
|
||||||
.Include(x => x.RetirementProfiles)
|
.Include(x => x.RetirementProfiles)
|
||||||
.Where(x => x.CreatedAt.Year == year)
|
.Where(x => x.Year == year)
|
||||||
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||||
.OrderByDescending(x => x.Round)
|
.OrderByDescending(x => x.Round)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
@ -121,13 +121,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
var data = await _context.RetirementPeriods
|
var data = await _context.RetirementPeriods
|
||||||
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||||
.Where(x => year > 0 ? (x.CreatedAt.Year == year) : (x.CreatedAt.Year > 0))
|
.Where(x => year > 0 ? (x.Year == year) : (x.Year > 0))
|
||||||
.Select(x => new
|
.Select(x => new
|
||||||
{
|
{
|
||||||
Id = x.Id,
|
Id = x.Id,
|
||||||
CreatedAt = x.CreatedAt,
|
CreatedAt = x.CreatedAt,
|
||||||
|
Year = x.Year,
|
||||||
Round = x.Round,
|
Round = x.Round,
|
||||||
Total = retire_old.Id == x.Id ? retire_old.RetirementProfiles.Count() : retire_old.RetirementProfiles.Count() - x.RetirementProfiles.Where(x => x.Remove == true).Count(),
|
Total = retire_old.Id == x.Id ? retire_old.RetirementProfiles.Count() : retire_old.RetirementProfiles.Count() - x.RetirementProfiles.Where(x => x.Remove != "pending").Count(),
|
||||||
}).OrderByDescending(x => x.CreatedAt)
|
}).OrderByDescending(x => x.CreatedAt)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
return Success(data);
|
return Success(data);
|
||||||
|
|
@ -152,7 +153,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var round = 1;
|
var round = 1;
|
||||||
var retire_old = await _context.RetirementPeriods
|
var retire_old = await _context.RetirementPeriods
|
||||||
.Include(x => x.RetirementProfiles)
|
.Include(x => x.RetirementProfiles)
|
||||||
.Where(x => x.CreatedAt.Year == year)
|
.Where(x => x.Year == year)
|
||||||
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||||
.OrderByDescending(x => x.Round)
|
.OrderByDescending(x => x.Round)
|
||||||
.FirstOrDefaultAsync();
|
.FirstOrDefaultAsync();
|
||||||
|
|
@ -163,6 +164,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
Round = round,
|
Round = round,
|
||||||
Type = type.Trim().ToUpper(),
|
Type = type.Trim().ToUpper(),
|
||||||
|
Year = year,
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
CreatedFullName = UserId ?? "System Administrator",
|
CreatedFullName = UserId ?? "System Administrator",
|
||||||
CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
|
|
@ -175,7 +177,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
var profiles = await _context.RetirementProfiles
|
var profiles = await _context.RetirementProfiles
|
||||||
.Where(x => x.RetirementPeriod == retire_old)
|
.Where(x => x.RetirementPeriod == retire_old)
|
||||||
.Where(x => x.Remove == false)
|
.Where(x => x.Remove == "pending")
|
||||||
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
.Where(x => x.RetirementPeriod.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
foreach (var profile in profiles)
|
foreach (var profile in profiles)
|
||||||
|
|
@ -198,14 +200,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
// where p.BirthDate.CalculateRetireDate().Year == year
|
// where p.BirthDate.CalculateRetireDate().Year == year
|
||||||
// select p)
|
// select p)
|
||||||
// .ToListAsync();
|
// .ToListAsync();
|
||||||
profiles = profiles.Where(x=>x.BirthDate.CalculateRetireDate().Year == year).ToList();
|
profiles = profiles.Where(x => x.BirthDate.CalculateRetireDate().Year == year).ToList();
|
||||||
var order = 1;
|
var order = 1;
|
||||||
foreach (var profile in profiles)
|
foreach (var profile in profiles)
|
||||||
{
|
{
|
||||||
var data = new RetirementProfile
|
var data = new RetirementProfile
|
||||||
{
|
{
|
||||||
Order = order,
|
Order = order,
|
||||||
Remove = false,
|
Remove = "pending",
|
||||||
RetirementPeriod = retire,
|
RetirementPeriod = retire,
|
||||||
Profile = profile,
|
Profile = profile,
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
|
|
@ -220,15 +222,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_context.SaveChanges();
|
|
||||||
var retire_all_year = await _context.RetirementPeriods
|
|
||||||
.Where(x => x.CreatedAt.Year == year)
|
|
||||||
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
|
||||||
.CountAsync();
|
|
||||||
if (retire_all_year <= 1)
|
|
||||||
{
|
|
||||||
await GenOrderByYear(type.Trim().ToUpper(), year);
|
|
||||||
}
|
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
var profile_new = await _context.RetirementProfiles
|
var profile_new = await _context.RetirementProfiles
|
||||||
.Where(x => x.RetirementPeriod == retire)
|
.Where(x => x.RetirementPeriod == retire)
|
||||||
|
|
@ -255,7 +248,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
PosNoEmployee = x.Profile.PosNoEmployee,
|
PosNoEmployee = x.Profile.PosNoEmployee,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
return Success(new { retire.Id, retire.CreatedAt, retire.Round, retire.Type, profile = profile_new });
|
return Success(new { retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, profile = profile_new });
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -277,6 +270,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
|
||||||
var retire_old = await _context.RetirementPeriods
|
var retire_old = await _context.RetirementPeriods
|
||||||
.Where(x => x.CreatedAt < retire.CreatedAt)
|
.Where(x => x.CreatedAt < retire.CreatedAt)
|
||||||
|
.Where(x => x.Year == retire.Year)
|
||||||
.Where(x => x.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
|
.Where(x => x.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -326,7 +320,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound, 404);
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
_context.RetirementProfiles.Remove(profile);
|
profile.Remove = "delete";
|
||||||
|
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
|
profile.LastUpdateUserId = UserId ?? "";
|
||||||
|
profile.LastUpdatedAt = DateTime.Now;
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
|
|
@ -356,9 +353,13 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
return Error(GlobalMessages.InvalidRetirementRequest, 404);
|
return Error(GlobalMessages.InvalidRetirementRequest, 404);
|
||||||
var order = 1;
|
var order = 1;
|
||||||
var retire_old = await _context.RetirementPeriods
|
var retire_old = await _context.RetirementPeriods
|
||||||
.Where(x => x.CreatedAt.Year == retire.CreatedAt.Year)
|
.Include(x => x.RetirementProfiles)
|
||||||
|
.ThenInclude(x => x.Profile)
|
||||||
|
.Where(x => x.Year == retire.Year)
|
||||||
.Where(x => x.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
|
.Where(x => x.Type.Trim().ToUpper().Contains(retire.Type.Trim().ToUpper()))
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
if (retire_old.Where(x => x.RetirementProfiles.Where(y => y.Profile == profile).Count() > 0).Count() > 0)
|
||||||
|
return Error("บุคคลนี้ได้ทำการเลือกไว้อยู่แล้ว");
|
||||||
|
|
||||||
var last_order = await _context.RetirementProfiles
|
var last_order = await _context.RetirementProfiles
|
||||||
.Where(x => retire_old.Contains(x.RetirementPeriod))
|
.Where(x => retire_old.Contains(x.RetirementPeriod))
|
||||||
|
|
@ -370,7 +371,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
var data = new RetirementProfile
|
var data = new RetirementProfile
|
||||||
{
|
{
|
||||||
Order = order,
|
Order = order,
|
||||||
Remove = false,
|
Remove = "pending",
|
||||||
RetirementPeriod = retire,
|
RetirementPeriod = retire,
|
||||||
Profile = profile,
|
Profile = profile,
|
||||||
CreatedUserId = FullName ?? "",
|
CreatedUserId = FullName ?? "",
|
||||||
|
|
@ -380,10 +381,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdatedAt = DateTime.Now,
|
LastUpdatedAt = DateTime.Now,
|
||||||
};
|
};
|
||||||
if (retire_old.Count() <= 1)
|
|
||||||
{
|
|
||||||
await GenOrderByYear(retire.Type.Trim().ToUpper(), retire.CreatedAt.Year);
|
|
||||||
}
|
|
||||||
|
|
||||||
_context.RetirementProfiles.Add(data);
|
_context.RetirementProfiles.Add(data);
|
||||||
_context.SaveChanges();
|
_context.SaveChanges();
|
||||||
|
|
@ -409,7 +406,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound, 404);
|
return Error(GlobalMessages.DataNotFound, 404);
|
||||||
|
|
||||||
profile.Remove = true;
|
profile.Remove = "change";
|
||||||
profile.Reason = req.Reason;
|
profile.Reason = req.Reason;
|
||||||
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
profile.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
profile.LastUpdateUserId = UserId ?? "";
|
profile.LastUpdateUserId = UserId ?? "";
|
||||||
|
|
@ -443,5 +440,27 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
|
|
||||||
return Success(profile);
|
return Success(profile);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// View รายชื่อผู้เกษียณอายุราชการในประกาศ
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="retireId">Id ประกาศ</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("{retireId:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> UpdateProfileRetirement(Guid retireId)
|
||||||
|
{
|
||||||
|
var retire = await _context.RetirementPeriods
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == retireId);
|
||||||
|
if (retire == null)
|
||||||
|
return Error(GlobalMessages.InvalidRetirementRequest, 404);
|
||||||
|
|
||||||
|
await GenOrderByYear(retire.Type.Trim().ToUpper(), retire.Year);
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue