diff --git a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
index 814ea9ce..2f7d9c4e 100644
--- a/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
+++ b/BMA.EHR.Application/Repositories/Commands/CommandRepository.cs
@@ -1467,6 +1467,9 @@ namespace BMA.EHR.Application.Repositories.Commands
case "C-PM-12":
await ExecuteCommand12Async(command);
break;
+ case "C-PM-13":
+ await ExecuteCommand13Async(command);
+ break;
case "C-PM-15":
await ExecuteCommand15Async(command);
break;
@@ -2185,7 +2188,168 @@ namespace BMA.EHR.Application.Repositories.Commands
}
///
- /// C-PM-12 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
+ /// C-PM-12 - คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
+ ///
+ /// object ของรายการคำสั่ง
+ ///
+ private async Task ExecuteCommand12Async(Command command)
+ {
+ try
+ {
+ foreach (var recv in command.Receivers)
+ {
+ var data = await _dbContext.Set()
+ .Include(x => x.Salaries)
+ .ThenInclude(x => x.PositionLevel)
+ .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
+
+ if (data == null)
+ throw new Exception(GlobalMessages.DataNotFound);
+
+ data.IsActive = false;
+ data.IsLeave = true;
+ data.LeaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด";
+ data.LeaveDate = command.CommandAffectDate;
+
+ var lastSarary = data.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
+ var order = 1;
+ if (lastSarary.Order != null)
+ order = lastSarary.Order.Value + 1;
+
+ var salary = new ProfileSalary
+ {
+ Order = order,
+ Date = command.CommandAffectDate,
+ Amount = lastSarary.Amount,
+ PositionSalaryAmount = lastSarary.PositionSalaryAmount,
+ MouthSalaryAmount = lastSarary.MouthSalaryAmount,
+ SalaryClass = "",
+ SalaryRef = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {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 ?? "",
+
+ };
+
+ if (lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
+ if (lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
+
+ data.Salaries.Add(salary);
+
+ // update placementstatus
+ //data.Status = "DONE";
+
+ await _dbContext.SaveChangesAsync();
+
+ // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
+ // Send noti inbox and email
+ var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ var body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ _emailSenderService.SendMail(subject, body, "dev@frappet.com");
+
+
+ var inbox = new Inbox
+ {
+ Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ ReceiverUserId = data.Id,
+ Payload = "",
+ };
+ _dbContext.Set().Add(inbox);
+
+ var noti = new Notification
+ {
+ Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ ReceiverUserId = data.Id,
+ Type = "",
+ Payload = "",
+ };
+ _dbContext.Set().Add(noti);
+ await _dbContext.SaveChangesAsync();
+ }
+
+ // send cc noti inbox
+ foreach (var cc in command.Deployments)
+ {
+ var pf = await _dbContext.Set().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
+ if (pf != null)
+ {
+ if (cc.IsSendInbox)
+ {
+ var inbox = new Inbox
+ {
+ Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ Body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ ReceiverUserId = pf.Id,
+ Payload = "",
+ };
+ _dbContext.Set().Add(inbox);
+ }
+
+ if (cc.IsSendMail)
+ {
+ // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
+ // Send noti inbox and email
+ var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ var body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
+ _emailSenderService.SendMail(subject, body, "dev@frappet.com");
+ }
+
+
+ var noti = new Notification
+ {
+ Body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
+ ReceiverUserId = pf.Id,
+ Type = "",
+ Payload = "",
+ };
+ _dbContext.Set().Add(noti);
+ }
+ }
+
+ // change command status
+ var cmdStatus = await _dbContext.Set().FirstOrDefaultAsync(x => x.Sequence == 5);
+ command.CommandStatusId = cmdStatus!.Id;
+
+ await _dbContext.SaveChangesAsync();
+ }
+ catch
+ {
+ throw;
+ }
+ }
+
+ ///
+ /// C-PM-13 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
///
/// object ของรายการคำสั่ง
///
@@ -2345,168 +2509,7 @@ namespace BMA.EHR.Application.Repositories.Commands
{
throw;
}
- }
-
- ///
- /// C-PM-13 - คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
- ///
- /// object ของรายการคำสั่ง
- ///
- private async Task ExecuteCommand12Async(Command command)
- {
- try
- {
- foreach (var recv in command.Receivers)
- {
- var data = await _dbContext.Set()
- .Include(x => x.Salaries)
- .ThenInclude(x => x.PositionLevel)
- .FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
-
- if (data == null)
- throw new Exception(GlobalMessages.DataNotFound);
-
- data.IsActive = false;
- data.IsLeave = true;
- data.LeaveReason = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด";
- data.LeaveDate = command.CommandAffectDate;
-
- var lastSarary = data.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
- var order = 1;
- if (lastSarary.Order != null)
- order = lastSarary.Order.Value + 1;
-
- var salary = new ProfileSalary
- {
- Order = order,
- Date = command.CommandAffectDate,
- Amount = lastSarary.Amount,
- PositionSalaryAmount = lastSarary.PositionSalaryAmount,
- MouthSalaryAmount = lastSarary.MouthSalaryAmount,
- SalaryClass = "",
- SalaryRef = "คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear} ลงวันที่ {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 ?? "",
-
- };
-
- if (lastSarary.PositionPathSideId != null) salary.PositionPathSideId = lastSarary.PositionPathSideId;
- if (lastSarary.PositionExecutiveSideId != null) salary.PositionExecutiveSideId = lastSarary.PositionExecutiveSideId;
-
- data.Salaries.Add(salary);
-
- // update placementstatus
- //data.Status = "DONE";
-
- await _dbContext.SaveChangesAsync();
-
- // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
- // Send noti inbox and email
- var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
- var body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
- _emailSenderService.SendMail(subject, body, "dev@frappet.com");
-
-
- var inbox = new Inbox
- {
- Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- ReceiverUserId = data.Id,
- Payload = "",
- };
- _dbContext.Set().Add(inbox);
-
- var noti = new Notification
- {
- Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- ReceiverUserId = data.Id,
- Type = "",
- Payload = "",
- };
- _dbContext.Set().Add(noti);
- await _dbContext.SaveChangesAsync();
- }
-
- // send cc noti inbox
- foreach (var cc in command.Deployments)
- {
- var pf = await _dbContext.Set().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
- if (pf != null)
- {
- if (cc.IsSendInbox)
- {
- var inbox = new Inbox
- {
- Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- Body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- ReceiverUserId = pf.Id,
- Payload = "",
- };
- _dbContext.Set().Add(inbox);
- }
-
- if (cc.IsSendMail)
- {
- // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
- // Send noti inbox and email
- var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
- var body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
- _emailSenderService.SendMail(subject, body, "dev@frappet.com");
- }
-
-
- var noti = new Notification
- {
- Body = $"คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
- ReceiverUserId = pf.Id,
- Type = "",
- Payload = "",
- };
- _dbContext.Set().Add(noti);
- }
- }
-
- // change command status
- var cmdStatus = await _dbContext.Set().FirstOrDefaultAsync(x => x.Sequence == 5);
- command.CommandStatusId = cmdStatus!.Id;
-
- await _dbContext.SaveChangesAsync();
- }
- catch
- {
- throw;
- }
- }
+ }
///
/// C-PM-15 - คำสั่งให้ช่วยราชการ