command
This commit is contained in:
parent
d887503b51
commit
ce377aaba5
1 changed files with 166 additions and 163 deletions
|
|
@ -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
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-12 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
|
||||
/// C-PM-12 - คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task ExecuteCommand12Async(Command command)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var recv in command.Receivers)
|
||||
{
|
||||
var data = await _dbContext.Set<Profile>()
|
||||
.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<Inbox>().Add(inbox);
|
||||
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
|
||||
ReceiverUserId = data.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// send cc noti inbox
|
||||
foreach (var cc in command.Deployments)
|
||||
{
|
||||
var pf = await _dbContext.Set<Profile>().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<Inbox>().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<Notification>().Add(noti);
|
||||
}
|
||||
}
|
||||
|
||||
// change command status
|
||||
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
|
||||
command.CommandStatusId = cmdStatus!.Id;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-13 - คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
|
|
@ -2345,168 +2509,7 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-13 - คำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task ExecuteCommand12Async(Command command)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var recv in command.Receivers)
|
||||
{
|
||||
var data = await _dbContext.Set<Profile>()
|
||||
.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<Inbox>().Add(inbox);
|
||||
|
||||
var noti = new Notification
|
||||
{
|
||||
Body = $"คุณได้รับคำสั่งให้ข้าราชการออกจากราชการเพราะผลการทดลองปฏิบัติหน้าที่ราชการต่ำกว่ามาตรฐานที่กำหนด เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
|
||||
ReceiverUserId = data.Id,
|
||||
Type = "",
|
||||
Payload = "",
|
||||
};
|
||||
_dbContext.Set<Notification>().Add(noti);
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
|
||||
// send cc noti inbox
|
||||
foreach (var cc in command.Deployments)
|
||||
{
|
||||
var pf = await _dbContext.Set<Profile>().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<Inbox>().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<Notification>().Add(noti);
|
||||
}
|
||||
}
|
||||
|
||||
// change command status
|
||||
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
|
||||
command.CommandStatusId = cmdStatus!.Id;
|
||||
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-15 - คำสั่งให้ช่วยราชการ
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue