fix : เครื่องราชย์ เก็บข้อมูลจากทะเบียนประวัติลง Field **** ยังไม่ได้ run migrate ****

This commit is contained in:
Suphonchai Phoonsawat 2024-07-05 16:49:50 +07:00
parent 0b13d5ccf2
commit d858010414
5 changed files with 5878 additions and 4398 deletions

File diff suppressed because it is too large Load diff

View file

@ -6,28 +6,46 @@ namespace BMA.EHR.Application.Requests
{
public Guid ProfileId { get; set; }
public string Prefix { get; set; }
public string CitizenId { get; set; } = String.Empty;
public string FullName { get; set; }
public string Prefix { get; set; } = String.Empty;
public string FirstName { get; set; } = String.Empty;
public string LastName { get; set; } = String.Empty;
public DateTime? BirthDate { get; set; }
public DateTime? DateAppoint { get; set; }
public string? ProfileType { get; set; }
public string? PosTypeName { get; set; }
public string? PosLevelName { get; set; }
public string Position { get; set; }
public string FullName { get; set; } = String.Empty;
public string Rank { get; set; }
public string Position { get; set; } = String.Empty;
public string GovAge { get; set; }
public string Rank { get; set; } = String.Empty;
public string GovAge { get; set; } = String.Empty;
public double? Salary { get; set; }
public double? PositionSalary { get; set; }
public string LastInsignia { get; set; }
public string LastInsignia { get; set; } = String.Empty;
public Guid? LastInsigniaId { get; set; }
//public Guid PosNo { get; set; }
public string PosNo { get; set; }
public string PosNo { get; set; } = String.Empty;
public InsigniaItem RequestInsignia { get; set; }
public InsigniaItem RequestInsignia { get; set; } = new();
public string Gender { get; set; }
public string Gender { get; set; } = String.Empty;
public int Seq { get; set; }
@ -40,4 +58,4 @@ namespace BMA.EHR.Application.Requests
public string Result { get; set; } = "";
}
}
}

View file

@ -71,5 +71,7 @@ namespace BMA.EHR.Domain.Models.Insignias
public string? PosNo { get; set; }
public double? Amount { get; set; }
public double? PositionSalaryAmount { get; set; }
public string? LastInsigniaName { get; set; }
}
}

View file

@ -1,49 +1,50 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>93677512-b64b-4a19-9e7d-dd283c7ec901</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerfileContext>.</DockerfileContext>
<RootNamespace>BMA.EHR.Insignia.Service</RootNamespace>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>93677512-b64b-4a19-9e7d-dd283c7ec901</UserSecretsId>
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<GenerateDocumentationFile>True</GenerateDocumentationFile>
<DockerfileContext>.</DockerfileContext>
<RootNamespace>BMA.EHR.Insignia.Service</RootNamespace>
<AssemblyName>BMA.EHR.Insignia</AssemblyName>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Hangfire" Version="1.8.5" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.5" />
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.32.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1" />
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Sentry.AspNetCore" Version="3.33.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Exceptions" Version="8.4.0" />
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0" />
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Hangfire" Version="1.8.5"/>
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.5"/>
<PackageReference Include="Hangfire.MySqlStorage" Version="2.0.3"/>
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.9"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.1.0"/>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.1.0"/>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.9"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.9">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.IdentityModel.Logging" Version="6.32.0"/>
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.18.1"/>
<PackageReference Include="runtime.osx.10.10-x64.CoreCompat.System.Drawing" Version="6.0.5.128"/>
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0"/>
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0"/>
<PackageReference Include="Sentry.AspNetCore" Version="3.33.1"/>
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0"/>
<PackageReference Include="Serilog.Exceptions" Version="8.4.0"/>
<PackageReference Include="Serilog.Sinks.Debug" Version="2.0.0"/>
<PackageReference Include="Serilog.Sinks.Elasticsearch" Version="9.0.3"/>
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0"/>
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Templates/PersonInsignia.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\BMA.EHR.Infrastructure\BMA.EHR.Infrastructure.csproj"/>
</ItemGroup>
<ItemGroup>
<None Update="Templates/PersonInsignia.xlsx">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
</Project>

View file

@ -220,7 +220,19 @@ namespace BMA.EHR.Insignia.Service.Controllers
isApprove = irp.IsApprove,
statusInstitute = irp.IsApprove.ToString(),
request_date = irp.RequestDate,
profile = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken),
profileId = irp.ProfileId,
citizenId = irp.CitizenId,
prefix = irp.Prefix,
firstname = irp.FirstName,
lastname = irp.LastName,
type = irp.ProfileType,
position = irp.Position,
posno = irp.PosNo,
rank = $"{irp.PosTypeName}/{irp.PosLevelName}",
lastInsigniaName = irp.LastInsigniaName,
//profile = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken),
instituteName = "",
instituteId = -1,
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
@ -231,44 +243,45 @@ namespace BMA.EHR.Insignia.Service.Controllers
requestSalary = irp.Salary,
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
})
.OrderBy(x => x.citizenId)
.ToList();
var dataResult = rawData
.Select(irp => new
{
irp.request_id,
irp.isApprove,
irp.statusInstitute,
irp.request_date,
profileId = irp.profile == null ? Guid.Empty : irp.profile.Id,
citizenId = irp.profile == null ? "" : irp.profile.CitizenId,
prefix = irp.profile == null ? "" : irp.profile.Prefix,
firstname = irp.profile == null ? "" : irp.profile.FirstName,
lastname = irp.profile == null ? "" : irp.profile.LastName,
type = irp.profile == null ? "" : irp.profile.ProfileType,
position = irp.profile == null ? "" : irp.profile.Position,
posno = irp.profile == null ? "" :
irp.profile.ProfileSalary == null || irp.profile.ProfileSalary.Count == 0 ? "" :
irp.profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PosNo,
rank = irp.profile == null ? "" : $"{irp.profile.PosType.PosTypeName}/{irp.profile.PosLevel.PosLevelName}",
irp.instituteName,
irp.instituteId,
lastInsigniaName = irp.profile == null ? "" :
irp.profile.ProfileInsignia == null || irp.profile.ProfileInsignia.Count == 0 ? "" :
_insigniaPeriodRepository.GetInsigniaById(irp.profile.ProfileInsignia.OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId.Value) == null ? "" :
_insigniaPeriodRepository.GetInsigniaById(irp.profile.ProfileInsignia.OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId.Value).Name,
irp.requestInsigniaLevel,
irp.requestInsigniaName,
irp.requestQua,
irp.requestDoc,
irp.requestNote,
irp.requestSalary,
irp.matchingConditions
})
.OrderBy(y => y.citizenId)
.ToList();
// var dataResult = rawData
// .Select(irp => new
// {
// irp.request_id,
// irp.isApprove,
// irp.statusInstitute,
// irp.request_date,
// profileId = irp.profile == null ? Guid.Empty : irp.profile.Id,
// citizenId = irp.profile == null ? "" : irp.profile.CitizenId,
// prefix = irp.profile == null ? "" : irp.profile.Prefix,
// firstname = irp.profile == null ? "" : irp.profile.FirstName,
// lastname = irp.profile == null ? "" : irp.profile.LastName,
// type = irp.profile == null ? "" : irp.profile.ProfileType,
// position = irp.profile == null ? "" : irp.profile.Position,
// posno = irp.profile == null ? "" :
// irp.profile.ProfileSalary == null || irp.profile.ProfileSalary.Count == 0 ? "" :
// irp.profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PosNo,
// rank = irp.profile == null ? "" : $"{irp.profile.PosType.PosTypeName}/{irp.profile.PosLevel.PosLevelName}",
// irp.instituteName,
// irp.instituteId,
// lastInsigniaName = irp.profile == null ? "" :
// irp.profile.ProfileInsignia == null || irp.profile.ProfileInsignia.Count == 0 ? "" :
// _insigniaPeriodRepository.GetInsigniaById(irp.profile.ProfileInsignia.OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId.Value) == null ? "" :
// _insigniaPeriodRepository.GetInsigniaById(irp.profile.ProfileInsignia.OrderByDescending(x => x.Year).FirstOrDefault().InsigniaId.Value).Name,
// irp.requestInsigniaLevel,
// irp.requestInsigniaName,
// irp.requestQua,
// irp.requestDoc,
// irp.requestNote,
// irp.requestSalary,
// irp.matchingConditions
// })
// .OrderBy(y => y.citizenId)
// .ToList();
return dataResult;
return rawData;
}
#endregion
@ -291,169 +304,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
#endregion
#region " จัดทำรายชื่อครูที่มีสิทธิในการยืนขอเครื่องราชฯ "
// [HttpGet("old/{role}/{ocId:length(36)}")]
// public async Task<ActionResult<ResponseObject>> GetInsignaiRequest(Guid id, Guid ocId, string role)
// {
// var result = await _repository.GetInsigniaRequest(id, ocId);
// if (result != null)
// {
// Guid period = result.PeriodId;
// string periodName = result.Name;
// string requestStatus = result.RequestStatus;
// var resend = new InsigniaResults
// {
// PeriodId = period,
// Year = result.Year,
// Name = periodName,
// RequestStatus = requestStatus,
// OrganizationName = result.OrganizationName,
// Items = new List<dynamic>()
// };
// var candidate = await _repository.GetInsigniaCandidate(period, ocId);
// // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
// if (requestStatus == null)
// {
// // บันทึกรายชื่อ
// _repository.InsertCandidate(period, ocId, candidate);
// }
// if (role == "officer")
// {
// resend.Items = await _repository.InsigniaHasProfile(period, ocId);
// return Success(resend);
// }
// else
// {
// var passData = _context.InsigniaRequests.AsQueryable()
// .Include(x => x.Organization)
// .Include(x => x.RequestProfiles)
// .Where(x => x.Organization.Id == ocId)
// .Where(x => x.Period.Id == period)
// .Select(ir => new
// {
// requstID = ir.Id,
// requstStatus = ir.RequestStatus,
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
// fkInstituteId = -1,
// // fkDivisionId = ir.Organization.Id,
// // fkDivision = ir.Organization.Name,
// fkInstitute = "",
// fkPeriodId = ir.Period.Id,
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// // .ThenInclude(x => x.PositionNumber)
// .Include(x => x.Profile)
// // .ThenInclude(x => x.AcademicStanding)
// .Include(x => x.RequestInsignia)
// .ThenInclude(x => x.InsigniaType)
// .Select(irp => new
// {
// request_id = irp.Request.Id,
// isApprove = irp.IsApprove,
// statusInstitute = irp.IsApprove.ToString(),
// request_date = irp.RequestDate,
// profileId = irp.Profile.Id,
// // prefix = irp.Profile.Prefix,
// firstname = irp.Profile.FirstName,
// lastname = irp.Profile.LastName,
// // posno = irp.Profile.PositionNumber.Id,
// type = irp.Profile.ProfileType,
// // position = irp.Profile.Position.Name,
// // rank = irp.Profile.AcademicStanding.Name,
// instituteName = "",
// instituteId = -1,
// // divisionName = irp.Profile.OrganizationOrganization.Name,
// // divisionId = irp.Profile.OrganizationOrganization.Id,
// lastInsigniaName = "",
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType == null ? null : irp.RequestInsignia.InsigniaType.Name,
// requestInsigniaName = irp.RequestInsignia.Name,
// requestQua = irp.QualificationStatus,
// requestDoc = irp.DocumentStatus,
// requestNote = irp.Note,
// requestSalary = irp.Salary,
// })
// .Where(x => x.isApprove)
// .OrderBy(y => y.profileId)
// .ToList()
// })
// .ToList()
// .FirstOrDefault();
// var failData = _context.InsigniaRequests.AsQueryable()
// .Include(x => x.Organization)
// .Include(x => x.RequestProfiles)
// .Where(x => x.Organization.Id == ocId)
// .Where(x => x.Period.Id == period)
// .Select(ir => new
// {
// requstID = ir.Id,
// requstStatus = ir.RequestStatus,
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
// fkInstituteId = -1,
// // fkDivisionId = ir.Organization.Id,
// // fkDivision = ir.Organization.Name,
// fkInstitute = "",
// fkPeriodId = ir.Period.Id,
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// // .ThenInclude(x => x.PositionNumber)
// .Include(x => x.Profile)
// // .ThenInclude(x => x.AcademicStanding)
// .Include(x => x.RequestInsignia)
// .ThenInclude(x => x.InsigniaType)
// .Select(irp => new
// {
// request_id = irp.Request.Id,
// isApprove = irp.IsApprove,
// statusInstitute = irp.IsApprove.ToString(),
// request_date = irp.RequestDate,
// profileId = irp.Profile.Id,
// // prefix = irp.Profile.Prefix,
// firstname = irp.Profile.FirstName,
// lastname = irp.Profile.LastName,
// // posno = irp.Profile.PositionNumber.Id,
// type = irp.Profile.ProfileType,
// // position = irp.Profile.Position.Name,
// // rank = irp.Profile.AcademicStanding.Name,
// instituteName = "",
// instituteId = -1,
// // divisionName = irp.Profile.OrganizationOrganization.Name,
// // divisionId = irp.Profile.OrganizationOrganization.Id,
// lastInsigniaName = "",
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType == null ? null : irp.RequestInsignia.InsigniaType.Name,
// requestInsigniaName = irp.RequestInsignia.Name,
// requestQua = irp.QualificationStatus,
// requestDoc = irp.DocumentStatus,
// requestNote = irp.Note,
// requestSalary = irp.Salary,
// })
// .Where(x => !x.isApprove)
// .OrderBy(y => y.profileId)
// .ToList()
// })
// .ToList()
// .FirstOrDefault();
// var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
// where p.Id == period
// select new
// {
// periodName = p.Name,
// periodYear = p.Year,
// }).FirstOrDefault();
// return Success(new { passData = passData, failData = failData, period = period_data });
// }
// // select data to display
// }
// return Success();
// }
/// <summary>
/// list รายการคำขอเครื่องราช ผู้ได้รับ,คนไม่ยื่น,คนที่ถูกลบ
/// </summary>
@ -666,49 +517,48 @@ namespace BMA.EHR.Insignia.Service.Controllers
[HttpGet("{insigniaPeriodId:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdateInsigniaRequestBkk(Guid insigniaPeriodId)
{
// jack add เพื่อให้ทำการรันแค่เขตพระนคร
// TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
var ocId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3");
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
if (result != null)
{
Guid period = result.PeriodId;
string requestStatus = result.RequestStatus;
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, ocId);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
{
// บันทึกรายชื่อ
await _repository.InsertCandidate(period, ocId, candidate);
}
}
// // jack add เพื่อให้ทำการรันแค่เขตพระนคร
// // TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
// var ocId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3");
// var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
// if (result != null)
// {
// Guid period = result.PeriodId;
// string requestStatus = result.RequestStatus;
// var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, ocId);
// // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
// if (requestStatus == null)
// {
// // บันทึกรายชื่อ
// await _repository.InsertCandidate(period, ocId, candidate);
// }
// }
// TODO: original code use this in production
//var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
//foreach (var organization in organizations)
//{
// if (organization == null)
// continue;
foreach (var organization in organizations)
{
if (organization == null)
continue;
//if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
// if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
// var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
// if (result != null)
// {
// Guid period = result.PeriodId;
// string requestStatus = result.RequestStatus;
// var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
// // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
// if (requestStatus == null)
// {
// // บันทึกรายชื่อ
// await _repository.InsertCandidate(period, organization.Id, candidate);
// }
// }
//}
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
if (result != null)
{
Guid period = result.PeriodId;
string requestStatus = result.RequestStatus;
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
if (requestStatus == null)
{
// บันทึกรายชื่อ
await _repository.InsertCandidate(period, organization.Id, candidate);
}
}
}
return Success();
}
@ -732,6 +582,13 @@ namespace BMA.EHR.Insignia.Service.Controllers
#region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
/// <summary>
///
/// </summary>
/// <param name="id"></param>
/// <param name="ocId"></param>
/// <param name="items"></param>
/// <returns></returns>
[HttpPut("approve/{ocId:length(36)}")]
public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
{