แก้คำสั่ง

This commit is contained in:
kittapath 2024-10-02 22:54:34 +07:00
parent a09a732ff1
commit 4cf3f15fb8
8 changed files with 296 additions and 27 deletions

View file

@ -19,6 +19,7 @@ using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
using Newtonsoft.Json.Linq;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Command.Service.Controllers
{
@ -6664,7 +6665,6 @@ namespace BMA.EHR.Command.Service.Controllers
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
profileId = recv.refId,
@ -6768,7 +6768,6 @@ namespace BMA.EHR.Command.Service.Controllers
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
profileId = recv.refId,
@ -6793,7 +6792,7 @@ namespace BMA.EHR.Command.Service.Controllers
[HttpPost("command19/report")]
public async Task<ActionResult<ResponseObject>> PostReportCommand19([FromBody] ReportPersonRequest req)
{
var placementProfiles = await _context.RetirementDischarges
var placementProfiles = await _context.RetirementDischarges.AsQueryable()
.Where(x => req.refIds.Contains(x.Id.ToString()))
.ToListAsync();
@ -6826,7 +6825,6 @@ namespace BMA.EHR.Command.Service.Controllers
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
profileId = recv.refId,
@ -6837,6 +6835,25 @@ namespace BMA.EHR.Command.Service.Controllers
var _result = await _res.Content.ReadAsStringAsync();
}
}
var dataSend = req.refIds.Select(x => new
{
Id = x.refId,
CommandAffectDate = x.commandAffectDate,
CommandNo = x.commandNo,
CommandYear = x.commandYear.ToThaiYear(),
Detail = "คำสั่งลงโทษ ปลดออกจากราชการ"
});
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/discipline/result/report/up/resume";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend });
var result = await res.Content.ReadAsStringAsync();
}
return Success();
}
@ -6851,7 +6868,7 @@ namespace BMA.EHR.Command.Service.Controllers
[HttpPost("command20/report")]
public async Task<ActionResult<ResponseObject>> PostReportcommand20([FromBody] ReportPersonRequest req)
{
var placementProfiles = await _context.RetirementExpulsions
var placementProfiles = await _context.RetirementExpulsions.AsQueryable()
.Where(x => req.refIds.Contains(x.Id.ToString()))
.ToListAsync();
@ -6884,7 +6901,6 @@ namespace BMA.EHR.Command.Service.Controllers
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
profileId = recv.refId,
@ -6895,6 +6911,25 @@ namespace BMA.EHR.Command.Service.Controllers
var _result = await _res.Content.ReadAsStringAsync();
}
}
var dataSend = req.refIds.Select(x => new
{
Id = x.refId,
CommandAffectDate = x.commandAffectDate,
CommandNo = x.commandNo,
CommandYear = x.commandYear.ToThaiYear(),
detail = "คำสั่งลงโทษ ไล่ออกจากราชการ"
});
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/discipline/result/report/up/resume";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var res = await client.PostAsJsonAsync(_apiUrl, new { result = dataSend });
var result = await res.Content.ReadAsStringAsync();
}
return Success();
}
@ -7021,6 +7056,23 @@ namespace BMA.EHR.Command.Service.Controllers
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
foreach (var recv in req.refIds)
{
var apiUrl2 = $"{baseAPI}/org/profile/command25/{recv.refId}";
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(apiUrl2, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
@ -7053,6 +7105,23 @@ namespace BMA.EHR.Command.Service.Controllers
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
foreach (var recv in req.refIds)
{
var apiUrl2 = $"{baseAPI}/org/profile/command26/{recv.refId}";
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(apiUrl2, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
@ -7085,6 +7154,23 @@ namespace BMA.EHR.Command.Service.Controllers
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
foreach (var recv in req.refIds)
{
var apiUrl2 = $"{baseAPI}/org/profile/command27/{recv.refId}";
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(apiUrl2, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
@ -7117,6 +7203,23 @@ namespace BMA.EHR.Command.Service.Controllers
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
foreach (var recv in req.refIds)
{
var apiUrl2 = $"{baseAPI}/org/profile/command28/{recv.refId}";
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(apiUrl2, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
@ -7149,6 +7252,23 @@ namespace BMA.EHR.Command.Service.Controllers
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
foreach (var recv in req.refIds)
{
var apiUrl2 = $"{baseAPI}/org/profile/command29/{recv.refId}";
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(apiUrl2, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
@ -7181,6 +7301,23 @@ namespace BMA.EHR.Command.Service.Controllers
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
foreach (var recv in req.refIds)
{
var apiUrl2 = $"{baseAPI}/org/profile/command30/{recv.refId}";
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(apiUrl2, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
@ -7213,6 +7350,23 @@ namespace BMA.EHR.Command.Service.Controllers
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
foreach (var recv in req.refIds)
{
var apiUrl2 = $"{baseAPI}/org/profile/command31/{recv.refId}";
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(apiUrl2, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
@ -7245,6 +7399,23 @@ namespace BMA.EHR.Command.Service.Controllers
var res = await client.PostAsJsonAsync(apiUrl, new { result = data });
var result = await res.Content.ReadAsStringAsync();
}
foreach (var recv in req.refIds)
{
var apiUrl2 = $"{baseAPI}/org/profile/command32/{recv.refId}";
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(apiUrl2, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
@ -7396,5 +7567,33 @@ namespace BMA.EHR.Command.Service.Controllers
}
return Success();
}
/// <summary>
/// ออกคำสั่ง C-PM-38
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command38/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand38Execute([FromBody] ReportExecuteRequest req)
{
return Success();
}
/// <summary>
/// ออกคำสั่ง C-PM-40
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command40/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand40Execute([FromBody] ReportExecuteRequest req)
{
return Success();
}
}
}

View file

@ -576,7 +576,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report")]
[HttpPost("command/report")]
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
{
var placementProfiles = await _context.PlacementOfficers
@ -600,7 +600,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report/attachment")]
[HttpPost("command/report/attachment")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
@ -642,7 +642,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/excecute")]
[HttpPost("command/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
{
// create new profile

View file

@ -888,7 +888,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report")]
[HttpPost("command/report")]
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
{
var placementProfiles = await _context.PlacementReceives
@ -912,7 +912,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report/attachment")]
[HttpPost("command/report/attachment")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
@ -970,7 +970,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/excecute")]
[HttpPost("command/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
{
// create new profile

View file

@ -483,7 +483,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report")]
[HttpPost("command/report")]
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
{
var placementProfiles = await _context.PlacementRepatriations
@ -506,7 +506,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/excecute")]
[HttpPost("command/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
{
// create new profile

View file

@ -766,7 +766,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report")]
[HttpPost("command/report")]
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
{
var placementProfiles = await _context.PlacementTransfers
@ -790,7 +790,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report/attachment")]
[HttpPost("command/report/attachment")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
@ -837,7 +837,7 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/excecute")]
[HttpPost("command/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
{
// create new profile

View file

@ -839,7 +839,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
NewPositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
NewPositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
NewPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
// NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
LeaveDate = p.LeaveDate == null ? "" : p.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(),
MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(),

View file

@ -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;
@ -473,8 +474,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command18/report")]
public async Task<ActionResult<ResponseObject>> PostReportCommand18([FromBody] ReportPersonRequest req)
[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()))
@ -496,7 +497,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command18/report/excecute")]
[HttpPost("command/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecuteLeave([FromBody] ReportExecuteRequest req)
{
// create new profile

View file

@ -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
{
@ -1637,7 +1634,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report")]
[HttpPost("command/report")]
public async Task<ActionResult<ResponseObject>> PostReport([FromBody] ReportPersonRequest req)
{
var placementProfiles = await _context.RetirementResigns
@ -1661,7 +1658,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/report/attachment")]
[HttpPost("command/report/attachment")]
[AllowAnonymous]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
@ -1704,7 +1701,7 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report/excecute")]
[HttpPost("command/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecute([FromBody] ReportExecuteRequest req)
{
// create new profile
@ -1811,5 +1808,77 @@ $"คำขอลาออกของ {updated.prefix}{updated.firstName} {upda
}
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("leave-cancel/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecuteLeaveCancel([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var data = await _context.RetirementResigns
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
if (data == null)
throw new Exception(GlobalMessages.DataNotFound);
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/leave/{data.profileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrl, new
{
isLeave = false,
leaveReason = _null,
dateLeave = _null,
});
var _result = await _res.Content.ReadAsStringAsync();
}
var apiUrlSalary = $"{baseAPI}/org/profile/salary";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileId = data.profileId,
date = recv.commandAffectDate,
amount = recv.amount,
positionSalaryAmount = recv.positionSalaryAmount,
mouthSalaryAmount = recv.mouthSalaryAmount,
posNo = data.PositionNumberOld,
position = data.PositionOld,
positionLine = "",
positionPathSide = "",
positionExecutive = "",
positionType = data.PositionTypeOld,
positionLevel = data.PositionLevelOld,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
templateDoc = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
// update placementstatus
data.Status = "DONEREJECT";
await _context.SaveChangesAsync();
}
return Success();
}
}
}