diff --git a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
index 4700c31f..d48ad9ca 100644
--- a/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
+++ b/BMA.EHR.Placement.Service/Controllers/PlacementController.cs
@@ -1446,5 +1446,217 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success(position);
}
+ ///
+ /// ส่งรายชื่อออกคำสั่ง
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("recruit/report")]
+ public async Task> PostReportRecruit([FromBody] ReportPersonRequest req)
+ {
+ var placementProfiles = await _context.PlacementProfiles
+ .Where(x => req.refIds.Contains(x.Id.ToString()))
+ .ToListAsync();
+ foreach (var placementProfile in placementProfiles)
+ {
+ // update placementstatus
+ placementProfile.PlacementStatus = "PREPARE-CONTAIN";
+ }
+ await _context.SaveChangesAsync();
+ return Success();
+ }
+
+ ///
+ /// ออกคำสั่ง
+ ///
+ ///
+ ///
+ /// ค่าตัวแปรที่ส่งมาไม่ถูกต้อง
+ /// ไม่ได้ Login เข้าระบบ
+ /// เมื่อเกิดข้อผิดพลาดในการทำงาน
+ [HttpPost("recruit/report/excecute")]
+ public async Task> PostReportExecuteRecruit([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();
+ }
+
}
}
diff --git a/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs b/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs
new file mode 100644
index 00000000..fc5b180c
--- /dev/null
+++ b/BMA.EHR.Placement.Service/Requests/ReportExecuteRequest.cs
@@ -0,0 +1,18 @@
+using BMA.EHR.Domain.Models.MetaData;
+using Microsoft.EntityFrameworkCore;
+
+namespace BMA.EHR.Placement.Service.Requests
+{
+ public class ReportExecuteRequest
+ {
+ public ReportExecuteRequestObj[] refIds { get; set; }
+ }
+ public class ReportExecuteRequestObj
+ {
+ public string? refId { get; set; }
+ public DateTime commandAffectDate { get; set; }
+ public string? commandNo { get; set; }
+ public int commandYear { get; set; }
+ public string? templateDoc { get; set; }
+ }
+}
diff --git a/BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs b/BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs
new file mode 100644
index 00000000..e061f5a1
--- /dev/null
+++ b/BMA.EHR.Placement.Service/Requests/ReportPersonRequest.cs
@@ -0,0 +1,10 @@
+using BMA.EHR.Domain.Models.MetaData;
+using Microsoft.EntityFrameworkCore;
+
+namespace BMA.EHR.Placement.Service.Requests
+{
+ public class ReportPersonRequest
+ {
+ public string[] refIds { get; set; }
+ }
+}