From a2bc99f73945cb503c61d42cccd2afbbda3f3553 Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 26 Sep 2023 00:25:23 +0700 Subject: [PATCH] =?UTF-8?q?=E0=B9=80=E0=B8=81=E0=B8=A9=E0=B8=B5=E0=B8=A2?= =?UTF-8?q?=E0=B8=93=E0=B9=80=E0=B8=9E=E0=B8=B4=E0=B9=88=E0=B8=A1=E0=B8=AA?= =?UTF-8?q?=E0=B9=88=E0=B8=A7=E0=B8=99=E0=B8=A3=E0=B8=B2=E0=B8=8A=E0=B8=81?= =?UTF-8?q?=E0=B8=B2=E0=B8=A3=E0=B8=95=E0=B9=89=E0=B8=99=E0=B8=AA=E0=B8=B1?= =?UTF-8?q?=E0=B8=87=E0=B8=81=E0=B8=B1=E0=B8=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Repositories/InsigniaPeriodsRepository.cs | 155 ++++++++++++------ .../Reports/InsigniaReportRepository.cs | 34 ++-- .../Controllers/PlacementController.cs | 4 + .../Reports/31-ประกาศเกษียณข้าราชการ-1.trdp | Bin 28717 -> 28706 bytes .../Reports/32-ประกาศเกษียณลูกจ้างประจำ-1.trdp | Bin 28747 -> 28737 bytes .../Controllers/RetirementController.cs | 105 ++++++++++++ .../Controllers/RetirementOtherController.cs | 31 ++-- .../Controllers/RetirementResignController.cs | 4 +- .../Requests/ProfileJsonRequest.cs | 2 + 9 files changed, 250 insertions(+), 85 deletions(-) diff --git a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs index 8018877c..ae18d6a0 100644 --- a/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs +++ b/BMA.EHR.Application/Repositories/InsigniaPeriodsRepository.cs @@ -1,4 +1,4 @@ -using BMA.EHR.Application.Common.Interfaces; +using BMA.EHR.Application.Common.Interfaces; using BMA.EHR.Application.Requests; using BMA.EHR.Domain.Models.HR; using BMA.EHR.Domain.Models.Insignias; @@ -238,7 +238,6 @@ namespace BMA.EHR.Application.Repositories p.IsActive == true && p.IsLeave == false && p.DateAppoint != null && - p.ProfileType == "employee" && p.EmployeeClass == "perm" ) @@ -5359,6 +5358,7 @@ namespace BMA.EHR.Application.Repositories { var result_candidate = new List(); + var type_coin = await GetCoinCandidate(periodId, ocId); var employee_type1 = await GetEmployeeInsignia_Type1(periodId, ocId); var employee_type2 = await GetEmployeeInsignia_Type2(periodId, ocId); var type1_level1 = await GetInsigniaCandidate_Type1_Level1(periodId, ocId); @@ -5375,9 +5375,15 @@ namespace BMA.EHR.Application.Repositories var type3_level11 = await GetInsigniaCandidate_Type3_Level11(periodId, ocId); var type4_level10 = await GetInsigniaCandidate_Type4_Level10(periodId, ocId); var type4_level11 = await GetInsigniaCandidate_Type4_Level11(periodId, ocId); - var type_coin = await GetInsigniaCandidate(periodId, ocId); + var type = await GetInsigniaCandidate(periodId, ocId); // union result + foreach (var r in type_coin) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + if (old == null) + result_candidate.Add(r); + } foreach (var r in type4_level11) { var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); @@ -5474,7 +5480,7 @@ namespace BMA.EHR.Application.Repositories if (old == null) result_candidate.Add(r); } - foreach (var r in type_coin) + foreach (var r in type) { var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); if (old == null) @@ -5520,64 +5526,105 @@ namespace BMA.EHR.Application.Repositories } } - // - /// กรองรายชื่อผู้มิสิทธิ์ยื่นขอเหรียญจักรพรรดิมาลา - /// - /// รหัสของรอบการขอ - /// รหัสโรงเรียน - /// - // public async List GetCoinCandidate(Guid periodId, Guid ocId) - // { - // try - // { + //กรองรายชื่อผู้มิสิทธิ์ยื่นขอเหรียญจักรพรรดิมาลา + public async Task> GetCoinCandidate(Guid periodId, Guid ocId) + { + try + { + var allOc = GetAllIdByRoot(ocId); - // var allOc = profileService.GetAllIdByRoot(ocId); + var period = await _dbContext.Set().FirstOrDefaultAsync(p => p.Id == periodId); - // var period = await _dbContext.Set().FirstOrDefault(p => p.Id == periodId); + if (period == null) + throw new Exception(GlobalMessages.CoinPeriodNotFound); - // if (period == null) - // throw new Exception(GlobalMessages.CoinPeriodNotFound); + var oc = await _dbContext.Set().FirstOrDefaultAsync(x => x.Id == ocId); - // var oc = await _dbContext.Set().FirstOrDefault(x => x.OcId == ocId); + if (oc == null) + throw new Exception(GlobalMessages.OCNotFound); - // if (oc == null) - // throw new Exception(GlobalMessages.OCNotFound); - // var result = await _dbContext.Set() - // .Include(p => p.Position) - // .Include(p => p.PosNo) - // .Include(p => p.PositionLevel) - // .Include(p => p.Insignias) - // .ThenInclude(i => i.Insignia) - // .Include(p => p.Salaries) - // .Where(p => allOc.Contains(p.OrganizationChart.OcId) - // && p.IsLeave == false - // && p.IsActive == true - // && p.DateAppoint != null - // && p.DateAppoint.Value.CalculateGovAgeInYear(0, 0).ToInteger() >= 25) - // .Select(p => new InsigniaResultSet - // { - // ProfileId = p.Id, - // Prefix = p.Prefix, - // FullName = $"{(p.Prefix == null ? null : p.Prefix.Name)}{p.FirstName} {p.LastName}", - // Position = p.Position.Name, - // Rank = p.PositionLevel.Name, - // GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), - // LastInsignia = p.Insignias.Count == 0 ? "" : p.Insignias.OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Name, - // Salary = p.Salaries.Count() == 0 ? null : p.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount, - // PosNo = p.PosNo == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PosNo.Id, - // RequestInsignia = GetInsigniaByName("เหรียญจักรพรรดิมาลา") - // }); + var inst_profile = _dbContext.Set() + .Include(p => p.Prefix) + .Include(p => p.Position) + .Include(p => p.PosNo) + .Include(p => p.PositionType) + .Include(p => p.PositionLevel) + .Include(p => p.Insignias) + .ThenInclude(i => i.Insignia) + .Include(p => p.Salaries) + .Where(p => + allOc.Contains(p.OcId == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OcId.Value) && + p.IsActive == true && + p.IsLeave == false && + p.DateAppoint != null + ) + .Select(p => new + { + ProfileId = p.Id, + Prefix = p.Prefix == null ? null : p.Prefix.Name, + FullName = $"{(p.Prefix == null ? null : p.Prefix.Name)}{p.FirstName} {p.LastName}", + Position = p.Position == null ? null : p.Position.Name, + Rank = p.PositionLevel == null ? null : p.PositionLevel.Name, + ProfileDateAppoint = p.DateAppoint.Value, + GovAge = p.DateAppoint.Value.CalculateGovAgeStr(0, 0), + PosNo = p.PosNo == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PosNo.Id, + Gender = p.Gender == null ? null : p.Gender.Name, + LastInsignia = p.Insignias.Count == 0 ? "" : p.Insignias.Where(x => !x.Insignia.Name.Contains("เหรียญจักรพรรดิมาลา")).OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Name, + LastInsigniaId = p.Insignias.Count == 0 ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Insignias.Where(x => !x.Insignia.Name.Contains("เหรียญจักรพรรดิมาลา")).OrderByDescending(x => x.Year).FirstOrDefault().Insignia.Id, + Salary = p.Salaries.Count() == 0 ? null : p.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount, + }); - // result = result.Where(x => !x.LastInsignia.Contains("เหรียญจักรพรรดิมาลา")); + // check วันที่บรรจะต้องมากกว่า 25 ปี + var result = ((from p in inst_profile + where p.ProfileDateAppoint <= new DateTime(period.Year - 25, 5, 29) + select p) + .ToList() + .Select(p => new InsigniaResultSet + { + ProfileId = p.ProfileId, + Prefix = p.Prefix, + FullName = p.FullName, + Position = p.Position, + PosNo = p.PosNo, + Rank = p.Rank, + GovAge = p.GovAge, + LastInsignia = p.LastInsignia, + LastInsigniaId = p.LastInsigniaId, + Salary = p.Salary, + RequestInsignia = GetInsigniaByName("เหรียญจักรพรรดิมาลา"), + Seq = 1, + Gender = p.Gender, + MatchingConditions = new List(), + })).ToList(); - // return result.ToList(); - // } - // catch - // { - // throw; - // } - // } + var result_candidate = new List(); + + foreach (var r in result) + { + var old = result_candidate.FirstOrDefault(x => x.ProfileId == r.ProfileId); + + // Check ได้รับหรือเคยยื่นขอไปในปีที่แล้วหรือไม่? + if (!CanRequestInsignia(r.ProfileId, period.Year)) + continue; + + // Check ว่าชั้นที่ขอสูงกว่าชั้นที่เคยได้รับแล้วหรือไม่? + if (!IsHigherLevel2(r.LastInsignia, r.RequestInsignia.Name)) + continue; + + if (old == null) + { + result_candidate.Add(r); + } + } + + return result_candidate; + } + catch + { + throw; + } + } #endregion diff --git a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs index c93ac4f9..83da2a99 100644 --- a/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs +++ b/BMA.EHR.Application/Repositories/Reports/InsigniaReportRepository.cs @@ -911,23 +911,23 @@ namespace BMA.EHR.Application.Repositories.Reports .ToListAsync(); foreach (var insigniaPeriod in insigniaPeriods) { - // if (insigniaPeriod.EndDate.AddDays(-insigniaPeriod.Amount).Date == DateTime.Now.Date) - // { - await _repositoryNoti.PushNotificationAsync( - Guid.Parse("08db721d-ade4-480e-8d84-0853946a0ea5"), - $"แจ้งเตือนรอบการเสนอขอ {insigniaPeriod.Name} รอบที่{insigniaPeriod.Round} {insigniaPeriod.EndDate.AddDays(-insigniaPeriod.Amount).Date}", - $"แจ้งเตือนรอบการเสนอขอ {insigniaPeriod.Name} รอบที่{insigniaPeriod.Round} {DateTime.Now.Date}", - "", - true - ); - await _repositoryNoti.PushNotificationAsync( - Guid.Parse("08db721d-adff-47b0-8762-41cd5c991001"), - $"แจ้งเตือนรอบการเสนอขอ {insigniaPeriod.Name} รอบที่{insigniaPeriod.Round}", - $"แจ้งเตือนรอบการเสนอขอ {insigniaPeriod.Name} รอบที่{insigniaPeriod.Round}", - "", - true - ); - // } + if (insigniaPeriod.EndDate.AddDays(-insigniaPeriod.Amount).Date == DateTime.Now.Date) + { + await _repositoryNoti.PushNotificationAsync( + Guid.Parse("08db721d-ade4-480e-8d84-0853946a0ea5"), + $"แจ้งเตือนรอบการเสนอขอ {insigniaPeriod.Name} รอบที่{insigniaPeriod.Round}", + $"แจ้งเตือนรอบการเสนอขอ {insigniaPeriod.Name} รอบที่{insigniaPeriod.Round}", + "", + true + ); + await _repositoryNoti.PushNotificationAsync( + Guid.Parse("08db721d-adff-47b0-8762-41cd5c991001"), + $"แจ้งเตือนรอบการเสนอขอ {insigniaPeriod.Name} รอบที่{insigniaPeriod.Round}", + $"แจ้งเตือนรอบการเสนอขอ {insigniaPeriod.Name} รอบที่{insigniaPeriod.Round}", + "", + true + ); + } } } diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs index ece5a07f..9bf8ec95 100644 --- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs +++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs @@ -1151,6 +1151,8 @@ namespace BMA.EHR.Placement.Service.Controllers FirstName = x.Profile.FirstName, LastName = x.Profile.LastName, CitizenId = x.Profile.CitizenId, + Position = x.OrganizationPosition.PositionMaster.PositionPath == null ? "-" : x.OrganizationPosition.PositionMaster.PositionPath.Name, + PositionLevel = x.Profile.PositionLevel == null ? "-" : x.Profile.PositionLevel.Name, IsDirector = x.OrganizationPosition.PositionMaster.IsDirector, }) .ToListAsync(); @@ -1173,6 +1175,8 @@ namespace BMA.EHR.Placement.Service.Controllers FirstName = x.Profile.FirstName, LastName = x.Profile.LastName, CitizenId = x.Profile.CitizenId, + Position = x.Profile.Position == null ? "-" : x.Profile.Position.Name, + PositionLevel = x.Profile.PositionLevel == null ? "-" : x.Profile.PositionLevel.Name, IsDirector = x.OrganizationPosition.PositionMaster.IsDirector, }) .ToListAsync(); diff --git a/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-1.trdp b/BMA.EHR.Report.Service/Reports/31-ประกาศเกษียณข้าราชการ-1.trdp index 31cc58f294ea9f11abafd127ced32ca07bebad95..7004416fc0d5f88d68cf99ede83f6c46698ebd5d 100644 GIT binary patch delta 1535 zcmVM@!Vrm4;xM5RUXUzY^ zFv89{?OUPFs6zw$3%%p@jQ}lxU87hi&KO1A)W9$yja!WNLma|G%j(fZYISMQrX2>P zNGq^icE??^LdGYX+JfbTR3nSj?yWQ6QqX5oHhy+}f`Z0XB!Omk*dU;Df8GYU)kot7 zeusuXnlbfzmNTGwYvraU{YOAa03Vj<0~l8I5`S3p{H9jmqqhABBiZg)4s8V5XU?5@cY!)k5U611PuI!>kcs`DbB|t1bYcU z!dPHzNj#C(16;I2fU*wh)yd-)R9~MmXejz;)C$Djc_Is&iMp!hRW;#7H|y9v=tG}U z7ffhpFLc;vl-H@xf6h|$NqMWX_PXU$S?^`Bjb*VH^kQ1-72O;ads#P&X4-o~Zljp% z+dT^V9(q9H-?H89I`l31C%xg#C5y0RyHvP3ZwI15Hnkh~bByL#NTla#6eT^kO_cSD z(kMvYUmX2}wf6$6^3u2BcX9L@H~kh0PcFXG;vs1Miu+<4e?NDT^DBgyzVpw#J-K0U zg4;unx%Mu)@&cXP!x)@^1UB-I1l1#Cc8m}QQ@1NYoBQ!_3$5)Y+=sAupGYn*5$q5j z|3M`Y@Ra9c1Cb~-D`B`ZS`LAzcgQRj-JbDi8w;k_Qq1P<}phN zmY{ctJA^wYf3gG#f0pU9wP}5pZ_9VqWgEuWNza%#>d6^V9P<2^c9KfkYP+h6dc>Qc zab9n-o=hGZGd-`EeOXlMO3Q;|u4stjOsLmNrqcKxFWA)ShPoF(6rQB7>P#MsjJCTCBGD)1qszOOr4Ij;UjCuX! z!5I0eS`KYvf}xYtfsWfHeC5T%nQa_CLAQ? z1QC~BoUef;py_gPAcejE`z2BP2IA{D6ky z7oz54wi?D}~qo z4Fgb10|XQR000O8&3uz>Ztnuke3M>pNDa+=Iaji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w||Akl7JJ9Aw*-55MO_nENCA5)8D@hg%q8HzhoT z8T&*Lc#a5%`1lw49brnls<@Ak1&&cfbV0aGnd5q?BoLhU5_5Q4f=m7v#U*DDT0u+J z5vsN~CZB5oe{-~ANqUF4Ekts1m0*=0=ft%(OUCo?h@c7& zv+r|m9n0h8&NHaWkJ1SYD&}mxK9#|pf#(U#lS$0He+~&ana`bqMHs}cSke3`p)w8I zmccdjO65d!+nk-L6{D{NdFa`*L%$+%Xop(4umO6G@7{Mr@;9_`o=x@DY-)0kWL#?F zov5uq5s6M7uJF$Bh6H3j@Vej-4d4QI(}(`|;6S1budgm+BBEa@7lMFgS4vf?^7y@R z%*j@Ke{>9t)uv2bV`I{S!%%eH^&z86(5y?2-;Fy?IJ%-L0?SU+bNx(Cl;NgYBtc_U zqa?dVjOGKzf`0m7jq=nZN=;RyqzNn6UZ<3)DQH<8=o&Xs-j>r9_kP7nte0XnMK0TL z&+o7x8kbBsJ*pQ(-gL$KiE7R}G0ivir1v80e|zbQ=g@O-DW6e#>2p?q#?>eogd=x+ zN*BH-#@e?8-^nkOPERxEyQpN&RJ2<_Z^Cn&d=Y>QFZ*u-wYYan@(ZM4j`{3c_j;QcJo9TFuk{KFUrvYC_Jg1O%2}YxiO&alM@Cgomi9 z7+z8~vJGFrRv9n+3s6e~1QY-O00;o8Sd(II?*gh=lT&X<4XRiSd-ar906gI_HQNzP;USL0044&?tlOQ diff --git a/BMA.EHR.Report.Service/Reports/32-ประกาศเกษียณลูกจ้างประจำ-1.trdp b/BMA.EHR.Report.Service/Reports/32-ประกาศเกษียณลูกจ้างประจำ-1.trdp index 35a2941f3f28df46de97716c46cbec5d47cdda3c..556463be418c8367d3899e769d998aefc44fc36b 100644 GIT binary patch delta 1566 zcmV+(2I2Y3-~qwl0Sr(}0|XQR000O8+I+DLlxPjwd^uO%o^_m;1pokPldWhoe{FBu zHW2uXc-MZJMG0Ul%L6HRr zkOafJ4F%S8?c{%>pEB|&S`@9sNz<(;66(mi=Z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?QZ7JZwx&0C5>V?@LPs$Rt!S@ zZqRf6e#;oL+h^vC^XJ}wZ+?}Ae?i2^Ew{(kVO^s;FvyBCpeLgue9I*4%yA8n^km#EXDQHORJ zI7Ql#>$B_rvJ*2g*)kR#FQx`rqHcekwTz}Yn>iB})l(3(tpiCgx66hRe_aSR$dv)w zw(xgsh2t69yy|+ z#@|N^yQp=jwDO?{^?fCmI|PFRG%k(&f@U9JG=JkKIP(ezPnBeZ<840rK8y0B%zyv^ z1HYr*0VX5E`B(p0Cxd^2O4|fnHX*Slxz~oe8&C#JVtz)QNOsMARnkmW zRHLk(i72-Vp4$fkfBKaAV8S?gi9?4`QK2C_Nx7$mt;;&=PDoXy&&mc?WnM9>S&`RG zdtBzTrd_o&)`^9UYH4gYDRew^e;VI4x7YLNe-xjJM$k$TVcGSm4E3TLNos5vmu{69 zEwPYFPel2Jb8_cf4+&cuin1L&;f8`2Yq{v zmZ!HmIYmQ)Y2Ykj5n_9QNL#oyFA(Fg&>L-$rd*leejTFuCs}jy(NBB?nm@u%f{=TB zw220GQg26~u}2j6GqitzpD%IUA;z<#X!IfafMcW#z5Opz=D1!;00i}3qxt3#Q1kHw@7hkJC@^?NPj0_11e@q2OC3CC|O z<-j#3f9kt_)-_6SLv@94V^wnrHws4!0b{`+{jkPy>J}w+D5sp!&t64}T zHffn_Wu5-1DZ3{rg@RmV5;{y{l=4O5MLKm6UdN`clFXcOYKgZ>c!kq1pokElgDo_0&7{5_-`Bmf0Gq(CI)VA00000 DTT$V~ diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs index d9dfd9d9..c9b62cf8 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs @@ -141,6 +141,96 @@ namespace BMA.EHR.Retirement.Service.Controllers return 999999999; return index; } + + private async Task GetAgency(Guid profileId) + { + var organizationAgency = "-"; + var _profile = await _context.Profiles + .Where(x => x.Id == profileId) + .FirstOrDefaultAsync(); + if (_profile != null) + { + if (_profile.ProfileType == "officer") + { + var organization = await _context.Organizations + .Where(x => x.Id == _profile.OcId) + .FirstOrDefaultAsync(); + if (organization != null) + { + var _organizationAgency = await _context.Organizations + .Include(x => x.OrganizationOrganization) + .Where(x => x.Id == organization.OrganizationAgencyId) + .FirstOrDefaultAsync(); + if (_organizationAgency != null && _organizationAgency.OrganizationOrganization != null) + { + organizationAgency = _organizationAgency.OrganizationOrganization.Name; + } + } + } + else + { + var profilePosition = await _context.OrganizationEmployees + .Include(x => x.OrganizationAgency) + .ThenInclude(x => x.OrganizationOrganization) + .Where(x => x.Organization != null) + .Where(x => x.OrganizationAgency != null) + .Where(x => x.OrganizationAgency.OrganizationOrganization != null) + .Where(x => x.OrganizationAgency.OrganizationOrganization.Name != null) + .Where(x => x.Organization.Id == _profile.OcId) + .FirstOrDefaultAsync(); + if (profilePosition != null) + { + organizationAgency = profilePosition.OrganizationAgency.OrganizationOrganization.Name; + } + } + } + return organizationAgency; + } + + private async Task GetGovermentAgency(Guid profileId) + { + var organizationGovernmentAgency = "-"; + var _profile = await _context.Profiles + .Where(x => x.Id == profileId) + .FirstOrDefaultAsync(); + if (_profile != null) + { + if (_profile.ProfileType == "officer") + { + var organization = await _context.Organizations + .Where(x => x.Id == _profile.OcId) + .FirstOrDefaultAsync(); + if (organization != null) + { + var _organizationGovernmentAgency = await _context.Organizations + .Include(x => x.OrganizationOrganization) + .Where(x => x.Id == organization.OrganizationGovernmentAgencyId) + .FirstOrDefaultAsync(); + if (_organizationGovernmentAgency != null && _organizationGovernmentAgency.OrganizationOrganization != null) + { + organizationGovernmentAgency = _organizationGovernmentAgency.OrganizationOrganization.Name; + } + } + } + else + { + var profilePosition = await _context.OrganizationEmployees + .Include(x => x.OrganizationGovernmentAgency) + .ThenInclude(x => x.OrganizationOrganization) + .Where(x => x.Organization != null) + .Where(x => x.OrganizationGovernmentAgency != null) + .Where(x => x.OrganizationGovernmentAgency.OrganizationOrganization != null) + .Where(x => x.OrganizationGovernmentAgency.OrganizationOrganization.Name != null) + .Where(x => x.Organization.Id == _profile.OcId) + .FirstOrDefaultAsync(); + if (profilePosition != null) + { + organizationGovernmentAgency = profilePosition.OrganizationGovernmentAgency.OrganizationOrganization.Name; + } + } + } + return organizationGovernmentAgency; + } #endregion /// @@ -308,6 +398,9 @@ namespace BMA.EHR.Retirement.Service.Controllers var profile_olds = new List(); foreach (var r in profile_old) { + var organizationAgency = await GetAgency(r.profileId); + var organizationGovernmentAgency = await GetGovermentAgency(r.profileId); + var data = new ProfileJsonRequest { order = r.order, @@ -328,6 +421,8 @@ namespace BMA.EHR.Retirement.Service.Controllers positionEmployeeLevel = r.positionEmployeeLevel, positionEmployeeGroup = r.positionEmployeeGroup, posNoEmployee = r.posNoEmployee, + organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด + organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด }; profile_olds.Add(data); } @@ -465,6 +560,9 @@ namespace BMA.EHR.Retirement.Service.Controllers var profile_news = new List(); foreach (var r in profile_new) { + var organizationAgency = await GetAgency(r.profileId); + var organizationGovernmentAgency = await GetGovermentAgency(r.profileId); + var data = new ProfileJsonRequest { order = r.order, @@ -485,6 +583,8 @@ namespace BMA.EHR.Retirement.Service.Controllers positionEmployeeLevel = r.positionEmployeeLevel, positionEmployeeGroup = r.positionEmployeeGroup, posNoEmployee = r.posNoEmployee, + organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด + organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด }; profile_news.Add(data); } @@ -553,6 +653,9 @@ namespace BMA.EHR.Retirement.Service.Controllers var profile_news = new List(); foreach (var r in profile_new) { + var organizationAgency = await GetAgency(r.profileId); + var organizationGovernmentAgency = await GetGovermentAgency(r.profileId); + var data = new ProfileJsonRequest { order = r.order, @@ -573,6 +676,8 @@ namespace BMA.EHR.Retirement.Service.Controllers positionEmployeeLevel = r.positionEmployeeLevel, positionEmployeeGroup = r.positionEmployeeGroup, posNoEmployee = r.posNoEmployee, + organizationAgency = organizationAgency,//หน่วยงานต้นสังกัด + organizationGovernmentAgency = organizationGovernmentAgency,//ส่วนราชการต้นสังกัด }; profile_news.Add(data); } diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs index b4208c72..2b8d151d 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementOtherController.cs @@ -144,12 +144,12 @@ namespace BMA.EHR.Retirement.Service.Controllers p.Status, p.Amount, p.RecruitDate, - PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id, - PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id, - PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id, - PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id, - PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id, - PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id, + PosNo = p.PositionNumber == null ? "-" : p.PositionNumber.Name, + Position = p.PositionPath == null ? "-" : p.PositionPath.Name, + PositionPathSide = p.PositionPathSide == null ? "-" : p.PositionPathSide.Name, + PositionType = p.PositionType == null ? "-" : p.PositionType.Name, + PositionLine = p.PositionLine == null ? "-" : p.PositionLine.Name, + PositionLevel = p.PositionLevel == null ? "-" : p.PositionLevel.Name, OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id, p.CreatedAt, p.Reason, @@ -198,12 +198,12 @@ namespace BMA.EHR.Retirement.Service.Controllers data.Status, data.Amount, data.RecruitDate, - data.PosNoId, - data.PositionId, - data.PositionPathSideId, - data.PositionTypeId, - data.PositionLineId, - data.PositionLevelId, + data.PosNo, + data.Position, + data.PositionPathSide, + data.PositionType, + data.PositionLine, + data.PositionLevel, data.OrganizationPositionId, data.CreatedAt, data.Reason, @@ -267,6 +267,13 @@ namespace BMA.EHR.Retirement.Service.Controllers PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name, PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name, OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}", + PositionNumber = profile.PosNo, + PositionPath = profile.Position, + PositionPathSide = await _context.PositionPathSides.FindAsync(profile.PositionPathSideId), + PositionType = profile.PositionType, + PositionLine = await _context.PositionLines.FindAsync(profile.PositionLineId), + PositionLevel = profile.PositionLevel, + // OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id, Status = "WAITTING", CreatedUserId = UserId ?? "System Administrator", CreatedFullName = FullName ?? "", diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs index 6781d1e1..933b452b 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementResignController.cs @@ -354,8 +354,8 @@ namespace BMA.EHR.Retirement.Service.Controllers } await _repositoryNoti.PushNotificationAsync( Guid.Parse("08db721d-ae2f-4f5d-836a-02d2413df33d"), - $"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นคำลาออก", - $"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นคำลาออก", + $"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นขอลาออก", + $"{profile.Prefix?.Name}{profile.FirstName} {profile.LastName} ได้ทำการยื่นขอลาออก", "", true ); diff --git a/BMA.EHR.Retirement.Service/Requests/ProfileJsonRequest.cs b/BMA.EHR.Retirement.Service/Requests/ProfileJsonRequest.cs index 356e8b67..e54bfd6b 100644 --- a/BMA.EHR.Retirement.Service/Requests/ProfileJsonRequest.cs +++ b/BMA.EHR.Retirement.Service/Requests/ProfileJsonRequest.cs @@ -23,5 +23,7 @@ namespace BMA.EHR.Retirement.Service.Requests public string? positionEmployeeLevel { get; set; } public string? positionEmployeeGroup { get; set; } public string? posNoEmployee { get; set; } + public string? organizationAgency { get; set; } + public string? organizationGovernmentAgency { get; set; } } }