Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2023-08-04 09:20:40 +07:00
commit 71c8ff95e4
13 changed files with 12650 additions and 67 deletions

View file

@ -76,12 +76,13 @@
#region " Retirement "
public static readonly string InvalidRetirementRequest = "ไม่พบข้อมูลการประกาศเกษียณอายุราชการ";
public static readonly string InvalidRetirementHistoryRequest = "ไม่พบข้อมูลประวัติการประกาศเกษียณอายุราชการ";
#endregion
#region " Command "
public static readonly string CommandNotFound = "ไม่พบรายการคำสั่งนี้ในระบบ โปรดตรวจความถูกต้อง";
#endregion
}

View file

@ -7,6 +7,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="3.7.201.7" />
<PackageReference Include="EPPlus" Version="6.2.7" />
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
@ -20,6 +21,7 @@
<PackageReference Include="Microsoft.Extensions.Configuration" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="7.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="7.0.0" />
<PackageReference Include="MimeTypeMapOfficial" Version="1.0.17" />
<PackageReference Include="Oracle.EntityFrameworkCore" Version="7.21.9" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="7.0.0" />
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql.Design" Version="1.1.2" />

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,77 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class addTableretire_history : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "TypeReport",
table: "RetirementPeriods",
type: "longtext",
nullable: true,
comment: "ประเภทคำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateTable(
name: "RetirementPeriodHistorys",
columns: table => new
{
Id = table.Column<Guid>(type: "char(36)", nullable: false, comment: "PrimaryKey", collation: "ascii_general_ci"),
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false, comment: "สร้างข้อมูลเมื่อ"),
CreatedUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true, comment: "แก้ไขข้อมูลล่าสุดเมื่อ"),
LastUpdateUserId = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false, comment: "User Id ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
CreatedFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่สร้างข้อมูล")
.Annotation("MySql:CharSet", "utf8mb4"),
LastUpdateFullName = table.Column<string>(type: "varchar(200)", maxLength: 200, nullable: false, comment: "ชื่อ User ที่แก้ไขข้อมูลล่าสุด")
.Annotation("MySql:CharSet", "utf8mb4"),
Round = table.Column<int>(type: "int", nullable: false, comment: "ครั้งที่"),
TypeReport = table.Column<string>(type: "longtext", nullable: true, comment: "ประเภทคำสั่ง")
.Annotation("MySql:CharSet", "utf8mb4"),
Year = table.Column<int>(type: "int", nullable: false, comment: "ปีงบประมาณ"),
Total = table.Column<int>(type: "int", nullable: false, comment: "จำนวนคน"),
Type = table.Column<string>(type: "longtext", nullable: false, comment: "ประเภท")
.Annotation("MySql:CharSet", "utf8mb4"),
ProfileFile = table.Column<string>(type: "longtext", nullable: false, comment: "รายชื่อเกษียญ")
.Annotation("MySql:CharSet", "utf8mb4"),
RetirementPeriodId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
},
constraints: table =>
{
table.PrimaryKey("PK_RetirementPeriodHistorys", x => x.Id);
table.ForeignKey(
name: "FK_RetirementPeriodHistorys_RetirementPeriods_RetirementPeriodId",
column: x => x.RetirementPeriodId,
principalTable: "RetirementPeriods",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_RetirementPeriodHistorys_RetirementPeriodId",
table: "RetirementPeriodHistorys",
column: "RetirementPeriodId");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "RetirementPeriodHistorys");
migrationBuilder.DropColumn(
name: "TypeReport",
table: "RetirementPeriods");
}
}
}

View file

@ -10559,6 +10559,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("ประเภท");
b.Property<string>("TypeReport")
.HasColumnType("longtext")
.HasComment("ประเภทคำสั่ง");
b.Property<int>("Year")
.HasColumnType("int")
.HasComment("ปีงบประมาณ");
@ -10568,6 +10572,89 @@ namespace BMA.EHR.Infrastructure.Migrations
b.ToTable("RetirementPeriods");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriodHistory", b =>
{
b.Property<Guid>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("char(36)")
.HasColumnOrder(0)
.HasComment("PrimaryKey")
.HasAnnotation("Relational:JsonPropertyName", "id");
b.Property<DateTime>("CreatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(100)
.HasComment("สร้างข้อมูลเมื่อ");
b.Property<string>("CreatedFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(104)
.HasComment("ชื่อ User ที่สร้างข้อมูล");
b.Property<string>("CreatedUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(101)
.HasComment("User Id ที่สร้างข้อมูล");
b.Property<string>("LastUpdateFullName")
.IsRequired()
.HasMaxLength(200)
.HasColumnType("varchar(200)")
.HasColumnOrder(105)
.HasComment("ชื่อ User ที่แก้ไขข้อมูลล่าสุด");
b.Property<string>("LastUpdateUserId")
.IsRequired()
.HasMaxLength(40)
.HasColumnType("varchar(40)")
.HasColumnOrder(103)
.HasComment("User Id ที่แก้ไขข้อมูลล่าสุด");
b.Property<DateTime?>("LastUpdatedAt")
.HasColumnType("datetime(6)")
.HasColumnOrder(102)
.HasComment("แก้ไขข้อมูลล่าสุดเมื่อ");
b.Property<string>("ProfileFile")
.IsRequired()
.HasColumnType("longtext")
.HasComment("รายชื่อเกษียญ");
b.Property<Guid>("RetirementPeriodId")
.HasColumnType("char(36)");
b.Property<int>("Round")
.HasColumnType("int")
.HasComment("ครั้งที่");
b.Property<int>("Total")
.HasColumnType("int")
.HasComment("จำนวนคน");
b.Property<string>("Type")
.IsRequired()
.HasColumnType("longtext")
.HasComment("ประเภท");
b.Property<string>("TypeReport")
.HasColumnType("longtext")
.HasComment("ประเภทคำสั่ง");
b.Property<int>("Year")
.HasColumnType("int")
.HasComment("ปีงบประมาณ");
b.HasKey("Id");
b.HasIndex("RetirementPeriodId");
b.ToTable("RetirementPeriodHistorys");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementProfile", b =>
{
b.Property<Guid>("Id")
@ -11827,6 +11914,17 @@ namespace BMA.EHR.Infrastructure.Migrations
b.Navigation("Religion");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriodHistory", b =>
{
b.HasOne("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", "RetirementPeriod")
.WithMany("RetirementPeriodHistorys")
.HasForeignKey("RetirementPeriodId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("RetirementPeriod");
});
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementProfile", b =>
{
b.HasOne("BMA.EHR.Domain.Models.HR.Profile", "Profile")
@ -12053,6 +12151,8 @@ namespace BMA.EHR.Infrastructure.Migrations
modelBuilder.Entity("BMA.EHR.Domain.Models.Retirement.RetirementPeriod", b =>
{
b.Navigation("RetirementPeriodHistorys");
b.Navigation("RetirementProfiles");
});
#pragma warning restore 612, 618

View file

@ -7,6 +7,7 @@ using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using MimeTypes;
using System.Net.Http.Headers;
namespace BMA.EHR.Application.Repositories
@ -265,15 +266,20 @@ namespace BMA.EHR.Application.Repositories
System.IO.MemoryStream filestream = new System.IO.MemoryStream(fileContents);
//var fileNameWithoutExt = Path.GetFileNameWithoutExtension(fileName);
var fileExt = Path.GetExtension(fileName);
// var fileType = MimeTypeMap.GetMimeType(fileExt);
var fileType = MimeTypeMap.GetMimeType(fileExt);
var file_name = Path.GetFileName(fileName);
Console.WriteLine($"{_bucketName}{subFolder}");
Console.WriteLine(fileName);
Console.WriteLine(file_name);
Console.WriteLine(filestream);
Console.WriteLine(fileType);
var request = new PutObjectRequest
{
BucketName = $"{_bucketName}{subFolder}",
Key = file_name,
InputStream = filestream,
// ContentType = fileType,
ContentType = fileType,
CannedACL = S3CannedACL.PublicRead
};
@ -285,21 +291,18 @@ namespace BMA.EHR.Application.Repositories
}
}
public async Task<string> GenerateJsonFile(string json, string path, string fileName)
public async Task GenerateJsonFile(string json, string path, string fileName)
{
var tmpFile = "";
var tmpDir = Path.Combine("tmp");
if (!Directory.Exists(tmpDir))
Directory.CreateDirectory(tmpDir);
var tmpFile = Path.Combine(tmpDir, $"tmp_{DateTime.Now.ToString("ddMMyyyyHHmmss")}{fileName}.json");
try
{
var tmpDir = Path.Combine(_hostingEnvironment.ContentRootPath, "tmp");
if (!Directory.Exists(tmpDir))
Directory.CreateDirectory(tmpDir);
tmpFile = Path.Combine(tmpDir, fileName);
SaveToJsonFile(tmpFile, json);
await UploadFileAsyncTemp(tmpFile, path);
return "EMPLOYEE";
}
catch
{

View file

@ -26,10 +26,10 @@
}
},
"MinIO": {
"Endpoint": "https://s3.frappet.com/",
"Endpoint": "https://s3cluster.frappet.com/",
"AccessKey": "frappet",
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
"SecretKey": "FPTadmin2357",
"BucketName": "bma-ehr-fpt"
},
"Protocol": "HTTPS"
}

View file

@ -437,5 +437,78 @@ namespace BMA.EHR.OrganizationEmployee.Service.Controllers
return Success();
}
[HttpGet("position/{profileId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetPositionEmployeeByProfile(Guid profileId)
{
var profile = await _context.Profiles.FindAsync(profileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var organizationEmployee = await _context.OrganizationEmployees
.Include(x => x.Profile)
.Where(x => x.Profile == profile)
.Select(x => new
{
Id = x.Id,
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,
}),
})
.FirstOrDefaultAsync();
if (organizationEmployee == null)
return Error(GlobalMessages.OrganizationEmployeeNotFound, 404);
return Success(organizationEmployee);
}
}
}

View file

@ -26,10 +26,10 @@
}
},
"MinIO": {
"Endpoint": "https://s3.frappet.com/",
"Endpoint": "https://s3cluster.frappet.com/",
"AccessKey": "frappet",
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
"SecretKey": "FPTadmin2357",
"BucketName": "bma-ehr-fpt"
},
"Protocol": "HTTPS"
}

View file

@ -12,6 +12,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AWSSDK.S3" Version="3.7.201.7" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />

View file

@ -164,8 +164,28 @@ namespace BMA.EHR.Retirement.Service.Controllers
Year = x.Year,
Round = x.Round,
Total = x.Total,
Json = true,
})
.ToListAsync();
var retire = await _context.RetirementPeriods
.Include(x => x.RetirementProfiles)
.Where(x => x.Year == year)
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
.FirstOrDefaultAsync();
if (retire != null)
{
retire_old.Add(new
{
Id = retire.Id,
CreatedAt = retire.CreatedAt,
Year = retire.Year,
Round = retire.Round,
Total = retire.RetirementProfiles.Count(),
Json = false,
});
}
return Success(retire_old);
}
return Success();
@ -224,7 +244,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
var data = new RetirementProfile
{
Order = order,
Remove = "pending",
Remove = "PENDING",
RetirementPeriod = retire,
Profile = profile,
CreatedUserId = FullName ?? "",
@ -244,8 +264,32 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
if (req.Option == null)
req.Option = "EDIT";
var file_name = DateTime.Now.ToString();
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(retire.RetirementProfiles);
var file_name = DateTime.Now.ToString("yyyyMMddTHHmmss");
var profile_old = await _context.RetirementProfiles
.Where(x => x.RetirementPeriod == retire)
.Select(x => new
{
order = x.Order,
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
oc = x.Profile.Oc,
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
posNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(profile_old);
await _documentService.GenerateJsonFile(profile, "/retire", file_name);
var history = new RetirementPeriodHistory
{
@ -271,15 +315,56 @@ namespace BMA.EHR.Retirement.Service.Controllers
retire.LastUpdateFullName = FullName ?? "System Administrator";
retire.LastUpdateUserId = UserId ?? "";
retire.LastUpdatedAt = DateTime.Now;
// RetireHistoryId
////ดึงไฟล์json
// foreach (var retire_profile in retire.RetirementProfiles)
// {
// retire_profile.Remove = retire_profile.Remove.Trim().ToUpper().Contains("CHANGE") ? "PENDING" : retire_profile.Remove;
// retire_profile.LastUpdateFullName = FullName ?? "System Administrator";
// retire_profile.LastUpdateUserId = UserId ?? "";
// retire_profile.LastUpdatedAt = DateTime.Now;
// }
_context.RetirementProfiles.RemoveRange(retire.RetirementProfiles);
if (!req.Option.Trim().ToUpper().Contains("ADD"))
{
var profileHistorys = await _context.RetirementPeriodHistorys.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == req.RetireHistoryId);
var profileOlds = new List<RetirementProfile>();
if (profileHistorys != null)
{
using (var client = new HttpClient())
{
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/retire/{profileHistorys.ProfileFile}";
var responseTask = client.GetAsync(url);
var results = responseTask.Result;
profileOlds = Newtonsoft.Json.JsonConvert.DeserializeObject<List<RetirementProfile>>(results.Content.ReadAsStringAsync().Result);
}
}
else
{
var retireOld = await _context.RetirementPeriods
.FirstOrDefaultAsync(x => x.Id == req.RetireHistoryId);
if (retireOld == null)
return Error(GlobalMessages.InvalidRetirementRequest, 404);
profileOlds = await _context.RetirementProfiles.AsQueryable()
.Where(x => x.RetirementPeriod == retireOld)
.ToListAsync();
}
if (profileOlds != null)
{
profileOlds = profileOlds.Where(x => !x.Remove.Trim().ToUpper().Contains("REMOVE")).ToList();
foreach (var profileOld in profileOlds)
{
var data = new RetirementProfile
{
Order = profileOld.Order,
Remove = "PENDING",
RetirementPeriod = retire,
Profile = profileOld.Profile,
CreatedUserId = profileOld.CreatedUserId,
CreatedFullName = profileOld.CreatedFullName,
CreatedAt = profileOld.CreatedAt,
LastUpdateFullName = profileOld.LastUpdateFullName,
LastUpdateUserId = profileOld.LastUpdateUserId,
LastUpdatedAt = profileOld.LastUpdatedAt,
};
retire.RetirementProfiles.Add(data);
}
}
}
await _context.SaveChangesAsync();
}
@ -288,24 +373,24 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Where(x => x.RetirementPeriod == retire)
.Select(x => new
{
Order = x.Order,
Id = x.Id,
Reason = x.Reason,
Remove = x.Remove,
ProfileId = x.Profile.Id,
CitizenId = x.Profile.CitizenId,
Prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
FullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
OrganizationOrganization = x.Profile.OrganizationOrganization,
Oc = x.Profile.Oc,
Position = x.Profile.Position == null ? null : x.Profile.Position.Name,
PositionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
PositionExecutive = x.Profile.PositionExecutive,
PosNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
PositionEmployeePosition = x.Profile.PositionEmployeePosition,
PositionEmployeeLevel = x.Profile.PositionEmployeeLevel,
PositionEmployeeGroup = x.Profile.PositionEmployeeGroup,
PosNoEmployee = x.Profile.PosNoEmployee,
order = x.Order,
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
oc = x.Profile.Oc,
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
posNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
return Success(new { retire.Id, retire.CreatedAt, retire.Year, retire.Round, retire.Type, profile = profile_new });
@ -323,12 +408,50 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpGet("{retireId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetProfileRetirement(Guid retireId)
{
var retire = await _context.RetirementPeriodHistorys
var retire = await _context.RetirementPeriods
.Include(x => x.RetirementProfiles)
.FirstOrDefaultAsync(x => x.Id == retireId);
if (retire == null)
return Error(GlobalMessages.InvalidRetirementRequest, 404);
{
var profileHistorys = await _context.RetirementPeriodHistorys.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == retireId);
if (profileHistorys == null)
return Error(GlobalMessages.InvalidRetirementHistoryRequest, 404);
using (var client = new HttpClient())
{
var url = $"https://s3cluster.frappet.com/bma-ehr-fpt/retire/{profileHistorys.ProfileFile}.json";
var responseTask = client.GetAsync(url);
var results = responseTask.Result;
// Console.WriteLine(results.Content.ReadAsStringAsync().Result);
return Success(new { Json = true, profile = Newtonsoft.Json.JsonConvert.DeserializeObject<List<dynamic>>(results.Content.ReadAsStringAsync().Result) });
}
}
var profile_new = await _context.RetirementProfiles
.Where(x => x.RetirementPeriod == retire)
.Select(x => new
{
order = x.Order,
id = x.Id,
reason = x.Reason,
remove = x.Remove,
profileId = x.Profile.Id,
citizenId = x.Profile.CitizenId,
prefix = x.Profile.Prefix == null ? null : x.Profile.Prefix.Name,
fullName = $"{x.Profile.FirstName} {x.Profile.LastName}",
organizationOrganization = x.Profile.OrganizationOrganization,
oc = x.Profile.Oc,
position = x.Profile.Position == null ? null : x.Profile.Position.Name,
positionType = x.Profile.PositionType == null ? null : x.Profile.PositionType.Name,
positionExecutive = x.Profile.PositionExecutive,
posNo = x.Profile.PosNo == null ? null : x.Profile.PosNo.Name,
positionEmployeePosition = x.Profile.PositionEmployeePosition,
positionEmployeeLevel = x.Profile.PositionEmployeeLevel,
positionEmployeeGroup = x.Profile.PositionEmployeeGroup,
posNoEmployee = x.Profile.PosNoEmployee,
})
.ToListAsync();
return Success(retire);
return Success(new { Json = false, profile = profile_new });
}
/// <summary>
@ -340,19 +463,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpDelete("profile/{retireProfileId:length(36)}")]
public async Task<ActionResult<ResponseObject>> DeleteProfileRetirement(Guid retireProfileId)
{
var profile = await _context.RetirementProfiles
.FirstOrDefaultAsync(x => x.Id == retireProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
// [HttpDelete("profile/{retireProfileId:length(36)}")]
// public async Task<ActionResult<ResponseObject>> DeleteProfileRetirement(Guid retireProfileId)
// {
// var profile = await _context.RetirementProfiles
// .FirstOrDefaultAsync(x => x.Id == retireProfileId);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
_context.RetirementProfiles.Remove(profile);
_context.SaveChanges();
// _context.RetirementProfiles.Remove(profile);
// _context.SaveChanges();
return Success();
}
// return Success();
// }
/// <summary>
/// Add รายชื่อผู้เกษียณอายุราชการในประกาศ
@ -427,7 +550,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("reason")]
[HttpPost("edit")]
public async Task<ActionResult<ResponseObject>> EditReasonProfileRetirement([FromBody] ProfileRetireRequest req)
{
var profile = await _context.RetirementProfiles
@ -445,6 +568,44 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
/// <summary>
/// แก้ไขข้อมูลบุคคล
/// </summary>
/// <param name="retireProfileId">Id ผู้ใช้งานในประกาศ</param>
/// <param name="reason">เหตุผล</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("remove")]
public async Task<ActionResult<ResponseObject>> RemoveReasonProfileRetirement([FromBody] ProfileRetireRequest req)
{
var profile = await _context.RetirementProfiles
.Include(x => x.RetirementPeriod)
.ThenInclude(x => x.RetirementPeriodHistorys)
.FirstOrDefaultAsync(x => x.Id == req.RetireProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
if (profile.RetirementPeriod.RetirementPeriodHistorys.Count() == 0)
{
await GenOrderByYear(profile.RetirementPeriod.Id);
_context.RetirementProfiles.Remove(profile);
}
else
{
profile.Remove = "REMOVE";
profile.Reason = req.Reason;
profile.LastUpdateFullName = FullName ?? "System Administrator";
profile.LastUpdateUserId = UserId ?? "";
profile.LastUpdatedAt = DateTime.Now;
}
_context.SaveChanges();
return Success();
}
/// <summary>
/// View เหตุผลแก้ไขข้อมูลบุคคล
/// </summary>

View file

@ -27,10 +27,10 @@
}
},
"MinIO": {
"Endpoint": "https://s3.frappet.com/",
"Endpoint": "https://s3cluster.frappet.com/",
"AccessKey": "frappet",
"SecretKey": "P@ssw0rd",
"BucketName": "bma-recruit"
"SecretKey": "FPTadmin2357",
"BucketName": "bma-ehr-fpt"
},
"Protocol": "HTTPS"
}

View file

@ -0,0 +1 @@
[{"order":2,"id":"08db93d9-a26b-4a93-8ecc-01f6bc4425b7","reason":"","remove":"PENDING","profileId":"08db721d-b171-45f1-845e-d78809081cfa","citizenId":"0000000000053","prefix":"นาย","fullName":"บล ตง","organizationOrganization":"กองพัฒนาระบบราชการกรุงเทพมหานคร","oc":"ปลัดกรุงเทพมหานคร/สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร/กองพัฒนาระบบราชการกรุงเทพมหานคร","position":"ผู้อำนวยการ","positionType":"อำนวยการ","positionExecutive":"ผู้อำนวยการกอง","posNo":"กพร.1","positionEmployeePosition":null,"positionEmployeeLevel":null,"positionEmployeeGroup":null,"posNoEmployee":null},{"order":1,"id":"08db93d9-a26f-4d4e-885e-c996514222f2","reason":"","remove":"PENDING","profileId":"08db721d-b438-414e-861a-bd74b2cc8b03","citizenId":"0000000000088","prefix":"นาง","fullName":"สจ สว","organizationOrganization":"ส่วนโครงสร้างและอัตรากำลัง","oc":"ปลัดกรุงเทพมหานคร/สำนักงานคณะกรรมการข้าราชการกรุงเทพมหานคร/กองอัตรากำลัง/ส่วนโครงสร้างและอัตรากำลัง","position":"ผู้อำนวยการ","positionType":"อำนวยการ","positionExecutive":"ผู้อำนวยการส่วน","posNo":"กคอ.70","positionEmployeePosition":null,"positionEmployeeLevel":null,"positionEmployeeGroup":null,"posNoEmployee":null},{"order":4,"id":"08db93d9-a26f-4dbb-8afb-4bed0ac1c147","reason":"","remove":"PENDING","profileId":"08db721d-bb39-4902-8dab-dc582de20ab7","citizenId":"0000000000209","prefix":"นางสาว","fullName":"วณ มจ","organizationOrganization":"ฝ่ายบริหารงานทั่วไป","oc":"ปลัดกรุงเทพมหานคร/สำนักปลัดกรุงเทพมหานคร/สถาบันพัฒนาข้าราชการกรุงเทพมหานคร/ฝ่ายบริหารงานทั่วไป","position":"เจ้าพนักงานธุรการ","positionType":"ทั่วไป","positionExecutive":null,"posNo":"สพข.15","positionEmployeePosition":null,"positionEmployeeLevel":null,"positionEmployeeGroup":null,"posNoEmployee":null},{"order":3,"id":"08db93d9-a26f-4ddf-8c67-3ce67296b477","reason":"","remove":"PENDING","profileId":"08db721d-c0f0-4a43-820e-0d505da95a20","citizenId":"0000000000301","prefix":"นางสาว","fullName":"มร พจ","organizationOrganization":"ศูนย์การเรียนรู้มหานคร","oc":"ปลัดกรุงเทพมหานคร/สำนักปลัดกรุงเทพมหานคร/สถาบันพัฒนาข้าราชการกรุงเทพมหานคร/ศูนย์การเรียนรู้มหานคร","position":"นักจัดการงานทั่วไป","positionType":"วิชาการ","positionExecutive":"ผู้อำนวยการศูนย์","posNo":"สพข.107","positionEmployeePosition":null,"positionEmployeeLevel":null,"positionEmployeeGroup":null,"posNoEmployee":null}]