refid ส่งกลับ

This commit is contained in:
moss 2025-04-01 11:08:27 +07:00
parent b1d198133f
commit 6dd057516f
5 changed files with 20143 additions and 1 deletions

View file

@ -101,5 +101,7 @@ namespace BMA.EHR.Domain.Models.Placement
public string? posLevelOldId { get; set; }
[Comment("ชื่อระดับตำแหน่ง old")]
public string? posLevelNameOld { get; set; }
[Comment("Id อ้างอิงช่วยราช")]
public Guid? refId { get; set; }
}
}

View file

@ -0,0 +1,31 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class update_table_placementRepatriation_add_refId : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<Guid>(
name: "refId",
table: "PlacementRepatriations",
type: "char(36)",
nullable: true,
comment: "Id อ้างอิงช่วยราช",
collation: "ascii_general_ci");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "refId",
table: "PlacementRepatriations");
}
}
}

View file

@ -14083,6 +14083,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("profile Id");
b.Property<Guid?>("refId")
.HasColumnType("char(36)")
.HasComment("Id อ้างอิงช่วยราช");
b.Property<string>("rootDnaOldId")
.HasColumnType("longtext")
.HasComment("id หน่วยงาน rootDna old");

View file

@ -221,7 +221,7 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{
var placementOfficer = await _context.PlacementOfficers
.Where(x => x.Id == (req.OfficerId ?? Guid.Parse("00000000-0000-0000-0000-000000000000")))
.FirstOrDefaultAsync();
@ -230,6 +230,7 @@ namespace BMA.EHR.Placement.Service.Controllers
var placementRepatriation = new PlacementRepatriation
{
Organization = placementOfficer.Organization,
refId = req.OfficerId ?? Guid.Parse("00000000-0000-0000-0000-000000000000"),
// Reason = placementOfficer.Reason,
Date = placementOfficer.DateStart,
DateRepatriation = placementOfficer.DateEnd,
@ -298,6 +299,20 @@ namespace BMA.EHR.Placement.Service.Controllers
(org.result.root == null ? "" : org.result.root);
placementRepatriation.OrganizationPositionOld = org.result.position + "\n" + (placementRepatriation.PositionExecutiveOld == null ? "" : placementRepatriation.PositionExecutiveOld + "\n") + placementRepatriation.OrganizationOld;
}
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/profile/assistance/status";
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
{
refId = req.OfficerId ?? Guid.Parse("00000000-0000-0000-0000-000000000000"),
status = "DONE"
});
var _result = await _res.Content.ReadAsStringAsync();
}
await _context.PlacementRepatriations.AddAsync(placementRepatriation);
await _context.SaveChangesAsync();
@ -391,6 +406,20 @@ namespace BMA.EHR.Placement.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null)
return NotFound();
var baseAPIOrg = _configuration["API"];
var apiUrlOrg = $"{baseAPIOrg}/org/profile/assistance/status";
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
{
refId = deleted.refId ?? Guid.Parse("00000000-0000-0000-0000-000000000000"),
status = "PENDING"
});
var _result = await _res.Content.ReadAsStringAsync();
}
_context.PlacementRepatriations.Remove(deleted);
await _context.SaveChangesAsync();