ออกคำสั่ง 22 24

This commit is contained in:
Kittapath 2023-10-30 20:36:53 +07:00
parent cbabad68a9
commit cc711146c5
9 changed files with 634 additions and 42 deletions

View file

@ -1089,7 +1089,7 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
public async Task<List<CommandType21Response>> GetCommandType22AttachmentAsync(Guid id)
public async Task<List<CommandType22Response>> GetCommandType22AttachmentAsync(Guid id)
{
try
{
@ -1124,19 +1124,21 @@ namespace BMA.EHR.Application.Repositories.Commands
.ThenInclude(x => x.PositionEmployeeLevel)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType21Response
select new CommandType22Response
{
Seq = r.Sequence.ToString().ToThaiNumber(),
CitizenId = r.CitizenId.ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Organization = p.OrgEmployee == null || p.OrgEmployee!.OrganizationAgency == null || p.OrgEmployee!.OrganizationAgency!.OrganizationOrganization == null ? "" : p.OrgEmployee!.OrganizationAgency!.OrganizationOrganization!.Name,
PositionName = p.OrgEmployee.PositionEmployeePosition == null ? "" : p.OrgEmployee.PositionEmployeePosition.Name.ToThaiNumber(),
PositionLevel = p.OrgEmployee.OrganizationPositionEmployeeLevels == null ? "" : p.OrgEmployee.OrganizationPositionEmployeeLevels.First().PositionEmployeeLevel.Name.ToThaiNumber(),
PositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name.ToThaiNumber(),
PositionNumber = p.OrgEmployee.PosNo == null ? "" : p.OrgEmployee.PosNo.ToThaiNumber(),
Salary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
RetireDate = p.Profile.BirthDate.CalculateRetireDate().ToThaiFullDate3().ToThaiNumber(),
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber()
Organization = p.OrganizationPositionOld,
OldPositionName = p.OrganizationPositionOld,
OldPositionLevel = p.PositionLevelOld,
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.OrgEmployee == null || p.OrgEmployee.PositionEmployeePosition == null ? "" : p.OrgEmployee.PositionEmployeePosition.Name,
NewPositionLevel = p.OrgEmployee == null || p.OrgEmployee.OrganizationPositionEmployeeLevels == null || p.OrgEmployee.OrganizationPositionEmployeeLevels.Count() == 0 ? "" : p.OrgEmployee.OrganizationPositionEmployeeLevels.FirstOrDefault().PositionEmployeeLevel.Name,
NewPositionNumber = p.OrgEmployee == null || p.OrgEmployee.PosNo == null ? "" : p.OrgEmployee.PosNo.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
})
.ToList();
@ -1196,13 +1198,74 @@ namespace BMA.EHR.Application.Repositories.Commands
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Organization = p.OrganizationPositionOld ?? "",
PositionName = p.Profile.PositionEmployeePosition == null ? "" : p.Profile.PositionEmployeePosition.Name.ToThaiNumber(),
PositionLevel = p.PositionLevelOld == null ? "" :p.PositionLevelOld.ToThaiNumber(),
PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(),
PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld.ToThaiNumber(),
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
RetireDate = p.ActiveDate.Value.ToThaiFullDate3().ToThaiNumber(),
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
})
.ToList();
return report_data;
}
catch
{
throw;
}
}
public async Task<List<CommandType22Response>> GetCommandType24AttachmentAsync(Guid id)
{
try
{
var raw_data = await _dbContext.Set<CommandReceiver>()
.Include(c => c.Command)
.Where(c => c.Command.Id == id)
.ToListAsync();
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementAppointment>()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionType)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationAgency)
.ThenInclude(x => x.OrganizationOrganization)
//.Include(x => x.OrgEmployee)
//.ThenInclude(x => x.PosNo)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.PositionEmployeePosition)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationPositionEmployeeLevels)
.ThenInclude(x => x.PositionEmployeeLevel)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType22Response
{
Seq = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Organization = p.OrganizationPositionOld,
OldPositionName = p.OrganizationPositionOld,
OldPositionLevel = p.PositionLevelOld,
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.OrgEmployee == null || p.OrgEmployee.PositionEmployeePosition == null ? "" : p.OrgEmployee.PositionEmployeePosition.Name,
NewPositionLevel = p.OrgEmployee == null || p.OrgEmployee.OrganizationPositionEmployeeLevels == null || p.OrgEmployee.OrganizationPositionEmployeeLevels.Count() == 0 ? "" : p.OrgEmployee.OrganizationPositionEmployeeLevels.FirstOrDefault().PositionEmployeeLevel.Name,
NewPositionNumber = p.OrgEmployee == null || p.OrgEmployee.PosNo == null ? "" : p.OrgEmployee.PosNo.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
})
.ToList();

View file

@ -1734,6 +1734,9 @@ namespace BMA.EHR.Application.Repositories.Commands
case "C-PM-23":
await ExecuteCommand23Async(command);
break;
case "C-PM-24":
await ExecuteCommand24Async(command);
break;
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
}
@ -6378,7 +6381,7 @@ namespace BMA.EHR.Application.Repositories.Commands
}
/// <summary>
/// C-PM-22 - คำสั่งจ้างและแต่งตั้งลูกจ้างประจำ
/// C-PM-22 - คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน)
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
@ -6404,7 +6407,6 @@ namespace BMA.EHR.Application.Repositories.Commands
foreach (var recv in command.Receivers)
{
// TODO: รอมอสเข้ามา Query แล้วแก้ไขข้อมูลทะเบียนประวัติ
var data = await _dbContext.Set<PlacementAppointment>()
.Include(x => x.PositionEmployeeLine)
.Include(x => x.PositionEmployeePosition)
@ -6415,19 +6417,32 @@ namespace BMA.EHR.Application.Repositories.Commands
.ThenInclude(x => x.PositionEmployeeLine)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionEmployeePosition)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionEmployeeLevel)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationShortName)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationOrganization)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.Organization)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.PositionEmployeePosition)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationPositionEmployeeLevels)
.ThenInclude(x => x.PositionEmployeeLevel)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.PositionEmployeeLine)
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
data.Profile.EmployeeClass = "perm"; // ลจ ประจำ
data.Profile.PositionEmployeeLine = data.PositionEmployeeLine;
data.Profile.PositionEmployeePosition = data.PositionEmployeePosition;
// data.Profile.PositionEmployeeLine = data.PositionEmployeeLine;
// data.Profile.PositionEmployeePosition = data.PositionEmployeePosition;
data.Profile.PositionEmployeePosition = data.OrgEmployee == null ? null : data.OrgEmployee!.PositionEmployeePosition;
// data.Profile.PositionEmployeePositionSide = data.OrgEmployee == null ? null : data.OrgEmployee!.po;
data.Profile.PositionEmployeeLevel = data.OrgEmployee == null || data.OrgEmployee.OrganizationPositionEmployeeLevels == null || data.OrgEmployee.OrganizationPositionEmployeeLevels.Count() == 0 ? null : data.OrgEmployee!.OrganizationPositionEmployeeLevels.FirstOrDefault().PositionEmployeeLevel;
// data.Profile.PositionEmployeeGroup = data.OrgEmployee == null ? null : data.OrgEmployee!.gr;
data.Profile.PositionEmployeeLine = data.OrgEmployee == null ? null : data.OrgEmployee!.PositionEmployeeLine;
data.Profile.OrganizationShortNameId = data.OrgEmployee == null || data.OrgEmployee!.OrganizationShortName == null ? null : data.OrgEmployee!.OrganizationShortName!.Id;
data.Profile.OrganizationShortName = data.OrgEmployee == null || data.OrgEmployee!.OrganizationShortName == null ? null : data.OrgEmployee!.OrganizationShortName!.Name;
data.Profile.OrganizationOrganizationId = data.OrgEmployee == null || data.OrgEmployee!.OrganizationOrganization == null ? null : data.OrgEmployee!.OrganizationOrganization!.Id;
@ -6449,7 +6464,7 @@ namespace BMA.EHR.Application.Repositories.Commands
PositionSalaryAmount = recv.PositionSalaryAmount,
MouthSalaryAmount = recv.MouthSalaryAmount,
SalaryClass = "",
SalaryRef = "คำสั่งจ้างและแต่งตั้งลูกจ้างประจำ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
SalaryRef = "คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
//OcId = lastSarary.OcId,
//PositionLevel = lastSarary.PositionLevel,
//PositionLineId = lastSarary.PositionLineId,
@ -6460,10 +6475,10 @@ namespace BMA.EHR.Application.Repositories.Commands
RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
//PositionEmployeeGroupId = null,
//PositionEmployeeLevelId = null,
//PositionEmployeePositionId = null,
PositionEmployeeLevelId = data.Profile.PositionEmployeeLevel == null ? null : data.Profile.PositionEmployeeLevel.Id,
PositionEmployeePositionId = data.Profile.PositionEmployeePosition == null ? null : data.Profile.PositionEmployeePosition.Id,
//PositionEmployeePositionSideId = null,
//PosNoEmployee = "",
PosNoEmployee = data.Profile.PosNoEmployee,
////PositionPathSideId = lastSarary.PositionPathSideId == null,
//PositionExecutiveId = lastSarary.PositionExecutiveId,
////PositionExecutiveSideId = lastSarary.PositionExecutiveSideId,
@ -6483,7 +6498,7 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
var body = $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com");
@ -6520,7 +6535,7 @@ namespace BMA.EHR.Application.Repositories.Commands
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()}",
Body = $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Payload = payload_str,
};
@ -6532,14 +6547,14 @@ namespace BMA.EHR.Application.Repositories.Commands
// 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()}";
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()}",
Body = $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน) คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id,
Type = "LINK",
Payload = payload_str,
@ -6740,6 +6755,201 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
/// <summary>
/// C-PM-24 - คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย)
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task ExecuteCommand24Async(Command command)
{
try
{
// create command payload
var payload_attach = command.Documents
.Select(x => new PayloadAttachment
{
name = x.Category == "cover" ? "สำเนาคำสั่ง" : "สำเนาเอกสารแนบท้าย",
url = $"{_configuration["API"]}/order/download/attachment/{x.Document.Id}"
})
.ToList();
var payload = new CommandPayload()
{
attachments = payload_attach
};
var payload_str = JsonConvert.SerializeObject(payload);
foreach (var recv in command.Receivers)
{
var data = await _dbContext.Set<PlacementAppointment>()
.Include(x => x.PositionEmployeeLine)
.Include(x => x.PositionEmployeePosition)
.Include(x => x.Profile)
.ThenInclude(x => x.Salaries)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionEmployeeLine)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionEmployeePosition)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionEmployeeLevel)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationShortName)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationOrganization)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.Organization)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.PositionEmployeePosition)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationPositionEmployeeLevels)
.ThenInclude(x => x.PositionEmployeeLevel)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.PositionEmployeeLine)
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
// data.Profile.PositionEmployeeLine = data.PositionEmployeeLine;
// data.Profile.PositionEmployeePosition = data.PositionEmployeePosition;
data.Profile.PositionEmployeePosition = data.OrgEmployee == null ? null : data.OrgEmployee!.PositionEmployeePosition;
// data.Profile.PositionEmployeePositionSide = data.OrgEmployee == null ? null : data.OrgEmployee!.po;
data.Profile.PositionEmployeeLevel = data.OrgEmployee == null || data.OrgEmployee.OrganizationPositionEmployeeLevels == null || data.OrgEmployee.OrganizationPositionEmployeeLevels.Count() == 0 ? null : data.OrgEmployee!.OrganizationPositionEmployeeLevels.FirstOrDefault().PositionEmployeeLevel;
// data.Profile.PositionEmployeeGroup = data.OrgEmployee == null ? null : data.OrgEmployee!.gr;
data.Profile.PositionEmployeeLine = data.OrgEmployee == null ? null : data.OrgEmployee!.PositionEmployeeLine;
data.Profile.OrganizationShortNameId = data.OrgEmployee == null || data.OrgEmployee!.OrganizationShortName == null ? null : data.OrgEmployee!.OrganizationShortName!.Id;
data.Profile.OrganizationShortName = data.OrgEmployee == null || data.OrgEmployee!.OrganizationShortName == null ? null : data.OrgEmployee!.OrganizationShortName!.Name;
data.Profile.OrganizationOrganizationId = data.OrgEmployee == null || data.OrgEmployee!.OrganizationOrganization == null ? null : data.OrgEmployee!.OrganizationOrganization!.Id;
data.Profile.OrganizationOrganization = data.OrgEmployee == null || data.OrgEmployee!.OrganizationOrganization == null ? null : data.OrgEmployee!.OrganizationOrganization!.Name;
data.Profile.PosNoEmployee = data.OrgEmployee == null ? null : data.OrgEmployee!.PosNo;
data.Profile.OcId = data.OrgEmployee == null || data.OrgEmployee!.Organization == null ? null : data.OrgEmployee!.Organization!.Id;
data.Profile.Oc = data.OrgEmployee == null || data.OrgEmployee!.Organization == null ? null : _organizationCommonRepository.GetOrganizationNameFullPath(data.OrgEmployee!.Organization!.Id, false, false, "/");
var lastSarary = data.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault();
var order = 1;
if (lastSarary != null && lastSarary.Order != null)
order = lastSarary.Order.Value + 1;
var salary = new ProfileSalary
{
Order = order,
Date = command.CommandAffectDate,
Amount = recv.Amount,
PositionSalaryAmount = recv.PositionSalaryAmount,
MouthSalaryAmount = recv.MouthSalaryAmount,
SalaryClass = "",
SalaryRef = "คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย) คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
//OcId = lastSarary.OcId,
//PositionLevel = lastSarary.PositionLevel,
//PositionLineId = lastSarary.PositionLineId,
//PositionTypeId = lastSarary.PositionTypeId,
//OrganizationShortNameId = lastSarary.OrganizationShortNameId,
//PosNoId = lastSarary.PosNoId,
CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
//PositionEmployeeGroupId = null,
PositionEmployeeLevelId = data.Profile.PositionEmployeeLevel == null ? null : data.Profile.PositionEmployeeLevel.Id,
PositionEmployeePositionId = data.Profile.PositionEmployeePosition == null ? null : data.Profile.PositionEmployeePosition.Id,
//PositionEmployeePositionSideId = null,
PosNoEmployee = data.Profile.PosNoEmployee,
////PositionPathSideId = lastSarary.PositionPathSideId == null,
//PositionExecutiveId = lastSarary.PositionExecutiveId,
////PositionExecutiveSideId = lastSarary.PositionExecutiveSideId,
IsActive = true,
CreatedAt = DateTime.Now,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
};
data.Profile.Salaries.Add(salary);
// update placementstatus
data.Status = "DONE";
await _dbContext.SaveChangesAsync();
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email
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");
// รอเอาข้อมูลที่ได้มาส่ง inbox noti ให้ผู้รับคำสั่ง
//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 = data.Profile.Id,
// Payload = payload_str,
//};
//_dbContext.Set<Inbox>().Add(inbox);
//var noti = new Notification
//{
// Body = $"คุณได้รับคำสั่งจ้างและแต่งตั้งลูกจ้างประจำ เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = data.Profile.Id,
// Type = "LINK",
// Payload = payload_str,
//};
//_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 = payload_str,
};
_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 = "LINK",
Payload = payload_str,
};
_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;
}
}
#endregion
#region " Regenerate Json File "

View file

@ -0,0 +1,20 @@
namespace BMA.EHR.Application.Responses.Reports
{
public class CommandType22Response
{
public string? Seq { get; set; } = string.Empty;
// public string CitizenId { get; set; } = string.Empty;
public string? FullName { get; set; } = string.Empty;
public string? Organization { get; set; } = string.Empty;
public string? OldPositionName { get; set; } = string.Empty;
public string? OldPositionLevel { get; set; } = string.Empty;
public string? OldPositionNumber { get; set; } = string.Empty;
public string? OldSalary { get; set; } = "";
// public string NewOc { get; set; } = string.Empty;
public string? NewPositionName { get; set; } = string.Empty;
public string? NewPositionLevel { get; set; } = string.Empty;
public string? NewPositionNumber { get; set; } = string.Empty;
public string? NewSalary { get; set; } = "";
public string? Reason { get; set; } = string.Empty;
}
}