Merge branch 'develop' into working
This commit is contained in:
commit
15cb83db64
30 changed files with 4684 additions and 57 deletions
|
|
@ -233,6 +233,54 @@ namespace BMA.EHR.Application.Repositories.MessageQueue
|
|||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task PushNotificationsAsync(Guid[] ReceiverUserIds, string Subject, string Body, string Payload = "", bool IsSendInbox = false, bool IsSendMail = false)
|
||||
{
|
||||
try
|
||||
{
|
||||
foreach (var ReceiverUserId in ReceiverUserIds)
|
||||
{
|
||||
_dbContext.Set<Notification>().Add(new Notification
|
||||
{
|
||||
Body = Body,
|
||||
ReceiverUserId = ReceiverUserId,
|
||||
Type = "",
|
||||
Payload = Payload,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
if (IsSendInbox == true)
|
||||
{
|
||||
_dbContext.Set<Inbox>().Add(new Inbox
|
||||
{
|
||||
Subject = Subject,
|
||||
Body = Body,
|
||||
ReceiverUserId = ReceiverUserId,
|
||||
Payload = Payload,
|
||||
CreatedFullName = FullName ?? "System Administrator",
|
||||
CreatedUserId = UserId ?? "",
|
||||
CreatedAt = DateTime.Now,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
});
|
||||
}
|
||||
if (IsSendMail == true)
|
||||
{
|
||||
_emailSenderService.SendMail(Subject, Body, "kittapath@frappet.com");
|
||||
}
|
||||
}
|
||||
await _dbContext.SaveChangesAsync();
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
public async Task PushNotificationAsyncV2(string? ReceiverUserId, string Subject, string Body, string Payload = "", bool IsSendInbox = false, bool IsSendMail = false)
|
||||
{
|
||||
try
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@ using BMA.EHR.Application.Repositories;
|
|||
using BMA.EHR.Application.Repositories.Commands;
|
||||
using BMA.EHR.Application.Requests.Commands;
|
||||
using BMA.EHR.Application.Responses;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Command.Service.Requests;
|
||||
using BMA.EHR.Command.Service.Responses;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Commands.Core;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -16,11 +16,11 @@ using Microsoft.AspNetCore.Authorization;
|
|||
using Microsoft.AspNetCore.Mvc;
|
||||
using Newtonsoft.Json;
|
||||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Net;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using BMA.EHR.Application.Responses.Reports;
|
||||
|
||||
namespace BMA.EHR.Command.Service.Controllers
|
||||
{
|
||||
|
|
|
|||
26
BMA.EHR.Command.Service/Requests/ReportAttachmentRequest.cs
Normal file
26
BMA.EHR.Command.Service/Requests/ReportAttachmentRequest.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Command.Service.Requests
|
||||
{
|
||||
public class ReportAttachmentRequest
|
||||
{
|
||||
public ReportAttachmentRequestObj[] refIds { get; set; }
|
||||
}
|
||||
public class ReportAttachmentRequestObj
|
||||
{
|
||||
public string? refId { get; set; }
|
||||
public int? Sequence { get; set; }
|
||||
public string? CitizenId { get; set; }
|
||||
public string? Prefix { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public double? Amount { get; set; }
|
||||
public double? PositionSalaryAmount { get; set; }
|
||||
public double? MouthSalaryAmount { get; set; }
|
||||
public string? RemarkHorizontal { get; set; }
|
||||
public string? RemarkVertical { get; set; }
|
||||
public int CommandYear { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
21
BMA.EHR.Command.Service/Requests/ReportExecuteRequest.cs
Normal file
21
BMA.EHR.Command.Service/Requests/ReportExecuteRequest.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Command.Service.Requests
|
||||
{
|
||||
public class ReportExecuteRequest
|
||||
{
|
||||
public ReportExecuteRequestObj[] refIds { get; set; }
|
||||
}
|
||||
public class ReportExecuteRequestObj
|
||||
{
|
||||
public string? refId { get; set; }
|
||||
public DateTime commandAffectDate { get; set; }
|
||||
public string? commandNo { get; set; }
|
||||
public int commandYear { get; set; }
|
||||
public string? templateDoc { get; set; }
|
||||
public double? amount { get; set; }
|
||||
public double? positionSalaryAmount { get; set; }
|
||||
public double? mouthSalaryAmount { get; set; }
|
||||
}
|
||||
}
|
||||
10
BMA.EHR.Command.Service/Requests/ReportPersonRequest.cs
Normal file
10
BMA.EHR.Command.Service/Requests/ReportPersonRequest.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Command.Service.Requests
|
||||
{
|
||||
public class ReportPersonRequest
|
||||
{
|
||||
public string[] refIds { get; set; }
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -86,7 +86,7 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
|
|||
Prefix = x.Prefix,
|
||||
FirstName = x.FirstName,
|
||||
LastName = x.LastName,
|
||||
|
||||
ProfileId = x.PersonId,
|
||||
Organization = x.Organization,
|
||||
root = x.root,
|
||||
rootId = x.rootId,
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace BMA.EHR.Discipline.Service.Requests
|
|||
public class DisciplineDataResponse
|
||||
{
|
||||
public Guid id { get; set; } = Guid.Empty;
|
||||
public Guid personId { get; set; } = Guid.Empty;
|
||||
// public Guid personId { get; set; } = Guid.Empty;
|
||||
public Guid? commandId { get; set; } = Guid.Empty;
|
||||
|
||||
public DateTime? commandAffectDate { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
{
|
||||
public class ReportAttachmentRequest
|
||||
{
|
||||
public ReportAttachmentRequestObj[] refIds { get; set; }
|
||||
}
|
||||
public class ReportAttachmentRequestObj
|
||||
{
|
||||
public string? refId { get; set; }
|
||||
public int? Sequence { get; set; }
|
||||
public string? CitizenId { get; set; }
|
||||
public string? Prefix { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public double? Amount { get; set; }
|
||||
public double? PositionSalaryAmount { get; set; }
|
||||
public double? MouthSalaryAmount { get; set; }
|
||||
public string? RemarkHorizontal { get; set; }
|
||||
public string? RemarkVertical { get; set; }
|
||||
public int CommandYear { get; set; }
|
||||
}
|
||||
}
|
||||
21
BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs
Normal file
21
BMA.EHR.Discipline.Service/Requests/ReportExecuteRequest.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
{
|
||||
public class ReportExecuteRequest
|
||||
{
|
||||
public ReportExecuteRequestObj[] refIds { get; set; }
|
||||
}
|
||||
public class ReportExecuteRequestObj
|
||||
{
|
||||
public string? refId { get; set; }
|
||||
public DateTime commandAffectDate { get; set; }
|
||||
public string? commandNo { get; set; }
|
||||
public int commandYear { get; set; }
|
||||
public string? templateDoc { get; set; }
|
||||
public double? amount { get; set; }
|
||||
public double? positionSalaryAmount { get; set; }
|
||||
public double? mouthSalaryAmount { get; set; }
|
||||
}
|
||||
}
|
||||
10
BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs
Normal file
10
BMA.EHR.Discipline.Service/Requests/ReportPersonRequest.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Discipline.Service.Requests
|
||||
{
|
||||
public class ReportPersonRequest
|
||||
{
|
||||
public string[] refIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -2028,7 +2028,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
[HttpPut("note/doc/{insigniaNoteId:length(36)}")]
|
||||
public async Task<ActionResult<ResponseObject>> AddDocumentProfile([FromForm] InsigniaNoteDocRequest req, Guid insigniaNoteId)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_RECORD");
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_RECORD");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
|
|
@ -2297,7 +2297,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
[HttpPut("preview/receice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
|
||||
public async Task<ActionResult<ResponseObject>> PreviewReceiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_RECORD");
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_RECORD");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
|
|
@ -2429,7 +2429,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
[HttpPut("preview/invoice/{insigniaNoteId:length(36)}"), DisableRequestSizeLimit]
|
||||
public async Task<ActionResult<ResponseObject>> PreviewInvoiceProfile([FromForm] ImportFileRequest req, Guid insigniaNoteId)
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("UPDATE", "SYS_INSIGNIA_RECORD");
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("CREATE", "SYS_INSIGNIA_RECORD");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -62,10 +62,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpPost()]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUser([FromBody] NotiRequest req)
|
||||
{
|
||||
// var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.Id == req.ReceiverUserId);
|
||||
// if (profile == null)
|
||||
// return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
Guid.Parse(req.ReceiverUserId),
|
||||
req.Subject,
|
||||
|
|
@ -81,10 +77,6 @@ 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 apiUrl = $"{_configuration["API"]}/org/profile/keycloakid/position/" + req.ReceiverUserId;
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
|
|
@ -112,18 +104,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpPost("profile")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUserProfile([FromBody] NotiRequest req)
|
||||
{
|
||||
// var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == req.ReceiverUserId);
|
||||
// if (profile == null)
|
||||
// return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
// var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/" + req.ReceiverUserId;
|
||||
// using (var client = new HttpClient())
|
||||
// {
|
||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
// var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
// var _res = await client.SendAsync(_req);
|
||||
// var _result = await _res.Content.ReadAsStringAsync();
|
||||
// var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
|
||||
if (req.ReceiverUserId != null)
|
||||
{
|
||||
await _repositoryNoti.PushNotificationAsync(
|
||||
|
|
@ -136,7 +116,20 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
);
|
||||
}
|
||||
return Success();
|
||||
// }
|
||||
}
|
||||
|
||||
[HttpPost("profiles")]
|
||||
public async Task<ActionResult<ResponseObject>> UpdatePropertyByUserProfiles([FromBody] NotisRequest req)
|
||||
{
|
||||
await _repositoryNoti.PushNotificationsAsync(
|
||||
req.ReceiverUserIds.Select(x => Guid.Parse(x)).ToArray(),
|
||||
req.Subject,
|
||||
req.Body,
|
||||
req.Payload,
|
||||
req.IsSendInbox,
|
||||
req.IsSendMail
|
||||
);
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPut("{id:length(36)}")]
|
||||
|
|
@ -170,11 +163,6 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
}
|
||||
return Success();
|
||||
}
|
||||
// var profile = await _context.Profiles.FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(inbox.CreatedUserId));
|
||||
// if (profile == null)
|
||||
// return Error(GlobalMessages.DataNotFound);
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
||||
[HttpPost("cronjob")]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -481,6 +482,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
(org.result.child1 == null ? "" : org.result.child1 + "/") +
|
||||
(org.result.root == null ? "" : org.result.root);
|
||||
placementAppointment.OrganizationPositionOld = org.result.position + "-" + placementAppointment.OrganizationOld;
|
||||
placementAppointment.AmountOld = org.result.salary;
|
||||
}
|
||||
await _context.PlacementAppointments.AddAsync(placementAppointment);
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
@ -741,5 +743,783 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.ToListAsync();
|
||||
return Success(appointments);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-05
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("appoint/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportAppoint([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-05
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("appoint/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteAppoint([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "PENDING");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-05
|
||||
/// </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>
|
||||
[HttpPost("appoint/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportAppointAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
||||
OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld),
|
||||
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
||||
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
||||
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
LeaveDate = "",
|
||||
NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root),
|
||||
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
||||
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
||||
NewPositionNumber = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
||||
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-05 คำสั่งแต่งตั้ง
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("appoint/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
|
||||
position = p.position,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.posTypeName,
|
||||
positionLevel = p.posLevelName,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-06
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("slip/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportSlip([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-06
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("slip/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteSlip([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "PENDING");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-06
|
||||
/// </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>
|
||||
[HttpPost("slip/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReporSlipAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
||||
OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld),
|
||||
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
||||
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
||||
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
LeaveDate = "",
|
||||
NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root),
|
||||
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
||||
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
||||
NewPositionNumber = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
||||
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-06 เลื่อนข้าราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("slip/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteSlip([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
|
||||
position = p.position,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.posTypeName,
|
||||
positionLevel = p.posLevelName,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-07
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("move/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportMove([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-07
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("move/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteMove([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "PENDING");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-07
|
||||
/// </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>
|
||||
[HttpPost("move/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReporMoveAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
||||
OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld),
|
||||
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
||||
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
||||
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
LeaveDate = "",
|
||||
NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root),
|
||||
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
||||
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
||||
NewPositionNumber = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
||||
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-07 ย้ายข้าราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("move/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteMove([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
|
||||
position = p.position,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.posTypeName,
|
||||
positionLevel = p.posLevelName,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-22
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee-appoint/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportEmployeeAppoint([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.type == "EMPLOYEE")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-22
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee-appoint/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteEmployeeAppoint([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.type == "EMPLOYEE")
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "PENDING");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <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>
|
||||
[HttpPost("employee-appoint/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportEmployeeAppointAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
// .Where(x => x.type == "EMPLOYEE")
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
OldOrganization = (p.positionOld == null ? "" : p.positionOld) + "/" + (p.OrganizationOld == null ? "" : p.OrganizationOld),
|
||||
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld.ToThaiNumber(),
|
||||
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
|
||||
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root),
|
||||
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName.ToThaiNumber(),
|
||||
NewPositionNumber = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
||||
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-22 คำสั่งปรับระดับชั้นงาน
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee-appoint/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteEmployeeAppoint([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
|
||||
position = p.position,
|
||||
positionType = p.posTypeName,
|
||||
positionLevel = p.posLevelName,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-24
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee-move/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportEmployeeMove([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.type == "EMPLOYEE")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-24
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee-move/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteEmployeeMove([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.type == "EMPLOYEE")
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "PENDING");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-24
|
||||
/// </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>
|
||||
[HttpPost("employee-move/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportEmployeeMoveAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
// .Where(x => x.type == "EMPLOYEE")
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
OldOc = (p.positionOld == null ? "" : p.positionOld) + "/" + (p.OrganizationOld == null ? "" : p.OrganizationOld),
|
||||
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
|
||||
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root),
|
||||
NewPositionNumber = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
||||
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-24 คำสั่งย้ายลูกจ้างประจำ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee-move/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteEmployeeMove([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementAppointments
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
|
||||
position = p.position,
|
||||
positionType = p.posTypeName,
|
||||
positionLevel = p.posLevelName,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-current";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -1,6 +1,7 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -108,6 +109,8 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
|
|
@ -566,5 +569,143 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-15
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementOfficers
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-15
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDelete([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementOfficers
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "APPROVE");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-15
|
||||
/// </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>
|
||||
[HttpPost("command/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.PlacementOfficers
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
PositionName = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
|
||||
Organization = p.Organization == null ? "" : p.Organization,
|
||||
StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
EndDate = p.DateEnd == null ? "" : p.DateEnd.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
Reason = p.Reason == null ? "" : p.Reason.ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-15 คำสั่งให้ช่วยราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementOfficers
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -878,5 +879,208 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.ToListAsync();
|
||||
return Success(position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-14
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementReceives
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-14
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDelete([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementReceives
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "PENDING");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-14
|
||||
/// </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>
|
||||
[HttpPost("command/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.PlacementReceives
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
||||
OldOc = p.OrganizationPositionOld ?? "",
|
||||
OldPositionType = p.PositionTypeOld ?? "",
|
||||
OldPositionLevel = p.PositionLevelOld ?? "",
|
||||
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
NewOc = (p.position == null ? "" : p.position) + "/" + (p.root == null ? "" : p.root),
|
||||
NewPositionType = p.posTypeName == null ? "" : p.posTypeName,
|
||||
NewPositionLevel = p.posLevelName == null ? "" : p.posLevelName,
|
||||
NewPositionNumber = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}".ToThaiNumber() :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}".ToThaiNumber() : "",
|
||||
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
AppointDate = p.ReportingDate == null ? "" : p.ReportingDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-14 คำสั่งรับโอนข้าราชการกรุงเทพมหานครสามัญ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementReceives
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
bodyProfile = new
|
||||
{
|
||||
rank = string.Empty,
|
||||
prefix = p.prefix == null ? string.Empty : p.prefix,
|
||||
firstName = p.firstName == null ? string.Empty : p.firstName,
|
||||
lastName = p.lastName == null ? string.Empty : p.lastName,
|
||||
citizenId = p.citizenId == null ? string.Empty : p.citizenId,
|
||||
position = p.position == null ? string.Empty : p.position,
|
||||
posLevelId = p.posLevelId == null ? string.Empty : p.posLevelId,
|
||||
posTypeId = p.posTypeId == null ? string.Empty : p.posTypeId,
|
||||
email = (String?)null,
|
||||
phone = (String?)null,
|
||||
keycloak = string.Empty,
|
||||
isProbation = true,
|
||||
isLeave = false,
|
||||
dateRetire = (DateTime?)null,
|
||||
dateAppoint = r.commandAffectDate,
|
||||
dateStart = r.commandAffectDate,
|
||||
govAgeAbsent = 0,
|
||||
govAgePlus = 0,
|
||||
birthDate = p.DateOfBirth == null ? (DateTime?)null : p.DateOfBirth,
|
||||
reasonSameDate = (DateTime?)null,
|
||||
ethnicity = p.Race == null ? string.Empty : p.Race,
|
||||
telephoneNumber = (String?)null,
|
||||
nationality = p.Nationality == null ? string.Empty : p.Nationality,
|
||||
gender = p.Gender == null ? string.Empty : p.Gender,
|
||||
relationship = p.Relationship == null ? string.Empty : p.Relationship,
|
||||
religion = p.Religion == null ? string.Empty : p.Religion,
|
||||
bloodGroup = string.Empty,
|
||||
registrationAddress = (String?)null,
|
||||
registrationProvinceId = (String?)null,
|
||||
registrationDistrictId = (String?)null,
|
||||
registrationSubDistrictId = (String?)null,
|
||||
registrationZipCode = (String?)null,
|
||||
currentAddress = (String?)null,
|
||||
currentProvinceId = (String?)null,
|
||||
currentDistrictId = (String?)null,
|
||||
currentSubDistrictId = (String?)null,
|
||||
currentZipCode = (String?)null,
|
||||
},
|
||||
bodySalarys = new
|
||||
{
|
||||
profileId = string.Empty,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.posMasterNo == null ? "" :
|
||||
p.node == 4 ? $"{p.child4ShortName}{p.posMasterNo}" :
|
||||
p.node == 3 ? $"{p.child3ShortName}{p.posMasterNo}" :
|
||||
p.node == 2 ? $"{p.child2ShortName}{p.posMasterNo}" :
|
||||
p.node == 1 ? $"{p.child1ShortName}{p.posMasterNo}" :
|
||||
p.node == 0 ? $"{p.rootShortName}{p.posMasterNo}" : "",
|
||||
position = p.position == null ? string.Empty : p.position,
|
||||
positionLine = string.Empty,
|
||||
positionPathSide = string.Empty,
|
||||
positionExecutive = string.Empty,
|
||||
positionType = p.posTypeName == null ? string.Empty : p.posTypeName,
|
||||
positionLevel = p.posLevelName == null ? string.Empty : p.posLevelName,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc
|
||||
},
|
||||
bodyPosition = new
|
||||
{
|
||||
posmasterId = p.posmasterId,
|
||||
positionId = p.positionId
|
||||
}
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
//var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-current";
|
||||
var apiUrlOrg = $"{_configuration["API"]}/org/command/excexute/create-officer-profile";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -109,6 +110,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
|
|
@ -473,5 +475,98 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
// return Success();
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-16
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementRepatriations
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบส่งรายชื่อออกคำสั่ง C-PM-16
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDelete([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementRepatriations
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "APPROVE");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-16 คำสั่งส่งตัวกลับ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementRepatriations
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Placement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -12,7 +13,6 @@ using Newtonsoft.Json;
|
|||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Controllers
|
||||
|
|
@ -129,6 +129,23 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.IsActive,
|
||||
})
|
||||
.ToListAsync();
|
||||
//if (keyword != "")
|
||||
//{
|
||||
// var data = placementTransfers.Where(x =>
|
||||
// (x.OrganizationPositionOld != null && x.OrganizationPositionOld.Contains(keyword)) ||
|
||||
// (x.rootShortNameOld != null && x.rootShortNameOld.Contains(keyword)) ||
|
||||
// (x.PositionNumberOld != null && x.PositionNumberOld.Contains(keyword)) ||
|
||||
// (x.posTypeNameOld != null && x.posTypeNameOld.Contains(keyword)) ||
|
||||
// (x.posLevelNameOld != null && x.posLevelNameOld.Contains(keyword)) ||
|
||||
// (x.Organization != null && x.Organization.Contains(keyword))
|
||||
// )
|
||||
// .OrderByDescending(x => x.CreatedAt)
|
||||
// .Skip((page - 1) * pageSize)
|
||||
// .Take(pageSize)
|
||||
// .ToList();
|
||||
|
||||
// placementTransfers = data;
|
||||
//}
|
||||
return Success(placementTransfers);
|
||||
}
|
||||
}
|
||||
|
|
@ -181,6 +198,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
|
|
@ -740,5 +758,146 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-13
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementTransfers
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-13
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDelete([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.PlacementTransfers
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "APPROVE");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-13
|
||||
/// </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>
|
||||
[HttpPost("command/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.PlacementTransfers
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Oc = (p.PositionOld == null ? "" : p.PositionOld) + "/" + (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld),
|
||||
PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
||||
PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
||||
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
ReceiveOrganizationName = "",
|
||||
ActiveDate = p.Date == null ? "" : p.Date.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
Reason = p.Reason ?? "",
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-13 คำสั่งให้โอนข้าราชการกรุงเทพมหานครสามัญ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.PlacementTransfers
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
BMA.EHR.Placement.Service/Requests/NotisRequest.cs
Normal file
16
BMA.EHR.Placement.Service/Requests/NotisRequest.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class NotisRequest
|
||||
{
|
||||
public string Subject { get; set; }
|
||||
public string Body { get; set; }
|
||||
public string Payload { get; set; }
|
||||
public string[] ReceiverUserIds { get; set; }
|
||||
public bool IsSendMail { get; set; }
|
||||
public bool IsSendInbox { get; set; }
|
||||
public bool IsSendNotification { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class ReportAttachmentRequest
|
||||
{
|
||||
public ReportAttachmentRequestObj[] refIds { get; set; }
|
||||
}
|
||||
public class ReportAttachmentRequestObj
|
||||
{
|
||||
public string? refId { get; set; }
|
||||
public int? Sequence { get; set; }
|
||||
public string? CitizenId { get; set; }
|
||||
public string? Prefix { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public double? Amount { get; set; }
|
||||
public double? PositionSalaryAmount { get; set; }
|
||||
public double? MouthSalaryAmount { get; set; }
|
||||
public string? RemarkHorizontal { get; set; }
|
||||
public string? RemarkVertical { get; set; }
|
||||
public int CommandYear { get; set; }
|
||||
}
|
||||
}
|
||||
21
BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs
Normal file
21
BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class ReportExecuteRequest
|
||||
{
|
||||
public ReportExecuteRequestObj[] refIds { get; set; }
|
||||
}
|
||||
public class ReportExecuteRequestObj
|
||||
{
|
||||
public string? refId { get; set; }
|
||||
public DateTime commandAffectDate { get; set; }
|
||||
public string? commandNo { get; set; }
|
||||
public int commandYear { get; set; }
|
||||
public string? templateDoc { get; set; }
|
||||
public double? amount { get; set; }
|
||||
public double? positionSalaryAmount { get; set; }
|
||||
public double? mouthSalaryAmount { get; set; }
|
||||
}
|
||||
}
|
||||
10
BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs
Normal file
10
BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Placement.Service.Requests
|
||||
{
|
||||
public class ReportPersonRequest
|
||||
{
|
||||
public string[] refIds { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -118,6 +118,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -108,6 +109,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
|
|
@ -623,5 +625,306 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-08
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("appoint/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportAppoint([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementOthers
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-08
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("appoint/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteAppoint([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementOthers
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "WAITTING");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-08
|
||||
/// </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>
|
||||
[HttpPost("appoint/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportAppointAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.RetirementOthers
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
||||
OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld),
|
||||
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
||||
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
||||
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
LeaveDate = "",
|
||||
NewOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld),
|
||||
NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
||||
NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
||||
NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-08 บรรจุและแต่งตั้งข้าราชการกลับเข้ารับราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("appoint/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.RetirementOthers
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
string? _null = null;
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
isLeave = false,
|
||||
leaveReason = _null,
|
||||
dateLeave = _null,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-09
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("out/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportOut([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementOthers
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-09
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("out/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteOut([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementOthers
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "WAITTING");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-09
|
||||
/// </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>
|
||||
[HttpPost("out/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportOutAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.RetirementOthers
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
No = r.Sequence.ToString().ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
Education = p.EducationOld == null ? "-" : p.EducationOld,
|
||||
OldOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld),
|
||||
OldPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
||||
OldPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
||||
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
LeaveDate = "",
|
||||
MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
NewOc = (p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld) + "/" + (p.rootOld == null ? "" : p.rootOld),
|
||||
NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
|
||||
NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
|
||||
NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-09 คำสั่งบรรจุและแต่งตั้งผู้ออกไปรับราชการทหารกลับเข้ารับราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("out/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteOut([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.RetirementOthers
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
string? _null = null;
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
isLeave = false,
|
||||
leaveReason = _null,
|
||||
dateLeave = _null,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using BMA.EHR.Application.Repositories;
|
||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -107,6 +108,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
|
|
@ -464,5 +466,102 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-18
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-18
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostDeleteReport([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
// .Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "APPROVE");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-18 คำสั่งให้ออกจากราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteLeave([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.RetirementOuts
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
isLeave = true,
|
||||
leaveReason = "ให้ออกจากราชการ",
|
||||
dateLeave = r.commandAffectDate,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||
using BMA.EHR.Domain.Common;
|
||||
using BMA.EHR.Domain.Extensions;
|
||||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using BMA.EHR.Domain.Models.Retirement;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
|
|
@ -15,8 +14,6 @@ using Newtonsoft.Json.Linq;
|
|||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Security.Claims;
|
||||
using System.Security.Cryptography;
|
||||
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Controllers
|
||||
{
|
||||
|
|
@ -185,6 +182,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.profileId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
|
|
@ -1628,5 +1626,388 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
|
|||
|
||||
return Success(retirementQuestionnaireQuestion);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-17
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-17
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDelete([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "APPROVE");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-17
|
||||
/// </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>
|
||||
[HttpPost("command/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.RetirementResigns
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
Seq = r.Sequence.ToString().ToThaiNumber(),
|
||||
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
PositionName = p.PositionOld ?? "",
|
||||
Organization = p.OrganizationPositionOld ?? "",
|
||||
PositionLevel = p.PositionLevelOld ?? "",
|
||||
PositionType = p.PositionTypeOld ?? "",
|
||||
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
Remark = p.Reason ?? "",
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-17 คำสั่งอนุญาตให้ข้าราชการลาออกจากราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("command/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
isLeave = true,
|
||||
leaveReason = "ลาออกจากราชการ",
|
||||
dateLeave = r.commandAffectDate,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-23
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportEmployee([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-23
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteEmployee([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "APPROVE");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-23 คำสั่งให้ลูกจ้างออกจากราชการ
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("employee/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteEmployee([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
isLeave = true,
|
||||
leaveReason = "ลาออกจากราชการ",
|
||||
dateLeave = r.commandAffectDate,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-employee-leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONE");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ส่งรายชื่อออกคำสั่ง C-PM-41
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("leave-cancel/report")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportLeaveCancel([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "REPORT");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ลบรายชื่อออกคำสั่ง C-PM-41
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("leave-cancel/report/delete")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportDeleteLeaveCancel([FromBody] ReportPersonRequest req)
|
||||
{
|
||||
var placementProfiles = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Contains(x.Id.ToString()))
|
||||
.Where(x => x.Status.ToUpper() == "REPORT")
|
||||
.ToListAsync();
|
||||
placementProfiles.ForEach(profile => profile.Status = "DONECANCEL");
|
||||
await _context.SaveChangesAsync();
|
||||
return Success();
|
||||
}
|
||||
/// <summary>
|
||||
/// เอกสารแนบท้าย C-PM-41
|
||||
/// </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>
|
||||
[HttpPost("leave-cancel/report/attachment")]
|
||||
[AllowAnonymous]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportLeaveCancelAttachment([FromBody] ReportAttachmentRequest req)
|
||||
{
|
||||
try
|
||||
{
|
||||
var report_data = (from p in _context.RetirementResigns
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToList()
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
orderby r.Sequence
|
||||
select new
|
||||
{
|
||||
Seq = r.Sequence.ToString().ToThaiNumber(),
|
||||
CitizenId = r.CitizenId == null ? "-" : r.CitizenId.ToThaiNumber(),
|
||||
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
|
||||
PositionName = p.PositionOld ?? "",
|
||||
Organization = p.OrganizationPositionOld ?? "",
|
||||
PositionLevel = p.PositionLevelOld ?? "",
|
||||
PositionType = p.PositionTypeOld ?? "",
|
||||
PositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
|
||||
ActiveDate = p.ActiveDate == null ? "" : p.ActiveDate.Value.ToThaiShortDate2().ToThaiNumber(),
|
||||
Salary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
|
||||
Remark = p.Reason ?? "",
|
||||
RemarkHorizontal = r.RemarkHorizontal,
|
||||
RemarkVertical = r.RemarkVertical,
|
||||
}).ToList();
|
||||
return Success(report_data);
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ออกคำสั่ง C-PM-41 คำสั่งยกเลิกการลาออก
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("leave-cancel/report/excecute")]
|
||||
public async Task<ActionResult<ResponseObject>> PostReportExecuteLeaveCancel([FromBody] ReportExecuteRequest req)
|
||||
{
|
||||
var data = await _context.RetirementResigns
|
||||
.Where(x => req.refIds.Select(x => x.refId).Contains(x.Id.ToString()))
|
||||
.ToListAsync();
|
||||
string? _null = null;
|
||||
var resultData = (from p in data
|
||||
join r in req.refIds
|
||||
on p.Id.ToString() equals r.refId
|
||||
select new
|
||||
{
|
||||
profileId = p.profileId,
|
||||
date = r.commandAffectDate,
|
||||
amount = r.amount,
|
||||
positionSalaryAmount = r.positionSalaryAmount,
|
||||
mouthSalaryAmount = r.mouthSalaryAmount,
|
||||
posNo = p.PositionNumberOld,
|
||||
position = p.PositionOld,
|
||||
positionLine = "",
|
||||
positionPathSide = "",
|
||||
positionExecutive = "",
|
||||
positionType = p.PositionTypeOld,
|
||||
positionLevel = p.PositionLevelOld,
|
||||
refCommandNo = $"{r.commandNo}/{r.commandYear.ToThaiYear()}",
|
||||
templateDoc = r.templateDoc,
|
||||
isLeave = false,
|
||||
leaveReason = _null,
|
||||
dateLeave = _null,
|
||||
}).ToList();
|
||||
|
||||
var baseAPIOrg = _configuration["API"];
|
||||
var apiUrlOrg = $"{baseAPIOrg}/org/command/excexute/salary-leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlOrg, new
|
||||
{
|
||||
data = resultData,
|
||||
});
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
if (_res.IsSuccessStatusCode)
|
||||
{
|
||||
data.ForEach(profile => profile.Status = "DONEREJECT");
|
||||
await _context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
return Success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,25 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class ReportAttachmentRequest
|
||||
{
|
||||
public ReportAttachmentRequestObj[] refIds { get; set; }
|
||||
}
|
||||
public class ReportAttachmentRequestObj
|
||||
{
|
||||
public string? refId { get; set; }
|
||||
public int? Sequence { get; set; }
|
||||
public string? CitizenId { get; set; }
|
||||
public string? Prefix { get; set; }
|
||||
public string? FirstName { get; set; }
|
||||
public string? LastName { get; set; }
|
||||
public double? Amount { get; set; }
|
||||
public double? PositionSalaryAmount { get; set; }
|
||||
public double? MouthSalaryAmount { get; set; }
|
||||
public string? RemarkHorizontal { get; set; }
|
||||
public string? RemarkVertical { get; set; }
|
||||
public int CommandYear { get; set; }
|
||||
}
|
||||
}
|
||||
21
BMA.EHR.Retirement.Service/Requests/ReportExecuteRequest.cs
Normal file
21
BMA.EHR.Retirement.Service/Requests/ReportExecuteRequest.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class ReportExecuteRequest
|
||||
{
|
||||
public ReportExecuteRequestObj[] refIds { get; set; }
|
||||
}
|
||||
public class ReportExecuteRequestObj
|
||||
{
|
||||
public string? refId { get; set; }
|
||||
public DateTime commandAffectDate { get; set; }
|
||||
public string? commandNo { get; set; }
|
||||
public int commandYear { get; set; }
|
||||
public string? templateDoc { get; set; }
|
||||
public double? amount { get; set; }
|
||||
public double? positionSalaryAmount { get; set; }
|
||||
public double? mouthSalaryAmount { get; set; }
|
||||
}
|
||||
}
|
||||
10
BMA.EHR.Retirement.Service/Requests/ReportPersonRequest.cs
Normal file
10
BMA.EHR.Retirement.Service/Requests/ReportPersonRequest.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class ReportPersonRequest
|
||||
{
|
||||
public string[] refIds { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue