no message
Some checks failed
release-dev / release-dev (push) Failing after 10s

This commit is contained in:
kittapath 2025-01-17 11:21:39 +07:00
parent 37d1ff3f40
commit d516e265e0
3 changed files with 160 additions and 87 deletions

View file

@ -568,32 +568,63 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.ProfileId}";
using (var client = new HttpClient())
if (retirementDeceased.profileType.Trim().ToUpper() == "OFFICER")
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.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.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
if (org == null || org.result == null)
continue;
if (org == null || org.result == null)
continue;
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
}
}
else
{
var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{item.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.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
if (org == null || org.result == null)
continue;
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
}
}
await _context.SaveChangesAsync();

View file

@ -107,6 +107,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
p.Id,
p.profileType,
p.citizenId,
p.profileId,
p.prefix,
@ -178,6 +179,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
p.Id,
p.profileType,
p.profileId,
p.prefix,
p.firstName,
@ -258,27 +260,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
{
// var profile = await _context.Profiles
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionType)
// .Include(x => x.PosNo)
// .Include(x => x.Salaries)
// .Include(x => x.Position)
// .FirstOrDefaultAsync(x => x.Id == req.Id);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
var retirementOut = new RetirementOut
{
// Profile = profile,
// Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
// Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
// // Date = req.Date,
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
@ -287,57 +270,115 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.Id}";
using (var client = new HttpClient())
if (req.profileType.Trim().ToUpper() == "OFFICER")
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.Id}";
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.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementOut.profileId = org.result.profileId;
retirementOut.prefix = org.result.prefix;
retirementOut.firstName = org.result.firstName;
retirementOut.lastName = org.result.lastName;
retirementOut.citizenId = org.result.citizenId;
retirementOut.rootOld = org.result.root;
retirementOut.rootOldId = org.result.rootId;
retirementOut.rootShortNameOld = org.result.rootShortName;
retirementOut.child1Old = org.result.child1;
retirementOut.child1OldId = org.result.child1Id;
retirementOut.child1ShortNameOld = org.result.child1ShortName;
retirementOut.child2Old = org.result.child2;
retirementOut.child2OldId = org.result.child2Id;
retirementOut.child2ShortNameOld = org.result.child2ShortName;
retirementOut.child3Old = org.result.child3;
retirementOut.child3OldId = org.result.child3Id;
retirementOut.child3ShortNameOld = org.result.child3ShortName;
retirementOut.child4Old = org.result.child4;
retirementOut.child4OldId = org.result.child4Id;
retirementOut.child4ShortNameOld = org.result.child4ShortName;
retirementOut.posMasterNoOld = org.result.posMasterNo;
retirementOut.posTypeOldId = org.result.posTypeId;
retirementOut.posTypeNameOld = org.result.posTypeName;
retirementOut.posLevelOldId = org.result.posLevelId;
retirementOut.posLevelNameOld = org.result.posLevelName;
retirementOut.profileId = org.result.profileId;
retirementOut.prefix = org.result.prefix;
retirementOut.firstName = org.result.firstName;
retirementOut.lastName = org.result.lastName;
retirementOut.citizenId = org.result.citizenId;
retirementOut.rootOld = org.result.root;
retirementOut.rootOldId = org.result.rootId;
retirementOut.rootShortNameOld = org.result.rootShortName;
retirementOut.child1Old = org.result.child1;
retirementOut.child1OldId = org.result.child1Id;
retirementOut.child1ShortNameOld = org.result.child1ShortName;
retirementOut.child2Old = org.result.child2;
retirementOut.child2OldId = org.result.child2Id;
retirementOut.child2ShortNameOld = org.result.child2ShortName;
retirementOut.child3Old = org.result.child3;
retirementOut.child3OldId = org.result.child3Id;
retirementOut.child3ShortNameOld = org.result.child3ShortName;
retirementOut.child4Old = org.result.child4;
retirementOut.child4OldId = org.result.child4Id;
retirementOut.child4ShortNameOld = org.result.child4ShortName;
retirementOut.posMasterNoOld = org.result.posMasterNo;
retirementOut.posTypeOldId = org.result.posTypeId;
retirementOut.posTypeNameOld = org.result.posTypeName;
retirementOut.posLevelOldId = org.result.posLevelId;
retirementOut.posLevelNameOld = org.result.posLevelName;
retirementOut.PositionOld = org.result.position;
retirementOut.PositionLevelOld = org.result.posLevelName;
retirementOut.PositionTypeOld = org.result.posTypeName;
retirementOut.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
retirementOut.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementOut.OrganizationPositionOld = org.result.position + "/" + retirementOut.OrganizationOld;
retirementOut.AmountOld = org.result.salary;
retirementOut.PositionOld = org.result.position;
retirementOut.PositionLevelOld = org.result.posLevelName;
retirementOut.PositionTypeOld = org.result.posTypeName;
retirementOut.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
retirementOut.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementOut.OrganizationPositionOld = org.result.position + "/" + retirementOut.OrganizationOld;
retirementOut.AmountOld = org.result.salary;
}
}
else
{
var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{req.Id}";
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.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementOut.profileId = org.result.profileId;
retirementOut.prefix = org.result.prefix;
retirementOut.firstName = org.result.firstName;
retirementOut.lastName = org.result.lastName;
retirementOut.citizenId = org.result.citizenId;
retirementOut.rootOld = org.result.root;
retirementOut.rootOldId = org.result.rootId;
retirementOut.rootShortNameOld = org.result.rootShortName;
retirementOut.child1Old = org.result.child1;
retirementOut.child1OldId = org.result.child1Id;
retirementOut.child1ShortNameOld = org.result.child1ShortName;
retirementOut.child2Old = org.result.child2;
retirementOut.child2OldId = org.result.child2Id;
retirementOut.child2ShortNameOld = org.result.child2ShortName;
retirementOut.child3Old = org.result.child3;
retirementOut.child3OldId = org.result.child3Id;
retirementOut.child3ShortNameOld = org.result.child3ShortName;
retirementOut.child4Old = org.result.child4;
retirementOut.child4OldId = org.result.child4Id;
retirementOut.child4ShortNameOld = org.result.child4ShortName;
retirementOut.posMasterNoOld = org.result.posMasterNo;
retirementOut.posTypeOldId = org.result.posTypeId;
retirementOut.posTypeNameOld = org.result.posTypeName;
retirementOut.posLevelOldId = org.result.posLevelId;
retirementOut.posLevelNameOld = org.result.posLevelName;
retirementOut.PositionOld = org.result.position;
retirementOut.PositionLevelOld = org.result.posLevelName;
retirementOut.PositionTypeOld = org.result.posTypeName;
retirementOut.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
retirementOut.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementOut.OrganizationPositionOld = org.result.position + "/" + retirementOut.OrganizationOld;
retirementOut.AmountOld = org.result.salary;
}
}
await _context.RetirementOuts.AddAsync(retirementOut);
await _context.SaveChangesAsync();

View file

@ -6,5 +6,6 @@ namespace BMA.EHR.Retirement.Service.Requests
public class RetirementAddProfileRequest
{
public Guid Id { get; set; }
public string profileType { get; set; }
}
}