Merge branch 'develop' into work
This commit is contained in:
commit
7546ac39e8
4 changed files with 655 additions and 0 deletions
|
|
@ -1089,6 +1089,131 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<CommandType21Response>> GetCommandType22AttachmentAsync(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 CommandType21Response
|
||||
{
|
||||
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()
|
||||
})
|
||||
.ToList();
|
||||
|
||||
return report_data;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<CommandType21Response>> GetCommandType23AttachmentAsync(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<RetirementResign>()
|
||||
.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.Profile)
|
||||
.ThenInclude(x => x.PositionEmployeePosition)
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.PositionEmployeeLevel)
|
||||
//.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 CommandType21Response
|
||||
{
|
||||
Seq = r.Sequence.ToString().ToThaiNumber(),
|
||||
CitizenId = r.CitizenId.ToThaiNumber(),
|
||||
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(),
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1661,6 +1661,12 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
case "C-PM-21":
|
||||
await ExecuteCommand21Async(command);
|
||||
break;
|
||||
case "C-PM-22":
|
||||
await ExecuteCommand22Async(command);
|
||||
break;
|
||||
case "C-PM-23":
|
||||
await ExecuteCommand23Async(command);
|
||||
break;
|
||||
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
|
||||
}
|
||||
|
||||
|
|
@ -6060,6 +6066,294 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-22 - คำสั่งจ้างและแต่งตั้งลูกจ้างประจำ
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task ExecuteCommand22Async(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)
|
||||
{
|
||||
// TODO: รอมอสเข้ามา Query แล้วแก้ไขข้อมูลทะเบียนประวัติ
|
||||
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// C-PM-23 - คำสั่งให้ลูกจ้างออกจากราชการ
|
||||
/// </summary>
|
||||
/// <param name="command">object ของรายการคำสั่ง</param>
|
||||
/// <returns></returns>
|
||||
private async Task ExecuteCommand23Async(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<RetirementResign>()
|
||||
.Include(x => x.Profile)
|
||||
.ThenInclude(x => x.Salaries)
|
||||
.ThenInclude(x => x.PositionLevel)
|
||||
|
||||
.FirstOrDefaultAsync(x => x.Id == recv.RefPlacementProfileId);
|
||||
|
||||
if (data == null)
|
||||
throw new Exception(GlobalMessages.DataNotFound);
|
||||
|
||||
data.Profile.IsActive = false;
|
||||
data.Profile.IsLeave = true;
|
||||
data.Profile.LeaveReason = "ออกจากราชการ";
|
||||
data.Profile.LeaveDate = command.CommandAffectDate;
|
||||
|
||||
var lastSarary = data.Profile.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.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()}",
|
||||
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.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");
|
||||
|
||||
|
||||
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 "
|
||||
|
|
|
|||
|
|
@ -2071,6 +2071,156 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region " C-PM-22 "
|
||||
|
||||
private async Task<byte[]> GenerateCommandReportType22_Cover(Guid commandId, string exportType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var raw_data = await _repository.GetByIdAsync(commandId);
|
||||
if (raw_data == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
}
|
||||
|
||||
//var recvId = raw_data.Receivers.Select(x => x.RefPlacementProfileId).ToList();
|
||||
//var positionList = string.Empty;
|
||||
|
||||
var command = new
|
||||
{
|
||||
CommandNo = raw_data.CommandNo.ToThaiNumber(),
|
||||
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
||||
IssuerOrganizationName = raw_data.IssuerOrganizationName,
|
||||
ConclusionRegisterNo = raw_data.ConclusionRegisterNo.ToThaiNumber(),
|
||||
ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
||||
ConclusionResultNo = raw_data.ConclusionResultNo.ToThaiNumber(),
|
||||
ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
||||
PositionList = "",
|
||||
Count = raw_data.Receivers.Count.ToString().ToThaiNumber(),
|
||||
CommandAffectDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
||||
AuthorizedUserFullName = raw_data.AuthorizedUserFullName,
|
||||
AuthorizedPosition = raw_data.AuthorizedPosition,
|
||||
Subject = $"เรื่อง {raw_data.CommandSubject}",
|
||||
};
|
||||
|
||||
|
||||
var receiver = await _commandReportRepository.GetCommandType22AttachmentAsync(commandId);
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งจ้างและแต่งตั้งลูกจ้างประจำ.trdp");
|
||||
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
|
||||
report.DataSource = command;
|
||||
|
||||
var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||||
|
||||
tblData.DataSource = receiver;
|
||||
|
||||
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 content;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " C-PM-23 "
|
||||
|
||||
private async Task<byte[]> GenerateCommandReportType23_Cover(Guid commandId, string exportType)
|
||||
{
|
||||
try
|
||||
{
|
||||
var raw_data = await _repository.GetByIdAsync(commandId);
|
||||
if (raw_data == null)
|
||||
{
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
}
|
||||
|
||||
//var recvId = raw_data.Receivers.Select(x => x.RefPlacementProfileId).ToList();
|
||||
//var positionList = string.Empty;
|
||||
|
||||
var command = new
|
||||
{
|
||||
CommandNo = raw_data.CommandNo.ToThaiNumber(),
|
||||
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
|
||||
IssuerOrganizationName = raw_data.IssuerOrganizationName,
|
||||
ConclusionRegisterNo = raw_data.ConclusionRegisterNo.ToThaiNumber(),
|
||||
ConclusionRegisterDate = raw_data.ConclusionRegisterDate == null ? "" : raw_data.ConclusionRegisterDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
||||
ConclusionResultNo = raw_data.ConclusionResultNo.ToThaiNumber(),
|
||||
ConclusionResultDate = raw_data.ConclusionResultDate == null ? "" : raw_data.ConclusionResultDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
||||
PositionList = "",
|
||||
Count = raw_data.Receivers.Count.ToString().ToThaiNumber(),
|
||||
CommandAffectDate = raw_data.CommandAffectDate == null ? "" : raw_data.CommandAffectDate.Value.ToThaiFullDate3().ToThaiNumber(),
|
||||
AuthorizedUserFullName = raw_data.AuthorizedUserFullName,
|
||||
AuthorizedPosition = raw_data.AuthorizedPosition,
|
||||
Subject = $"เรื่อง {raw_data.CommandSubject}",
|
||||
};
|
||||
|
||||
|
||||
var receiver = await _commandReportRepository.GetCommandType23AttachmentAsync(commandId);
|
||||
|
||||
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"35-คำสั่งอนุญาตให้ลูกจ้างลาออก.trdp");
|
||||
|
||||
ReportPackager reportPackager = new ReportPackager();
|
||||
Telerik.Reporting.Report? report = null;
|
||||
using (var sourceStream = System.IO.File.OpenRead(rptFile))
|
||||
{
|
||||
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
|
||||
}
|
||||
|
||||
report.DataSource = command;
|
||||
|
||||
var tblData = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["table1"];
|
||||
|
||||
tblData.DataSource = receiver;
|
||||
|
||||
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 content;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region " C-PM-01 คำสั่งบรรจุและแต่งตั้ง: สำหรับผู้สอบแข่งขันได้ "
|
||||
|
|
@ -3489,6 +3639,92 @@ namespace BMA.EHR.Report.Service.Controllers
|
|||
|
||||
#endregion
|
||||
|
||||
#region " C-PM-22 คำสั่งจ้างและแต่งตั้งลูกจ้างประจำ "
|
||||
|
||||
/// <summary>
|
||||
/// คำสั่ง C-PM-22 คำสั่งจ้างและแต่งตั้งลูกจ้างประจำ
|
||||
/// </summary>
|
||||
/// <param name="id">Record Id ของคำสั่ง</param>
|
||||
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("c-pm-22/cover/{exportType}/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandType22CoverReportAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
var mimeType = "";
|
||||
switch (exportType.Trim().ToLower())
|
||||
{
|
||||
case "pdf": mimeType = "application/pdf"; break;
|
||||
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
||||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
}
|
||||
|
||||
var cmd = await _repository.GetByIdAsync(id);
|
||||
if (cmd == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
var contentData = await GenerateCommandReportType22_Cover(id, exportType);
|
||||
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region " C-PM-23 คำสั่งให้ลูกจ้างออกจากราชการ "
|
||||
|
||||
/// <summary>
|
||||
/// คำสั่ง C-PM-23 คำสั่งให้ลูกจ้างออกจากราชการ
|
||||
/// </summary>
|
||||
/// <param name="id">Record Id ของคำสั่ง</param>
|
||||
/// <param name="exportType">pdf, docx หรือ xlsx</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("c-pm-23/cover/{exportType}/{id}")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetCommandType23CoverReportAsync(Guid id, string exportType = "pdf")
|
||||
{
|
||||
try
|
||||
{
|
||||
var mimeType = "";
|
||||
switch (exportType.Trim().ToLower())
|
||||
{
|
||||
case "pdf": mimeType = "application/pdf"; break;
|
||||
case "docx": mimeType = "application/vnd.openxmlformats-officedocument.wordprocessingml.document"; break;
|
||||
case "xlsx": mimeType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"; break;
|
||||
}
|
||||
|
||||
var cmd = await _repository.GetByIdAsync(id);
|
||||
if (cmd == null)
|
||||
throw new Exception(GlobalMessages.CommandNotFound);
|
||||
|
||||
var contentData = await GenerateCommandReportType23_Cover(id, exportType);
|
||||
return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue