no message

This commit is contained in:
kittapath 2024-10-02 15:14:37 +07:00
parent 874d310b35
commit bce6732bdb
7 changed files with 284 additions and 3 deletions

View file

@ -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,10 +16,8 @@ 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;
namespace BMA.EHR.Command.Service.Controllers
@ -6575,5 +6573,73 @@ namespace BMA.EHR.Command.Service.Controllers
}
#endregion
/// <summary>
/// ออกคำสั่ง C-PM-11
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command11/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand11Execute([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/command11/{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 _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
/// <summary>
/// ออกคำสั่ง C-PM-12
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command12/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand12Execute([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/command12/{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 _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
}
}