Merge branch 'develop' into working

This commit is contained in:
Suphonchai Phoonsawat 2024-06-29 11:37:57 +07:00
commit cdfb282c32
8 changed files with 585 additions and 87 deletions

View file

@ -200,6 +200,9 @@ namespace BMA.EHR.Application.Repositories.Commands
case "C-PM-37":
result = await GetReceiver37Async(command, token);
break;
case "C-PM-38":
result = await GetReceiver38Async(command, token);
break;
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
}
@ -2550,6 +2553,57 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
/// <summary>
/// C-PM-38
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task<List<CommandReceiver>> GetReceiver38Async(Command command, string token)
{
try
{
var resultData = new List<CommandReceiver>();
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/salary/report/command/38/{command.SalaryPeriodId}";
var response = new PassSalaryResponse();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
var req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var res = await client.SendAsync(req);
var result = await res.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject<PassSalaryResponse>(result);
var seq = 1;
foreach (var d in response!.result)
{
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = d.citizenId,
Prefix = d.prefix == null ? "" : d.prefix,
FirstName = d.firstName,
LastName = d.lastName,
RefPlacementProfileId = d.profileId == null ? null : Guid.Parse(d.profileId),
RefDisciplineId = d.id,
};
seq++;
resultData.Add(receiver);
}
}
return resultData;
}
catch
{
throw;
}
}
#endregion
#region " Execute and Deploy "
@ -2667,6 +2721,9 @@ namespace BMA.EHR.Application.Repositories.Commands
case "C-PM-37":
await ExecuteCommand37Async(command, token);
break;
case "C-PM-38":
await ExecuteCommand38Async(command, token);
break;
default: throw new Exception(GlobalMessages.MethodForCommandTypeNotImplement);
}
@ -7991,6 +8048,121 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
/// <summary>
/// C-PM-38 - คำสั่งปรับโครงสร้าง
/// </summary>
/// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns>
private async Task ExecuteCommand38Async(Command command, string token = "")
{
try
{
// var data = command.Receivers.Select(x => new
// {
// PersonId = x.RefPlacementProfileId,
// Id = x.RefDisciplineId,
// });
// var baseAPI = _configuration["API"];
// var apiUrl = $"{baseAPI}/salary/report/command/38/resume";
// using (var client = new HttpClient())
// {
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
// var req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
// var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
// var result = await res.Content.ReadAsStringAsync();
// }
// 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: ต้องเปลี่ยนเป็น 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 = recv.RefPlacementProfileId.Value,
// Payload = payload_str,
// };
// _dbContext.Set<Inbox>().Add(inbox);
// var noti = new Notification
// {
// Body = $"คุณได้รับคำสั่งยุติเรื่อง เลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
// ReceiverUserId = recv.RefPlacementProfileId.Value,
// Type = "LINK",
// Payload = payload_str,
// };
// _dbContext.Set<Notification>().Add(noti);
// await _dbContext.SaveChangesAsync();
// }
// send cc noti inbox
foreach (var cc in command.Deployments)
{
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 = Guid.Parse(cc.ReceiveUserId),
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 = Guid.Parse(cc.ReceiveUserId),
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 "
@ -8681,7 +8853,7 @@ namespace BMA.EHR.Application.Repositories.Commands
{
try
{
var command = await _dbContext.Set<Command>().Include(c => c.CommandStatus).FirstOrDefaultAsync(x => x.Id == id);
var command = await _dbContext.Set<Command>().Include(c => c.CommandType).Include(c => c.CommandStatus).FirstOrDefaultAsync(x => x.Id == id);
if (command == null)
throw new Exception(GlobalMessages.CommandNotFound);
@ -8689,7 +8861,13 @@ namespace BMA.EHR.Application.Repositories.Commands
if (!notProcess.Contains(command.CommandStatus.Sequence))
{
var nextStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(c => c.Sequence == command.CommandStatus.Sequence + 1);
var num = command.CommandStatus.Sequence + 1;
// if (command.CommandType.CommandCode == "C-PM-38" && command.CommandStatus.Sequence == 1)
// {
// num = num + 1;
// }
var nextStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(c => c.Sequence == num);
command.CommandStatus = nextStatus!;
_dbContext.Attatch(nextStatus!);
await _dbContext.SaveChangesAsync();
@ -9151,6 +9329,7 @@ namespace BMA.EHR.Application.Repositories.Commands
{
try
{
var orgIdSend = new List<Guid>() { Guid.Parse("08dc4c9f-ca39-44dd-8f93-04024aedccbe"), Guid.Parse("08dc4c9f-b4e7-47ae-8cb9-87b615151ada"), Guid.Parse("08dc4c9f-9da6-443e-8a72-30b8be40d954"), Guid.Parse("08dc4c9f-8487-4966-8ca6-11ba71d91971"), Guid.Parse("08dc4c9f-6e7e-4c75-8996-a48295978eca"), Guid.Parse("08dc4c9f-4166-4146-8460-f8af7cc8a4f1"), Guid.Parse("08dc4c9f-2710-4e98-8340-c9f2a65467db"), Guid.Parse("08dc4c9f-0ef3-4e51-805f-74766c67c1df"), Guid.Parse("08dc4c9e-f8be-4dae-89ed-30d662a29eed"), Guid.Parse("08dc4c9e-dd93-4072-8f37-482e7b91da28"), Guid.Parse("08dc4c9e-30c6-4674-8a35-4275eb70038f"), Guid.Parse("08dc4c9e-060b-4ae1-8068-bcf59b1d4642"), Guid.Parse("08dc4c9d-e7a2-4a26-84b8-655fac120ceb"), Guid.Parse("08dc4c9d-d0fe-4393-8948-d1ef0dece9e3"), Guid.Parse("08dc4c9d-b930-4be9-8428-82f802f28d99"), Guid.Parse("08dc4c9d-a10d-49ea-8484-a9646be5f6da"), Guid.Parse("08dc4c9d-8937-4432-865f-ffd3992feb25"), Guid.Parse("08dc4c9d-72f7-4f8a-8916-4b1791ca24c8"), Guid.Parse("08dc4c9d-5993-46b9-8ae8-96c4edbc163d"), Guid.Parse("08dc4c9d-291b-4761-8013-81027aac3b3d"), Guid.Parse("08dc4c9d-147d-4117-83fa-5211ca38f639"), Guid.Parse("08dc4c9b-277f-4b4e-8a60-08581ec7a2cc"), Guid.Parse("08dc4c9b-1148-4b92-8589-a94f4870102e"), Guid.Parse("08dc4c9a-f6d7-4ca3-80b0-0609375e1c76"), Guid.Parse("08dc4c9a-c587-4754-87ad-430a0e10b072"), Guid.Parse("08dc4c9a-9d74-4436-8709-33bd7aa5d5f7"), Guid.Parse("08dc4c9a-65c9-4306-80bf-f279e011f2a8"), Guid.Parse("08dc4c9a-2588-4766-8f6e-5051eb3423f5"), Guid.Parse("08dc4c99-d3f1-4640-8307-ddaaa6c3a541"), Guid.Parse("08dc4c99-bc91-41e9-87fd-9c29def6618d"), Guid.Parse("08dc4c99-9c44-4e4a-876c-59688334acd5"), Guid.Parse("08dc4c99-8170-4a65-8e20-c08845d3ea86"), Guid.Parse("08dc4c99-31b4-4027-8509-b322a173d7d3"), Guid.Parse("08dc4c99-12ca-46d7-813c-c35acc6ec7ae"), Guid.Parse("08dc4c98-f71d-472e-89a7-c9a6cb731650"), Guid.Parse("08dc4c98-dc64-4a8f-846d-342f05a49d02"), Guid.Parse("08dc4c98-c01c-47cf-83c9-7974df162e55"), Guid.Parse("08dc4c98-a219-4402-8624-00a9ad3a65cb"), Guid.Parse("08dc4c98-8739-401f-8180-65a982ee4237"), Guid.Parse("08dc4966-b6ac-4b49-85d4-2e5319d9b009"), Guid.Parse("08dc432c-2bc5-4b81-8089-9c057c51192c"), Guid.Parse("08dc4307-0adc-4bcd-8213-5479bb010236"), Guid.Parse("08dc4271-7bf5-4600-839c-6c93a35d33a6"), Guid.Parse("08dc4261-8aa8-4a85-8991-fb2ac9bcb132"), Guid.Parse("08dc3f36-8af2-4fd4-83bf-6f25126eec13"), Guid.Parse("08dc3f1a-ed56-469f-8b1e-c4fe6b30442a"), Guid.Parse("08dc3e6c-4b50-4b2e-8584-a3a0462c1b29"), Guid.Parse("08dc3e51-df19-47d9-8dd4-063fe6011eb3"), Guid.Parse("08dc3db9-257d-470d-8256-3dc24f6fa332"), Guid.Parse("08dc7bcd-7248-42ba-8f0e-d50b2f7faed7") };
var profiles = await _dbContext.Set<Profile>()
.Include(x => x.Prefix)
.Include(x => x.Gender)
@ -9175,6 +9354,7 @@ namespace BMA.EHR.Application.Repositories.Commands
// .Include(x => x.Assessments)
// .Include(x => x.Others)
// .Take(10)
.Where(x => orgIdSend.Contains(x.Id))
.ToListAsync();
var _baseAPI = _configuration["API"];
@ -9182,7 +9362,7 @@ namespace BMA.EHR.Application.Repositories.Commands
// create new profile
foreach (var profile in profiles)
{
// var apiUrl = $"{_baseAPI}/org/profile/all/dump-db";
var apiUrl = $"{_baseAPI}/org/profile/all/dump-db";
// var profileId = string.Empty;
// using (var client = new HttpClient())
// {
@ -9508,38 +9688,38 @@ namespace BMA.EHR.Application.Repositories.Commands
// }
// }
var Salaries = await _dbContext.Set<ProfileSalary>()
.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<ProfileSalary>()
// .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)
// {
@ -9616,7 +9796,7 @@ namespace BMA.EHR.Application.Repositories.Commands
// var Insignias = await _dbContext.Set<ProfileInsignia>()
// .Include(x => x.Insignia)
// .Where(x => x.Profile.Id == profile.Id)
// .Where(x => orgIdSend.Contains(x.ProfileId))
// .ToListAsync();
// if (Insignias.Count > 0)
// {
@ -9648,7 +9828,10 @@ namespace BMA.EHR.Application.Repositories.Commands
// }
// }
// if (profile.Honors.Count > 0)
// var Honor = await _dbContext.Set<ProfileHonor>()
// .Where(x => orgIdSend.Contains(x.ProfileId))
// .ToListAsync();
// if (Honor.Count > 0)
// {
// var apiUrlHonor = $"{_baseAPI}/org/profile/honor";
// using (var client = new HttpClient())

View file

@ -187,9 +187,9 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
{
try
{
var profile = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.Id == ReceiverUserId);
if (profile != null)
{
// var profile = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.Id == ReceiverUserId);
//if (profile != null)
//{
_dbContext.Set<Notification>().Add(new Notification
{
Body = Body,
@ -224,7 +224,7 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
_emailSenderService.SendMail(Subject, Body, "kittapath@frappet.com");
}
await _dbContext.SaveChangesAsync();
}
//}
}
catch
{

View file

@ -470,6 +470,18 @@ namespace BMA.EHR.Command.Service.Controllers
else
return Success(new { result = "N" });
}
case "C-PM-38":
{
if (command.CommandNo != "" &&
command.CommandYear != null &&
command.CommandExcecuteDate != null &&
cover != null)
{
return Success(new { result = "Y" });
}
else
return Success(new { result = "N" });
}
default:
{
if (command.CommandNo != "" &&
@ -4488,6 +4500,111 @@ namespace BMA.EHR.Command.Service.Controllers
#endregion
#region " C-PM-38 "
/// <summary>
/// PM7-22 : สร้างข้อมูลรายละเอียดการออกคำสั่ง C-PM-38
/// </summary>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("c-pm-38/detail")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> PostType38Async([FromBody] CreateCommandGroup15Request req)
{
try
{
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
var inserted = new Domain.Models.Commands.Core.Command
{
CommandNo = req.orderNo,
CommandYear = req.orderYear.ToString(),
CommandSubject = req.orderTitle,
CommandTypeId = req.orderTypeValue,
IssuerOrganizationId = req.orderBy,
IssuerOrganizationName = req.orderByOrganizationName,
AuthorizedUserFullName = req.signatoryBy,
AuthorizedPosition = req.signatoryPosition,
CommandAffectDate = req.orderDate,
OwnerGovId = OcId,
CaseFault = req.caseFault,
FaultLevel = req.faultLevel,
RefRaw = req.refRaw,
Result = req.result,
SalaryPeriodId = req.salaryPeriodId,
SalaryPeriod = req.salaryPeriod,
Year = req.year,
};
var result = await _repository.AddAsync(inserted);
return Success(result);
}
catch
{
throw;
}
}
/// <summary>
/// PM7-23 : แก้ไขข้อมูลรายละเอียดการออกคำสั่ง C-PM-38
/// </summary>
/// <param name="orderId">Record Id ของคำสั่ง</param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("c-pm-38/detail/{orderId}")]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> PutType38Async(Guid orderId, [FromBody] CreateCommandGroup15Request req)
{
try
{
var order = await _repository.GetByIdAsync(orderId);
if (order == null)
throw new Exception(GlobalMessages.CommandNotFound);
var commandType = await _commandTypeRepository.GetByIdAsync(req.orderTypeValue);
var status = await _commandStatusRepository.GetByIdAsync(order.CommandStatusId);
order.CommandNo = req.orderNo;
order.CommandYear = req.orderYear.ToString();
order.CommandSubject = req.orderTitle;
order.CommandType = commandType!;
order.IssuerOrganizationId = req.orderBy;
order.IssuerOrganizationName = req.orderByOrganizationName;
order.AuthorizedUserFullName = req.signatoryBy;
order.AuthorizedPosition = req.signatoryPosition;
order.CommandStatus = status!;
order.CommandAffectDate = req.orderDate;
order.CaseFault = req.caseFault;
order.FaultLevel = req.faultLevel;
order.RefRaw = req.refRaw;
order.Result = req.result;
order.SalaryPeriodId = req.salaryPeriodId;
order.SalaryPeriod = req.salaryPeriod;
order.Year = req.year;
var result = await _repository.UpdateAsync(order);
return Success(result);
}
catch
{
throw;
}
}
#endregion
#endregion
/// <summary>

View file

@ -15,8 +15,8 @@
public int orderYear { get; set; }
public string signatoryBy { get; set; } = string.Empty;
public string signatoryPosition { get; set; } = string.Empty;
public Guid salaryPeriodId { get; set; }
public string year { get; set; }
public string salaryPeriod { get; set; }
public Guid? salaryPeriodId { get; set; }
public string? year { get; set; }
public string? salaryPeriod { get; set; }
}
}

View file

@ -14,7 +14,7 @@
"AllowedHosts": "*",
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
"DefaultConnection": "server=192.168.1.61;user=root;password=adminVM123;port=4061;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
@ -42,5 +42,5 @@
"MailFrom": "saraban.csc.rd@bangkok.go.th",
"Port": "25"
},
"API": "https://bma-ehr.frappet.com/api/v1"
"API": "https://bma-ehr.frappet.synology.me/api/v1"
}

View file

@ -75,12 +75,12 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost("keycloak")]
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUserKeycloak([FromBody] NotiRequest req)
{
var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == req.ReceiverUserId);
if (profile == null)
return Error(GlobalMessages.DataNotFound);
// var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == req.ReceiverUserId);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound);
await _repositoryNoti.PushNotificationAsync(
profile.Id,
req.ReceiverUserId,
req.Subject,
req.Body,
req.Payload,

View file

@ -152,6 +152,7 @@ namespace BMA.EHR.Placement.Service.Controllers
Draft = x.Draft,
typeCommand = x.typeCommand,
IsOfficer = x.IsOfficer,
IsRelief = x.IsRelief,
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
}).OrderBy(x => x.ExamNumber).ToListAsync();
@ -202,6 +203,7 @@ namespace BMA.EHR.Placement.Service.Controllers
p.StatusId,
p.Draft,
p.typeCommand,
p.IsRelief,
p.posLevelCandidateId,
p.posTypeCandidateId,
};
@ -277,6 +279,7 @@ namespace BMA.EHR.Placement.Service.Controllers
Draft = x.Draft,
typeCommand = x.typeCommand,
IsOfficer = x.IsOfficer,
IsRelief = x.IsRelief,
posLevelCandidateId = x.PositionLevel == null ? (Guid?)null : x.PositionLevel.Id,
posTypeCandidateId = x.PositionType == null ? (Guid?)null : x.PositionType.Id,
}).OrderBy(x => x.ExamNumber).ToListAsync();
@ -327,6 +330,7 @@ namespace BMA.EHR.Placement.Service.Controllers
p.StatusId,
p.Draft,
p.typeCommand,
p.IsRelief,
p.posLevelCandidateId,
p.posTypeCandidateId,
};
@ -449,6 +453,7 @@ namespace BMA.EHR.Placement.Service.Controllers
ExamNumber = x.ExamNumber,
ExamRound = x.ExamRound,
Pass = x.Pass,
IsRelief = x.IsRelief,
IsProperty = x.IsProperty == null ? null : Newtonsoft.Json.JsonConvert.DeserializeObject<List<PersonPropertyRequest>>(x.IsProperty),
BmaOfficer = x.IsOfficer == true ? "OFFICER" : null,
PlacementProfileDocs = x.PlacementProfileDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
@ -527,6 +532,7 @@ namespace BMA.EHR.Placement.Service.Controllers
data.ExamRound,
data.Pass,
data.IsProperty,
data.IsRelief,
BmaOfficer = data.BmaOfficer,
Docs = placementProfileDocs,
};

View file

@ -122,14 +122,33 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(commandId);
if (command == null)
//var command = await _repository.GetByIdAsync(commandId);
//if (command == null)
//{
// throw new Exception(GlobalMessages.CommandNotFound);
//}
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType01AttachmentAsync(commandId);
return data;
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"01-คำสั่งบรรจุและแต่งตั้งผู้สอบแข่งขันได้-2.trdp");
//ReportPackager reportPackager = new ReportPackager();
@ -241,14 +260,33 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(commandId);
if (command == null)
//var command = await _repository.GetByIdAsync(commandId);
//if (command == null)
//{
// throw new Exception(GlobalMessages.CommandNotFound);
//}
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType02AttachmentAsync(commandId);
return data;
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"02-คำสั่งบรรจุและแต่งตั้งผู้ได้รับคัดเลือก-4.trdp");
//ReportPackager reportPackager = new ReportPackager();
@ -360,14 +398,32 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(commandId);
if (command == null)
//var command = await _repository.GetByIdAsync(commandId);
//if (command == null)
//{
// throw new Exception(GlobalMessages.CommandNotFound);
//}
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType03AttachmentAsync(commandId);
return data;
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"03-คำสั่งแต่งตั้งผู้สอบแข่งขัน.trdp");
//ReportPackager reportPackager = new ReportPackager();
@ -479,14 +535,33 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(commandId);
if (command == null)
//var command = await _repository.GetByIdAsync(commandId);
//if (command == null)
//{
// throw new Exception(GlobalMessages.CommandNotFound);
//}
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType03AttachmentAsync(commandId);
return data;
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"04-คำสั่งย้ายผู้สอบแข่งขัน.trdp");
//ReportPackager reportPackager = new ReportPackager();
@ -1035,7 +1110,8 @@ namespace BMA.EHR.Report.Service.Controllers
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType08AttachmentAsync(commandId);
return new {
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
@ -1958,14 +2034,34 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(commandId);
if (command == null)
//var command = await _repository.GetByIdAsync(commandId);
//if (command == null)
//{
// throw new Exception(GlobalMessages.CommandNotFound);
//}
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType17AttachmentAsync(commandId);
return data;
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"34-คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ-5.trdp");
//ReportPackager reportPackager = new ReportPackager();
@ -2255,6 +2351,8 @@ namespace BMA.EHR.Report.Service.Controllers
//var recvId = raw_data.Receivers.Select(x => x.RefPlacementProfileId).ToList();
//var positionList = string.Empty;
//GetCommandType21AttachmentAsync
var receiver = await _commandReportRepository.GetCommandType21AttachmentAsync(commandId);
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
@ -2270,9 +2368,18 @@ namespace BMA.EHR.Report.Service.Controllers
AuthorizedUserFullName = raw_data.AuthorizedUserFullName,
AuthorizedPosition = raw_data.AuthorizedPosition,
Subject = $"เรื่อง {raw_data.CommandSubject}",
employee = receiver,
};
return command;
//return new
//{
// CommandNo = command.CommandNo,
// CommandYear = command.CommandYear,
// IssuerOrganizationName = command.IssuerOrganizationName,
// CommandExcecuteDate = command.CommandExcecuteDate,
// data = data,
//};
//var receiver = await _commandReportRepository.GetCommandType21AttachmentAsync(commandId);
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"20-คำสั่งแต่งตั้งลูกจ้างชั่วคราวเป็นลูกจ้างประจำ-2.trdp");
@ -2387,14 +2494,32 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(commandId);
if (command == null)
//var command = await _repository.GetByIdAsync(commandId);
//if (command == null)
//{
// throw new Exception(GlobalMessages.CommandNotFound);
//}
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType22AttachmentAsync(commandId);
return data;
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ปรับระดับชั้นงาน)-แนบท้าย.trdp");
//ReportPackager reportPackager = new ReportPackager();
@ -2449,7 +2574,7 @@ namespace BMA.EHR.Report.Service.Controllers
//var recvId = raw_data.Receivers.Select(x => x.RefPlacementProfileId).ToList();
//var positionList = string.Empty;
var receiver = await _commandReportRepository.GetCommandType23AttachmentAsync(commandId);
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
@ -2465,6 +2590,7 @@ namespace BMA.EHR.Report.Service.Controllers
AuthorizedUserFullName = raw_data.AuthorizedUserFullName,
AuthorizedPosition = raw_data.AuthorizedPosition,
Subject = $"เรื่อง {raw_data.CommandSubject}",
employee = receiver
};
return command;
@ -2584,14 +2710,33 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var command = await _repository.GetByIdAsync(commandId);
if (command == null)
//var command = await _repository.GetByIdAsync(commandId);
//if (command == null)
//{
// throw new Exception(GlobalMessages.CommandNotFound);
//}
var raw_data = await _repository.GetByIdAsync(commandId);
if (raw_data == null)
{
throw new Exception(GlobalMessages.CommandNotFound);
}
var command = new
{
CommandNo = raw_data.CommandNo.ToThaiNumber(),
CommandYear = raw_data.CommandYear.ToInteger().ToThaiYear().ToString().ToThaiNumber(),
IssuerOrganizationName = raw_data.IssuerOrganizationName,
CommandExcecuteDate = raw_data.CommandExcecuteDate != null ? raw_data.CommandExcecuteDate.Value.ToThaiFullDate3().ToThaiNumber() : "-",
};
var data = await _commandReportRepository.GetCommandType24AttachmentAsync(commandId);
return data;
return new
{
CommandNo = command.CommandNo,
CommandYear = command.CommandYear,
IssuerOrganizationName = command.IssuerOrganizationName,
CommandExcecuteDate = command.CommandExcecuteDate,
data = data,
};
//var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"คำสั่งแต่งตั้งลูกจ้างประจำ(ย้าย)-แนบท้าย.trdp");
//ReportPackager reportPackager = new ReportPackager();
@ -2839,7 +2984,7 @@ namespace BMA.EHR.Report.Service.Controllers
//return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-01",
template = "C-PM-01-attachment",
reportName = "docx-report",
data = contentData
};
@ -2940,7 +3085,7 @@ namespace BMA.EHR.Report.Service.Controllers
//return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-02",
template = "C-PM-02-attachment",
reportName = "docx-report",
data = contentData
};
@ -3036,7 +3181,7 @@ namespace BMA.EHR.Report.Service.Controllers
//return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-03",
template = "C-PM-03-attachment",
reportName = "docx-report",
data = contentData
};
@ -3132,7 +3277,7 @@ namespace BMA.EHR.Report.Service.Controllers
//return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-04",
template = "C-PM-04-attachment",
reportName = "docx-report",
data = contentData
};
@ -4206,7 +4351,7 @@ namespace BMA.EHR.Report.Service.Controllers
//return File(contentData, mimeType, $"command-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-17",
template = "C-PM-17-attachment",
reportName = "docx-report",
data = contentData
};
@ -4533,7 +4678,7 @@ namespace BMA.EHR.Report.Service.Controllers
//return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-22",
template = "C-PM-22-attachment",
reportName = "docx-report",
data = contentData
};
@ -4679,7 +4824,7 @@ namespace BMA.EHR.Report.Service.Controllers
//return File(contentData, mimeType, $"command-attachment-{cmd.CommandNo}-{cmd.CommandYear.ToInteger().ToThaiYear()}.{exportType.Trim().ToLower()}");
var data = new
{
template = "C-PM-24",
template = "C-PM-24-attachment",
reportName = "docx-report",
data = contentData
};
@ -5432,6 +5577,53 @@ namespace BMA.EHR.Report.Service.Controllers
}
#endregion
#region " C-PM-38 คำสั่งปรับโครงสร้าง "
/// <summary>
/// คำสั่ง C-PM-38 คำสั่งปรับโครงสร้าง
/// </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-38/cover/{exportType}/{id}")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
public async Task<ActionResult<ResponseObject>> GetCommandType38CoverReport(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;
}
var cmd = await _repository.GetByIdAsync(id);
if (cmd == null)
throw new Exception(GlobalMessages.CommandNotFound);
var contentData = await GenerateCommandReportType33_Cover(id, exportType);
var data = new
{
template = "C-PM-38",
reportName = "docx-report",
data = contentData
};
return Success(data);
}
catch
{
throw;
}
}
#endregion
#endregion
}
}