เพิ่มเครื่องราชฯ เพิ่มหน้ากรองลูกจ้างประจำก่อนประมวลผล
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
kittapath 2025-01-25 01:20:08 +07:00
parent d0e5089a06
commit 8a3baab88f
10 changed files with 19516 additions and 2 deletions

View file

@ -92,6 +92,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
var insigniaPeriods = await _context.InsigniaPeriods.AsQueryable()
.Include(x => x.InsigniaEmployees)
.OrderByDescending(x => x.Year)
.ThenByDescending(x => x.StartDate)
.Select(p => new
@ -105,6 +106,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
period_status = p.IsLock == true ? "DONE" : (p.InsigniaRequests.Count() == 0 ? "WAITTING" : "PENDING"),
period_year = p.Year,
period_isActive = p.IsActive,
empPosId = p.InsigniaEmployees.Select(x => x.RefId),
period_doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
period_revision = p.RevisionId,
})
@ -123,6 +125,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
period_status = insigniaPeriod.period_status,
period_year = insigniaPeriod.period_year,
period_isActive = insigniaPeriod.period_isActive,
empPosId = insigniaPeriod.empPosId,
period_doc = insigniaPeriod.period_doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(insigniaPeriod.period_doc),
period_revision = insigniaPeriod.period_revision,
};
@ -151,6 +154,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
var data = await _context.InsigniaPeriods.AsQueryable()
.Include(x => x.InsigniaEmployees)
.Where(x => x.Id == id)
.Select(p => new
{
@ -163,6 +167,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
period_status = p.IsLock == true ? "DONE" : (p.InsigniaRequests.Count() == 0 ? "WAITTING" : "PENDING"),
period_year = p.Year,
period_isActive = p.IsActive,
empPosId = p.InsigniaEmployees.Select(x => x.RefId),
period_doc = p.ReliefDoc == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.ReliefDoc.Id,
})
.FirstOrDefaultAsync();
@ -180,6 +185,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
period_status = data.period_status,
period_year = data.period_year,
period_isActive = data.period_isActive,
empPosId = data.empPosId,
period_doc = data.period_doc == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.period_doc),
};
@ -235,6 +241,23 @@ namespace BMA.EHR.Insignia.Service.Controllers
LastUpdatedAt = DateTime.Now,
RevisionId = revisionId ?? Guid.Empty
};
if (req.EmpPosId != null && req.EmpPosId.Count() != 0)
{
foreach (var item in req.EmpPosId)
{
period.InsigniaEmployees.Add(
new InsigniaEmployee
{
RefId = item,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
}
await _context.InsigniaPeriods.AddAsync(period);
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
@ -318,6 +341,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
return Error(GlobalMessages.InsigniaDupicate);
var uppdated = await _context.InsigniaPeriods.AsQueryable()
.Include(x => x.InsigniaEmployees)
.Include(x => x.ReliefDoc)
.FirstOrDefaultAsync(x => x.Id == id);
@ -333,6 +357,24 @@ namespace BMA.EHR.Insignia.Service.Controllers
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
_context.InsigniaEmployees.RemoveRange(uppdated.InsigniaEmployees);
if (req.EmpPosId != null && req.EmpPosId.Count() != 0)
{
foreach (var item in req.EmpPosId)
{
uppdated.InsigniaEmployees.Add(
new InsigniaEmployee
{
RefId = item,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
}
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{