This commit is contained in:
parent
37d1ff3f40
commit
d516e265e0
3 changed files with 160 additions and 87 deletions
|
|
@ -568,32 +568,63 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdatedAt = DateTime.Now,
|
LastUpdatedAt = DateTime.Now,
|
||||||
};
|
};
|
||||||
|
if (retirementDeceased.profileType.Trim().ToUpper() == "OFFICER")
|
||||||
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.ProfileId}";
|
|
||||||
using (var client = new HttpClient())
|
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.ProfileId}";
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
using (var client = new HttpClient())
|
||||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
{
|
||||||
var _res = await client.SendAsync(_req);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
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)
|
if (org == null || org.result == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
|
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
|
||||||
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
|
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
|
||||||
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
|
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
|
||||||
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
|
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
|
||||||
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
|
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
|
||||||
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "/") +
|
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "/") +
|
||||||
(org.result.child3 == null ? "" : org.result.child3 + "/") +
|
(org.result.child3 == null ? "" : org.result.child3 + "/") +
|
||||||
(org.result.child2 == null ? "" : org.result.child2 + "/") +
|
(org.result.child2 == null ? "" : org.result.child2 + "/") +
|
||||||
(org.result.child1 == null ? "" : org.result.child1 + "/") +
|
(org.result.child1 == null ? "" : org.result.child1 + "/") +
|
||||||
(org.result.root == null ? "" : org.result.root);
|
(org.result.root == null ? "" : org.result.root);
|
||||||
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
|
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();
|
await _context.SaveChangesAsync();
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
.Select(p => new
|
.Select(p => new
|
||||||
{
|
{
|
||||||
p.Id,
|
p.Id,
|
||||||
|
p.profileType,
|
||||||
p.citizenId,
|
p.citizenId,
|
||||||
p.profileId,
|
p.profileId,
|
||||||
p.prefix,
|
p.prefix,
|
||||||
|
|
@ -178,6 +179,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
.Select(p => new
|
.Select(p => new
|
||||||
{
|
{
|
||||||
p.Id,
|
p.Id,
|
||||||
|
p.profileType,
|
||||||
p.profileId,
|
p.profileId,
|
||||||
p.prefix,
|
p.prefix,
|
||||||
p.firstName,
|
p.firstName,
|
||||||
|
|
@ -258,27 +260,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
[HttpPost()]
|
[HttpPost()]
|
||||||
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
|
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
|
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",
|
Status = "WAITTING",
|
||||||
CreatedFullName = FullName ?? "System Administrator",
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
CreatedUserId = UserId ?? "",
|
CreatedUserId = UserId ?? "",
|
||||||
|
|
@ -287,57 +270,115 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdatedAt = DateTime.Now,
|
LastUpdatedAt = DateTime.Now,
|
||||||
};
|
};
|
||||||
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.Id}";
|
if (req.profileType.Trim().ToUpper() == "OFFICER")
|
||||||
using (var client = new HttpClient())
|
|
||||||
{
|
{
|
||||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.Id}";
|
||||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
using (var client = new HttpClient())
|
||||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
{
|
||||||
var _res = await client.SendAsync(_req);
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
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)
|
if (org == null || org.result == null)
|
||||||
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||||
|
|
||||||
retirementOut.profileId = org.result.profileId;
|
retirementOut.profileId = org.result.profileId;
|
||||||
retirementOut.prefix = org.result.prefix;
|
retirementOut.prefix = org.result.prefix;
|
||||||
retirementOut.firstName = org.result.firstName;
|
retirementOut.firstName = org.result.firstName;
|
||||||
retirementOut.lastName = org.result.lastName;
|
retirementOut.lastName = org.result.lastName;
|
||||||
retirementOut.citizenId = org.result.citizenId;
|
retirementOut.citizenId = org.result.citizenId;
|
||||||
retirementOut.rootOld = org.result.root;
|
retirementOut.rootOld = org.result.root;
|
||||||
retirementOut.rootOldId = org.result.rootId;
|
retirementOut.rootOldId = org.result.rootId;
|
||||||
retirementOut.rootShortNameOld = org.result.rootShortName;
|
retirementOut.rootShortNameOld = org.result.rootShortName;
|
||||||
retirementOut.child1Old = org.result.child1;
|
retirementOut.child1Old = org.result.child1;
|
||||||
retirementOut.child1OldId = org.result.child1Id;
|
retirementOut.child1OldId = org.result.child1Id;
|
||||||
retirementOut.child1ShortNameOld = org.result.child1ShortName;
|
retirementOut.child1ShortNameOld = org.result.child1ShortName;
|
||||||
retirementOut.child2Old = org.result.child2;
|
retirementOut.child2Old = org.result.child2;
|
||||||
retirementOut.child2OldId = org.result.child2Id;
|
retirementOut.child2OldId = org.result.child2Id;
|
||||||
retirementOut.child2ShortNameOld = org.result.child2ShortName;
|
retirementOut.child2ShortNameOld = org.result.child2ShortName;
|
||||||
retirementOut.child3Old = org.result.child3;
|
retirementOut.child3Old = org.result.child3;
|
||||||
retirementOut.child3OldId = org.result.child3Id;
|
retirementOut.child3OldId = org.result.child3Id;
|
||||||
retirementOut.child3ShortNameOld = org.result.child3ShortName;
|
retirementOut.child3ShortNameOld = org.result.child3ShortName;
|
||||||
retirementOut.child4Old = org.result.child4;
|
retirementOut.child4Old = org.result.child4;
|
||||||
retirementOut.child4OldId = org.result.child4Id;
|
retirementOut.child4OldId = org.result.child4Id;
|
||||||
retirementOut.child4ShortNameOld = org.result.child4ShortName;
|
retirementOut.child4ShortNameOld = org.result.child4ShortName;
|
||||||
retirementOut.posMasterNoOld = org.result.posMasterNo;
|
retirementOut.posMasterNoOld = org.result.posMasterNo;
|
||||||
retirementOut.posTypeOldId = org.result.posTypeId;
|
retirementOut.posTypeOldId = org.result.posTypeId;
|
||||||
retirementOut.posTypeNameOld = org.result.posTypeName;
|
retirementOut.posTypeNameOld = org.result.posTypeName;
|
||||||
retirementOut.posLevelOldId = org.result.posLevelId;
|
retirementOut.posLevelOldId = org.result.posLevelId;
|
||||||
retirementOut.posLevelNameOld = org.result.posLevelName;
|
retirementOut.posLevelNameOld = org.result.posLevelName;
|
||||||
|
|
||||||
retirementOut.PositionOld = org.result.position;
|
retirementOut.PositionOld = org.result.position;
|
||||||
retirementOut.PositionLevelOld = org.result.posLevelName;
|
retirementOut.PositionLevelOld = org.result.posLevelName;
|
||||||
retirementOut.PositionTypeOld = org.result.posTypeName;
|
retirementOut.PositionTypeOld = org.result.posTypeName;
|
||||||
retirementOut.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
|
retirementOut.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
|
||||||
retirementOut.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "/") +
|
retirementOut.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "/") +
|
||||||
(org.result.child3 == null ? "" : org.result.child3 + "/") +
|
(org.result.child3 == null ? "" : org.result.child3 + "/") +
|
||||||
(org.result.child2 == null ? "" : org.result.child2 + "/") +
|
(org.result.child2 == null ? "" : org.result.child2 + "/") +
|
||||||
(org.result.child1 == null ? "" : org.result.child1 + "/") +
|
(org.result.child1 == null ? "" : org.result.child1 + "/") +
|
||||||
(org.result.root == null ? "" : org.result.root);
|
(org.result.root == null ? "" : org.result.root);
|
||||||
retirementOut.OrganizationPositionOld = org.result.position + "/" + retirementOut.OrganizationOld;
|
retirementOut.OrganizationPositionOld = org.result.position + "/" + retirementOut.OrganizationOld;
|
||||||
retirementOut.AmountOld = org.result.salary;
|
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.RetirementOuts.AddAsync(retirementOut);
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
|
||||||
|
|
@ -6,5 +6,6 @@ namespace BMA.EHR.Retirement.Service.Requests
|
||||||
public class RetirementAddProfileRequest
|
public class RetirementAddProfileRequest
|
||||||
{
|
{
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
|
public string profileType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue