Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop

This commit is contained in:
Kittapath 2024-05-09 12:53:30 +07:00
commit 7876063288
2 changed files with 411 additions and 271 deletions

View file

@ -2557,7 +2557,7 @@ namespace BMA.EHR.Application.Repositories.Commands
{ {
case "C-PM-01": case "C-PM-01":
case "C-PM-02": case "C-PM-02":
await ExecuteCommand01_02Async(command); await ExecuteCommand01_02Async(command, token);
break; break;
case "C-PM-03": case "C-PM-03":
await ExecuteCommand03Async(command); await ExecuteCommand03Async(command);
@ -2675,7 +2675,7 @@ namespace BMA.EHR.Application.Repositories.Commands
/// </summary> /// </summary>
/// <param name="command">object ของรายการคำสั่ง</param> /// <param name="command">object ของรายการคำสั่ง</param>
/// <returns></returns> /// <returns></returns>
private async Task ExecuteCommand01_02Async(Command command) private async Task ExecuteCommand01_02Async(Command command, string token="")
{ {
try try
{ {
@ -2756,228 +2756,363 @@ namespace BMA.EHR.Application.Repositories.Commands
throw new Exception("Invalid placement profile: " + recv.RefPlacementProfileId); throw new Exception("Invalid placement profile: " + recv.RefPlacementProfileId);
// ใส่ฟีลจากข้อมูล // ใส่ฟีลจากข้อมูล
var profile = new Profile ////var profile = new Profile
////{
//// ProfileType = "officer",
//// CitizenId = placementProfile.CitizenId,
//// Prefix = placementProfile.Prefix,
//// FirstName = placementProfile.Firstname,
//// LastName = placementProfile.Lastname,
//// Gender = placementProfile.Gender,
//// Nationality = placementProfile.Nationality,
//// BirthDate = placementProfile.DateOfBirth == null ? DateTime.MinValue : placementProfile.DateOfBirth.Value,
//// RelationshipId = placementProfile.Relationship == null ? Guid.Empty : placementProfile.Relationship!.Id,
//// TelephoneNumber = placementProfile.Telephone,
//// Race = placementProfile.Race,
//// ReligionId = placementProfile.Religion == null ? Guid.Empty : placementProfile.Religion.Id,
//// BloodGroupId = placementProfile.BloodGroup == null ? Guid.Empty : placementProfile.BloodGroup.Id,
//// DateAppoint = placementProfile.RecruitDate == null ? null : placementProfile.RecruitDate.Value,
//// DateStart = placementProfile.RecruitDate == null ? null : placementProfile.RecruitDate.Value,
//// RegistrationAddress = placementProfile.RegistAddress,
//// RegistrationSubDistrictId = placementProfile.RegistSubDistrict == null ? Guid.Empty : placementProfile.RegistSubDistrict!.Id,
//// RegistrationDistrictId = placementProfile.RegistDistrict == null ? Guid.Empty : placementProfile.RegistDistrict!.Id,
//// RegistrationProvinceId = placementProfile.RegistProvince == null ? Guid.Empty : placementProfile.RegistProvince!.Id,
//// RegistrationZipCode = placementProfile.RegistSubDistrict == null ? null : placementProfile.RegistSubDistrict!.ZipCode,
//// CurrentAddress = placementProfile.CurrentAddress,
//// CurrentSubDistrictId = placementProfile.CurrentSubDistrict == null ? Guid.Empty : placementProfile.CurrentSubDistrict!.Id,
//// CurrentDistrictId = placementProfile.CurrentDistrict == null ? Guid.Empty : placementProfile.CurrentDistrict!.Id,
//// CurrentProvinceId = placementProfile.CurrentProvince == null ? Guid.Empty : placementProfile.CurrentProvince!.Id,
//// CurrentZipCode = placementProfile.CurrentSubDistrict == null ? null : placementProfile.CurrentSubDistrict!.ZipCode,
//// FatherPrefixId = placementProfile.FatherPrefix == null ? null : placementProfile.FatherPrefix.Id,
//// FatherFirstName = placementProfile.FatherFirstName,
//// FatherLastName = placementProfile.FatherLastName,
//// FatherCareer = placementProfile.FatherOccupation,
//// FatherLive = true,
//// MotherPrefixId = placementProfile.MotherPrefix == null ? null : placementProfile.MotherPrefix.Id,
//// MotherFirstName = placementProfile.MotherFirstName,
//// MotherLastName = placementProfile.MotherLastName,
//// MotherCareer = placementProfile.MotherOccupation,
//// MotherLive = true,
//// Couple = placementProfile.MarryPrefix == null ? false : true,
//// CouplePrefixId = placementProfile.MarryPrefix == null ? null : placementProfile.MarryPrefix.Id,
//// CoupleFirstName = placementProfile.MarryFirstName,
//// CoupleLastName = placementProfile.MarryLastName,
//// CoupleCareer = placementProfile.MarryOccupation,
//// CoupleLive = placementProfile.MarryPrefix == null ? false : true,
//// Position = placementProfile.PositionPath,
//// PositionPathSideId = placementProfile.PositionPathSide == null ? Guid.Empty : placementProfile.PositionPathSide.Id,
//// PositionType = placementProfile.PositionType,
//// PositionLevel = placementProfile.PositionLevel,
//// //PositionEmployeeLevel = placementProfile.PositionLevel,
//// PositionLineId = placementProfile.PositionLine == null ? Guid.Empty : placementProfile.PositionLine.Id,
//// PositionLine = placementProfile.PositionLine == null ? "" : placementProfile.PositionLine.Name,
//// PosNo = placementProfile.OrganizationPosition!.PositionNumber,
//// IsVerified = true,
//// IsProbation = true,
//// Physical = "",
//// Ability = "",
//// AvatarRef = "",
//// GovAgeAbsent = 0,
//// GovAgePlus = 0,
//// EntryStatus = "",
//// IsTransfer = false,
//// IsActive = true,
//// IsLeave = false,
//// VerifiedUser = "",
//// FirstNameOld = "",
//// LastNameOld = "",
//// // CoupleLive = false,
//// // FatherLive = false,
//// // MotherLive = false,
//// CreatedUser = "",
//// Educations = new List<ProfileEducation>(),
//// Certificates = new List<ProfileCertificate>(),
//// Salaries = new List<ProfileSalary>(),
//// CreatedAt = DateTime.Now,
//// CreatedFullName = FullName ?? "System Administrator",
//// CreatedUserId = UserId ?? "",
//// LastUpdatedAt = DateTime.Now,
//// LastUpdateFullName = FullName ?? "System Administrator",
//// LastUpdateUserId = UserId ?? "",
//// // organization
//// OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
//// OrganizationShortName = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Name,
//// OrganizationOrganizationId = placementProfile.OrganizationPosition!.Organization!.OrganizationOrganization!.Id,
//// OrganizationOrganization = placementProfile.OrganizationPosition!.Organization!.OrganizationOrganization!.Name,
//// OcId = placementProfile.OrganizationPosition!.Organization!.Id,
//// Oc = _organizationCommonRepository.GetOrganizationNameFullPath(placementProfile.OrganizationPosition!.Organization!.Id, false, false, "/"),
////};
/*ข้อมูล Profile ใหม่*/
var apiUrl = $"{_configuration["API"]}/org/profile/all";
var profileId = string.Empty;
using (var client = new HttpClient())
{ {
ProfileType = "officer", client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
CitizenId = placementProfile.CitizenId, var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
Prefix = placementProfile.Prefix, var _res = await client.PostAsJsonAsync(apiUrl, new
FirstName = placementProfile.Firstname, {
LastName = placementProfile.Lastname, rank = string.Empty,
Gender = placementProfile.Gender, prefix = placementProfile.Prefix.Name == null ? string.Empty : placementProfile.Prefix.Name,
Nationality = placementProfile.Nationality, firstName = placementProfile.Firstname == null ? string.Empty : placementProfile.Firstname,
BirthDate = placementProfile.DateOfBirth == null ? DateTime.MinValue : placementProfile.DateOfBirth.Value, lastName = placementProfile.Lastname == null ? string.Empty : placementProfile.Lastname,
RelationshipId = placementProfile.Relationship == null ? Guid.Empty : placementProfile.Relationship!.Id, citizenId = placementProfile.CitizenId == null ? string.Empty : placementProfile.CitizenId,
TelephoneNumber = placementProfile.Telephone, position = placementProfile.positionName == null ? string.Empty : placementProfile.positionName,
Race = placementProfile.Race, posLevelId = placementProfile.posLevelId == null ? string.Empty : placementProfile.posLevelId,
ReligionId = placementProfile.Religion == null ? Guid.Empty : placementProfile.Religion.Id, posTypeId = placementProfile.posTypeId == null ? string.Empty : placementProfile.posTypeId,
BloodGroupId = placementProfile.BloodGroup == null ? Guid.Empty : placementProfile.BloodGroup.Id, email = placementProfile.Email == null ? string.Empty : placementProfile.Email,
phone = placementProfile.MobilePhone == null ? string.Empty : placementProfile.MobilePhone,
DateAppoint = placementProfile.RecruitDate == null ? null : placementProfile.RecruitDate.Value, keycloak = string.Empty,
DateStart = placementProfile.RecruitDate == null ? null : placementProfile.RecruitDate.Value, isProbation = false,
isLeave = false,
RegistrationAddress = placementProfile.RegistAddress, dateRetire = (DateTime?)null,
RegistrationSubDistrictId = placementProfile.RegistSubDistrict == null ? Guid.Empty : placementProfile.RegistSubDistrict!.Id, dateAppoint = placementProfile.RecruitDate == null ? (DateTime?)null : placementProfile.RecruitDate,
RegistrationDistrictId = placementProfile.RegistDistrict == null ? Guid.Empty : placementProfile.RegistDistrict!.Id, dateStart = (DateTime?)null,
RegistrationProvinceId = placementProfile.RegistProvince == null ? Guid.Empty : placementProfile.RegistProvince!.Id, govAgeAbsent = 0,
RegistrationZipCode = placementProfile.RegistSubDistrict == null ? null : placementProfile.RegistSubDistrict!.ZipCode, govAgePlus = 0,
birthDate = placementProfile.DateOfBirth == null ? (DateTime?)null : placementProfile.DateOfBirth,
CurrentAddress = placementProfile.CurrentAddress, reasonSameDate = (DateTime?)null,
CurrentSubDistrictId = placementProfile.CurrentSubDistrict == null ? Guid.Empty : placementProfile.CurrentSubDistrict!.Id, ethnicity = placementProfile.Race == null ? string.Empty : placementProfile.Race,
CurrentDistrictId = placementProfile.CurrentDistrict == null ? Guid.Empty : placementProfile.CurrentDistrict!.Id, telephoneNumber = placementProfile.Telephone == null ? string.Empty : placementProfile.Telephone,
CurrentProvinceId = placementProfile.CurrentProvince == null ? Guid.Empty : placementProfile.CurrentProvince!.Id, nationality = placementProfile.Nationality == null ? string.Empty : placementProfile.Nationality,
CurrentZipCode = placementProfile.CurrentSubDistrict == null ? null : placementProfile.CurrentSubDistrict!.ZipCode, gender = placementProfile.Gender == null ? string.Empty : placementProfile.Gender.Name,
relationship = placementProfile.Relationship == null ? string.Empty : placementProfile.Relationship.Name,
FatherPrefixId = placementProfile.FatherPrefix == null ? null : placementProfile.FatherPrefix.Id, religion = placementProfile.Religion == null ? string.Empty : placementProfile.Religion.Name,
FatherFirstName = placementProfile.FatherFirstName, bloodGroup = string.Empty,
FatherLastName = placementProfile.FatherLastName, registrationAddress = placementProfile.RegistAddress == null ? string.Empty : placementProfile.RegistAddress,
FatherCareer = placementProfile.FatherOccupation, registrationProvinceId = (String?)null,
FatherLive = true, registrationDistrictId = (String?)null,
registrationSubDistrictId = (String?)null,
MotherPrefixId = placementProfile.MotherPrefix == null ? null : placementProfile.MotherPrefix.Id, registrationZipCode = placementProfile.RegistZipCode == null ? string.Empty : placementProfile.RegistZipCode,
MotherFirstName = placementProfile.MotherFirstName, currentAddress = placementProfile.CurrentAddress == null ? string.Empty : placementProfile.CurrentAddress,
MotherLastName = placementProfile.MotherLastName, currentProvinceId = (String?)null,
MotherCareer = placementProfile.MotherOccupation, currentDistrictId = (String?)null,
MotherLive = true, currentSubDistrictId = (String?)null,
currentZipCode = placementProfile.CurrentZipCode == null ? string.Empty : placementProfile.CurrentZipCode,
Couple = placementProfile.MarryPrefix == null ? false : true, });
CouplePrefixId = placementProfile.MarryPrefix == null ? null : placementProfile.MarryPrefix.Id, var _result = await _res.Content.ReadAsStringAsync();
CoupleFirstName = placementProfile.MarryFirstName, profileId = JsonConvert.DeserializeObject<PlacementProfileId>(_result).result;
CoupleLastName = placementProfile.MarryLastName, }
CoupleCareer = placementProfile.MarryOccupation,
CoupleLive = placementProfile.MarryPrefix == null ? false : true,
Position = placementProfile.PositionPath,
PositionPathSideId = placementProfile.PositionPathSide == null ? Guid.Empty : placementProfile.PositionPathSide.Id,
PositionType = placementProfile.PositionType,
PositionLevel = placementProfile.PositionLevel,
//PositionEmployeeLevel = placementProfile.PositionLevel,
PositionLineId = placementProfile.PositionLine == null ? Guid.Empty : placementProfile.PositionLine.Id,
PositionLine = placementProfile.PositionLine == null ? "" : placementProfile.PositionLine.Name,
PosNo = placementProfile.OrganizationPosition!.PositionNumber,
IsVerified = true,
IsProbation = true,
Physical = "",
Ability = "",
AvatarRef = "",
GovAgeAbsent = 0,
GovAgePlus = 0,
EntryStatus = "",
IsTransfer = false,
IsActive = true,
IsLeave = false,
VerifiedUser = "",
FirstNameOld = "",
LastNameOld = "",
// CoupleLive = false,
// FatherLive = false,
// MotherLive = false,
CreatedUser = "",
Educations = new List<ProfileEducation>(),
Certificates = new List<ProfileCertificate>(),
Salaries = new List<ProfileSalary>(),
CreatedAt = DateTime.Now,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
// organization
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
OrganizationShortName = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Name,
OrganizationOrganizationId = placementProfile.OrganizationPosition!.Organization!.OrganizationOrganization!.Id,
OrganizationOrganization = placementProfile.OrganizationPosition!.Organization!.OrganizationOrganization!.Name,
OcId = placementProfile.OrganizationPosition!.Organization!.Id,
Oc = _organizationCommonRepository.GetOrganizationNameFullPath(placementProfile.OrganizationPosition!.Organization!.Id, false, false, "/"),
};
// add profile education // add profile education
foreach (var edu in placementProfile.PlacementEducations) ////foreach (var edu in placementProfile.PlacementEducations)
////{
//// profile.Educations.Add(new ProfileEducation
//// {
//// Country = edu.Country,
//// Degree = edu.Degree,
//// Duration = edu.Duration,
//// DurationYear = edu.DurationYear == null ? 0 : edu.DurationYear.Value,
//// EducationLevelId = edu.EducationLevel == null ? Guid.Empty : edu.EducationLevel.Id,
//// EducationLevel = edu.EducationLevel == null ? "" : edu.EducationLevel.Name,
//// StartDate = edu.StartDate,
//// EndDate = edu.EndDate,
//// Field = edu.Field,
//// FinishDate = edu.FinishDate,
//// FundName = edu.FundName,
//// Gpa = edu.Gpa,
//// Institute = edu.Institute,
//// IsActive = true,
//// CreatedAt = DateTime.Now,
//// CreatedFullName = FullName ?? "System Administrator",
//// CreatedUserId = UserId ?? "",
//// LastUpdatedAt = DateTime.Now,
//// LastUpdateFullName = FullName ?? "System Administrator",
//// LastUpdateUserId = UserId ?? "",
//// });
////}
if (placementProfile.PlacementEducations != null)
{ {
profile.Educations.Add(new ProfileEducation var apiUrlEdu = $"{_configuration["API"]}/org/profile/educations";
using (var client = new HttpClient())
{ {
Country = edu.Country, client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
Degree = edu.Degree, foreach (var edu in placementProfile.PlacementEducations)
Duration = edu.Duration, {
DurationYear = edu.DurationYear == null ? 0 : edu.DurationYear.Value, var _res = await client.PostAsJsonAsync(apiUrlEdu, new
EducationLevelId = edu.EducationLevel == null ? Guid.Empty : edu.EducationLevel.Id, {
EducationLevel = edu.EducationLevel == null ? "" : edu.EducationLevel.Name, profileId = profileId,
StartDate = edu.StartDate, country = edu.Country == null ? string.Empty : edu.Country,
EndDate = edu.EndDate, degree = edu.Degree == null ? string.Empty : edu.Degree,
Field = edu.Field, duration = edu.Duration == null ? string.Empty : edu.Duration,
FinishDate = edu.FinishDate, durationYear = edu.DurationYear == null ? 0 : edu.DurationYear,
FundName = edu.FundName, field = edu.Field == null ? string.Empty : edu.Field,
Gpa = edu.Gpa, finishDate = edu.FinishDate == null ? (DateTime?)null : edu.FinishDate,
Institute = edu.Institute, fundName = edu.FundName == null ? string.Empty : edu.FundName,
IsActive = true, gpa = edu.Gpa == null ? string.Empty : edu.Gpa,
CreatedAt = DateTime.Now, institute = edu.Institute == null ? string.Empty : edu.Institute,
CreatedFullName = FullName ?? "System Administrator", other = edu.Other == null ? string.Empty : edu.Other,
CreatedUserId = UserId ?? "", startDate = edu.StartDate == null ? (DateTime?)null : edu.StartDate,
LastUpdatedAt = DateTime.Now, endDate = edu.EndDate == null ? (DateTime?)null : edu.EndDate,
LastUpdateFullName = FullName ?? "System Administrator", educationLevel = edu.EducationLevel == null ? string.Empty : edu.EducationLevel.Name,
LastUpdateUserId = UserId ?? "", 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();
}
}
} }
// add profile certificate // add profile certificate
foreach (var cert in placementProfile.PlacementCertificates) ////foreach (var cert in placementProfile.PlacementCertificates)
////{
//// profile.Certificates.Add(new ProfileCertificate
//// {
//// CertificateNo = cert.CertificateNo,
//// IssueDate = cert.IssueDate,
//// Issuer = cert.Issuer,
//// CertificateType = cert.CertificateType,
//// ExpireDate = cert.ExpireDate,
//// IsActive = true,
//// CreatedAt = DateTime.Now,
//// CreatedFullName = FullName ?? "System Administrator",
//// CreatedUserId = UserId ?? "",
//// LastUpdatedAt = DateTime.Now,
//// LastUpdateFullName = FullName ?? "System Administrator",
//// LastUpdateUserId = UserId ?? "",
//// });
////}
if (placementProfile.PlacementCertificates != null)
{ {
profile.Certificates.Add(new ProfileCertificate var apiUrlCer = $"{_configuration["API"]}/org/profile/certificate";
using (var client = new HttpClient())
{ {
CertificateNo = cert.CertificateNo, client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
IssueDate = cert.IssueDate, foreach (var cer in placementProfile.PlacementCertificates)
Issuer = cert.Issuer, {
CertificateType = cert.CertificateType, var _res = await client.PostAsJsonAsync(apiUrlCer, new
ExpireDate = cert.ExpireDate, {
IsActive = true, profileId = profileId,
CreatedAt = DateTime.Now, expireDate = cer.ExpireDate == null ? (DateTime?)null : cer.ExpireDate,
CreatedFullName = FullName ?? "System Administrator", issueDate = cer.IssueDate == null ? (DateTime?)null : cer.IssueDate,
CreatedUserId = UserId ?? "", certificateNo = cer.CertificateNo == null ? string.Empty : cer.CertificateNo,
LastUpdatedAt = DateTime.Now, certificateType = cer.CertificateType == null ? string.Empty : cer.CertificateType,
LastUpdateFullName = FullName ?? "System Administrator", issuer = cer.Issuer == null ? string.Empty : cer.Issuer,
LastUpdateUserId = UserId ?? "", });
}); var _result = await _res.Content.ReadAsStringAsync();
}
}
} }
// add profile document // add profile document
foreach (var doc in placementProfile.PlacementProfileDocs) ////foreach (var doc in placementProfile.PlacementProfileDocs)
{ ////{
profile.Papers.Add(new ProfilePaper //// profile.Papers.Add(new ProfilePaper
{ //// {
CategoryName = "Profile Documents", //// CategoryName = "Profile Documents",
Document = doc.Document, //// Document = doc.Document,
Detail = doc.Document.FileName, //// Detail = doc.Document.FileName,
CreatedAt = DateTime.Now, //// CreatedAt = DateTime.Now,
CreatedFullName = FullName ?? "System Administrator", //// CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "", //// CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now, //// LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator", //// LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "", //// LastUpdateUserId = UserId ?? "",
}); //// });
} ////}
// add profile salary // add profile salary
var oc = _dbContext.Set<OrganizationEntity>() ////var oc = _dbContext.Set<OrganizationEntity>()
.FirstOrDefault(x => x.Id == placementProfile.OrganizationPosition!.Organization!.Id); //// .FirstOrDefault(x => x.Id == placementProfile.OrganizationPosition!.Organization!.Id);
var position = placementProfile.PositionPath; ////var position = placementProfile.PositionPath;
var positionNumber = placementProfile.PositionNumber; ////var positionNumber = placementProfile.PositionNumber;
var positionType = placementProfile.PositionType; ////var positionType = placementProfile.PositionType;
var positionLevel = placementProfile.PositionLevel; ////var positionLevel = placementProfile.PositionLevel;
var salary = new ProfileSalary ////var salary = new ProfileSalary
////{
//// Order = 1,
//// Date = command.CommandAffectDate,
//// Amount = placementProfile.Amount == null ? 0 : placementProfile.Amount,
//// PositionSalaryAmount = placementProfile.PositionSalaryAmount == null ? 0 : placementProfile.PositionSalaryAmount,
//// MouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? 0 : placementProfile.MouthSalaryAmount,
//// SalaryClass = "",
//// SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}",
//// OcId = oc == null ? Guid.Empty : oc.Id,
//// PositionId = position!.Id,
//// PositionLevel = placementProfile.PositionLevel,
//// PositionLineId = placementProfile.PositionLine!.Id,
//// PositionTypeId = placementProfile.PositionType!.Id,
//// OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
//// PosNoId = positionNumber!.Id,
//// CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
//// RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
//// CommandTypeName = command.CommandType.Name,
//// PositionEmployeeGroupId = null,
//// PositionEmployeeLevelId = null,
//// PositionEmployeePositionId = null,
//// PositionEmployeePositionSideId = null,
//// PosNoEmployee = "",
//// PositionPathSideId = placementProfile.PositionPathSide! == null ? null : placementProfile.PositionPathSide!.Id,
//// PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id,
//// PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id,
//// IsActive = true,
//// CreatedAt = DateTime.Now,
//// CreatedFullName = FullName ?? "System Administrator",
//// CreatedUserId = UserId ?? "",
//// LastUpdatedAt = DateTime.Now,
//// LastUpdateFullName = FullName ?? "System Administrator",
//// LastUpdateUserId = UserId ?? "",
////};
var apiUrlSalary = $"{_configuration["API"]}/org/profile/salary";
using (var client = new HttpClient())
{ {
Order = 1, client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
Date = command.CommandAffectDate, var _res = await client.PostAsJsonAsync(apiUrlSalary, new
Amount = placementProfile.Amount == null ? 0 : placementProfile.Amount, {
PositionSalaryAmount = placementProfile.PositionSalaryAmount == null ? 0 : placementProfile.PositionSalaryAmount, profileId = profileId,
MouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? 0 : placementProfile.MouthSalaryAmount, date = command.CommandAffectDate == null ? (DateTime?)null : command.CommandAffectDate,
SalaryClass = "", amount = placementProfile.Amount == null ? null : placementProfile.Amount,
SalaryRef = "บรรจุและแต่งตั้งผู้สอบแข่งขันได้วุฒิ คำสั่ง" + command.IssuerOrganizationName + "ที่ " + $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate!.Value.ToThaiFullDate3()}", positionSalaryAmount = placementProfile.PositionSalaryAmount == null ? null : placementProfile.PositionSalaryAmount,
mouthSalaryAmount = placementProfile.MouthSalaryAmount == null ? null : placementProfile.MouthSalaryAmount,
posNo = placementProfile.PosNumber == null ? string.Empty : placementProfile.PosNumber.ToString(),
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.PositionLevel == null ? string.Empty : placementProfile.PositionLevel.Name,
refCommandNo = string.Empty,
templateDoc = string.Empty,
});
var _result = await _res.Content.ReadAsStringAsync();
}
OcId = oc == null ? Guid.Empty : oc.Id,
PositionId = position!.Id,
PositionLevel = placementProfile.PositionLevel,
PositionLineId = placementProfile.PositionLine!.Id,
PositionTypeId = placementProfile.PositionType!.Id,
OrganizationShortNameId = placementProfile.OrganizationPosition!.Organization!.OrganizationShortName!.Id,
PosNoId = positionNumber!.Id,
CommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
RefCommandNo = $"{command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()}",
CommandTypeName = command.CommandType.Name,
PositionEmployeeGroupId = null,
PositionEmployeeLevelId = null,
PositionEmployeePositionId = null,
PositionEmployeePositionSideId = null,
PosNoEmployee = "",
PositionPathSideId = placementProfile.PositionPathSide! == null ? null : placementProfile.PositionPathSide!.Id,
PositionExecutiveId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutive!.Id,
PositionExecutiveSideId = placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide! == null ? null : placementProfile.OrganizationPosition!.PositionMaster!.PositionExecutiveSide!.Id,
IsActive = true,
CreatedAt = DateTime.Now,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
};
//if (placementProfile.PositionPathSide! != null) //if (placementProfile.PositionPathSide! != null)
//{ //{
@ -2996,97 +3131,97 @@ namespace BMA.EHR.Application.Repositories.Commands
//} //}
// add profile position // add profile position
var profilePosition = new ProfilePosition ////var profilePosition = new ProfilePosition
{ ////{
Profile = profile, //// Profile = profile,
OrganizationPosition = placementProfile.OrganizationPosition, //// OrganizationPosition = placementProfile.OrganizationPosition,
IsActive = true, //// IsActive = true,
IsPublished = true, //// IsPublished = true,
}; ////};
_dbContext.Set<ProfilePosition>().Add(profilePosition); ////_dbContext.Set<ProfilePosition>().Add(profilePosition);
profile.Salaries.Add(salary); ////profile.Salaries.Add(salary);
_dbContext.Set<Profile>().Add(profile); ////_dbContext.Set<Profile>().Add(profile);
// update placementstatus // update placementstatus
placementProfile.PlacementStatus = "CONTAIN"; placementProfile.PlacementStatus = "CONTAIN";
await _dbContext.SaveChangesAsync(); await _dbContext.SaveChangesAsync();
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่ ////// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email ////// Send noti inbox and email
var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}"; ////var subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
var body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}"; ////var body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com"); ////_emailSenderService.SendMail(subject, body, "dev@frappet.com");
var inbox = new Inbox ////var inbox = new Inbox
{ ////{
Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}", //// Subject = $"คุณได้รับคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}", //// Body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = profile.Id, //// ReceiverUserId = profile.Id,
Payload = payload_str, //// Payload = payload_str,
}; ////};
_dbContext.Set<Inbox>().Add(inbox); ////_dbContext.Set<Inbox>().Add(inbox);
var noti = new Notification ////var noti = new Notification
{ ////{
Body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}", //// Body = $"คุณได้รับรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ ตามคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = profile.Id, //// ReceiverUserId = profile.Id,
Type = "LINK", //// Type = "LINK",
Payload = payload_str, //// Payload = payload_str,
}; ////};
_dbContext.Set<Notification>().Add(noti); ////_dbContext.Set<Notification>().Add(noti);
await _dbContext.SaveChangesAsync(); ////await _dbContext.SaveChangesAsync();
} }
// send cc noti inbox //// send cc noti inbox
foreach (var cc in command.Deployments) ////foreach (var cc in command.Deployments)
{ ////{
var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId); //// var pf = await _dbContext.Set<Profile>().FirstOrDefaultAsync(x => x.CitizenId == cc.CitizenId);
if (pf != null) //// if (pf != null)
{ //// {
if (cc.IsSendInbox) //// if (cc.IsSendInbox)
{ //// {
var inbox = new Inbox //// var inbox = new Inbox
{ //// {
Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}", //// Subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
Body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}", //// Body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id, //// ReceiverUserId = pf.Id,
Payload = payload_str, //// Payload = payload_str,
}; //// };
_dbContext.Set<Inbox>().Add(inbox); //// _dbContext.Set<Inbox>().Add(inbox);
} //// }
if (cc.IsSendMail) //// if (cc.IsSendMail)
{ //// {
// TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่ //// // TODO: ต้องเปลี่ยนเป็น Email จริงนะ ตอนนี้ Hardcode อยู่
// Send noti inbox and email //// // Send noti inbox and email
var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}"; //// var subject = $"คุณได้รับสำเนาคำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
var body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}"; //// var body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}";
_emailSenderService.SendMail(subject, body, "dev@frappet.com"); //// _emailSenderService.SendMail(subject, body, "dev@frappet.com");
} //// }
var noti = new Notification //// var noti = new Notification
{ //// {
Body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}", //// Body = $"คำสั่งบรรจุเป็นข้าราชการกรุงเทพมหานครสามัญ คำสั่งเลขที่ {command.CommandNo}/{command.CommandYear.ToInteger().ToThaiYear()} ลงวันที่ {command.CommandExcecuteDate.Value.ToThaiFullDate3()}",
ReceiverUserId = pf.Id, //// ReceiverUserId = pf.Id,
Type = "LINK", //// Type = "LINK",
Payload = payload_str, //// Payload = payload_str,
}; //// };
_dbContext.Set<Notification>().Add(noti); //// _dbContext.Set<Notification>().Add(noti);
} //// }
} ////}
// change command status ////// change command status
var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5); ////var cmdStatus = await _dbContext.Set<CommandStatus>().FirstOrDefaultAsync(x => x.Sequence == 5);
command.CommandStatusId = cmdStatus!.Id; ////command.CommandStatusId = cmdStatus!.Id;
await _dbContext.SaveChangesAsync(); ////await _dbContext.SaveChangesAsync();
} }
catch catch
{ {

View file

@ -7,6 +7,11 @@ using BMA.EHR.Domain.Models.Documents;
namespace BMA.EHR.Domain.Models.Placement namespace BMA.EHR.Domain.Models.Placement
{ {
public class PlacementProfileId
{
[Comment("Id Profile")]
public string result { get; set; }
}
public class PlacementProfile : EntityBase public class PlacementProfile : EntityBase
{ {