This commit is contained in:
parent
2095cd7fb4
commit
37d1ff3f40
2 changed files with 126 additions and 109 deletions
|
|
@ -103,6 +103,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,
|
||||||
|
|
@ -126,7 +127,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
p.IsActive,
|
p.IsActive,
|
||||||
})
|
})
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
return Success(retirementDeceaseds);
|
return Success(retirementDeceaseds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -147,6 +148,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
p.Id,
|
p.Id,
|
||||||
p.profileId,
|
p.profileId,
|
||||||
|
p.profileType,
|
||||||
p.prefix,
|
p.prefix,
|
||||||
p.firstName,
|
p.firstName,
|
||||||
p.lastName,
|
p.lastName,
|
||||||
|
|
@ -236,6 +238,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
{
|
{
|
||||||
// Profile = profile,
|
// Profile = profile,
|
||||||
Number = req.Number,
|
Number = req.Number,
|
||||||
|
profileType = req.profileType.Trim().ToUpper(),
|
||||||
Date = req.Date,
|
Date = req.Date,
|
||||||
Location = req.Location,
|
Location = req.Location,
|
||||||
Reason = req.Reason,
|
Reason = req.Reason,
|
||||||
|
|
@ -247,65 +250,129 @@ 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.ProfileId}";
|
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.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);
|
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
|
||||||
|
|
||||||
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
|
|
||||||
|
|
||||||
if (org == null || org.result == null)
|
|
||||||
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
|
||||||
|
|
||||||
retirementDeceased.profileId = org.result.profileId;
|
|
||||||
retirementDeceased.prefix = org.result.prefix;
|
|
||||||
retirementDeceased.firstName = org.result.firstName;
|
|
||||||
retirementDeceased.lastName = org.result.lastName;
|
|
||||||
retirementDeceased.citizenId = org.result.citizenId;
|
|
||||||
retirementDeceased.root = org.result.root;
|
|
||||||
retirementDeceased.rootId = org.result.rootId;
|
|
||||||
retirementDeceased.rootShortName = org.result.rootShortName;
|
|
||||||
retirementDeceased.child1 = org.result.child1;
|
|
||||||
retirementDeceased.child1Id = org.result.child1Id;
|
|
||||||
retirementDeceased.child1ShortName = org.result.child1ShortName;
|
|
||||||
retirementDeceased.child2 = org.result.child2;
|
|
||||||
retirementDeceased.child2Id = org.result.child2Id;
|
|
||||||
retirementDeceased.child2ShortName = org.result.child2ShortName;
|
|
||||||
retirementDeceased.child3 = org.result.child3;
|
|
||||||
retirementDeceased.child3Id = org.result.child3Id;
|
|
||||||
retirementDeceased.child3ShortName = org.result.child3ShortName;
|
|
||||||
retirementDeceased.child4 = org.result.child4;
|
|
||||||
retirementDeceased.child4Id = org.result.child4Id;
|
|
||||||
retirementDeceased.child4ShortName = org.result.child4ShortName;
|
|
||||||
retirementDeceased.posMasterNo = org.result.posMasterNo;
|
|
||||||
retirementDeceased.position = org.result.position;
|
|
||||||
retirementDeceased.posTypeId = org.result.posTypeId;
|
|
||||||
retirementDeceased.posTypeName = org.result.posTypeName;
|
|
||||||
retirementDeceased.posLevelId = org.result.posLevelId;
|
|
||||||
retirementDeceased.posLevelName = org.result.posLevelName;
|
|
||||||
}
|
|
||||||
await _context.RetirementDeceaseds.AddAsync(retirementDeceased);
|
|
||||||
//await _context.SaveChangesAsync();
|
|
||||||
|
|
||||||
var _baseAPI = _configuration["API"];
|
|
||||||
var _apiUrl = $"{_baseAPI}/org/profile/leave/{req.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);
|
|
||||||
var _res = await client.PostAsJsonAsync(_apiUrl, new
|
|
||||||
{
|
{
|
||||||
isLeave = true,
|
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||||
leaveReason = "ถึงแก่กรรม",
|
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||||
dateLeave = req.Date,
|
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||||
});
|
var _res = await client.SendAsync(_req);
|
||||||
var _result = await _res.Content.ReadAsStringAsync();
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
|
||||||
|
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
|
||||||
|
|
||||||
|
if (org == null || org.result == null)
|
||||||
|
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||||
|
|
||||||
|
retirementDeceased.profileId = org.result.profileId;
|
||||||
|
retirementDeceased.prefix = org.result.prefix;
|
||||||
|
retirementDeceased.firstName = org.result.firstName;
|
||||||
|
retirementDeceased.lastName = org.result.lastName;
|
||||||
|
retirementDeceased.citizenId = org.result.citizenId;
|
||||||
|
retirementDeceased.root = org.result.root;
|
||||||
|
retirementDeceased.rootId = org.result.rootId;
|
||||||
|
retirementDeceased.rootShortName = org.result.rootShortName;
|
||||||
|
retirementDeceased.child1 = org.result.child1;
|
||||||
|
retirementDeceased.child1Id = org.result.child1Id;
|
||||||
|
retirementDeceased.child1ShortName = org.result.child1ShortName;
|
||||||
|
retirementDeceased.child2 = org.result.child2;
|
||||||
|
retirementDeceased.child2Id = org.result.child2Id;
|
||||||
|
retirementDeceased.child2ShortName = org.result.child2ShortName;
|
||||||
|
retirementDeceased.child3 = org.result.child3;
|
||||||
|
retirementDeceased.child3Id = org.result.child3Id;
|
||||||
|
retirementDeceased.child3ShortName = org.result.child3ShortName;
|
||||||
|
retirementDeceased.child4 = org.result.child4;
|
||||||
|
retirementDeceased.child4Id = org.result.child4Id;
|
||||||
|
retirementDeceased.child4ShortName = org.result.child4ShortName;
|
||||||
|
retirementDeceased.posMasterNo = org.result.posMasterNo;
|
||||||
|
retirementDeceased.position = org.result.position;
|
||||||
|
retirementDeceased.posTypeId = org.result.posTypeId;
|
||||||
|
retirementDeceased.posTypeName = org.result.posTypeName;
|
||||||
|
retirementDeceased.posLevelId = org.result.posLevelId;
|
||||||
|
retirementDeceased.posLevelName = org.result.posLevelName;
|
||||||
|
}
|
||||||
|
await _context.RetirementDeceaseds.AddAsync(retirementDeceased);
|
||||||
|
|
||||||
|
var _baseAPI = _configuration["API"];
|
||||||
|
var _apiUrl = $"{_baseAPI}/org/profile/leave/{req.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);
|
||||||
|
var _res = await client.PostAsJsonAsync(_apiUrl, new
|
||||||
|
{
|
||||||
|
isLeave = true,
|
||||||
|
leaveReason = "ถึงแก่กรรม",
|
||||||
|
dateLeave = req.Date,
|
||||||
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{req.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)
|
||||||
|
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||||
|
|
||||||
|
retirementDeceased.profileId = org.result.profileId;
|
||||||
|
retirementDeceased.prefix = org.result.prefix;
|
||||||
|
retirementDeceased.firstName = org.result.firstName;
|
||||||
|
retirementDeceased.lastName = org.result.lastName;
|
||||||
|
retirementDeceased.citizenId = org.result.citizenId;
|
||||||
|
retirementDeceased.root = org.result.root;
|
||||||
|
retirementDeceased.rootId = org.result.rootId;
|
||||||
|
retirementDeceased.rootShortName = org.result.rootShortName;
|
||||||
|
retirementDeceased.child1 = org.result.child1;
|
||||||
|
retirementDeceased.child1Id = org.result.child1Id;
|
||||||
|
retirementDeceased.child1ShortName = org.result.child1ShortName;
|
||||||
|
retirementDeceased.child2 = org.result.child2;
|
||||||
|
retirementDeceased.child2Id = org.result.child2Id;
|
||||||
|
retirementDeceased.child2ShortName = org.result.child2ShortName;
|
||||||
|
retirementDeceased.child3 = org.result.child3;
|
||||||
|
retirementDeceased.child3Id = org.result.child3Id;
|
||||||
|
retirementDeceased.child3ShortName = org.result.child3ShortName;
|
||||||
|
retirementDeceased.child4 = org.result.child4;
|
||||||
|
retirementDeceased.child4Id = org.result.child4Id;
|
||||||
|
retirementDeceased.child4ShortName = org.result.child4ShortName;
|
||||||
|
retirementDeceased.posMasterNo = org.result.posMasterNo;
|
||||||
|
retirementDeceased.position = org.result.position;
|
||||||
|
retirementDeceased.posTypeId = org.result.posTypeId;
|
||||||
|
retirementDeceased.posTypeName = org.result.posTypeName;
|
||||||
|
retirementDeceased.posLevelId = org.result.posLevelId;
|
||||||
|
retirementDeceased.posLevelName = org.result.posLevelName;
|
||||||
|
}
|
||||||
|
await _context.RetirementDeceaseds.AddAsync(retirementDeceased);
|
||||||
|
|
||||||
|
var _baseAPI = _configuration["API"];
|
||||||
|
var _apiUrl = $"{_baseAPI}/org/profile-employee/leave/{req.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);
|
||||||
|
var _res = await client.PostAsJsonAsync(_apiUrl, new
|
||||||
|
{
|
||||||
|
isLeave = true,
|
||||||
|
leaveReason = "ถึงแก่กรรม",
|
||||||
|
dateLeave = req.Date,
|
||||||
|
});
|
||||||
|
var _result = await _res.Content.ReadAsStringAsync();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var _doc = new Domain.Models.Documents.Document();
|
var _doc = new Domain.Models.Documents.Document();
|
||||||
|
|
@ -320,56 +387,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
if (_doc != null)
|
if (_doc != null)
|
||||||
retirementDeceased.Document = _doc;
|
retirementDeceased.Document = _doc;
|
||||||
}
|
}
|
||||||
// await _context.ProfileSalaries.AddAsync(new ProfileSalary
|
|
||||||
// {
|
|
||||||
// Date = req.Date,
|
|
||||||
// SalaryRef = req.Number,
|
|
||||||
// CommandNo = "-",
|
|
||||||
// SalaryClass = "-",
|
|
||||||
// PosNoEmployee = "-",
|
|
||||||
// CommandTypeName = "-",
|
|
||||||
// SalaryStatus = "DEATH",
|
|
||||||
// Profile = profile,
|
|
||||||
// CreatedFullName = FullName ?? "System Administrator",
|
|
||||||
// CreatedUserId = UserId ?? "",
|
|
||||||
// CreatedAt = DateTime.Now,
|
|
||||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
|
||||||
// LastUpdateUserId = UserId ?? "",
|
|
||||||
// LastUpdatedAt = DateTime.Now,
|
|
||||||
// });
|
|
||||||
// if (_doc != null)
|
|
||||||
// {
|
|
||||||
// await _context.ProfilePapers.AddAsync(new ProfilePaper
|
|
||||||
// {
|
|
||||||
// Detail = "ถึงแก่กรรม",
|
|
||||||
// CategoryName = "DEATH",
|
|
||||||
// Document = _doc,
|
|
||||||
// Profile = profile,
|
|
||||||
// CreatedFullName = FullName ?? "System Administrator",
|
|
||||||
// CreatedUserId = UserId ?? "",
|
|
||||||
// CreatedAt = DateTime.Now,
|
|
||||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
|
||||||
// LastUpdateUserId = UserId ?? "",
|
|
||||||
// LastUpdatedAt = DateTime.Now,
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// var orgPos = await _context.ProfilePositions
|
|
||||||
// .Include(x => x.Profile)
|
|
||||||
// .ThenInclude(x => x!.Prefix)
|
|
||||||
// .Include(x => x.OrganizationPosition)
|
|
||||||
// .ThenInclude(x => x!.Organization)
|
|
||||||
// .ThenInclude(x => x!.OrganizationOrganization)
|
|
||||||
// .Include(x => x.OrganizationPosition)
|
|
||||||
// .ThenInclude(x => x!.PositionMaster)
|
|
||||||
// .ThenInclude(x => x!.PositionPath)
|
|
||||||
// .Where(x => x.OrganizationPosition!.IsDirector! == true)
|
|
||||||
// .Where(x => x.OrganizationPosition!.Organization!.Id == profile.OcId)
|
|
||||||
// .FirstOrDefaultAsync();
|
|
||||||
|
|
||||||
// if (orgPos != null)
|
|
||||||
// {
|
|
||||||
// if (orgPos.Profile != null)
|
|
||||||
// {
|
|
||||||
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
|
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
|
||||||
{
|
{
|
||||||
CitizenId = retirementDeceased.citizenId == null ? "" : retirementDeceased.citizenId,
|
CitizenId = retirementDeceased.citizenId == null ? "" : retirementDeceased.citizenId,
|
||||||
|
|
@ -389,8 +407,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
||||||
LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
LastUpdatedAt = DateTime.Now,
|
LastUpdatedAt = DateTime.Now,
|
||||||
});
|
});
|
||||||
// }
|
|
||||||
// }
|
|
||||||
await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
|
|
|
||||||
|
|
@ -11,5 +11,6 @@ namespace BMA.EHR.Retirement.Service.Requests
|
||||||
public string? Location { get; set; }
|
public string? Location { get; set; }
|
||||||
public string? Reason { get; set; }
|
public string? Reason { get; set; }
|
||||||
public string ProfileId { get; set; }
|
public string ProfileId { get; set; }
|
||||||
|
public string profileType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue