fix
This commit is contained in:
parent
fd25873348
commit
9483d537ce
2 changed files with 259 additions and 1 deletions
|
|
@ -8974,6 +8974,100 @@ namespace BMA.EHR.Application.Repositories
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// insert candidate list
|
// insert candidate list
|
||||||
|
|
||||||
|
public async Task UpdateCandidateAsync(Guid periodId, Guid ocId, string oc, List<InsigniaResultSet> items)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||||
|
|
||||||
|
if (period == null)
|
||||||
|
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
|
||||||
|
var req = await _dbContext.Set<InsigniaRequest>()
|
||||||
|
.Include(x => x.RequestProfiles)
|
||||||
|
.Include(x => x.Period)
|
||||||
|
.Where(x => x.Period.Id == periodId)
|
||||||
|
.Where(x => x.OrganizationId == ocId)
|
||||||
|
.FirstOrDefaultAsync();
|
||||||
|
|
||||||
|
if (req != null)
|
||||||
|
{
|
||||||
|
foreach (var item in items)
|
||||||
|
{
|
||||||
|
var reqInsignia = await _dbContext.Set<Insignia>()
|
||||||
|
.FirstOrDefaultAsync(i => i.Id == item.RequestInsignia.Id);
|
||||||
|
|
||||||
|
if (reqInsignia == null) throw new Exception(GlobalMessages.InsigniaNotFound);
|
||||||
|
|
||||||
|
var pf = req.RequestProfiles.FirstOrDefault(x => x.ProfileId == item.ProfileId);
|
||||||
|
if (pf != null) continue; // มีอยู่แล้วข้ามไป
|
||||||
|
|
||||||
|
req.RequestProfiles.Add(new InsigniaRequestProfile
|
||||||
|
{
|
||||||
|
Status = "PENDING",
|
||||||
|
ProfileId = item.ProfileId,
|
||||||
|
RequestInsignia = reqInsignia,
|
||||||
|
Salary = item.Salary,
|
||||||
|
RequestDate = DateTime.Now,
|
||||||
|
MatchingConditions =
|
||||||
|
System.Text.Json.JsonSerializer.Serialize(item.MatchingConditions),
|
||||||
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
|
CreatedUserId = UserId ?? "",
|
||||||
|
CreatedAt = DateTime.Now,
|
||||||
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
|
LastUpdateUserId = UserId ?? "",
|
||||||
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
|
||||||
|
// Add Information for reused in API Call
|
||||||
|
ProfileType = item.ProfileType ?? "officer",
|
||||||
|
Prefix = item.Prefix,
|
||||||
|
FirstName = item.FirstName,
|
||||||
|
LastName = item.LastName,
|
||||||
|
CitizenId = item.CitizenId,
|
||||||
|
BirthDate = item.BirthDate,
|
||||||
|
DateAppoint = item.DateAppoint,
|
||||||
|
Position = item.Position,
|
||||||
|
Gender = item.Gender,
|
||||||
|
PosTypeName = item.PosTypeName,
|
||||||
|
PosLevelName = item.PosLevelName,
|
||||||
|
PosNo = item.PosNo,
|
||||||
|
Amount = item.Salary,
|
||||||
|
PositionSalaryAmount = item.PositionSalary,
|
||||||
|
LastInsigniaName = item.LastInsignia,
|
||||||
|
Root = item.Root,
|
||||||
|
RootId = item.RootId,
|
||||||
|
RootDnaId = item.RootDnaId,
|
||||||
|
Child1 = item.Child1,
|
||||||
|
Child1Id = item.Child1Id,
|
||||||
|
Child1DnaId = item.Child1DnaId,
|
||||||
|
Child2 = item.Child2,
|
||||||
|
Child2Id = item.Child2Id,
|
||||||
|
Child2DnaId = item.Child2DnaId,
|
||||||
|
Child3 = item.Child3,
|
||||||
|
Child3Id = item.Child3Id,
|
||||||
|
Child3DnaId = item.Child3DnaId,
|
||||||
|
Child4 = item.Child4,
|
||||||
|
Child4Id = item.Child4Id,
|
||||||
|
Child4DnaId = item.Child4DnaId,
|
||||||
|
|
||||||
|
MarkDiscipline = item.MarkDiscipline,
|
||||||
|
MarkInsignia = item.MarkInsignia,
|
||||||
|
MarkLeave = item.MarkLeave,
|
||||||
|
MarkRate = item.MarkRate
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
await _dbContext.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task InsertCandidate(Guid periodId, Guid ocId, string oc, List<InsigniaResultSet> items)
|
public async Task InsertCandidate(Guid periodId, Guid ocId, string oc, List<InsigniaResultSet> items)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
@ -8981,7 +9075,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
var period = await _dbContext.Set<InsigniaPeriod>().FirstOrDefaultAsync(p => p.Id == periodId);
|
||||||
|
|
||||||
if (period == null)
|
if (period == null)
|
||||||
throw new Exception(GlobalMessages.CoinPeriodNotFound);
|
throw new Exception(GlobalMessages.InsigniaPeriodNotFound);
|
||||||
|
|
||||||
var periodOlds = await _dbContext.Set<InsigniaPeriod>().Where(p => p.Year == period.Year).ToListAsync();
|
var periodOlds = await _dbContext.Set<InsigniaPeriod>().Where(p => p.Year == period.Year).ToListAsync();
|
||||||
foreach (var periodOld in periodOlds)
|
foreach (var periodOld in periodOlds)
|
||||||
|
|
|
||||||
|
|
@ -659,6 +659,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
// บันทึกรายชื่อ
|
// บันทึกรายชื่อ
|
||||||
await _repository.InsertCandidate(period, organization.Id, organization.OrgRootName, candidate);
|
await _repository.InsertCandidate(period, organization.Id, organization.OrgRootName, candidate);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// update รายชื่อ
|
||||||
|
await _repository.UpdateCandidateAsync(period, organization.Id, organization.OrgRootName, candidate);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1472,6 +1478,164 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
return Success(insigniaNotes);
|
return Success(insigniaNotes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ (แยก officer, employee)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="req">Reqest Body</param>
|
||||||
|
/// <param name="type">officer or employee</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
/// <response code="200"></response>
|
||||||
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
|
[HttpPost("note/search/{type}")]
|
||||||
|
public async Task<ActionResult<ResponseObject>> GetListNoteProfileByTypeAsync([FromBody] InsigniaNoteSearchRequest req, string type = "officer")
|
||||||
|
{
|
||||||
|
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_INSIGNIA_RECORD");
|
||||||
|
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||||
|
if (jsonData["status"]?.ToString() != "200")
|
||||||
|
{
|
||||||
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
|
}
|
||||||
|
var insigniaNote = await _context.InsigniaNotes
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.InsigniaNoteId);
|
||||||
|
if (insigniaNote == null)
|
||||||
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
|
var insigniaType = await _context.InsigniaTypes
|
||||||
|
.FirstOrDefaultAsync(x => x.Id == req.InsigniaTypeId);
|
||||||
|
if (insigniaType == null)
|
||||||
|
return Error(GlobalMessages.InsigniaTypeNotFound);
|
||||||
|
|
||||||
|
var rawNoteProfiles = await _context.InsigniaNoteProfiles
|
||||||
|
.Where(x => x.ProfileType!.ToLower() == type.ToLower())
|
||||||
|
.Where(x => x.InsigniaNote == insigniaNote)
|
||||||
|
.Where(x => x.RequestInsignia.InsigniaType == insigniaType)
|
||||||
|
.Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId))
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
x.Prefix,
|
||||||
|
x.FirstName,
|
||||||
|
x.LastName,
|
||||||
|
x.Position,
|
||||||
|
x.CitizenId,
|
||||||
|
x.ProfileType,
|
||||||
|
OcId = x.RootId, // TODO: ต้องมาแก้ไข
|
||||||
|
RequestInsignia = x.RequestInsignia.Name,
|
||||||
|
RequestInsigniaId = x.RequestInsignia.Id,
|
||||||
|
RequestInsigniaShortName = x.RequestInsignia.ShortName,
|
||||||
|
DateReceive = x.DateReceive,
|
||||||
|
x.OrganizationOrganizationSend,
|
||||||
|
x.OrganizationOrganizationReceive,
|
||||||
|
Status = x.Status,
|
||||||
|
Issue = x.Issue,
|
||||||
|
Date = x.Date,
|
||||||
|
VolumeNo = x.VolumeNo,
|
||||||
|
Section = x.Section,
|
||||||
|
Page = x.Page,
|
||||||
|
No = x.No,
|
||||||
|
DatePayment = x.DatePayment,
|
||||||
|
TypePayment = x.TypePayment,
|
||||||
|
Address = x.Address,
|
||||||
|
Number = x.Number,
|
||||||
|
Salary = x.Salary,
|
||||||
|
DateReceiveInsignia = x.DateReceiveInsignia,
|
||||||
|
DocReceiveInsignia = x.DocReceiveInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReceiveInsignia.Id,
|
||||||
|
x.OrgReceiveInsignia,
|
||||||
|
x.OrgReceiveInsigniaId,
|
||||||
|
DateReturnInsignia = x.DateReturnInsignia,
|
||||||
|
DocReturnInsignia = x.DocReturnInsignia == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.DocReturnInsignia.Id,
|
||||||
|
x.OrgReturnInsignia,
|
||||||
|
x.OrgReturnInsigniaId,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
var insigniaNoteProfiles = rawNoteProfiles
|
||||||
|
.Select(x => new
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
Prefix = x.Prefix ?? "",
|
||||||
|
Position = x.Position ?? "",
|
||||||
|
ProfileType = x.ProfileType ?? "",
|
||||||
|
x.OcId,
|
||||||
|
CitizenId = x.CitizenId ?? "",
|
||||||
|
FullName = $"{x.Prefix ?? ""}{x.FirstName ?? ""} {x.LastName ?? ""}".Trim(),
|
||||||
|
RequestInsignia = x.RequestInsignia,
|
||||||
|
RequestInsigniaId = x.RequestInsigniaId,
|
||||||
|
RequestInsigniaShortName = x.RequestInsigniaShortName,
|
||||||
|
DateReceive = x.DateReceive,
|
||||||
|
x.OrganizationOrganizationSend,
|
||||||
|
x.OrganizationOrganizationReceive,
|
||||||
|
Status = x.Status,
|
||||||
|
Issue = x.Issue,
|
||||||
|
Date = x.Date,
|
||||||
|
VolumeNo = x.VolumeNo,
|
||||||
|
Section = x.Section,
|
||||||
|
Page = x.Page,
|
||||||
|
No = x.No,
|
||||||
|
DatePayment = x.DatePayment,
|
||||||
|
TypePayment = x.TypePayment,
|
||||||
|
Address = x.Address,
|
||||||
|
Number = x.Number,
|
||||||
|
Salary = x.Salary,
|
||||||
|
DateReceiveInsignia = x.DateReceiveInsignia,
|
||||||
|
DocReceiveInsignia = x.DocReceiveInsignia,
|
||||||
|
x.OrgReceiveInsignia,
|
||||||
|
x.OrgReceiveInsigniaId,
|
||||||
|
DateReturnInsignia = x.DateReturnInsignia,
|
||||||
|
DocReturnInsignia = x.DocReturnInsignia,
|
||||||
|
x.OrgReturnInsignia,
|
||||||
|
x.OrgReturnInsigniaId,
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
var _insigniaNoteProfiles = new List<dynamic>();
|
||||||
|
foreach (var insigniaNoteProfile in insigniaNoteProfiles)
|
||||||
|
{
|
||||||
|
_insigniaNoteProfiles.Add(
|
||||||
|
new
|
||||||
|
{
|
||||||
|
insigniaNoteProfile.Id,
|
||||||
|
insigniaNoteProfile.Prefix,
|
||||||
|
insigniaNoteProfile.Position,
|
||||||
|
insigniaNoteProfile.CitizenId,
|
||||||
|
insigniaNoteProfile.ProfileType,
|
||||||
|
insigniaNoteProfile.FullName,
|
||||||
|
insigniaNoteProfile.RequestInsignia,
|
||||||
|
insigniaNoteProfile.RequestInsigniaId,
|
||||||
|
insigniaNoteProfile.RequestInsigniaShortName,
|
||||||
|
insigniaNoteProfile.DateReceive,
|
||||||
|
insigniaNoteProfile.OrganizationOrganizationSend,
|
||||||
|
insigniaNoteProfile.OrganizationOrganizationReceive,
|
||||||
|
insigniaNoteProfile.Status,
|
||||||
|
insigniaNoteProfile.Issue,
|
||||||
|
insigniaNoteProfile.Date,
|
||||||
|
insigniaNoteProfile.VolumeNo,
|
||||||
|
insigniaNoteProfile.Section,
|
||||||
|
insigniaNoteProfile.Page,
|
||||||
|
insigniaNoteProfile.No,
|
||||||
|
insigniaNoteProfile.DatePayment,
|
||||||
|
insigniaNoteProfile.TypePayment,
|
||||||
|
insigniaNoteProfile.Address,
|
||||||
|
insigniaNoteProfile.Number,
|
||||||
|
insigniaNoteProfile.Salary,
|
||||||
|
insigniaNoteProfile.DateReceiveInsignia,
|
||||||
|
DocReceiveInsignia = insigniaNoteProfile.DocReceiveInsignia == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNoteProfile.DocReceiveInsignia),
|
||||||
|
insigniaNoteProfile.OrgReceiveInsignia,
|
||||||
|
insigniaNoteProfile.OrgReceiveInsigniaId,
|
||||||
|
insigniaNoteProfile.DateReturnInsignia,
|
||||||
|
DocReturnInsignia = insigniaNoteProfile.DocReturnInsignia == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaNoteProfile.DocReturnInsignia),
|
||||||
|
insigniaNoteProfile.OrgReturnInsignia,
|
||||||
|
insigniaNoteProfile.OrgReturnInsigniaId,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Success(_insigniaNoteProfiles);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// list รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
|
/// list รายชื่อบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue