From 468bd38e0b7369c96c55d9d40ed6fabb397f00af Mon Sep 17 00:00:00 2001 From: Kittapath Date: Tue, 25 Jun 2024 09:27:34 +0700 Subject: [PATCH] no message --- .../Commands/CommandRepository.cs | 257 +++++++++--------- .../MessageQueue/InboxRepository.cs | 37 ++- .../MessageQueue/NotificationRepository.cs | 46 +++- BMA.EHR.Command.Service/appsettings.json | 2 +- .../Models/Retirement/RetirementPeriod.cs | 2 +- .../Retirement/RetirementPeriodHistory.cs | 2 +- .../Controllers/CommandReportController.cs | 61 +++-- .../Controllers/RetirementController.cs | 2 +- .../RetirementDeceasedController.cs | 4 +- 9 files changed, 247 insertions(+), 166 deletions(-) diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs index f4f905a3..daf17ebb 100644 --- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs +++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs @@ -2765,7 +2765,7 @@ namespace BMA.EHR.Application.Repositories.Commands isLeave = false, dateRetire = (DateTime?)null, dateAppoint = placementProfile.RecruitDate == null ? (DateTime?)null : placementProfile.RecruitDate, - dateStart = (DateTime?)null, + dateStart = command.CommandAffectDate == null ? null : command.CommandAffectDate, govAgeAbsent = 0, govAgePlus = 0, birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth, @@ -2858,17 +2858,22 @@ namespace BMA.EHR.Application.Repositories.Commands { profileId = profileId, date = command.CommandAffectDate == null ? (DateTime?)null : command.CommandAffectDate, - amount = recv.Amount == null ? null : recv.Amount, - positionSalaryAmount = placementProfile.PositionSalaryAmount == null ? null : placementProfile.PositionSalaryAmount, - mouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? null : placementProfile.MouthSalaryAmount, - posNo = placementProfile.PosNumber == null ? string.Empty : placementProfile.PosNumber.ToString(), + amount = placementProfile.Amount, + positionSalaryAmount = placementProfile.PositionSalaryAmount, + mouthSalaryAmount = placementProfile.MouthSalaryAmount, + posNo = placementProfile.posMasterNo == null ? "" : + placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" : + placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "", position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName, positionLine = string.Empty, positionPathSide = string.Empty, positionExecutive = string.Empty, positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName, - positionLevel = placementProfile.PositionLevel == null ? string.Empty : placementProfile.PositionLevel.Name, - refCommandNo = string.Empty, + positionLevel = placementProfile.posLevelName == null ? string.Empty : placementProfile.posLevelName, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = string.Empty, }); var _result = await _res.Content.ReadAsStringAsync(); @@ -2884,7 +2889,7 @@ namespace BMA.EHR.Application.Repositories.Commands { posmasterId = placementProfile.posmasterId, positionId = placementProfile.positionId, - profileId = placementProfile.profileId, + profileId = profileId, }); var _result = await _res.Content.ReadAsStringAsync(); } @@ -3012,8 +3017,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = placementProfile.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = placementProfile.posMasterNo == null ? "" : placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : @@ -3026,7 +3031,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = placementProfile.posTypeName, positionLevel = placementProfile.posLevelName, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", SalaryRef = "คำสั่งแต่งตั้ง คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -3167,8 +3172,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = placementProfile.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = placementProfile.posMasterNo == null ? "" : placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : @@ -3181,7 +3186,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = placementProfile.posTypeName, positionLevel = placementProfile.posLevelName, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", SalaryRef = "คำสั่งย้าย คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -3324,8 +3329,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = placementProfile.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = placementProfile.posMasterNo == null ? "" : placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : @@ -3338,7 +3343,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = placementProfile.posTypeName, positionLevel = placementProfile.posLevelName, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งแต่งตั้ง คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -3483,8 +3488,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = placementProfile.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = placementProfile.posMasterNo == null ? "" : placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : @@ -3497,7 +3502,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = placementProfile.posTypeName, positionLevel = placementProfile.posLevelName, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งเลื่อน คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -3639,8 +3644,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = placementProfile.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = placementProfile.posMasterNo == null ? "" : placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : @@ -3653,7 +3658,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = placementProfile.posTypeName, positionLevel = placementProfile.posLevelName, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งย้าย คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -3796,8 +3801,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = placementProfile.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = placementProfile.PositionNumberOld, position = placementProfile.PositionOld, positionLine = "", @@ -3805,7 +3810,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = placementProfile.PositionTypeOld, positionLevel = placementProfile.PositionLevelOld, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งบรรจุและแต่งตั้งข้าราชการฯ กลับเข้ารับราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -3822,7 +3827,7 @@ namespace BMA.EHR.Application.Repositories.Commands { isLeave = false, leaveReason = _null, - leaveDate = _null, + dateLeave = _null, }); var _result = await _res.Content.ReadAsStringAsync(); } @@ -3948,8 +3953,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = placementProfile.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = placementProfile.PositionNumberOld, position = placementProfile.PositionOld, positionLine = "", @@ -3957,7 +3962,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = placementProfile.PositionTypeOld, positionLevel = placementProfile.PositionLevelOld, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -3974,7 +3979,7 @@ namespace BMA.EHR.Application.Repositories.Commands { isLeave = false, leaveReason = _null, - leaveDate = _null, + dateLeave = _null, }); var _result = await _res.Content.ReadAsStringAsync(); } @@ -4536,7 +4541,7 @@ namespace BMA.EHR.Application.Repositories.Commands // { // isLeave = true, // leaveReason = "คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ", - // leaveDate = command.CommandAffectDate, + // dateLeave = command.CommandAffectDate, // }); // var _result = await _res.Content.ReadAsStringAsync(); // } @@ -4550,8 +4555,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = data.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = data.PositionNumberOld, position = data.PositionOld, positionLine = "", @@ -4559,7 +4564,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = data.PositionTypeOld, positionLevel = data.PositionLevelOld, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -4703,8 +4708,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = placementProfile.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = placementProfile.posMasterNo == null ? "" : placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" : placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" : @@ -4717,7 +4722,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = placementProfile.posTypeName, positionLevel = placementProfile.posLevelName, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "รับโอนข้าราชการกรุงเทพมหานครสามัญ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -4863,8 +4868,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = data.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = data.PositionNumberOld, position = data.PositionOld, positionLine = "", @@ -4872,7 +4877,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = data.PositionTypeOld, positionLevel = data.PositionLevelOld, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งให้ช่วยราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -5017,8 +5022,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = data.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = data.PositionNumberOld, position = data.PositionOld, positionLine = "", @@ -5026,7 +5031,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = data.PositionTypeOld, positionLevel = data.PositionLevelOld, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งส่งตัวกลับ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -5172,7 +5177,7 @@ namespace BMA.EHR.Application.Repositories.Commands { isLeave = true, leaveReason = "ลาออกจากราชการ", - leaveDate = command.CommandAffectDate, + dateLeave = command.CommandAffectDate, }); var _result = await _res.Content.ReadAsStringAsync(); } @@ -5187,8 +5192,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = data.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = data.PositionNumberOld, position = data.PositionOld, positionLine = "", @@ -5196,7 +5201,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = data.PositionTypeOld, positionLevel = data.PositionLevelOld, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -5342,7 +5347,7 @@ namespace BMA.EHR.Application.Repositories.Commands { isLeave = true, leaveReason = "ได้รับโทษทางวินัย ให้ออกจากราชการ", - leaveDate = command.CommandAffectDate, + dateLeave = command.CommandAffectDate, }); var _result = await _res.Content.ReadAsStringAsync(); } @@ -5357,8 +5362,8 @@ namespace BMA.EHR.Application.Repositories.Commands profileId = data.profileId, date = command.CommandAffectDate, amount = recv.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = data.PositionNumberOld, position = data.PositionOld, positionLine = "", @@ -5366,7 +5371,7 @@ namespace BMA.EHR.Application.Repositories.Commands positionExecutive = "", positionType = data.PositionTypeOld, positionLevel = data.PositionLevelOld, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งให้ออกจากราชการ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -5926,9 +5931,9 @@ namespace BMA.EHR.Application.Repositories.Commands { profileEmployeeId = data.profileId, date = command.CommandAffectDate, - amount = data.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + amount = recv.Amount, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = data.posMasterNo == null ? "" : data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" : data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" : @@ -5938,7 +5943,7 @@ namespace BMA.EHR.Application.Repositories.Commands position = data.position, positionType = data.posTypeName, positionLevel = data.posLevelName, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -6085,7 +6090,7 @@ namespace BMA.EHR.Application.Repositories.Commands { isLeave = true, leaveReason = "ลาออกจากราชการ", - leaveDate = command.CommandAffectDate, + dateLeave = command.CommandAffectDate, }); var _result = await _res.Content.ReadAsStringAsync(); } @@ -6213,9 +6218,9 @@ namespace BMA.EHR.Application.Repositories.Commands { profileEmployeeId = data.profileId, date = command.CommandAffectDate, - amount = data.Amount, - positionSalaryAmount = 0, - mouthSalaryAmount = 0, + amount = recv.Amount, + positionSalaryAmount = recv.PositionSalaryAmount, + mouthSalaryAmount = recv.MouthSalaryAmount, posNo = data.posMasterNo == null ? "" : data.node == 4 ? $"{data.child4ShortName}{data.posMasterNo}" : data.node == 3 ? $"{data.child3ShortName}{data.posMasterNo}" : @@ -6225,7 +6230,7 @@ namespace BMA.EHR.Application.Repositories.Commands position = data.position, positionType = data.posTypeName, positionLevel = data.posLevelName, - refCommandNo = command.CommandNo, + refCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}", templateDoc = "คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", }); var _result = await _res.Content.ReadAsStringAsync(); @@ -9463,38 +9468,38 @@ namespace BMA.EHR.Application.Repositories.Commands // } // } - // var Salaries = await _dbContext.Set() - // .Where(x => x.Profile.Id == profile.Id) - // .ToListAsync(); - // if (Salaries.Count > 0) - // { - // var apiUrlSalary = $"{_baseAPI}/org/profile/salary"; - // using (var client = new HttpClient()) - // { - // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - // foreach (var salary in Salaries) - // { - // var _res = await client.PostAsJsonAsync(apiUrlSalary, new - // { - // profileId = profile.Id, - // date = salary.Date, - // amount = salary.Amount, - // positionSalaryAmount = salary.PositionSalaryAmount, - // mouthSalaryAmount = salary.MouthSalaryAmount, - // posNo = salary.PosNoName, - // position = salary.PositionName, - // positionLine = salary.PositionLineName, - // positionPathSide = salary.PositionPathSideName, - // positionExecutive = salary.PositionExecutiveName, - // positionType = salary.PositionTypeName, - // positionLevel = salary.PositionLevelName, - // refCommandNo = salary.RefCommandNo, - // templateDoc = salary.SalaryRef, - // }); - // var _result = await _res.Content.ReadAsStringAsync(); - // } - // } - // } + var Salaries = await _dbContext.Set() + .Where(x => x.Profile.Id == profile.Id) + .ToListAsync(); + if (Salaries.Count > 0) + { + var apiUrlSalary = $"{_baseAPI}/org/profile/salary"; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + foreach (var salary in Salaries) + { + var _res = await client.PostAsJsonAsync(apiUrlSalary, new + { + profileId = profile.Id, + date = salary.Date, + amount = salary.Amount, + positionSalaryAmount = salary.PositionSalaryAmount, + mouthSalaryAmount = salary.MouthSalaryAmount, + posNo = salary.PosNoName, + position = salary.PositionName, + positionLine = salary.PositionLineName, + positionPathSide = salary.PositionPathSideName, + positionExecutive = salary.PositionExecutiveName, + positionType = salary.PositionTypeName, + positionLevel = salary.PositionLevelName, + refCommandNo = salary.RefCommandNo, + templateDoc = salary.SalaryRef, + }); + var _result = await _res.Content.ReadAsStringAsync(); + } + } + } // if (profile.Nopaids.Count > 0) // { @@ -9569,39 +9574,39 @@ namespace BMA.EHR.Application.Repositories.Commands // } // } - var Insignias = await _dbContext.Set() - .Include(x => x.Insignia) - .Where(x => x.Profile.Id == profile.Id) - .ToListAsync(); - if (Insignias.Count > 0) - { - var apiUrlInsig = $"{_baseAPI}/org/dotnet/insignia/Dumb"; - using (var client = new HttpClient()) - { - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); - foreach (var insignia in Insignias) - { - var _res = await client.PostAsJsonAsync(apiUrlInsig, new - { - profileId = profile.Id, - year = insignia.Year, - no = insignia.No, - volume = insignia.Volume, - section = insignia.Section, - page = insignia.Page, - receiveDate = insignia.ReceiveDate, - insigniaId = insignia.Insignia.Id, //where in node - dateAnnounce = insignia.DateAnnounce, - issue = insignia.Issue, - volumeNo = insignia.VolumeNo, - refCommandDate = insignia.RefCommandDate, - refCommandNo = insignia.RefCommandNo, - note = insignia.Note, - }); - var _result = await _res.Content.ReadAsStringAsync(); - } - } - } + // var Insignias = await _dbContext.Set() + // .Include(x => x.Insignia) + // .Where(x => x.Profile.Id == profile.Id) + // .ToListAsync(); + // if (Insignias.Count > 0) + // { + // var apiUrlInsig = $"{_baseAPI}/org/dotnet/insignia/Dumb"; + // using (var client = new HttpClient()) + // { + // client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", "")); + // foreach (var insignia in Insignias) + // { + // var _res = await client.PostAsJsonAsync(apiUrlInsig, new + // { + // profileId = profile.Id, + // year = insignia.Year, + // no = insignia.No, + // volume = insignia.Volume, + // section = insignia.Section, + // page = insignia.Page, + // receiveDate = insignia.ReceiveDate, + // insigniaId = insignia.Insignia.Id, //where in node + // dateAnnounce = insignia.DateAnnounce, + // issue = insignia.Issue, + // volumeNo = insignia.VolumeNo, + // refCommandDate = insignia.RefCommandDate, + // refCommandNo = insignia.RefCommandNo, + // note = insignia.Note, + // }); + // var _result = await _res.Content.ReadAsStringAsync(); + // } + // } + // } // if (profile.Honors.Count > 0) // { diff --git a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs index 28621221..8034f3d5 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/InboxRepository.cs @@ -6,7 +6,9 @@ using BMA.EHR.Domain.Models.Notifications; using BMA.EHR.Domain.Shared; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using Newtonsoft.Json; +using System.Net.Http.Headers; using System.Text.RegularExpressions; namespace BMA.EHR.Application.Repositories.MessageQueue @@ -17,16 +19,19 @@ namespace BMA.EHR.Application.Repositories.MessageQueue private readonly IApplicationDBContext _dbContext; private readonly IHttpContextAccessor _httpContextAccessor; + private readonly IConfiguration _configuration; #endregion #region " Constructor and Destuctor " public InboxRepository(IApplicationDBContext dbContext, - IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor) + IHttpContextAccessor httpContextAccessor, + IConfiguration configuration) : base(dbContext, httpContextAccessor) { _dbContext = dbContext; _httpContextAccessor = httpContextAccessor; + _configuration = configuration; } #endregion @@ -37,17 +42,35 @@ namespace BMA.EHR.Application.Repositories.MessageQueue { try { - var profile = await _dbContext.Set() - .FirstOrDefaultAsync(p => p.KeycloakId == Guid.Parse(UserId!)); + // var profile = await _dbContext.Set() + // .FirstOrDefaultAsync(p => p.KeycloakId == Guid.Parse(UserId!)); - if (profile == null) + // if (profile == null) + // { + // return new List(); + // // throw new Exception(GlobalMessages.DataNotFound); + // } + + var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var profileId = ""; + using (var client = new HttpClient()) { - return new List(); - // throw new Exception(GlobalMessages.DataNotFound); + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + return new List(); + profileId = org.result.rootId == null ? "" : org.result.profileId; } + if (profileId == null || profileId == "") + return new List(); var data_search = await _dbContext.Set() - .Where(x => x.ReceiverUserId == profile.Id) + .Where(x => x.ReceiverUserId == Guid.Parse(profileId)) .Where(x => x.DeleteDate == null) .OrderByDescending(x => x.ReceiveDate) .Select(x => new InboxResponse diff --git a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs index 81b106f1..cf255741 100644 --- a/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs +++ b/BMA.EHR.Application/Repositories/MessageQueue/NotificationRepository.cs @@ -7,7 +7,9 @@ using BMA.EHR.Domain.Models.Notifications; using BMA.EHR.Domain.Shared; using Microsoft.AspNetCore.Http; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.Configuration; using Newtonsoft.Json; +using System.Net.Http.Headers; using System.Text.RegularExpressions; namespace BMA.EHR.Application.Repositories.MessageQueue @@ -19,6 +21,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue private readonly IApplicationDBContext _dbContext; private readonly IHttpContextAccessor _httpContextAccessor; private readonly EmailSenderService _emailSenderService; + private readonly IConfiguration _configuration; #endregion @@ -26,11 +29,13 @@ namespace BMA.EHR.Application.Repositories.MessageQueue public NotificationRepository(IApplicationDBContext dbContext, EmailSenderService emailSenderService, - IHttpContextAccessor httpContextAccessor) : base(dbContext, httpContextAccessor) + IHttpContextAccessor httpContextAccessor, + IConfiguration configuration) : base(dbContext, httpContextAccessor) { _dbContext = dbContext; _httpContextAccessor = httpContextAccessor; _emailSenderService = emailSenderService; + _configuration = configuration; } #endregion @@ -50,8 +55,26 @@ namespace BMA.EHR.Application.Repositories.MessageQueue // // throw new Exception(GlobalMessages.DataNotFound); // } + var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var profileId = ""; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + return new List(); + profileId = org.result.rootId == null ? "" : org.result.profileId; + } + if (profileId == null || profileId == "") + return new List(); + var data_search = await _dbContext.Set() - .Where(x => x.KeycloakUserId == UserId) + .Where(x => x.ReceiverUserId == Guid.Parse(profileId)) .Where(x => x.DeleteDate == null) .OrderByDescending(x => x.ReceiveDate) .ToListAsync(); @@ -107,9 +130,26 @@ namespace BMA.EHR.Application.Repositories.MessageQueue // { // return 0; // } + var apiUrl = $"{_configuration["API"]}/org/profile/keycloak/position"; + var profileId = ""; + using (var client = new HttpClient()) + { + client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", "")); + var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl); + var _res = await client.SendAsync(_req); + var _result = await _res.Content.ReadAsStringAsync(); + + var org = JsonConvert.DeserializeObject(_result); + + if (org == null || org.result == null) + return 0; + profileId = org.result.rootId == null ? "" : org.result.profileId; + } + if (profileId == null || profileId == "") + return 0; var data_search = await _dbContext.Set() - .Where(x => x.KeycloakUserId == UserId) + .Where(x => x.ReceiverUserId == Guid.Parse(profileId)) .Where(x => x.DeleteDate == null) .Where(x => x.IsOpen == false) .OrderByDescending(x => x.ReceiveDate) diff --git a/BMA.EHR.Command.Service/appsettings.json b/BMA.EHR.Command.Service/appsettings.json index 026c49c5..980f7296 100644 --- a/BMA.EHR.Command.Service/appsettings.json +++ b/BMA.EHR.Command.Service/appsettings.json @@ -42,5 +42,5 @@ "MailFrom": "saraban.csc.rd@bangkok.go.th", "Port": "25" }, - "API": "https://bma-ehr.frappet.synology.me/api/v1" + "API": "https://bma-ehr.frappet.com/api/v1" } \ No newline at end of file diff --git a/BMA.EHR.Domain/Models/Retirement/RetirementPeriod.cs b/BMA.EHR.Domain/Models/Retirement/RetirementPeriod.cs index 78c625da..c5326885 100644 --- a/BMA.EHR.Domain/Models/Retirement/RetirementPeriod.cs +++ b/BMA.EHR.Domain/Models/Retirement/RetirementPeriod.cs @@ -20,7 +20,7 @@ namespace BMA.EHR.Domain.Models.Retirement [Comment("เอกสารประกาศ")] public Document? Document { get; set; } [Comment("รายละเอียดมติ อกก")] - public string Detail { get; set; } = "มาตรา ๑๖ และมาตรา ๒๑ แห่งพระราชบัญญัตบำเหน็จบำนาญข้าราชการส่วนท้องถิ่น พ.ศ.๒๕๗๗ มาตรา ๘ แห่งพระราชบัญญัติบัเหน็จบำนาญข้าราชการกรุงเทพมหานคร พ.ศ.๒๕๕๔ ประกอบกับมติ ก.ก. ครั้งที่๑๑/๒๕๕๕ เมื่อวันที่ ๑๕ พฤศจิกายน ๒๕๕๕และมติ อ.ก.ก. สามัญข้ารายการสามัญครั้งที่ ๑/๒๕๖๕ เมื่อวันที่ ๒๑ กุมภาพันธ์ ๒๕๖๕"; + public string Detail { get; set; } = "มาตรา ๑๖ และมาตรา ๒๑ แห่งพระราชบัญญัติบำเหน็จบำนาญข้าราชการส่วนท้องถิ่น พ.ศ.๒๕๗๗ มาตรา ๘ แห่งพระราชบัญญัติบำเหน็จบำนาญข้าราชการกรุงเทพมหานคร พ.ศ.๒๕๕๔ ประกอบกับมติ ก.ก. ครั้งที่๑๑/๒๕๕๕ เมื่อวันที่ ๑๕ พฤศจิกายน ๒๕๕๕และมติ อ.ก.ก. สามัญข้ารายการสามัญครั้งที่ ๑/๒๕๖๕ เมื่อวันที่ ๒๑ กุมภาพันธ์ ๒๕๖๕"; public virtual List RetirementPeriodHistorys { get; set; } = new List(); public virtual List RetirementProfiles { get; set; } = new List(); } diff --git a/BMA.EHR.Domain/Models/Retirement/RetirementPeriodHistory.cs b/BMA.EHR.Domain/Models/Retirement/RetirementPeriodHistory.cs index c090162a..de6060f6 100644 --- a/BMA.EHR.Domain/Models/Retirement/RetirementPeriodHistory.cs +++ b/BMA.EHR.Domain/Models/Retirement/RetirementPeriodHistory.cs @@ -24,7 +24,7 @@ namespace BMA.EHR.Domain.Models.Retirement [Comment("เอกสารประกาศ")] public Document? Document { get; set; } [Comment("รายละเอียดมติ อกก")] - public string Detail { get; set; } = "มาตรา ๑๖ และมาตรา ๒๑ แห่งพระราชบัญญัตบำเหน็จบำนาญข้าราชการส่วนท้องถิ่น พ.ศ.๒๕๗๗ มาตรา ๘ แห่งพระราชบัญญัติบัเหน็จบำนาญข้าราชการกรุงเทพมหานคร พ.ศ.๒๕๕๔ ประกอบกับมติ ก.ก. ครั้งที่๑๑/๒๕๕๕ เมื่อวันที่ ๑๕ พฤศจิกายน ๒๕๕๕และมติ อ.ก.ก. สามัญข้ารายการสามัญครั้งที่ ๑/๒๕๖๕ เมื่อวันที่ ๒๑ กุมภาพันธ์ ๒๕๖๕"; + public string Detail { get; set; } = "มาตรา ๑๖ และมาตรา ๒๑ แห่งพระราชบัญญัติบำเหน็จบำนาญข้าราชการส่วนท้องถิ่น พ.ศ.๒๕๗๗ มาตรา ๘ แห่งพระราชบัญญัติบำเหน็จบำนาญข้าราชการกรุงเทพมหานคร พ.ศ.๒๕๕๔ ประกอบกับมติ ก.ก. ครั้งที่๑๑/๒๕๕๕ เมื่อวันที่ ๑๕ พฤศจิกายน ๒๕๕๕และมติ อ.ก.ก. สามัญข้ารายการสามัญครั้งที่ ๑/๒๕๖๕ เมื่อวันที่ ๒๑ กุมภาพันธ์ ๒๕๖๕"; public RetirementPeriod RetirementPeriod { get; set; } } } diff --git a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs index 99245de5..59fa2d7b 100644 --- a/BMA.EHR.Report.Service/Controllers/CommandReportController.cs +++ b/BMA.EHR.Report.Service/Controllers/CommandReportController.cs @@ -54,7 +54,7 @@ namespace BMA.EHR.Report.Service.Controllers #region " C-PM-01 " - private async Task GenerateCommandReportType01_Cover(Guid commandId, string exportType) + private async Task GenerateCommandReportType01_Cover(Guid commandId, string exportType) { try { @@ -83,34 +83,40 @@ namespace BMA.EHR.Report.Service.Controllers AuthorizedPosition = raw_data.AuthorizedPosition, Subject = $"เรื่อง {raw_data.CommandSubject}", }; - - var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp"); - - ReportPackager reportPackager = new ReportPackager(); - Telerik.Reporting.Report? report = null; - using (var sourceStream = System.IO.File.OpenRead(rptFile)) + var content = new { - report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); - } - - report.DataSource = command; - - System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); - if (exportType == "docx") - deviceInfo["OutputFormat"] = "DOCX"; - - InstanceReportSource instanceReportSource = new InstanceReportSource() - { - ReportDocument = report + template = "01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1", + reportName = "01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1", + data = command }; + // var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-1.trdp"); - ReportProcessor reportProcessor = new ReportProcessor(_configuration); - RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + // ReportPackager reportPackager = new ReportPackager(); + // Telerik.Reporting.Report? report = null; + // using (var sourceStream = System.IO.File.OpenRead(rptFile)) + // { + // report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream); + // } - var content = result.DocumentBytes; + // report.DataSource = command; - return content; + // System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable(); + // if (exportType == "docx") + // deviceInfo["OutputFormat"] = "DOCX"; + + // InstanceReportSource instanceReportSource = new InstanceReportSource() + // { + // ReportDocument = report + // }; + + + // ReportProcessor reportProcessor = new ReportProcessor(_configuration); + // RenderingResult result = reportProcessor.RenderReport(exportType.ToUpper(), instanceReportSource, deviceInfo); + + // var content = result.DocumentBytes; + + return command; } catch { @@ -2640,7 +2646,14 @@ namespace BMA.EHR.Report.Service.Controllers throw new Exception(GlobalMessages.CommandNotFound); var contentData = await GenerateCommandReportType01_Cover(id, exportType); - return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); + var data = new + { + template = "Type01_Cover", + reportName = "Type01_Cover", + data = contentData + }; + return Success(data); + // return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}"); } catch { diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs index c0f700de..f48558f5 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementController.cs @@ -338,7 +338,7 @@ namespace BMA.EHR.Retirement.Service.Controllers { Round = round, TypeReport = null, - Detail = "มาตรา ๑๖ และมาตรา ๒๑ แห่งพระราชบัญญัตบำเหน็จบำนาญข้าราชการส่วนท้องถิ่น พ.ศ.๒๕๗๗ มาตรา ๘ แห่งพระราชบัญญัติบัเหน็จบำนาญข้าราชการกรุงเทพมหานคร พ.ศ.๒๕๕๔ ประกอบกับมติ ก.ก. ครั้งที่๑๑/๒๕๕๕ เมื่อวันที่ ๑๕ พฤศจิกายน ๒๕๕๕และมติ อ.ก.ก. สามัญข้ารายการสามัญครั้งที่ ๑/๒๕๖๕ เมื่อวันที่ ๒๑ กุมภาพันธ์ ๒๕๖๕", + Detail = "มาตรา ๑๖ และมาตรา ๒๑ แห่งพระราชบัญญัติบำเหน็จบำนาญข้าราชการส่วนท้องถิ่น พ.ศ.๒๕๗๗ มาตรา ๘ แห่งพระราชบัญญัติบำเหน็จบำนาญข้าราชการกรุงเทพมหานคร พ.ศ.๒๕๕๔ ประกอบกับมติ ก.ก. ครั้งที่๑๑/๒๕๕๕ เมื่อวันที่ ๑๕ พฤศจิกายน ๒๕๕๕และมติ อ.ก.ก. สามัญข้ารายการสามัญครั้งที่ ๑/๒๕๖๕ เมื่อวันที่ ๒๑ กุมภาพันธ์ ๒๕๖๕", Type = req.Type.Trim().ToUpper(), Year = req.Year, CreatedFullName = FullName ?? "System Administrator", diff --git a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs index 957d72b6..7e412955 100644 --- a/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs +++ b/BMA.EHR.Retirement.Service/Controllers/RetirementDeceasedController.cs @@ -319,7 +319,7 @@ namespace BMA.EHR.Retirement.Service.Controllers retirementDeceased.posLevelName = org.result.posLevelName; } await _context.RetirementDeceaseds.AddAsync(retirementDeceased); - await _context.SaveChangesAsync(); + //await _context.SaveChangesAsync(); var _baseAPI = _configuration["API"]; var _apiUrl = $"{_baseAPI}org/profile/leave/{req.ProfileId}"; @@ -420,7 +420,7 @@ namespace BMA.EHR.Retirement.Service.Controllers }); // } // } - await _context.SaveChangesAsync(); + //await _context.SaveChangesAsync(); return Success(); }