change insigniaTypeId เป็น optional
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
Suphonchai Phoonsawat 2025-05-07 14:05:08 +07:00
parent 8ce58201e9
commit 0b407f3c68
4 changed files with 116 additions and 78 deletions

View file

@ -7,6 +7,7 @@ using BMA.EHR.Application.Responses.Organizations;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Insignia.Service.Requests;
@ -1079,8 +1080,8 @@ namespace BMA.EHR.Insignia.Service.Controllers
pf = _userProfileRepository.GetEmployeeProfileById(profileOld.ProfileId, AccessToken);
var orgSend = "";
var orgRecv = "";
var orgRecv = "";
if (profileOld.Child4 != null || profileOld.Child4 != "")
orgSend += $"{profileOld.Child4}";
if (profileOld.Child3 != null || profileOld.Child3 != "")
@ -1099,7 +1100,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
var kk = pf.Keycloak == null ? Guid.Empty : pf.Keycloak.Value;
var pfData = await _userProfileRepository.GetProfileByKeycloakIdAsync(kk, AccessToken);
if (pfData != null)
{
{
if (pfData.Child4 != null || pfData.Child4 != "")
orgRecv += $"{pfData.Child4}";
if (pfData.Child3 != null || pfData.Child3 != "")
@ -1113,7 +1114,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
orgRecv = orgRecv.Trim();
}
}
}
@ -1126,10 +1127,10 @@ namespace BMA.EHR.Insignia.Service.Controllers
ProfileId = profileOld.ProfileId,
RequestInsignia = profileOld.RequestInsignia,
OrganizationOrganizationSend = orgSend,
OrganizationOrganizationReceive = orgRecv,
InsigniaNote = insigniaNote,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
@ -1417,17 +1418,23 @@ namespace BMA.EHR.Insignia.Service.Controllers
.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);
InsigniaType? insigniaType = null;
if (req.InsigniaTypeId != null)
{
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.InsigniaNote == insigniaNote)
.Where(x => x.RequestInsignia.InsigniaType == insigniaType)
//.Where(x => x.RequestInsignia.InsigniaType == insigniaType)
.Where(x => req.InsigniaId == null ? x.RequestInsignia != null : (x.RequestInsignia.Id == req.InsigniaId))
.Select(x => new
{
InsigniaTypeId = x.RequestInsignia.InsigniaType.Id,
Id = x.Id,
x.CitizenId,
x.Prefix,
@ -1465,6 +1472,11 @@ namespace BMA.EHR.Insignia.Service.Controllers
})
.ToListAsync();
if (req.InsigniaTypeId != null)
{
rawNoteProfiles = rawNoteProfiles.Where(x => x.InsigniaTypeId == req.InsigniaTypeId).ToList();
}
var insigniaNoteProfiles = rawNoteProfiles
.Select(x => new
{
@ -1659,68 +1671,68 @@ namespace BMA.EHR.Insignia.Service.Controllers
if (profileInsignia == null)
{
var insigniaNoteProfile = new InsigniaNoteProfile
{
Salary = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.Amount,
IsApprove = true,
Status = "PENDING",
ProfileId = profile.Id,
Issue = req.Issue,
Number = req.Number,
DateReceive = req.DateReceive,
Date = req.Date,
VolumeNo = req.VolumeNo,
Section = req.Section,
Page = req.Page,
No = req.No,
DatePayment = req.DatePayment,
TypePayment = req.TypePayment,
Address = req.Address,
RequestInsignia = insignia,
OrganizationOrganizationReceive = req.OrganizationOrganizationReceive,
OrganizationOrganizationSend = req.OrganizationOrganizationSend,
InsigniaNote = insigniaNote,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
var insigniaNoteProfile = new InsigniaNoteProfile
{
Salary = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.Amount,
IsApprove = true,
Status = "PENDING",
ProfileId = profile.Id,
Issue = req.Issue,
Number = req.Number,
DateReceive = req.DateReceive,
Date = req.Date,
VolumeNo = req.VolumeNo,
Section = req.Section,
Page = req.Page,
No = req.No,
DatePayment = req.DatePayment,
TypePayment = req.TypePayment,
Address = req.Address,
RequestInsignia = insignia,
OrganizationOrganizationReceive = req.OrganizationOrganizationReceive,
OrganizationOrganizationSend = req.OrganizationOrganizationSend,
InsigniaNote = insigniaNote,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
Amount = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.Amount,
CitizenId = profile.CitizenId,
DateAppoint = profile.DateAppoint,
Prefix = profile.Prefix,
FirstName = profile.FirstName,
LastName = profile.LastName,
Gender = profile.Gender,
PosLevelName = profile.PosLevel,
PosNo = profile.PosNo,
PosTypeName = profile.PosType,
Position = profile.Position,
ProfileType = profile.ProfileType,
PositionSalaryAmount = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.PositionSalaryAmount,
Amount = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.Amount,
CitizenId = profile.CitizenId,
DateAppoint = profile.DateAppoint,
Prefix = profile.Prefix,
FirstName = profile.FirstName,
LastName = profile.LastName,
Gender = profile.Gender,
PosLevelName = profile.PosLevel,
PosNo = profile.PosNo,
PosTypeName = profile.PosType,
Position = profile.Position,
ProfileType = profile.ProfileType,
PositionSalaryAmount = profile.ProfileSalary == null ? 0 : profile.ProfileSalary.PositionSalaryAmount,
Root = profile.Root,
RootId = profile.RootId,
RootDnaId = profile.RootDnaId,
Child1 = profile.Child1,
Child1Id = profile.Child1Id,
Child1DnaId = profile.Child1DnaId,
Child2 = profile.Child2,
Child2Id = profile.Child2Id,
Child2DnaId = profile.Child2DnaId,
Child3 = profile.Child3,
Child3Id = profile.Child3Id,
Child3DnaId = profile.Child3DnaId,
Child4 = profile.Child4,
Child4Id = profile.Child4Id,
Child4DnaId = profile.Child4DnaId,
Root = profile.Root,
RootId = profile.RootId,
RootDnaId = profile.RootDnaId,
Child1 = profile.Child1,
Child1Id = profile.Child1Id,
Child1DnaId = profile.Child1DnaId,
Child2 = profile.Child2,
Child2Id = profile.Child2Id,
Child2DnaId = profile.Child2DnaId,
Child3 = profile.Child3,
Child3Id = profile.Child3Id,
Child3DnaId = profile.Child3DnaId,
Child4 = profile.Child4,
Child4Id = profile.Child4Id,
Child4DnaId = profile.Child4DnaId,
};
};
insigniaNote.InsigniaNoteProfiles.Add(insigniaNoteProfile);