api อัพเดทสถานะ Mark ระบบเครื่องราช
This commit is contained in:
parent
6e1965ba79
commit
851c024171
6 changed files with 169 additions and 1 deletions
|
|
@ -8868,6 +8868,57 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task UpdateInsigniaRequestProfile(string[] items, string type, Guid? periodId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (type.Trim().ToUpper() == "OFFICER")
|
||||||
|
{
|
||||||
|
var allProfiles = await _userProfileRepository.GetInsigniaRequestsProfileAsync(items, type, AccessToken);
|
||||||
|
|
||||||
|
if (allProfiles != null && allProfiles.Count > 0)
|
||||||
|
{
|
||||||
|
var insigniaRequestProfiles = await _dbContext.Set<InsigniaRequestProfile>()
|
||||||
|
.Where(x => allProfiles.Select(x => x.Id).ToList().Contains(x.ProfileId))
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
foreach (var insigniaRequestProfile in insigniaRequestProfiles)
|
||||||
|
{
|
||||||
|
var profile = allProfiles.FirstOrDefault(p => p.Id == insigniaRequestProfile.ProfileId);
|
||||||
|
|
||||||
|
if (profile != null)
|
||||||
|
{
|
||||||
|
insigniaRequestProfile.MarkDiscipline = profile?.MarkDiscipline;
|
||||||
|
insigniaRequestProfile.MarkLeave = profile?.MarkLeave;
|
||||||
|
insigniaRequestProfile.MarkRate = profile?.MarkRate;
|
||||||
|
insigniaRequestProfile.MarkInsignia = profile?.MarkInsignia;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else if (type.Trim().ToUpper() == "EMPLOYEE" && periodId != null)
|
||||||
|
//{
|
||||||
|
// var insigniaRequests = await _dbContext.Set<InsigniaRequest>()
|
||||||
|
// .Where(x => x.Period.Id == periodId)
|
||||||
|
// .ToListAsync();
|
||||||
|
|
||||||
|
// var allEmpProfileIds = new List<string>();
|
||||||
|
// foreach (var insigniaRequest in insigniaRequests)
|
||||||
|
// {
|
||||||
|
// var orgRootId = insigniaRequest.Id.ToString();
|
||||||
|
// var allEmpProfiles = await _userProfileRepository.GetInsigniaRequestsProfileEmpAsync(items, orgRootId, AccessToken);
|
||||||
|
// }
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1073,6 +1073,34 @@ namespace BMA.EHR.Application.Repositories
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<GetMarkStatusDto>> GetInsigniaRequestsProfileAsync(string[] profileIds, string type, string? accessToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var apiPath = $"{_configuration["API"]}/org/dotnet/find/insignia-requests-profile/{type}";
|
||||||
|
var apiKey = _configuration["API_KEY"];
|
||||||
|
|
||||||
|
var body = new
|
||||||
|
{
|
||||||
|
profileIds
|
||||||
|
};
|
||||||
|
|
||||||
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||||
|
|
||||||
|
if (apiResult != null)
|
||||||
|
{
|
||||||
|
var raw = JsonConvert.DeserializeObject<GetMarkStatusResultDto>(apiResult);
|
||||||
|
if (raw != null)
|
||||||
|
return raw.Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
23
BMA.EHR.Application/Responses/Profiles/GetMarkStatusDto.cs
Normal file
23
BMA.EHR.Application/Responses/Profiles/GetMarkStatusDto.cs
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
namespace BMA.EHR.Application.Responses.Profiles
|
||||||
|
{
|
||||||
|
public class GetMarkStatusDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
public bool? MarkDiscipline { get; set; } = false;
|
||||||
|
public bool? MarkLeave { get; set; } = false;
|
||||||
|
public bool? MarkRate { get; set; } = false;
|
||||||
|
public bool? MarkInsignia { get; set; } = false;
|
||||||
|
|
||||||
|
public string? Apr1 { get; set; }
|
||||||
|
public string? Apr2 { get; set; }
|
||||||
|
public string? Apr3 { get; set; }
|
||||||
|
public string? Apr4 { get; set; }
|
||||||
|
public string? Apr5 { get; set; }
|
||||||
|
|
||||||
|
public string? Oct1 { get; set; }
|
||||||
|
public string? Oct2 { get; set; }
|
||||||
|
public string? Oct3 { get; set; }
|
||||||
|
public string? Oct4 { get; set; }
|
||||||
|
public string? Oct5 { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,12 @@
|
||||||
|
namespace BMA.EHR.Application.Responses.Profiles
|
||||||
|
{
|
||||||
|
public class GetMarkStatusResultDto
|
||||||
|
{
|
||||||
|
public string Message { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Status { get; set; } = -1;
|
||||||
|
|
||||||
|
public List<GetMarkStatusDto> Result { get; set; } = new();
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2704,5 +2704,59 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// อัพเดทสถานะ Mark (โทษทางวินัย, ไม่ได้เลื่อนเงินเดือน/ไม่ได้เลื่อนขั้น (เนื่องจากลาเกิน), ผลการประเมินการปฏิบัติราชการในรอบ 5 ปี, ข้อมูลเครื่องราชฯ)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="insigniaPeriodId">Id รอบเครื่องราช</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpGet("update/{insigniaPeriodId:length(36)}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> InsigniaRequestUpdateMark(Guid insigniaPeriodId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var insigniaPeriod = await _context.InsigniaPeriods
|
||||||
|
.Include(x => x.InsigniaRequests)
|
||||||
|
.Include(x => x.InsigniaEmployees)
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||||
|
if (insigniaPeriod == null)
|
||||||
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
|
|
||||||
|
if (insigniaPeriod.InsigniaRequests.Count > 0)
|
||||||
|
{
|
||||||
|
var allProfileIds = new List<string>();
|
||||||
|
foreach (var InsigniaRequest in insigniaPeriod.InsigniaRequests)
|
||||||
|
{
|
||||||
|
var profiles = await _context.Set<InsigniaRequestProfile>()
|
||||||
|
.Where(p => p.Request.Id == InsigniaRequest.Id && p.ProfileType.Trim().ToUpper() == "OFFICER").Select(x => x.ProfileId.ToString()).ToListAsync();
|
||||||
|
|
||||||
|
if (profiles != null && profiles.Count > 0)
|
||||||
|
{
|
||||||
|
allProfileIds.AddRange(profiles);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (allProfileIds.Count > 0)
|
||||||
|
{
|
||||||
|
await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(allProfileIds.ToArray(), "OFFICER", null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if (insigniaPeriod.InsigniaEmployees.Count > 0)
|
||||||
|
//{
|
||||||
|
// await _insigniaPeriodRepository.UpdateInsigniaRequestProfile(insigniaPeriod.InsigniaEmployees.Select(x => x.RefId!.ValueOrBlank()).ToArray(), "EMPLOYEE", insigniaPeriod.Id);
|
||||||
|
//}
|
||||||
|
|
||||||
|
return Success();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Error(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1049,7 +1049,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
||||||
dateStart = r.commandDateAffect,
|
dateStart = r.commandDateAffect,
|
||||||
govAgeAbsent = 0,
|
govAgeAbsent = 0,
|
||||||
govAgePlus = 0,
|
govAgePlus = 0,
|
||||||
birthDate = p.DateOfBirth == null ? (DateTime?)null : p.DateOfBirth,
|
birthDate = (p.DateOfBirth == null || p.DateOfBirth == DateTime.MinValue) ? (DateTime?)null : p.DateOfBirth,
|
||||||
reasonSameDate = (DateTime?)null,
|
reasonSameDate = (DateTime?)null,
|
||||||
ethnicity = p.Race == null ? string.Empty : p.Race,
|
ethnicity = p.Race == null ? string.Empty : p.Race,
|
||||||
telephoneNumber = (String?)null,
|
telephoneNumber = (String?)null,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue