From c285b4dd7219cb66467638f24a2a2ccaa0a59c9a Mon Sep 17 00:00:00 2001 From: Kittapath Date: Wed, 11 Oct 2023 15:10:52 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B8=9A=E0=B8=B1=E0=B8=99=E0=B8=97=E0=B8=B6?= =?UTF-8?q?=E0=B8=81=E0=B8=82=E0=B9=89=E0=B8=AD=E0=B8=A1=E0=B8=B9=E0=B8=A5?= =?UTF-8?q?=20=E0=B8=84=E0=B8=B3=E0=B8=AA=E0=B8=B1=E0=B9=88=E0=B8=87?= =?UTF-8?q?=E0=B8=88=E0=B9=89=E0=B8=B2=E0=B8=87=E0=B9=81=E0=B8=A5=E0=B8=B0?= =?UTF-8?q?=E0=B9=81=E0=B8=95=E0=B9=88=E0=B8=87=E0=B8=95=E0=B8=B1=E0=B9=89?= =?UTF-8?q?=E0=B8=87=E0=B8=A5=E0=B8=B9=E0=B8=81=E0=B8=88=E0=B9=89=E0=B8=B2?= =?UTF-8?q?=E0=B8=87=E0=B8=9B=E0=B8=A3=E0=B8=B0=E0=B8=88=E0=B8=B3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Commands/CommandRepository.cs | 73 ++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index 40a18302..b2593d11 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -1899,7 +1899,7 @@ namespace BMA.EHR.Application.Repositories.Commands } // add profile document - foreach(var doc in placementProfile.PlacementProfileDocs) + foreach (var doc in placementProfile.PlacementProfileDocs) { profile.Papers.Add(new ProfilePaper { @@ -6094,6 +6094,77 @@ namespace BMA.EHR.Application.Repositories.Commands foreach (var recv in command.Receivers) { // TODO: รอมอสเข้ามา Query แล้วแก้ไขข้อมูลทะเบียนประวัติ + var data = await _dbContext.Set() + .Include(x => x.PositionEmployeeLine) + .Include(x => x.PositionEmployeePosition) + .Include(x => x.Profile) + .ThenInclude(x => x.Salaries) + .ThenInclude(x => x.PositionLevel) + .Include(x => x.Profile) + .ThenInclude(x => x.PositionEmployeeLine) + .Include(x => x.Profile) + .ThenInclude(x => x.PositionEmployeePosition) + .Include(x => x.OrgEmployee) + .ThenInclude(x => x.OrganizationShortName) + .Include(x => x.OrgEmployee) + .ThenInclude(x => x.OrganizationOrganization) + .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId); + + if (data == null) + throw new Exception(GlobalMessages.DataNotFound); + data.Profile.EmployeeClass = "perm"; // ลจ ประจำ + data.Profile.PositionEmployeeLine = data.PositionEmployeeLine; + data.Profile.PositionEmployeePosition = data.PositionEmployeePosition; + data.Profile.OrganizationShortNameId = data.OrgEmployee == null || data.OrgEmployee!.OrganizationShortName == null ? null : data.OrgEmployee!.OrganizationShortName!.Id; + data.Profile.OrganizationShortName = data.OrgEmployee == null || data.OrgEmployee!.OrganizationShortName == null ? null : data.OrgEmployee!.OrganizationShortName!.Name; + data.Profile.OrganizationOrganizationId = data.OrgEmployee == null || data.OrgEmployee!.OrganizationOrganization == null ? null : data.OrgEmployee!.OrganizationOrganization!.Id; + data.Profile.OrganizationOrganization = data.OrgEmployee == null || data.OrgEmployee!.OrganizationOrganization == null ? null : data.OrgEmployee!.OrganizationOrganization!.Name; + data.Profile.PosNoEmployee = data.OrgEmployee == null ? null : data.OrgEmployee!.PosNo; + data.Profile.OcId = data.OrgEmployee == null || data.OrgEmployee!.Organization == null ? null : data.OrgEmployee!.Organization!.Id; + data.Profile.Oc = data.OrgEmployee == null || data.OrgEmployee!.Organization == null ? null : _organizationCommonRepository.GetOrganizationNameFullPath(data.OrgEmployee!.Organization!.Id, false, false, "/"); + + var lastSarary = data.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault(); + var order = 1; + if (lastSarary != null && lastSarary.Order != null) + order = lastSarary.Order.Value + 1; + + var salary = new ProfileSalary + { + Order = order, + Date = command.CommandAffectDate, + Amount = recv.Amount, + PositionSalaryAmount = recv.PositionSalaryAmount, + MouthSalaryAmount = recv.MouthSalaryAmount, + SalaryClass = "", + SalaryRef = "คำสั่งจ้างและแต่งตั้งลูกจ้างประจำ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", + //OcId = lastSarary.OcId, + //PositionLevel = lastSarary.PositionLevel, + //PositionLineId = lastSarary.PositionLineId, + //PositionTypeId = lastSarary.PositionTypeId, + //OrganizationShortNameId = lastSarary.OrganizationShortNameId, + //PosNoId = lastSarary.PosNoId, + CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", + CommandTypeName = command.CommandType.Name, + //PositionEmployeeGroupId = null, + //PositionEmployeeLevelId = null, + //PositionEmployeePositionId = null, + //PositionEmployeePositionSideId = null, + //PosNoEmployee = "", + ////PositionPathSideId = lastSarary.PositionPathSideId == null, + //PositionExecutiveId = lastSarary.PositionExecutiveId, + ////PositionExecutiveSideId = lastSarary.PositionExecutiveSideId, + IsActive = true, + CreatedAt = DateTime.Now, + CreatedFullName = FullName ?? "System Administrator", + CreatedUserId = UserId ?? "", + LastUpdatedAt = DateTime.Now, + LastUpdateFullName = FullName ?? "System Administrator", + LastUpdateUserId = UserId ?? "", + }; + data.Profile.Salaries.Add(salary); + // update placementstatus + data.Status = "DONE"; + await _dbContext.SaveChangesAsync(); // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่ // Send noti inbox and email