แก้บั้ก รายงานประวัติการรับราชการแบบย่อ

This commit is contained in:
Suphonchai Phoonsawat 2023-05-16 13:22:30 +07:00
parent 12cd324f2a
commit 7abdcc77ae
2 changed files with 134 additions and 116 deletions

View file

@ -57,7 +57,7 @@ namespace BMA.EHR.Report.Service.Controllers
#region " Methods "
/// <summary>
/// แสดงหนังสือรับรอง
/// แสดงประวัติการรับราชการแบบย่อ
/// </summary>
/// <param name="id">รหัสข้อมูลข้าราชการ</param>
/// <returns></returns>
@ -266,7 +266,15 @@ namespace BMA.EHR.Report.Service.Controllers
}
}
/// <summary>
/// แสดงรายงาน กก.1
/// </summary>
/// <param name="id">รหัสข้อมูลข้าราชการ</param>
/// <returns></returns>
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("kk1/{id:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
@ -594,6 +602,16 @@ namespace BMA.EHR.Report.Service.Controllers
}
}
/// <summary>
/// แสดงรายงาน กพ.7
/// </summary>
/// <param name="id">รหัสข้อมูลข้าราชการ</param>
/// <returns></returns>
/// <response code="200">เมื่อแสดงรายงานสำเร็จ</response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("kp7/{id:length(36)}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]

View file

@ -6,46 +6,46 @@ using System.Text.RegularExpressions;
namespace BMA.EHR.Profile.Service.Services
{
public class OrganizationItem
{
public Guid Id { get; set; }
public class OrganizationItem
{
public Guid Id { get; set; }
public string Name { get; set; } = string.Empty;
public string Name { get; set; } = string.Empty;
public int Order { get; set; } = 0;
}
public int Order { get; set; } = 0;
}
public class ProfileService
{
private readonly EHRDbContext _context;
public class ProfileService
{
private readonly EHRDbContext _context;
public ProfileService(EHRDbContext context)
{
_context = context;
}
public ProfileService(EHRDbContext context)
{
_context = context;
}
public string ConvertRelationshipToEng(string thai_text)
{
switch (thai_text)
{
case "หย่า":
case "หย่าร้าง": return "divorced";
case "โสด": return "single";
case "สมรส": return "married";
case "แยกกันอยู่": return "seperated";
default: return "na";
}
}
public string ConvertRelationshipToEng(string thai_text)
{
switch (thai_text)
{
case "หย่า":
case "หย่าร้าง": return "divorced";
case "โสด": return "single";
case "สมรส": return "married";
case "แยกกันอยู่": return "seperated";
default: return "na";
}
}
public string ConvertGenderToEng(string thai_text)
{
switch (thai_text)
{
case "ชาย": return "male";
case "หญิง": return "female";
default: return "na";
}
}
public string ConvertGenderToEng(string thai_text)
{
switch (thai_text)
{
case "ชาย": return "male";
case "หญิง": return "female";
default: return "na";
}
}
#region " Organizations "
@ -156,8 +156,8 @@ namespace BMA.EHR.Profile.Service.Services
{
ret = oc.Name + " " + ret;
}
ret = ret.Substring(0, ret.Length - 1);
if (ret.Length > 0)
ret = ret.Substring(0, ret.Length - 1);
return ret;
}
@ -415,99 +415,99 @@ namespace BMA.EHR.Profile.Service.Services
#region " Profiles "
public async Task<Models.HR.Profile> GetProfileById(Guid profileId)
{
try
{
var profile = await _context.Profiles.AsQueryable()
// .Include(p => p.Organization)
.Include(p => p.Position)
// .ThenInclude(p => p.PositionPath)
// .Include(p => p.PositionNumber)
{
try
{
var profile = await _context.Profiles.AsQueryable()
// .Include(p => p.Organization)
.Include(p => p.Position)
// .ThenInclude(p => p.PositionPath)
// .Include(p => p.PositionNumber)
.Include(p => p.Certificates)
.Include(p => p.Disciplines)
.Include(p => p.Educations)
.Include(p => p.Honors)
.Include(p => p.Insignias)
.Include(p => p.Trainings)
.Include(p => p.Certificates)
.Include(p => p.Disciplines)
.Include(p => p.Educations)
.Include(p => p.Honors)
.Include(p => p.Insignias)
.Include(p => p.Trainings)
// .Include(p => p.Salaries)
// .ThenInclude(s => s.SalaryPosition)
// .Include(s => s.Salaries)
// .ThenInclude(s => s.SalaryOrganization)
// .Include(p => p.Salaries)
// .ThenInclude(s => s.SalaryPositionNumber)
// .Include(p => p.Salaries)
// .ThenInclude(s => s.SalaryPositionLevel)
// .Include(p => p.Salaries)
// .ThenInclude(s => s.SalaryPositionType)
.Include(x => x.Avatar)
// .Include(p => p.Salaries)
// .ThenInclude(s => s.SalaryPosition)
// .Include(s => s.Salaries)
// .ThenInclude(s => s.SalaryOrganization)
// .Include(p => p.Salaries)
// .ThenInclude(s => s.SalaryPositionNumber)
// .Include(p => p.Salaries)
// .ThenInclude(s => s.SalaryPositionLevel)
// .Include(p => p.Salaries)
// .ThenInclude(s => s.SalaryPositionType)
.Include(x => x.Avatar)
// .Include(x => x.PositionType)
// .Include(x => x.PositionLevel)
.Include(x => x.Childrens)
.FirstOrDefaultAsync(p => p.Id == profileId);
// .Include(x => x.PositionType)
// .Include(x => x.PositionLevel)
.Include(x => x.Childrens)
.FirstOrDefaultAsync(p => p.Id == profileId);
return profile;
}
catch
{
throw;
}
}
return profile;
}
catch
{
throw;
}
}
public bool ValidateProfileById(string profileId)
{
var idcardno = profileId;
public bool ValidateProfileById(string profileId)
{
var idcardno = profileId;
if (string.IsNullOrEmpty(idcardno))
{
return false;
}
if (string.IsNullOrEmpty(idcardno))
{
return false;
}
if (idcardno.Length != 13)
{
return false;
}
if (idcardno.Length != 13)
{
return false;
}
bool isDigit = Regex.IsMatch(idcardno, @"^[0-9]*$");
if (!isDigit)
{
return false;
}
bool isDigit = Regex.IsMatch(idcardno, @"^[0-9]*$");
if (!isDigit)
{
return false;
}
int sum = 0;
for (int i = 0; i < 12; i++)
{
sum += Convert.ToInt32(idcardno.Substring(i, 1)) * (13 - i);
}
int sum = 0;
for (int i = 0; i < 12; i++)
{
sum += Convert.ToInt32(idcardno.Substring(i, 1)) * (13 - i);
}
int checksum = (11 - (sum % 11)) % 10;
if (checksum != Convert.ToInt32(idcardno.Substring(12)))
{
return false;
}
int checksum = (11 - (sum % 11)) % 10;
if (checksum != Convert.ToInt32(idcardno.Substring(12)))
{
return false;
}
return true;
return true;
}
}
public async Task<bool> CheckExistCitizenId(string profileId)
{
try
{
var profile = await _context.Profiles.AsQueryable().Where(p => p.CitizenId == profileId).FirstOrDefaultAsync();
public async Task<bool> CheckExistCitizenId(string profileId)
{
try
{
var profile = await _context.Profiles.AsQueryable().Where(p => p.CitizenId == profileId).FirstOrDefaultAsync();
return profile != null;
}
catch
{
throw;
}
}
return profile != null;
}
catch
{
throw;
}
}
#endregion
}
#endregion
}
}