แก้โครงสร้างพ้นราชการ
This commit is contained in:
parent
18d75f4b04
commit
db712d586a
41 changed files with 125142 additions and 411 deletions
|
|
@ -67,84 +67,105 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
[HttpGet()]
|
||||
public async Task<ActionResult<ResponseObject>> GetListByAdmin()
|
||||
{
|
||||
var rootId = "";
|
||||
var child1Id = "";
|
||||
var child2Id = "";
|
||||
var child3Id = "";
|
||||
var child4Id = "";
|
||||
var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
|
||||
var _res = await client.SendAsync(_req);
|
||||
var _result = await _res.Content.ReadAsStringAsync();
|
||||
// var rootId = "";
|
||||
// var child1Id = "";
|
||||
// var child2Id = "";
|
||||
// var child3Id = "";
|
||||
// var child4Id = "";
|
||||
// var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
|
||||
// using (var client = new HttpClient())
|
||||
// {
|
||||
// client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
// 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);
|
||||
rootId = org.result.rootId == null ? "" : org.result.rootId;
|
||||
child1Id = org.result.child1Id == null ? "" : org.result.child1Id;
|
||||
child2Id = org.result.child2Id == null ? "" : org.result.child2Id;
|
||||
child3Id = org.result.child3Id == null ? "" : org.result.child3Id;
|
||||
child4Id = org.result.child4Id == null ? "" : org.result.child4Id;
|
||||
// if (org == null || org.result == null)
|
||||
// return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
|
||||
// rootId = org.result.rootId == null ? "" : org.result.rootId;
|
||||
// child1Id = org.result.child1Id == null ? "" : org.result.child1Id;
|
||||
// child2Id = org.result.child2Id == null ? "" : org.result.child2Id;
|
||||
// child3Id = org.result.child3Id == null ? "" : org.result.child3Id;
|
||||
// child4Id = org.result.child4Id == null ? "" : org.result.child4Id;
|
||||
|
||||
var placementReceives = await _context.PlacementReceives.AsQueryable()
|
||||
var placementReceives = await _context.PlacementReceives.AsQueryable()
|
||||
.OrderByDescending(x => x.CreatedAt)
|
||||
.Where(x => PlacementAdmin == true ? true : (rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))))
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.citizenId,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
p.DateOfBirth,
|
||||
Gender = p.Gender == null ? null : p.Gender.Name,
|
||||
p.Status,
|
||||
p.Amount,
|
||||
p.RecruitDate,
|
||||
p.root,
|
||||
p.rootId,
|
||||
p.rootShortName,
|
||||
p.child1,
|
||||
p.child1Id,
|
||||
p.child1ShortName,
|
||||
p.child2,
|
||||
p.child2Id,
|
||||
p.child2ShortName,
|
||||
p.child3,
|
||||
p.child3Id,
|
||||
p.child3ShortName,
|
||||
p.child4,
|
||||
p.child4Id,
|
||||
p.child4ShortName,
|
||||
p.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.positionName,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
p.IsActive,
|
||||
p.Reason,
|
||||
p.EducationOld,
|
||||
p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
// if (PlacementAdmin == true)
|
||||
// placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
|
||||
// .Where(x => PlacementAdmin == true ? true : (rootId == "" ? true : (child1Id == "" ? x.rootId == rootId : (child2Id == "" ? x.child1Id == child1Id : (child3Id == "" ? x.child2Id == child2Id : (child4Id == "" ? x.child3Id == child3Id : x.child4Id == child4Id))))))
|
||||
.Select(p => new
|
||||
{
|
||||
p.Id,
|
||||
p.prefix,
|
||||
p.firstName,
|
||||
p.lastName,
|
||||
p.citizenId,
|
||||
p.Status,
|
||||
p.RecruitDate,
|
||||
p.root,
|
||||
p.rootId,
|
||||
p.rootShortName,
|
||||
p.child1,
|
||||
p.child1Id,
|
||||
p.child1ShortName,
|
||||
p.child2,
|
||||
p.child2Id,
|
||||
p.child2ShortName,
|
||||
p.child3,
|
||||
p.child3Id,
|
||||
p.child3ShortName,
|
||||
p.child4,
|
||||
p.child4Id,
|
||||
p.child4ShortName,
|
||||
p.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.position,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
|
||||
return Success(placementReceives);
|
||||
}
|
||||
p.IsActive,
|
||||
p.Reason,
|
||||
p.EducationOld,
|
||||
p.AmountOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.OrganizationOld,
|
||||
|
||||
p.rootOld,
|
||||
p.rootOldId,
|
||||
p.rootShortNameOld,
|
||||
p.child1Old,
|
||||
p.child1OldId,
|
||||
p.child1ShortNameOld,
|
||||
p.child2Old,
|
||||
p.child2OldId,
|
||||
p.child2ShortNameOld,
|
||||
p.child3Old,
|
||||
p.child3OldId,
|
||||
p.child3ShortNameOld,
|
||||
p.child4Old,
|
||||
p.child4OldId,
|
||||
p.child4ShortNameOld,
|
||||
p.posMasterNoOld,
|
||||
p.positionOld,
|
||||
p.posTypeOldId,
|
||||
p.posTypeNameOld,
|
||||
p.posLevelOldId,
|
||||
p.posLevelNameOld,
|
||||
p.CreatedAt,
|
||||
})
|
||||
.ToListAsync();
|
||||
// if (PlacementAdmin == true)
|
||||
// placementReceives.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
|
||||
|
||||
return Success(placementReceives);
|
||||
// }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -198,20 +219,46 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
p.orgRevisionId,
|
||||
p.positionId,
|
||||
p.posMasterNo,
|
||||
p.positionName,
|
||||
p.position,
|
||||
p.positionField,
|
||||
p.posTypeId,
|
||||
p.posTypeName,
|
||||
p.posLevelId,
|
||||
p.posLevelName,
|
||||
|
||||
p.CreatedAt,
|
||||
p.Reason,
|
||||
p.EducationOld,
|
||||
p.AmountOld,
|
||||
p.PositionOld,
|
||||
p.OrganizationOld,
|
||||
p.PositionTypeOld,
|
||||
p.PositionLevelOld,
|
||||
p.PositionNumberOld,
|
||||
p.OrganizationPositionOld,
|
||||
p.IsActive,
|
||||
|
||||
p.rootOld,
|
||||
p.rootOldId,
|
||||
p.rootShortNameOld,
|
||||
p.child1Old,
|
||||
p.child1OldId,
|
||||
p.child1ShortNameOld,
|
||||
p.child2Old,
|
||||
p.child2OldId,
|
||||
p.child2ShortNameOld,
|
||||
p.child3Old,
|
||||
p.child3OldId,
|
||||
p.child3ShortNameOld,
|
||||
p.child4Old,
|
||||
p.child4OldId,
|
||||
p.child4ShortNameOld,
|
||||
p.posMasterNoOld,
|
||||
p.posTypeOldId,
|
||||
p.posTypeNameOld,
|
||||
p.posLevelOldId,
|
||||
p.posLevelNameOld,
|
||||
|
||||
// Avatar = p.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Avatar.Id,
|
||||
PlacementReceiveDocs = p.PlacementReceiveDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
|
||||
})
|
||||
|
|
@ -263,23 +310,53 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
data.child4,
|
||||
data.child4Id,
|
||||
data.child4ShortName,
|
||||
node = data.root == null ? (int?)null : (data.child1 == null ? 0 : (data.child2 == null ? 1 : (data.child3 == null ? 2 : (data.child4 == null ? 3 : 4)))),
|
||||
nodeName = data.root == null ? null : (data.child1 == null ? data.root : (data.child2 == null ? data.child1 : (data.child3 == null ? data.child2 : (data.child4 == null ? data.child3 : data.child4)))),
|
||||
nodeId = data.rootId == null ? null : (data.child1Id == null ? data.rootId : (data.child2Id == null ? data.child1Id : (data.child3Id == null ? data.child2Id : (data.child4Id == null ? data.child3Id : data.child4Id)))),
|
||||
nodeShortName = data.rootShortName == null ? null : (data.child1ShortName == null ? data.rootShortName : (data.child2ShortName == null ? data.child1ShortName : (data.child3ShortName == null ? data.child2ShortName : (data.child4ShortName == null ? data.child3ShortName : data.child4ShortName)))),
|
||||
data.orgRevisionId,
|
||||
data.positionId,
|
||||
data.posMasterNo,
|
||||
data.positionName,
|
||||
data.position,
|
||||
data.positionField,
|
||||
data.posTypeId,
|
||||
data.posTypeName,
|
||||
data.posLevelId,
|
||||
data.posLevelName,
|
||||
|
||||
data.CreatedAt,
|
||||
data.Reason,
|
||||
data.EducationOld,
|
||||
data.AmountOld,
|
||||
data.PositionOld,
|
||||
data.OrganizationOld,
|
||||
data.PositionTypeOld,
|
||||
data.PositionLevelOld,
|
||||
data.PositionNumberOld,
|
||||
data.OrganizationPositionOld,
|
||||
data.IsActive,
|
||||
|
||||
data.rootOld,
|
||||
data.rootOldId,
|
||||
data.rootShortNameOld,
|
||||
data.child1Old,
|
||||
data.child1OldId,
|
||||
data.child1ShortNameOld,
|
||||
data.child2Old,
|
||||
data.child2OldId,
|
||||
data.child2ShortNameOld,
|
||||
data.child3Old,
|
||||
data.child3OldId,
|
||||
data.child3ShortNameOld,
|
||||
data.child4Old,
|
||||
data.child4OldId,
|
||||
data.child4ShortNameOld,
|
||||
data.posMasterNoOld,
|
||||
data.posTypeOldId,
|
||||
data.posTypeNameOld,
|
||||
data.posLevelOldId,
|
||||
data.posLevelNameOld,
|
||||
|
||||
// Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
|
||||
Docs = placementReceiveDocs,
|
||||
};
|
||||
|
|
@ -321,24 +398,60 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
};
|
||||
// var profile = await _context.Profiles
|
||||
// .Include(x => x.PositionLevel)
|
||||
// .Include(x => x.PositionType)
|
||||
// .Include(x => x.PosNo)
|
||||
// .Include(x => x.Salaries)
|
||||
// .Include(x => x.Educations)
|
||||
// .Include(x => x.Position)
|
||||
// .FirstOrDefaultAsync(x => x.CitizenId == req.CitizenId);
|
||||
// if (profile != null)
|
||||
// {
|
||||
// placementReceive.EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}";
|
||||
// placementReceive.AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
|
||||
// placementReceive.PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name;
|
||||
// placementReceive.PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name;
|
||||
// placementReceive.PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name;
|
||||
// placementReceive.OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}";
|
||||
// }
|
||||
|
||||
var apiUrl = $"{_configuration["API"]}org/profile/citizenid/position/{req.citizenId}";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
|
||||
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)
|
||||
{
|
||||
placementReceive.profileId = org.result.profileId;
|
||||
placementReceive.prefix = org.result.prefix;
|
||||
placementReceive.firstName = org.result.firstName;
|
||||
placementReceive.lastName = org.result.lastName;
|
||||
placementReceive.citizenId = org.result.citizenId;
|
||||
placementReceive.rootOld = org.result.root;
|
||||
placementReceive.rootOldId = org.result.rootId;
|
||||
placementReceive.rootShortNameOld = org.result.rootShortName;
|
||||
placementReceive.child1Old = org.result.child1;
|
||||
placementReceive.child1OldId = org.result.child1Id;
|
||||
placementReceive.child1ShortNameOld = org.result.child1ShortName;
|
||||
placementReceive.child2Old = org.result.child2;
|
||||
placementReceive.child2OldId = org.result.child2Id;
|
||||
placementReceive.child2ShortNameOld = org.result.child2ShortName;
|
||||
placementReceive.child3Old = org.result.child3;
|
||||
placementReceive.child3OldId = org.result.child3Id;
|
||||
placementReceive.child3ShortNameOld = org.result.child3ShortName;
|
||||
placementReceive.child4Old = org.result.child4;
|
||||
placementReceive.child4OldId = org.result.child4Id;
|
||||
placementReceive.child4ShortNameOld = org.result.child4ShortName;
|
||||
placementReceive.posMasterNoOld = org.result.posMasterNo;
|
||||
placementReceive.posTypeOldId = org.result.posTypeId;
|
||||
placementReceive.posTypeNameOld = org.result.posTypeName;
|
||||
placementReceive.posLevelOldId = org.result.posLevelId;
|
||||
placementReceive.posLevelNameOld = org.result.posLevelName;
|
||||
|
||||
// placementReceive.EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}";
|
||||
// placementReceive.AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
|
||||
|
||||
placementReceive.PositionOld = org.result.position;
|
||||
placementReceive.PositionLevelOld = org.result.posLevelName;
|
||||
placementReceive.PositionTypeOld = org.result.posTypeName;
|
||||
placementReceive.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
|
||||
placementReceive.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 + "/");
|
||||
placementReceive.OrganizationPositionOld = org.result.position + "-" + placementReceive.OrganizationOld;
|
||||
}
|
||||
}
|
||||
await _context.PlacementReceives.AddAsync(placementReceive);
|
||||
await _context.SaveChangesAsync();
|
||||
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
|
||||
|
|
@ -478,7 +591,7 @@ namespace BMA.EHR.Placement.Service.Controllers
|
|||
uppdated.orgRevisionId = req.orgRevisionId;
|
||||
uppdated.positionId = req.positionId;
|
||||
uppdated.posMasterNo = req.posMasterNo;
|
||||
uppdated.positionName = req.positionName;
|
||||
uppdated.position = req.position;
|
||||
uppdated.positionField = req.positionField;
|
||||
uppdated.posTypeId = req.posTypeId;
|
||||
uppdated.posTypeName = req.posTypeName;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue