diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
index d48ad9ca..7201875f 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
@@ -1447,7 +1447,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ส่งรายชื่อออกคำสั่ง
+ /// ส่งรายชื่อออกคำสั่ง C-PM-01
///
///
///
@@ -1458,7 +1458,11 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task> PostReportRecruit([FromBody] ReportPersonRequest req)
{
var placementProfiles = await _context.PlacementProfiles
+ .Include(x => x.Placement)
+ .ThenInclude(x => x.PlacementType)
.Where(x => req.refIds.Contains(x.Id.ToString()))
+ .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน")
+ .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED")
.ToListAsync();
foreach (var placementProfile in placementProfiles)
{
@@ -1470,7 +1474,7 @@ namespace BMA.EHR.Placement.Service.Controllers
}
///
- /// ออกคำสั่ง
+ /// ออกคำสั่ง C-PM-01
///
///
///
@@ -1658,5 +1662,222 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
+
+ ///
+ /// ส่งรายชื่อออกคำสั่ง C-PM-02
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("candidate/report")]
+ public async Task> PostReportCandidate([FromBody] ReportPersonRequest req)
+ {
+ var placementProfiles = await _context.PlacementProfiles
+ .Include(x => x.Placement)
+ .ThenInclude(x => x.PlacementType)
+ .Where(x => req.refIds.Contains(x.Id.ToString()))
+ .Where(x => x.Placement!.PlacementType!.Name != "สอบแข่งขัน")
+ .Where(x => x.typeCommand.Trim().ToUpper() == "APPOINTED")
+ .ToListAsync();
+ foreach (var placementProfile in placementProfiles)
+ {
+ // update placementstatus
+ placementProfile.PlacementStatus = "PREPARE-CONTAIN";
+ }
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// ออกคำสั่ง C-PM-02
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("candidate/report/excecute")]
+ public async Task> PostReportExecuteCandidate([FromBody] ReportExecuteRequest req)
+ {
+ // create new profile
+ foreach (var recv in req.refIds)
+ {
+ // query placement Profile
+ var placementProfile = await _context.PlacementProfiles
+ .Include(x => x.PlacementCertificates)
+ .Include(x => x.PlacementEducations)
+ .ThenInclude(x => x.EducationLevel)
+ .FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
+
+ if (placementProfile == null)
+ continue;
+
+ /*ข้อมูล Profile ใหม่*/
+ var apiUrl = $"{_configuration["API"]}/org/profile/all";
+ var profileId = string.Empty;
+ 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
+ {
+ rank = string.Empty,
+ prefix = placementProfile.Prefix == null ? string.Empty : placementProfile.Prefix,
+ firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname,
+ lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname,
+ citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId,
+ position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
+ posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId,
+ posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId,
+ email = placementProfile.Email == null ? string.Empty : placementProfile.Email,
+ phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone,
+ keycloak = string.Empty,
+ isProbation = true,
+ isLeave = false,
+ dateRetire = (DateTime?)null,
+ dateAppoint = recv.commandAffectDate,
+ dateStart = recv.commandAffectDate,
+ govAgeAbsent = 0,
+ govAgePlus = 0,
+ birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth,
+ reasonSameDate = (DateTime?)null,
+ ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race,
+ telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone,
+ nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality,
+ gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender,
+ relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship,
+ religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion,
+ bloodGroup = string.Empty,
+ registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress,
+ registrationProvinceId = (String?)null,
+ registrationDistrictId = (String?)null,
+ registrationSubDistrictId = (String?)null,
+ registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode,
+ currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress,
+ currentProvinceId = (String?)null,
+ currentDistrictId = (String?)null,
+ currentSubDistrictId = (String?)null,
+ currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ profileId = JsonConvert.DeserializeObject(_result).result;
+ }
+
+ if (placementProfile.PlacementEducations != null)
+ {
+ var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ foreach (var edu in placementProfile.PlacementEducations)
+ {
+ var _res = await client.PostAsJsonAsync(apiUrlEdu, new
+ {
+ profileId = profileId,
+ country = edu.Country == null ? string.Empty : edu.Country,
+ degree = edu.Degree == null ? string.Empty : edu.Degree,
+ duration = edu.Duration == null ? string.Empty : edu.Duration,
+ durationYear = edu.DurationYear == null ? 0 : edu.DurationYear,
+ field = edu.Field == null ? string.Empty : edu.Field,
+ finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate,
+ fundName = edu.FundName == null ? string.Empty : edu.FundName,
+ gpa = edu.Gpa == null ? string.Empty : edu.Gpa,
+ institute = edu.Institute == null ? string.Empty : edu.Institute,
+ other = edu.Other == null ? string.Empty : edu.Other,
+ startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate,
+ endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate,
+ educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name,
+ educationLevelId = string.Empty,
+ positionPath = edu.PositionPath == null ? null : edu.PositionPath,
+ positionPathId = string.Empty,
+ isDate = edu.IsDate,
+ isEducation = edu.IsEducation,
+ note = string.Empty,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ }
+ }
+ }
+
+ if (placementProfile.PlacementCertificates != null)
+ {
+ var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate";
+ using (var client = new HttpClient())
+ {
+ client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
+ client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
+ foreach (var cer in placementProfile.PlacementCertificates)
+ {
+ var _res = await client.PostAsJsonAsync(apiUrlCer, new
+ {
+ profileId = profileId,
+ expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate,
+ issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate,
+ certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo,
+ certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType,
+ issuer = cer.Issuer == null ? string.Empty : cer.Issuer,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ }
+ }
+ }
+
+ var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary";
+ 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(apiUrlSalary, new
+ {
+ profileId = profileId,
+ date = recv.commandAffectDate,
+ amount = placementProfile.Amount,
+ positionSalaryAmount = placementProfile.PositionSalaryAmount,
+ mouthSalaryAmount = placementProfile.MouthSalaryAmount,
+ posNo = placementProfile.posMasterNo == null ? "" :
+ placementProfile.node == 4 ? $"{placementProfile.child4ShortName}{placementProfile.posMasterNo}" :
+ placementProfile.node == 3 ? $"{placementProfile.child3ShortName}{placementProfile.posMasterNo}" :
+ placementProfile.node == 2 ? $"{placementProfile.child2ShortName}{placementProfile.posMasterNo}" :
+ placementProfile.node == 1 ? $"{placementProfile.child1ShortName}{placementProfile.posMasterNo}" :
+ placementProfile.node == 0 ? $"{placementProfile.rootShortName}{placementProfile.posMasterNo}" : "",
+ position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
+ positionLine = string.Empty,
+ positionPathSide = string.Empty,
+ positionExecutive = string.Empty,
+ positionType = placementProfile.posTypeName == null ? string.Empty : placementProfile.posTypeName,
+ positionLevel = placementProfile.posLevelName == null ? string.Empty : placementProfile.posLevelName,
+ refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
+ templateDoc = recv.templateDoc,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ }
+
+ var baseAPIOrg = _configuration["API"];
+ var apiUrlOrg = $"{baseAPIOrg}/org/pos/report/current";
+ 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, apiUrlOrg);
+ var _res = await client.PostAsJsonAsync(apiUrlOrg, new
+ {
+ posmasterId = placementProfile.posmasterId,
+ positionId = placementProfile.positionId,
+ profileId = profileId,
+ });
+ var _result = await _res.Content.ReadAsStringAsync();
+ }
+ // update placementstatus
+ placementProfile.PlacementStatus = "CONTAIN";//DONE
+
+ await _context.SaveChangesAsync();
+ }
+ return Success();
+ }
+
}
}