แก้ระบบบรรจุผูกโครงสร้างใหม่

This commit is contained in:
Kittapath 2024-05-02 09:31:38 +07:00
parent 57164f5d45
commit 18d75f4b04
37 changed files with 79295 additions and 3904 deletions

View file

@ -68,21 +68,21 @@ jobs:
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- uses: snow-actions/line-notify@v1.1.0
if: success()
with:
access_token: ${{ env.TOKEN_LINE }}
message: |
-Success✅✅✅
Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
- uses: snow-actions/line-notify@v1.1.0
if: failure()
with:
access_token: ${{ env.TOKEN_LINE }}
message: |
-Failure❌❌❌
Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
# - uses: snow-actions/line-notify@v1.1.0
# if: success()
# with:
# access_token: ${{ env.TOKEN_LINE }}
# message: |
# -Success✅✅✅
# Image: ${{env.IMAGE_NAME}}
# Version: ${{ github.event.inputs.IMAGE_VER }}
# By: ${{secrets.DOCKER_USER}}
# - uses: snow-actions/line-notify@v1.1.0
# if: failure()
# with:
# access_token: ${{ env.TOKEN_LINE }}
# message: |
# -Failure❌❌❌
# Image: ${{env.IMAGE_NAME}}
# Version: ${{ github.event.inputs.IMAGE_VER }}
# By: ${{secrets.DOCKER_USER}}

View file

@ -304,21 +304,21 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementAppointment>()
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
.Include(x => x.PositionLevel)
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x.Organization)
// .Include(x => x.PositionPath)
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionNumber)
// .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
join pf in _dbContext.Set<Profile>()
.Include(x => x.Position)
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
.Include(x => x.Educations)
on r.CitizenId equals pf.CitizenId
// join pf in _dbContext.Set<Profile>()
// .Include(x => x.Position)
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionType)
// .Include(x => x.PosNo)
// .Include(x => x.Salaries)
// .Include(x => x.Educations)
// on r.CitizenId equals pf.CitizenId
orderby r.Sequence
select new CommandType03Response
{
@ -328,19 +328,19 @@ namespace BMA.EHR.Application.Repositories.Commands
Seq = r.Sequence.ToString().ToThaiNumber(),
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
OldPositionName = pf.Position == null ? "" : pf.Position.Name,
OldPositionLevel = pf.PositionLevel == null ? "" : pf.PositionLevel.Name,
OldPositionType = pf.PositionType == null ? "" : pf.PositionType.Name,
OldPositionNumber = pf.PosNo == null ? "" : pf.PosNo.Name.ToThaiNumber(),
// OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
// OldPositionName = pf.Position == null ? "" : pf.Position.Name,
// OldPositionLevel = pf.PositionLevel == null ? "" : pf.PositionLevel.Name,
// OldPositionType = pf.PositionType == null ? "" : pf.PositionType.Name,
// OldPositionNumber = pf.PosNo == null ? "" : pf.PosNo.Name.ToThaiNumber(),
// OldSalary = pf.Salaries == null || pf.Salaries.Count == 0 ? "" : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
OldSalaryDate = pf.Salaries == null || pf.Salaries.Count == 0 ? "" : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Date.Value.ToThaiShortDate2().ToThaiNumber(),
NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
// OldSalaryDate = pf.Salaries == null || pf.Salaries.Count == 0 ? "" : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Date.Value.ToThaiShortDate2().ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
// NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
// NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
// NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
// NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.RecruitDate == null ? "" : p.RecruitDate.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
@ -370,21 +370,21 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementAppointment>()
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
.Include(x => x.PositionLevel)
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x.Organization)
// .Include(x => x.PositionPath)
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionNumber)
// .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
join pf in _dbContext.Set<Profile>()
.Include(x => x.Position)
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
.Include(x => x.Educations)
on r.CitizenId equals pf.CitizenId
// join pf in _dbContext.Set<Profile>()
// .Include(x => x.Position)
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionType)
// .Include(x => x.PosNo)
// .Include(x => x.Salaries)
// .Include(x => x.Educations)
// on r.CitizenId equals pf.CitizenId
orderby r.Sequence
select new CommandType03Response
{
@ -394,18 +394,18 @@ namespace BMA.EHR.Application.Repositories.Commands
Seq = r.Sequence.ToString().ToThaiNumber(),
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
OldPositionName = pf.Position == null ? "" : pf.Position.Name,
OldPositionLevel = pf.PositionLevel == null ? "" : pf.PositionLevel.Name,
OldPositionType = pf.PositionType == null ? "" : pf.PositionType.Name,
OldPositionNumber = pf.PosNo == null ? "" : pf.PosNo.Name.ToThaiNumber(),
// OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
// OldPositionName = pf.Position == null ? "" : pf.Position.Name,
// OldPositionLevel = pf.PositionLevel == null ? "" : pf.PositionLevel.Name,
// OldPositionType = pf.PositionType == null ? "" : pf.PositionType.Name,
// OldPositionNumber = pf.PosNo == null ? "" : pf.PosNo.Name.ToThaiNumber(),
// OldSalary = pf.Salaries == null || pf.Salaries.Count == 0 ? "" : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
// NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
// NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
// NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
// NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.RecruitDate == null ? "" : p.RecruitDate.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
@ -435,24 +435,24 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<RetirementOther>()
.Include(x => x.Profile)
.ThenInclude(x => x.Salaries)
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionType)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
.Include(x => x.Profile)
.ThenInclude(x => x.Educations)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
.Include(x => x.PositionLevel)
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Salaries)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionLevel)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PosNo)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Educations)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x.Organization)
// .Include(x => x.PositionPath)
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionNumber)
// .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType03Response
@ -463,21 +463,21 @@ namespace BMA.EHR.Application.Repositories.Commands
Seq = r.Sequence.ToString().ToThaiNumber(),
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOc = p.Profile.Oc == null ? "" : p.Profile.Oc.Replace("/", " "),
OldPositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
OldPositionLevel = p.Profile.PositionLevel == null ? "" : p.Profile.PositionLevel.Name,
OldPositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name,
OldPositionNumber = p.Profile.PosNo == null ? "" : p.Profile.PosNo.Name.ToThaiNumber(),
// OldOc = p.Profile.Oc == null ? "" : p.Profile.Oc.Replace("/", " "),
// OldPositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
// OldPositionLevel = p.Profile.PositionLevel == null ? "" : p.Profile.PositionLevel.Name,
// OldPositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name,
// OldPositionNumber = p.Profile.PosNo == null ? "" : p.Profile.PosNo.Name.ToThaiNumber(),
// OldSalary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? "" : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
// NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
// NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
// NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
// NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
LeaveDate = p.Profile.LeaveDate == null ? "" : p.Profile.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(),
// LeaveDate = p.Profile.LeaveDate == null ? "" : p.Profile.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
})
.ToList();
@ -505,24 +505,24 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<RetirementOther>()
.Include(x => x.Profile)
.ThenInclude(x => x.Salaries)
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionType)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
.Include(x => x.Profile)
.ThenInclude(x => x.Educations)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
.Include(x => x.PositionLevel)
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Salaries)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionLevel)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PosNo)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Educations)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x.Organization)
// .Include(x => x.PositionPath)
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionNumber)
// .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType03Response
@ -533,21 +533,21 @@ namespace BMA.EHR.Application.Repositories.Commands
Seq = r.Sequence.ToString().ToThaiNumber(),
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOc = p.Profile.Oc == null ? "" : p.Profile.Oc.Replace("/", " "),
OldPositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
OldPositionLevel = p.Profile.PositionLevel == null ? "" : p.Profile.PositionLevel.Name,
OldPositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name,
OldPositionNumber = p.Profile.PosNo == null ? "" : p.Profile.PosNo.Name.ToThaiNumber(),
// OldOc = p.Profile.Oc == null ? "" : p.Profile.Oc.Replace("/", " "),
// OldPositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
// OldPositionLevel = p.Profile.PositionLevel == null ? "" : p.Profile.PositionLevel.Name,
// OldPositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name,
// OldPositionNumber = p.Profile.PosNo == null ? "" : p.Profile.PosNo.Name.ToThaiNumber(),
// OldSalary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? "" : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
// NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
// NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
// NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
// NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.PositionDate == null ? "" : p.PositionDate.Value.ToThaiShortDate2().ToThaiNumber(),
LeaveDate = p.Profile.LeaveDate == null ? "" : p.Profile.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(),
// LeaveDate = p.Profile.LeaveDate == null ? "" : p.Profile.LeaveDate.Value.ToThaiShortDate2().ToThaiNumber(),
MilitaryDate = p.MilitaryDate == null ? "" : p.MilitaryDate.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
})
@ -696,12 +696,12 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementReceive>()
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
.Include(x => x.PositionLevel)
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x.Organization)
// .Include(x => x.PositionPath)
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionNumber)
// .Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType03Response
@ -716,11 +716,11 @@ namespace BMA.EHR.Application.Repositories.Commands
OldPositionType = p.PositionTypeOld ?? "",
OldPositionNumber = p.PositionNumberOld == null ? "" : p.PositionNumberOld.ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
// NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
// NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
// NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
// NewPositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
AppointDate = p.RecruitDate == null ? "" : p.RecruitDate.Value.ToThaiShortDate2().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
@ -745,8 +745,8 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementOfficer>()
.Include(p => p.Profile)
.ThenInclude(p => p.Position)
//.Include(p => p.Profile)
//.ThenInclude(p => p.Position)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType15Response
@ -786,12 +786,12 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementRepatriation>()
.Include(p => p.Profile)
.ThenInclude(p => p.Position)
.Include(p => p.Profile)
.ThenInclude(p => p.Salaries)
.Include(p => p.Profile)
.ThenInclude(p => p.Prefix)
//.Include(p => p.Profile)
//.ThenInclude(p => p.Position)
//.Include(p => p.Profile)
//.ThenInclude(p => p.Salaries)
//.Include(p => p.Profile)
//.ThenInclude(p => p.Prefix)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType16Response
@ -807,7 +807,7 @@ namespace BMA.EHR.Application.Repositories.Commands
r.Command.GovAidCommandDate.Value.ToThaiFullDate3().ToThaiNumber(),
StartDate = p.Date == null ? "" : p.Date.Value.ToThaiFullDate3().ToThaiNumber(),
ActiveDate = p.DateRepatriation == null ? "" : p.DateRepatriation.Value.ToThaiFullDate3().ToThaiNumber(),
FullName = $"{p.Profile.Prefix!.Name}{p.Profile.FirstName!} {p.Profile.LastName!}",
FullName = $"{p.prefix}{p.firstName!} {p.lastName!}",
Subject = $"เรื่อง {r.Command.CommandSubject}",
})
.ToList();
@ -882,10 +882,10 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<RetirementOut>()
.Include(p => p.Profile)
.ThenInclude(p => p.Position)
.Include(p => p.Profile)
.ThenInclude(p => p.Salaries)
// .Include(p => p.Profile)
// .ThenInclude(p => p.Position)
// .Include(p => p.Profile)
// .ThenInclude(p => p.Salaries)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType18Response
@ -898,7 +898,7 @@ namespace BMA.EHR.Application.Repositories.Commands
AuthorizedPosition = r.Command.AuthorizedPosition,
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
// PositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
Organization = p.OrganizationPositionOld == null ? "" : p.OrganizationPositionOld,
PositionLevel = p.PositionLevelOld == null ? "" : p.PositionLevelOld,
PositionType = p.PositionTypeOld == null ? "" : p.PositionTypeOld,
@ -1104,24 +1104,24 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementAppointment>()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionType)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationAgency)
.ThenInclude(x => x.OrganizationOrganization)
//.Include(x => x.OrgEmployee)
//.ThenInclude(x => x.PosNo)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.PositionEmployeePosition)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationPositionEmployeeLevels)
.ThenInclude(x => x.PositionEmployeeLevel)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionLevel)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PosNo)
// .Include(x => x.OrgEmployee)
// .ThenInclude(x => x.OrganizationAgency)
// .ThenInclude(x => x.OrganizationOrganization)
// //.Include(x => x.OrgEmployee)
// //.ThenInclude(x => x.PosNo)
// .Include(x => x.OrgEmployee)
// .ThenInclude(x => x.PositionEmployeePosition)
// .Include(x => x.OrgEmployee)
// .ThenInclude(x => x.OrganizationPositionEmployeeLevels)
// .ThenInclude(x => x.PositionEmployeeLevel)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType22Response
@ -1134,9 +1134,9 @@ namespace BMA.EHR.Application.Repositories.Commands
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.OrgEmployee == null || p.OrgEmployee.PositionEmployeePosition == null ? "" : p.OrgEmployee.PositionEmployeePosition.Name,
NewPositionLevel = p.OrgEmployee == null || p.OrgEmployee.OrganizationPositionEmployeeLevels == null || p.OrgEmployee.OrganizationPositionEmployeeLevels.Count() == 0 ? "" : p.OrgEmployee.OrganizationPositionEmployeeLevels.FirstOrDefault().PositionEmployeeLevel.Name,
NewPositionNumber = p.OrgEmployee == null || p.OrgEmployee.PosNo == null ? "" : p.OrgEmployee.PosNo.ToThaiNumber(),
// NewPositionName = p.OrgEmployee == null || p.OrgEmployee.PositionEmployeePosition == null ? "" : p.OrgEmployee.PositionEmployeePosition.Name,
// NewPositionLevel = p.OrgEmployee == null || p.OrgEmployee.OrganizationPositionEmployeeLevels == null || p.OrgEmployee.OrganizationPositionEmployeeLevels.Count() == 0 ? "" : p.OrgEmployee.OrganizationPositionEmployeeLevels.FirstOrDefault().PositionEmployeeLevel.Name,
// NewPositionNumber = p.OrgEmployee == null || p.OrgEmployee.PosNo == null ? "" : p.OrgEmployee.PosNo.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
})
@ -1231,24 +1231,24 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementAppointment>()
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionType)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationAgency)
.ThenInclude(x => x.OrganizationOrganization)
//.Include(x => x.OrgEmployee)
//.ThenInclude(x => x.PosNo)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.PositionEmployeePosition)
.Include(x => x.OrgEmployee)
.ThenInclude(x => x.OrganizationPositionEmployeeLevels)
.ThenInclude(x => x.PositionEmployeeLevel)
// .Include(x => x.Profile)
// .ThenInclude(x => x.Position)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionLevel)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PositionType)
// .Include(x => x.Profile)
// .ThenInclude(x => x.PosNo)
// .Include(x => x.OrgEmployee)
// .ThenInclude(x => x.OrganizationAgency)
// .ThenInclude(x => x.OrganizationOrganization)
// //.Include(x => x.OrgEmployee)
// //.ThenInclude(x => x.PosNo)
// .Include(x => x.OrgEmployee)
// .ThenInclude(x => x.PositionEmployeePosition)
// .Include(x => x.OrgEmployee)
// .ThenInclude(x => x.OrganizationPositionEmployeeLevels)
// .ThenInclude(x => x.PositionEmployeeLevel)
on r.RefPlacementProfileId equals p.Id
orderby r.Sequence
select new CommandType22Response
@ -1261,9 +1261,9 @@ namespace BMA.EHR.Application.Repositories.Commands
OldPositionNumber = p.PositionNumberOld == null ? null : p.PositionNumberOld.ToThaiNumber(),
OldSalary = p.AmountOld == null ? "" : p.AmountOld.Value.ToNumericNoDecimalText().ToThaiNumber(),
// NewOc = p.OrganizationPosition == null || p.OrganizationPosition!.Organization == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.OrgEmployee == null || p.OrgEmployee.PositionEmployeePosition == null ? "" : p.OrgEmployee.PositionEmployeePosition.Name,
NewPositionLevel = p.OrgEmployee == null || p.OrgEmployee.OrganizationPositionEmployeeLevels == null || p.OrgEmployee.OrganizationPositionEmployeeLevels.Count() == 0 ? "" : p.OrgEmployee.OrganizationPositionEmployeeLevels.FirstOrDefault().PositionEmployeeLevel.Name,
NewPositionNumber = p.OrgEmployee == null || p.OrgEmployee.PosNo == null ? "" : p.OrgEmployee.PosNo.ToThaiNumber(),
// NewPositionName = p.OrgEmployee == null || p.OrgEmployee.PositionEmployeePosition == null ? "" : p.OrgEmployee.PositionEmployeePosition.Name,
// NewPositionLevel = p.OrgEmployee == null || p.OrgEmployee.OrganizationPositionEmployeeLevels == null || p.OrgEmployee.OrganizationPositionEmployeeLevels.Count() == 0 ? "" : p.OrgEmployee.OrganizationPositionEmployeeLevels.FirstOrDefault().PositionEmployeeLevel.Name,
// NewPositionNumber = p.OrgEmployee == null || p.OrgEmployee.PosNo == null ? "" : p.OrgEmployee.PosNo.ToThaiNumber(),
NewSalary = r.Amount == null ? "" : r.Amount.Value.ToNumericNoDecimalText().ToThaiNumber(),
Reason = p.Reason == null ? "-" : p.Reason,
})

File diff suppressed because it is too large Load diff

View file

@ -189,23 +189,41 @@ namespace BMA.EHR.Application.Repositories.Reports
.Select(p => new
{
p.Id,
ProfileId = p.Profile.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
p.Profile.FirstName,
p.Profile.LastName,
Position = p.Profile.Position == null ? null : p.Profile.Position.Name,
PositionId = p.Profile.Position == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Position.Id,
PositionType = p.Profile.PositionType == null ? null : p.Profile.PositionType.Name,
PositionTypeId = p.Profile.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionType.Id,
p.Profile.PositionLine,
p.Profile.PositionLineId,
PositionLevel = p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name,
PositionLevelId = p.Profile.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionLevel.Id,
p.Profile.PositionExecutive,
p.Profile.PositionExecutiveId,
Organization = p.Profile.Oc,
OrganizationId = p.Profile.OcId,
p.prefix,
p.profileId,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.posLevelName,
p.posTypeName,
// ProfileId = p.Profile.Id,
// Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
// PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
// p.Profile.FirstName,
// p.Profile.LastName,
// Position = p.Profile.Position == null ? null : p.Profile.Position.Name,
// PositionId = p.Profile.Position == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Position.Id,
// PositionType = p.Profile.PositionType == null ? null : p.Profile.PositionType.Name,
// PositionTypeId = p.Profile.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionType.Id,
// p.Profile.PositionLine,
// p.Profile.PositionLineId,
// PositionLevel = p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name,
// PositionLevelId = p.Profile.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionLevel.Id,
// p.Profile.PositionExecutive,
// p.Profile.PositionExecutiveId,
// Organization = p.Profile.Oc,
// OrganizationId = p.Profile.OcId,
p.Number,
p.Date,
p.Location,
@ -216,29 +234,34 @@ namespace BMA.EHR.Application.Repositories.Reports
if (data == null)
return null;
string Prefix = string.IsNullOrEmpty(data.Prefix.ToString()) ? string.Empty : data.Prefix.ToString();
string FirstName = string.IsNullOrEmpty(data.FirstName.ToString()) ? string.Empty : data.FirstName.ToString();
string LastName = string.IsNullOrEmpty(data.LastName.ToString()) ? string.Empty : data.LastName.ToString();
string FullName = $"{Prefix} {FirstName} {LastName}";
// string Prefix = string.IsNullOrEmpty(data.Prefix.ToString()) ? string.Empty : data.Prefix.ToString();
// string FirstName = string.IsNullOrEmpty(data.FirstName.ToString()) ? string.Empty : data.FirstName.ToString();
// string LastName = string.IsNullOrEmpty(data.LastName.ToString()) ? string.Empty : data.LastName.ToString();
// string FullName = $"{Prefix} {FirstName} {LastName}";
string Date = string.IsNullOrEmpty(data.Date.ToString()) ? "วันที่ - เดือน - พ.ศ. -" : DateTime.Parse(data.Date.ToString()).ToThaiFullDate().ToString().ToThaiNumber();
string CurrentDate = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd")).ToThaiFullDate().ToString().ToThaiNumber();
return new
{
FullName,
FullName = $"{data.prefix} {data.firstName} {data.lastName}",
Date,
CurrentDate,
data.Position,
data.PositionExecutive,
data.PositionType,
data.PositionLine,
data.PositionLevel,
data.Organization,
data.PositionId,
data.PositionExecutiveId,
data.PositionTypeId,
data.PositionLineId,
data.PositionLevelId,
data.OrganizationId,
data.profileId,
data.prefix,
data.firstName,
data.lastName,
data.root,
data.rootShortName,
data.child1,
data.child1ShortName,
data.child2,
data.child2ShortName,
data.child3,
data.child3ShortName,
data.child4,
data.child4ShortName,
data.posMasterNo,
data.posLevelName,
data.posTypeName,
data.Number,
data.Location,
data.Reason,
@ -250,7 +273,7 @@ namespace BMA.EHR.Application.Repositories.Reports
public async Task<dynamic> GetHeadRetirementDeceasedAsync(Guid id)
{
var data = await _dbContext.Set<RetirementDeceased>().AsQueryable()
.Include(x => x.Profile)
// .Include(x => x.Profile)
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
var oc = "";
@ -264,28 +287,28 @@ namespace BMA.EHR.Application.Repositories.Reports
Send = "หัวหน้าสำนักงาน ก.ก.",
};
if (data.Profile.OcId != null)
{
var organization = await _dbContext.Set<OrganizationEntity>().AsQueryable()
.Where(x => x.Id == data.Profile.OcId)
.FirstOrDefaultAsync();
if (organization != null)
{
var organizationAgency = await _dbContext.Set<OrganizationEntity>().AsQueryable()
.Where(x => x.Id == organization.OrganizationAgencyId)
.FirstOrDefaultAsync();
if (organizationAgency != null)
{
var agency = await _dbContext.Set<OrganizationEntity>().AsQueryable()
.Where(x => x.Id == organizationAgency.Id)
.FirstOrDefaultAsync();
if (agency != null)
{
oc = agency.OrganizationOrganization?.Name;
}
}
}
}
// if (data.Profile.OcId != null)
// {
// var organization = await _dbContext.Set<OrganizationEntity>().AsQueryable()
// .Where(x => x.Id == data.Profile.OcId)
// .FirstOrDefaultAsync();
// if (organization != null)
// {
// var organizationAgency = await _dbContext.Set<OrganizationEntity>().AsQueryable()
// .Where(x => x.Id == organization.OrganizationAgencyId)
// .FirstOrDefaultAsync();
// if (organizationAgency != null)
// {
// var agency = await _dbContext.Set<OrganizationEntity>().AsQueryable()
// .Where(x => x.Id == organizationAgency.Id)
// .FirstOrDefaultAsync();
// if (agency != null)
// {
// oc = agency.OrganizationOrganization?.Name;
// }
// }
// }
// }
return new
{
@ -302,7 +325,7 @@ namespace BMA.EHR.Application.Repositories.Reports
public async Task UploadFileRetirementDeceasedAsync(Guid id, Domain.Models.Documents.Document file)
{
var data = await _dbContext.Set<RetirementDeceased>().AsQueryable()
.Include(x => x.Profile)
// .Include(x => x.Profile)
.Where(x => x.Id == id)
.FirstOrDefaultAsync();
if (data != null)
@ -361,8 +384,8 @@ namespace BMA.EHR.Application.Repositories.Reports
data.LastName,
data.Location,
FullName = $"{data.Prefix}{data.FirstName} {data.LastName}",
SendDate = string.IsNullOrEmpty(data.SendDate.ToString())? string.Empty : DateTime.Parse(data.SendDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
ActiveDate = string.IsNullOrEmpty(data.ActiveDate.ToString())? string.Empty : DateTime.Parse(data.ActiveDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
SendDate = string.IsNullOrEmpty(data.SendDate.ToString()) ? string.Empty : DateTime.Parse(data.SendDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
ActiveDate = string.IsNullOrEmpty(data.ActiveDate.ToString()) ? string.Empty : DateTime.Parse(data.ActiveDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
data.Reason,
data.Status,
data.salary,
@ -376,7 +399,7 @@ namespace BMA.EHR.Application.Repositories.Reports
data.CreatedAt,
data.OligarchReject,
data.OligarchApproveReason,
data.OligarchRejectReason,
data.OligarchRejectReason,
OligarchRejectDate = string.IsNullOrEmpty(data.OligarchRejectDate.ToString()) ? string.Empty : DateTime.Parse(data.OligarchRejectDate.ToString()).ToThaiFullDate().ToString().ToThaiNumber(),
data.CommanderReject,
data.CommanderApproveReason,

View file

@ -70,16 +70,16 @@ namespace BMA.EHR.Application.Repositories
public async Task NotifyOut()
{
var cronjobNotis = await _dbContext.Set<RetirementOut>()
.Include(x => x.Profile)
.ThenInclude(x => x.Prefix)
//.Include(x => x.Profile)
//.ThenInclude(x => x.Prefix)
.Where(x => x.Date != null && x.Date.Value.Date == DateTime.Now.Date)
.AsQueryable()
.ToListAsync();
foreach (var cronjobNoti in cronjobNotis)
{
cronjobNoti.Profile.IsLeave = true;
cronjobNoti.Profile.LeaveReason = "LAYOFF";
cronjobNoti.Profile.LeaveDate = DateTime.Now;
//cronjobNoti.Profile.IsLeave = true;
//cronjobNoti.Profile.LeaveReason = "LAYOFF";
//cronjobNoti.Profile.LeaveDate = DateTime.Now;
// await _repositoryNoti.PushNotificationAsync(
// Guid.Parse("08db721d-ada0-4e64-89d3-7584a893d8b8"),
// $"แจ้งเตือนการปลดออกของ {cronjobNoti.Profile.Prefix?.Name}{cronjobNoti.Profile.FirstName} {cronjobNoti.Profile.LastName}",

View file

@ -11,56 +11,58 @@ namespace BMA.EHR.Domain.Models.Placement
{
public class PlacementAppointment : EntityBase
{
[Required, Comment("Id User")]
public Profile Profile { get; set; }
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
public string? CitizenId { get; set; }
[Required, Comment("คำนำหน้า")]
public Prefix? Prefix { get; set; }
[Required, Comment("ชื่อ")]
public string? Firstname { get; set; }
[Required, Comment("นามสกุล")]
public string? Lastname { get; set; }
[MaxLength(40), Comment("วันเกิด")]
public DateTime DateOfBirth { get; set; }
[Comment("Id เพศ")]
public Gender? Gender { get; set; }
[MaxLength(100), Comment("สัญชาติ")]
public string? Nationality { get; set; }
[MaxLength(100), Comment("เชื้อชาติ")]
public string? Race { get; set; }
[Comment("Id ศาสนา")]
public Religion? Religion { get; set; }
[Comment("Id กลุ่มเลือด")]
public BloodGroup? BloodGroup { get; set; }
[Comment("Id สถานะภาพ")]
public Relationship? Relationship { get; set; }
[MaxLength(50), Comment("เบอร์โทร")]
public string? TelephoneNumber { get; set; }
// [Required, Comment("Id User")]
// public Profile Profile { get; set; }
// [Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
// public string? CitizenId { get; set; }
// [Required, Comment("คำนำหน้า")]
// public Prefix? Prefix { get; set; }
// [Required, Comment("ชื่อ")]
// public string? Firstname { get; set; }
// [Required, Comment("นามสกุล")]
// public string? Lastname { get; set; }
// [MaxLength(40), Comment("วันเกิด")]
// public DateTime DateOfBirth { get; set; }
// [Comment("Id เพศ")]
// public Gender? Gender { get; set; }
// [MaxLength(100), Comment("สัญชาติ")]
// public string? Nationality { get; set; }
// [MaxLength(100), Comment("เชื้อชาติ")]
// public string? Race { get; set; }
// [Comment("Id ศาสนา")]
// public Religion? Religion { get; set; }
// [Comment("Id กลุ่มเลือด")]
// public BloodGroup? BloodGroup { get; set; }
// [Comment("Id สถานะภาพ")]
// public Relationship? Relationship { get; set; }
// [MaxLength(50), Comment("เบอร์โทร")]
// public string? TelephoneNumber { get; set; }
[Comment("สถานะคำขอ")]
public string Status { get; set; } = "WAITTING";
[Comment("Id เลขที่ตำแหน่ง")]
public OrganizationPositionEntity? OrganizationPosition { get; set; }
// [Comment("Id เลขที่ตำแหน่ง")]
// public OrganizationPositionEntity? OrganizationPosition { get; set; }
[Comment("วันที่บรรจุ")]
public DateTime? RecruitDate { get; set; }
[Comment("Id ตำแหน่งเลขที่")]
public PositionNumberEntity? PositionNumber { get; set; }
// [Comment("Id ตำแหน่งเลขที่")]
// public PositionNumberEntity? PositionNumber { get; set; }
[Comment("Id ตำแหน่ง")]
public PositionPath? PositionPath { get; set; }
// [Comment("Id ตำแหน่ง")]
// public PositionPath? PositionPath { get; set; }
[Comment("Id ด้าน/สาขา")]
public PositionPathSide? PositionPathSide { get; set; }
// [Comment("Id ด้าน/สาขา")]
// public PositionPathSide? PositionPathSide { get; set; }
[Comment("Id ประเภทตำแหน่ง")]
public PositionType? PositionType { get; set; }
// [Comment("Id ประเภทตำแหน่ง")]
// public PositionType? PositionType { get; set; }
[Comment("Id สายงาน")]
public PositionLine? PositionLine { get; set; }
// [Comment("Id สายงาน")]
// public PositionLine? PositionLine { get; set; }
[Comment("Id ระดับ")]
public PositionLevel? PositionLevel { get; set; }
// [Comment("Id ระดับ")]
// public PositionLevel? PositionLevel { get; set; }
[Comment("ประเภทราชการ")]
public string? type { get; set; }
[Comment("เงินเดือน")]
public double? Amount { get; set; }
[Comment("เหตุผลที่รับย้ายราชการ")]
@ -83,10 +85,127 @@ namespace BMA.EHR.Domain.Models.Placement
public CommandType? CommandType { get; set; }
[Comment("ดำรงตำแหน่งในระดับปัจจุบันเมื่อ")]
public DateTime? PositionDate { get; set; }
public OrgEmployee? OrgEmployee { get; set; }
public PositionEmployeeStatus? PositionEmployeeStatus { get; set; }
public PositionEmployeeLine? PositionEmployeeLine { get; set; }
public PositionEmployeePosition? PositionEmployeePosition { get; set; }
[Comment("profile Id")]
public string? profileId { get; set; }
[Comment("คำนำหน้า")]
public string? prefix { get; set; }
[Comment("ชื่อ")]
public string? firstName { get; set; }
[Comment("นามสกุล")]
public string? lastName { get; set; }
[Comment("เลขบัตรประชาชน")]
public string? citizenId { get; set; }
[Comment("ชื่อหน่วยงาน root")]
public string? root { get; set; }
[Comment("id หน่วยงาน root")]
public string? rootId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root")]
public string? rootShortName { get; set; }
[Comment("ชื่อหน่วยงาน child1")]
public string? child1 { get; set; }
[Comment("id หน่วยงาน child1")]
public string? child1Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1")]
public string? child1ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child2")]
public string? child2 { get; set; }
[Comment("id หน่วยงาน child2")]
public string? child2Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2")]
public string? child2ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child3")]
public string? child3 { get; set; }
[Comment("id หน่วยงาน child3")]
public string? child3Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3")]
public string? child3ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child4")]
public string? child4 { get; set; }
[Comment("id หน่วยงาน child4")]
public string? child4Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4")]
public string? child4ShortName { get; set; }
[Comment("ระดับโครงสร้าง")]
public int? node { get; set; }
[Comment("id โครงสร้าง")]
public Guid? nodeId { get; set; }
[Comment("id อัตรากำลัง")]
public string? posmasterId { get; set; }
[Comment("id revision")]
public string? orgRevisionId { get; set; }
[Comment("id ตำแหน่ง")]
public string? positionId { get; set; }
[Comment("สายงาน")]
public string? positionField { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public int? posMasterNo { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน")]
public string? positionName { get; set; }
[Comment("id ประเภทตำแหน่ง")]
public string? posTypeId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง")]
public string? posTypeName { get; set; }
[Comment("id ระดับตำแหน่ง")]
public string? posLevelId { get; set; }
[Comment("ชื่อระดับตำแหน่ง")]
public string? posLevelName { get; set; }
[Comment("ชื่อหน่วยงาน root old")]
public string? rootOld { get; set; }
[Comment("id หน่วยงาน root old")]
public string? rootOldId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root old")]
public string? rootShortNameOld { get; set; }
[Comment("ชื่อหน่วยงาน child1 old")]
public string? child1Old { get; set; }
[Comment("id หน่วยงาน child1 old")]
public string? child1OldId { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1 old")]
public string? child1ShortNameOld { get; set; }
[Comment("ชื่อหน่วยงาน child2 old")]
public string? child2Old { get; set; }
[Comment("id หน่วยงาน child2 old")]
public string? child2OldId { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2 old")]
public string? child2ShortNameOld { get; set; }
[Comment("ชื่อหน่วยงาน child3 old")]
public string? child3Old { get; set; }
[Comment("id หน่วยงาน child3 old")]
public string? child3OldId { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3 old")]
public string? child3ShortNameOld { get; set; }
[Comment("ชื่อหน่วยงาน child4 old")]
public string? child4Old { get; set; }
[Comment("id หน่วยงาน child4 old")]
public string? child4OldId { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4 old")]
public string? child4ShortNameOld { get; set; }
// [Comment("id revision old")]
// public string? orgRevisionId { get; set; }
[Comment("เลขที่ตำแหน่ง old")]
public int? posMasterNoOld { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน old")]
public string? positionOld { get; set; }
[Comment("id ประเภทตำแหน่ง old")]
public string? posTypeOldId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง old")]
public string? posTypeNameOld { get; set; }
[Comment("id ระดับตำแหน่ง old")]
public string? posLevelOldId { get; set; }
[Comment("ชื่อระดับตำแหน่ง old")]
public string? posLevelNameOld { get; set; }
// public OrgEmployee? OrgEmployee { get; set; }
// public PositionEmployeeStatus? PositionEmployeeStatus { get; set; }
// public PositionEmployeeLine? PositionEmployeeLine { get; set; }
// public PositionEmployeePosition? PositionEmployeePosition { get; set; }
public virtual List<PlacementAppointmentDoc> PlacementAppointmentDocs { get; set; } = new List<PlacementAppointmentDoc>();
}
}

View file

@ -9,8 +9,8 @@ namespace BMA.EHR.Domain.Models.Placement
{
public class PlacementOfficer : EntityBase
{
[Comment("Id User")]
public Profile? Profile { get; set; }
// [Comment("Id User")]
// public Profile? Profile { get; set; }
[Comment("เหตุผล")]
public string? Reason { get; set; } = string.Empty;
[Comment("ข้อมูลหน่วยงานเดิม ตำแหน่งประเภท")]
@ -33,6 +33,63 @@ namespace BMA.EHR.Domain.Models.Placement
public DateTime? DateEnd { get; set; }
[Comment("profile Id")]
public string? profileId { get; set; }
[Comment("คำนำหน้า")]
public string? prefix { get; set; }
[Comment("ชื่อ")]
public string? firstName { get; set; }
[Comment("นามสกุล")]
public string? lastName { get; set; }
[Comment("เลขบัตรประชาชน")]
public string? citizenId { get; set; }
[Comment("ชื่อหน่วยงาน root")]
public string? root { get; set; }
[Comment("id หน่วยงาน root")]
public string? rootId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root")]
public string? rootShortName { get; set; }
[Comment("ชื่อหน่วยงาน child1")]
public string? child1 { get; set; }
[Comment("id หน่วยงาน child1")]
public string? child1Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1")]
public string? child1ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child2")]
public string? child2 { get; set; }
[Comment("id หน่วยงาน child2")]
public string? child2Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2")]
public string? child2ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child3")]
public string? child3 { get; set; }
[Comment("id หน่วยงาน child3")]
public string? child3Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3")]
public string? child3ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child4")]
public string? child4 { get; set; }
[Comment("id หน่วยงาน child4")]
public string? child4Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4")]
public string? child4ShortName { get; set; }
// [Comment("id revision")]
// public string? orgRevisionId { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public int? posMasterNo { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน")]
public string? position { get; set; }
[Comment("id ประเภทตำแหน่ง")]
public string? posTypeId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง")]
public string? posTypeName { get; set; }
[Comment("id ระดับตำแหน่ง")]
public string? posLevelId { get; set; }
[Comment("ชื่อระดับตำแหน่ง")]
public string? posLevelName { get; set; }
[Comment("สถานะคำขอ")]
public string Status { get; set; } = "WAITTING";
[Comment("สถานะการใช้งาน")]

View file

@ -14,14 +14,14 @@ namespace BMA.EHR.Domain.Models.Placement
// public Profile Profile { get; set; }
[Comment("Fk Table Document")]
public Document? Avatar { get; set; }
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
public string CitizenId { get; set; }
[Required, Comment("คำนำหน้า")]
public Prefix Prefix { get; set; }
[Required, Comment("ชื่อ")]
public string Firstname { get; set; }
[Required, Comment("นามสกุล")]
public string Lastname { get; set; }
// [Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
// public string CitizenId { get; set; }
// [Required, Comment("คำนำหน้า")]
// public Prefix Prefix { get; set; }
// [Required, Comment("ชื่อ")]
// public string Firstname { get; set; }
// [Required, Comment("นามสกุล")]
// public string Lastname { get; set; }
[MaxLength(40), Comment("วันเกิด")]
public DateTime DateOfBirth { get; set; }
[Comment("Id เพศ")]
@ -40,30 +40,30 @@ namespace BMA.EHR.Domain.Models.Placement
public string? TelephoneNumber { get; set; }
[Comment("สถานะคำขอ")]
public string Status { get; set; } = "WAITTING";
[Comment("Id เลขที่ตำแหน่ง")]
public OrganizationPositionEntity? OrganizationPosition { get; set; }
// [Comment("Id เลขที่ตำแหน่ง")]
// public OrganizationPositionEntity? OrganizationPosition { get; set; }
[Comment("เงินเดือน")]
public double? Amount { get; set; }
[Comment("วันที่บรรจุ")]
public DateTime? RecruitDate { get; set; }
[Comment("Id ตำแหน่งเลขที่")]
public PositionNumberEntity? PositionNumber { get; set; }
// [Comment("Id ตำแหน่งเลขที่")]
// public PositionNumberEntity? PositionNumber { get; set; }
[Comment("Id ตำแหน่ง")]
public PositionPath? PositionPath { get; set; }
// [Comment("Id ตำแหน่ง")]
// public PositionPath? PositionPath { get; set; }
[Comment("Id ด้าน/สาขา")]
public PositionPathSide? PositionPathSide { get; set; }
// [Comment("Id ด้าน/สาขา")]
// public PositionPathSide? PositionPathSide { get; set; }
[Comment("Id ประเภทตำแหน่ง")]
public PositionType? PositionType { get; set; }
// [Comment("Id ประเภทตำแหน่ง")]
// public PositionType? PositionType { get; set; }
[Comment("Id สายงาน")]
public PositionLine? PositionLine { get; set; }
// [Comment("Id สายงาน")]
// public PositionLine? PositionLine { get; set; }
[Comment("Id ระดับ")]
public PositionLevel? PositionLevel { get; set; }
// [Comment("Id ระดับ")]
// public PositionLevel? PositionLevel { get; set; }
[Comment("เหตุผลที่รับโอนราชการ")]
public string? Reason { get; set; }
[Comment("วุฒิ/สาขาเดิม")]
@ -78,6 +78,75 @@ namespace BMA.EHR.Domain.Models.Placement
public string? PositionNumberOld { get; set; }
[Comment("ข้อมูลหน่วยงานเดิม เงินเดือน")]
public double? AmountOld { get; set; }
[Comment("profile Id")]
public string? profileId { get; set; }
[Comment("คำนำหน้า")]
public string? prefix { get; set; }
[Comment("ชื่อ")]
public string? firstName { get; set; }
[Comment("นามสกุล")]
public string? lastName { get; set; }
[Comment("เลขบัตรประชาชน")]
public string? citizenId { get; set; }
[Comment("ชื่อหน่วยงาน root")]
public string? root { get; set; }
[Comment("id หน่วยงาน root")]
public string? rootId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root")]
public string? rootShortName { get; set; }
[Comment("ชื่อหน่วยงาน child1")]
public string? child1 { get; set; }
[Comment("id หน่วยงาน child1")]
public string? child1Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1")]
public string? child1ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child2")]
public string? child2 { get; set; }
[Comment("id หน่วยงาน child2")]
public string? child2Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2")]
public string? child2ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child3")]
public string? child3 { get; set; }
[Comment("id หน่วยงาน child3")]
public string? child3Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3")]
public string? child3ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child4")]
public string? child4 { get; set; }
[Comment("id หน่วยงาน child4")]
public string? child4Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4")]
public string? child4ShortName { get; set; }
[Comment("ระดับโครงสร้าง")]
public int? node { get; set; }
[Comment("id โครงสร้าง")]
public Guid? nodeId { get; set; }
[Comment("id อัตรากำลัง")]
public string? posmasterId { get; set; }
[Comment("id revision")]
public string? orgRevisionId { get; set; }
[Comment("id ตำแหน่ง")]
public string? positionId { get; set; }
[Comment("สายงาน")]
public string? positionField { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public int? posMasterNo { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน")]
public string? positionName { get; set; }
[Comment("id ประเภทตำแหน่ง")]
public string? posTypeId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง")]
public string? posTypeName { get; set; }
[Comment("id ระดับตำแหน่ง")]
public string? posLevelId { get; set; }
[Comment("ชื่อระดับตำแหน่ง")]
public string? posLevelName { get; set; }
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
public virtual List<PlacementReceiveDoc> PlacementReceiveDocs { get; set; } = new List<PlacementReceiveDoc>();

View file

@ -9,8 +9,6 @@ namespace BMA.EHR.Domain.Models.Placement
{
public class PlacementRepatriation : EntityBase
{
[Required, Comment("Id User")]
public Profile Profile { get; set; }
[Comment("หน่วยงานที่ส่งตัวกลับไป")]
public string? Organization { get; set; } = string.Empty;
[Comment("เหตุผล")]
@ -33,5 +31,61 @@ namespace BMA.EHR.Domain.Models.Placement
public bool IsActive { get; set; } = true;
[Comment("ส่งตัวกลับตั้งแต่วันที่")]
public DateTime? DateRepatriation { get; set; }
[Comment("profile Id")]
public string? profileId { get; set; }
[Comment("คำนำหน้า")]
public string? prefix { get; set; }
[Comment("ชื่อ")]
public string? firstName { get; set; }
[Comment("นามสกุล")]
public string? lastName { get; set; }
[Comment("เลขบัตรประชาชน")]
public string? citizenId { get; set; }
[Comment("ชื่อหน่วยงาน root")]
public string? root { get; set; }
[Comment("id หน่วยงาน root")]
public string? rootId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root")]
public string? rootShortName { get; set; }
[Comment("ชื่อหน่วยงาน child1")]
public string? child1 { get; set; }
[Comment("id หน่วยงาน child1")]
public string? child1Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1")]
public string? child1ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child2")]
public string? child2 { get; set; }
[Comment("id หน่วยงาน child2")]
public string? child2Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2")]
public string? child2ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child3")]
public string? child3 { get; set; }
[Comment("id หน่วยงาน child3")]
public string? child3Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3")]
public string? child3ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child4")]
public string? child4 { get; set; }
[Comment("id หน่วยงาน child4")]
public string? child4Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4")]
public string? child4ShortName { get; set; }
// [Comment("id revision")]
// public string? orgRevisionId { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public int? posMasterNo { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน")]
public string? position { get; set; }
[Comment("id ประเภทตำแหน่ง")]
public string? posTypeId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง")]
public string? posTypeName { get; set; }
[Comment("id ระดับตำแหน่ง")]
public string? posLevelId { get; set; }
[Comment("ชื่อระดับตำแหน่ง")]
public string? posLevelName { get; set; }
}
}

View file

@ -22,8 +22,64 @@ namespace BMA.EHR.Domain.Models.Retirement
public string? Location { get; set; } = string.Empty;
[Comment("เหตุผลการเสียชีวิต")]
public string? Reason { get; set; } = string.Empty;
[Comment("Id ผู้ถึงแก่กรรม")]
public Profile Profile { get; set; }
[Comment("profile Id")]
public string? profileId { get; set; }
[Comment("คำนำหน้า")]
public string? prefix { get; set; }
[Comment("ชื่อ")]
public string? firstName { get; set; }
[Comment("นามสกุล")]
public string? lastName { get; set; }
[Comment("เลขบัตรประชาชน")]
public string? citizenId { get; set; }
[Comment("ชื่อหน่วยงาน root")]
public string? root { get; set; }
[Comment("id หน่วยงาน root")]
public string? rootId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root")]
public string? rootShortName { get; set; }
[Comment("ชื่อหน่วยงาน child1")]
public string? child1 { get; set; }
[Comment("id หน่วยงาน child1")]
public string? child1Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1")]
public string? child1ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child2")]
public string? child2 { get; set; }
[Comment("id หน่วยงาน child2")]
public string? child2Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2")]
public string? child2ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child3")]
public string? child3 { get; set; }
[Comment("id หน่วยงาน child3")]
public string? child3Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3")]
public string? child3ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child4")]
public string? child4 { get; set; }
[Comment("id หน่วยงาน child4")]
public string? child4Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4")]
public string? child4ShortName { get; set; }
// [Comment("id revision")]
// public string? orgRevisionId { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public int? posMasterNo { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน")]
public string? position { get; set; }
[Comment("id ประเภทตำแหน่ง")]
public string? posTypeId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง")]
public string? posTypeName { get; set; }
[Comment("id ระดับตำแหน่ง")]
public string? posLevelId { get; set; }
[Comment("ชื่อระดับตำแหน่ง")]
public string? posLevelName { get; set; }
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
public virtual List<RetirementDeceasedNoti> RetirementDeceasedNotis { get; set; } = new List<RetirementDeceasedNoti>();

View file

@ -10,56 +10,11 @@ namespace BMA.EHR.Domain.Models.Retirement
{
public class RetirementOther : EntityBase
{
[Required, Comment("Id User")]
public Profile Profile { get; set; }
[Required, MaxLength(20), Comment("เลขประจำตัวประชาชน")]
public string? CitizenId { get; set; }
[Required, Comment("คำนำหน้า")]
public Prefix? Prefix { get; set; }
[Required, Comment("ชื่อ")]
public string? Firstname { get; set; }
[Required, Comment("นามสกุล")]
public string? Lastname { get; set; }
[MaxLength(40), Comment("วันเกิด")]
public DateTime DateOfBirth { get; set; }
[Comment("Id เพศ")]
public Gender? Gender { get; set; }
[MaxLength(100), Comment("สัญชาติ")]
public string? Nationality { get; set; }
[MaxLength(100), Comment("เชื้อชาติ")]
public string? Race { get; set; }
[Comment("Id ศาสนา")]
public Religion? Religion { get; set; }
[Comment("Id กลุ่มเลือด")]
public BloodGroup? BloodGroup { get; set; }
[Comment("Id สถานะภาพ")]
public Relationship? Relationship { get; set; }
[MaxLength(50), Comment("เบอร์โทร")]
public string? TelephoneNumber { get; set; }
[Comment("สถานะคำขอ")]
public string Status { get; set; } = "WAITTING";
[Comment("Id เลขที่ตำแหน่ง")]
public OrganizationPositionEntity? OrganizationPosition { get; set; }
[Comment("วันที่บรรจุ")]
public DateTime? RecruitDate { get; set; }
[Comment("Id ตำแหน่งเลขที่")]
public PositionNumberEntity? PositionNumber { get; set; }
[Comment("Id ตำแหน่ง")]
public PositionPath? PositionPath { get; set; }
[Comment("Id ด้าน/สาขา")]
public PositionPathSide? PositionPathSide { get; set; }
[Comment("Id ประเภทตำแหน่ง")]
public PositionType? PositionType { get; set; }
[Comment("Id สายงาน")]
public PositionLine? PositionLine { get; set; }
[Comment("Id ระดับ")]
public PositionLevel? PositionLevel { get; set; }
[Comment("เงินเดือน")]
public double? Amount { get; set; }
[Comment("เหตุผลที่รับย้ายราชการ")]
@ -84,6 +39,64 @@ namespace BMA.EHR.Domain.Models.Retirement
public DateTime? PositionDate { get; set; }
[Comment("วันที่พ้นจากราชการทหาร")]
public DateTime? MilitaryDate { get; set; }
[Comment("profile Id")]
public string? profileId { get; set; }
[Comment("คำนำหน้า")]
public string? prefix { get; set; }
[Comment("ชื่อ")]
public string? firstName { get; set; }
[Comment("นามสกุล")]
public string? lastName { get; set; }
[Comment("เลขบัตรประชาชน")]
public string? citizenId { get; set; }
[Comment("ชื่อหน่วยงาน root")]
public string? root { get; set; }
[Comment("id หน่วยงาน root")]
public string? rootId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root")]
public string? rootShortName { get; set; }
[Comment("ชื่อหน่วยงาน child1")]
public string? child1 { get; set; }
[Comment("id หน่วยงาน child1")]
public string? child1Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1")]
public string? child1ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child2")]
public string? child2 { get; set; }
[Comment("id หน่วยงาน child2")]
public string? child2Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2")]
public string? child2ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child3")]
public string? child3 { get; set; }
[Comment("id หน่วยงาน child3")]
public string? child3Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3")]
public string? child3ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child4")]
public string? child4 { get; set; }
[Comment("id หน่วยงาน child4")]
public string? child4Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4")]
public string? child4ShortName { get; set; }
// [Comment("id revision")]
// public string? orgRevisionId { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public int? posMasterNo { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน")]
public string? position { get; set; }
[Comment("id ประเภทตำแหน่ง")]
public string? posTypeId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง")]
public string? posTypeName { get; set; }
[Comment("id ระดับตำแหน่ง")]
public string? posLevelId { get; set; }
[Comment("ชื่อระดับตำแหน่ง")]
public string? posLevelName { get; set; }
public virtual List<RetirementOtherDoc> RetirementOtherDocs { get; set; } = new List<RetirementOtherDoc>();
}
}

View file

@ -9,8 +9,6 @@ namespace BMA.EHR.Domain.Models.Retirement
{
public class RetirementOut : EntityBase
{
[Required, Comment("Id User")]
public Profile Profile { get; set; }
[Comment("หน่วยงานที่ให้ออกไป")]
public string? Organization { get; set; } = string.Empty;
[Comment("เหตุผล")]
@ -29,6 +27,64 @@ namespace BMA.EHR.Domain.Models.Retirement
public double? AmountOld { get; set; }
[Comment("สถานะคำขอ")]
public string Status { get; set; } = "WAITTING";
[Comment("profile Id")]
public string? profileId { get; set; }
[Comment("คำนำหน้า")]
public string? prefix { get; set; }
[Comment("ชื่อ")]
public string? firstName { get; set; }
[Comment("นามสกุล")]
public string? lastName { get; set; }
[Comment("เลขบัตรประชาชน")]
public string? citizenId { get; set; }
[Comment("ชื่อหน่วยงาน root")]
public string? root { get; set; }
[Comment("id หน่วยงาน root")]
public string? rootId { get; set; }
[Comment("ชื่อย่อหน่วยงาน root")]
public string? rootShortName { get; set; }
[Comment("ชื่อหน่วยงาน child1")]
public string? child1 { get; set; }
[Comment("id หน่วยงาน child1")]
public string? child1Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child1")]
public string? child1ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child2")]
public string? child2 { get; set; }
[Comment("id หน่วยงาน child2")]
public string? child2Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child2")]
public string? child2ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child3")]
public string? child3 { get; set; }
[Comment("id หน่วยงาน child3")]
public string? child3Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child3")]
public string? child3ShortName { get; set; }
[Comment("ชื่อหน่วยงาน child4")]
public string? child4 { get; set; }
[Comment("id หน่วยงาน child4")]
public string? child4Id { get; set; }
[Comment("ชื่อย่อหน่วยงาน child4")]
public string? child4ShortName { get; set; }
// [Comment("id revision")]
// public string? orgRevisionId { get; set; }
[Comment("เลขที่ตำแหน่ง")]
public int? posMasterNo { get; set; }
[Comment("ชื่อตำแหน่งในสายงาน")]
public string? position { get; set; }
[Comment("id ประเภทตำแหน่ง")]
public string? posTypeId { get; set; }
[Comment("ชื่อประเภทตำแหน่ง")]
public string? posTypeName { get; set; }
[Comment("id ระดับตำแหน่ง")]
public string? posLevelId { get; set; }
[Comment("ชื่อระดับตำแหน่ง")]
public string? posLevelName { get; set; }
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
}

View file

@ -0,0 +1,373 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetablePlacementOfficeraddchild1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
// migrationBuilder.DropForeignKey(
// name: "FK_PlacementOfficers_Profiles_ProfileId",
// table: "PlacementOfficers");
// migrationBuilder.DropIndex(
// name: "IX_PlacementOfficers_ProfileId",
// table: "PlacementOfficers");
migrationBuilder.RenameColumn(
name: "ProfileId",
table: "PlacementOfficers",
newName: "profileId");
migrationBuilder.AlterColumn<string>(
name: "profileId",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "profile Id",
oldClrType: typeof(Guid),
oldType: "char(36)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddColumn<string>(
name: "child1",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1Id",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1ShortName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2Id",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2ShortName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3Id",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3ShortName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4Id",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4ShortName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "citizenId",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "เลขบัตรประชาชน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "firstName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "lastName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "นามสกุล")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posLevelId",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "id ระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posLevelName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "posMasterNo",
table: "PlacementOfficers",
type: "int",
nullable: true,
comment: "เลขที่ตำแหน่ง");
migrationBuilder.AddColumn<string>(
name: "posTypeId",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "id ประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posTypeName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "position",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อตำแหน่งในสายงาน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "prefix",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "คำนำหน้า")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "root",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootId",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootShortName",
table: "PlacementOfficers",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "child1",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child1Id",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child1ShortName",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child2",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child2Id",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child2ShortName",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child3",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child3Id",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child3ShortName",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child4",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child4Id",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "child4ShortName",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "citizenId",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "firstName",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "lastName",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "posLevelId",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "posLevelName",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "posMasterNo",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "posTypeId",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "posTypeName",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "position",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "prefix",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "root",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "rootId",
table: "PlacementOfficers");
migrationBuilder.DropColumn(
name: "rootShortName",
table: "PlacementOfficers");
migrationBuilder.RenameColumn(
name: "profileId",
table: "PlacementOfficers",
newName: "ProfileId");
migrationBuilder.AlterColumn<Guid>(
name: "ProfileId",
table: "PlacementOfficers",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "profile Id")
.OldAnnotation("MySql:CharSet", "utf8mb4");
// migrationBuilder.CreateIndex(
// name: "IX_PlacementOfficers_ProfileId",
// table: "PlacementOfficers",
// column: "ProfileId");
// migrationBuilder.AddForeignKey(
// name: "FK_PlacementOfficers_Profiles_ProfileId",
// table: "PlacementOfficers",
// column: "ProfileId",
// principalTable: "Profiles",
// principalColumn: "Id",
// onDelete: ReferentialAction.Cascade);
}
}
}

View file

@ -0,0 +1,373 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetablePlacementRepatriationaddchild1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PlacementRepatriations_Profiles_ProfileId",
table: "PlacementRepatriations");
migrationBuilder.DropIndex(
name: "IX_PlacementRepatriations_ProfileId",
table: "PlacementRepatriations");
migrationBuilder.RenameColumn(
name: "ProfileId",
table: "PlacementRepatriations",
newName: "profileId");
migrationBuilder.AlterColumn<string>(
name: "profileId",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "profile Id",
oldClrType: typeof(Guid),
oldType: "char(36)")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("Relational:Collation", "ascii_general_ci");
migrationBuilder.AddColumn<string>(
name: "child1",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1Id",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1ShortName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2Id",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2ShortName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3Id",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3ShortName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4Id",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4ShortName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "citizenId",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "เลขบัตรประชาชน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "firstName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "lastName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "นามสกุล")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posLevelId",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "id ระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posLevelName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "posMasterNo",
table: "PlacementRepatriations",
type: "int",
nullable: true,
comment: "เลขที่ตำแหน่ง");
migrationBuilder.AddColumn<string>(
name: "posTypeId",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "id ประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posTypeName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "position",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อตำแหน่งในสายงาน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "prefix",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "คำนำหน้า")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "root",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootId",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootShortName",
table: "PlacementRepatriations",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "child1",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child1Id",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child1ShortName",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child2",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child2Id",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child2ShortName",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child3",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child3Id",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child3ShortName",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child4",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child4Id",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "child4ShortName",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "citizenId",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "firstName",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "lastName",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "posLevelId",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "posLevelName",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "posMasterNo",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "posTypeId",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "posTypeName",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "position",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "prefix",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "root",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "rootId",
table: "PlacementRepatriations");
migrationBuilder.DropColumn(
name: "rootShortName",
table: "PlacementRepatriations");
migrationBuilder.RenameColumn(
name: "profileId",
table: "PlacementRepatriations",
newName: "ProfileId");
migrationBuilder.AlterColumn<Guid>(
name: "ProfileId",
table: "PlacementRepatriations",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "profile Id")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.CreateIndex(
name: "IX_PlacementRepatriations_ProfileId",
table: "PlacementRepatriations",
column: "ProfileId");
migrationBuilder.AddForeignKey(
name: "FK_PlacementRepatriations_Profiles_ProfileId",
table: "PlacementRepatriations",
column: "ProfileId",
principalTable: "Profiles",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,743 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetablePlacementReciveaddchild1 : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_PlacementReceives_OrganizationPositions_OrganizationPosition~",
table: "PlacementReceives");
migrationBuilder.DropForeignKey(
name: "FK_PlacementReceives_PositionLevels_PositionLevelId",
table: "PlacementReceives");
migrationBuilder.DropForeignKey(
name: "FK_PlacementReceives_PositionLines_PositionLineId",
table: "PlacementReceives");
migrationBuilder.DropForeignKey(
name: "FK_PlacementReceives_PositionNumbers_PositionNumberId",
table: "PlacementReceives");
migrationBuilder.DropForeignKey(
name: "FK_PlacementReceives_PositionPathSides_PositionPathSideId",
table: "PlacementReceives");
migrationBuilder.DropForeignKey(
name: "FK_PlacementReceives_PositionPaths_PositionPathId",
table: "PlacementReceives");
migrationBuilder.DropForeignKey(
name: "FK_PlacementReceives_PositionTypes_PositionTypeId",
table: "PlacementReceives");
migrationBuilder.DropForeignKey(
name: "FK_PlacementReceives_Prefixes_PrefixId",
table: "PlacementReceives");
migrationBuilder.DropIndex(
name: "IX_PlacementReceives_OrganizationPositionId",
table: "PlacementReceives");
migrationBuilder.DropIndex(
name: "IX_PlacementReceives_PositionLevelId",
table: "PlacementReceives");
migrationBuilder.DropIndex(
name: "IX_PlacementReceives_PositionLineId",
table: "PlacementReceives");
migrationBuilder.DropIndex(
name: "IX_PlacementReceives_PositionNumberId",
table: "PlacementReceives");
migrationBuilder.DropIndex(
name: "IX_PlacementReceives_PositionPathId",
table: "PlacementReceives");
migrationBuilder.DropIndex(
name: "IX_PlacementReceives_PositionPathSideId",
table: "PlacementReceives");
migrationBuilder.DropIndex(
name: "IX_PlacementReceives_PositionTypeId",
table: "PlacementReceives");
migrationBuilder.DropIndex(
name: "IX_PlacementReceives_PrefixId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "OrganizationPositionId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "PositionLevelId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "PositionLineId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "PositionNumberId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "PositionPathId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "PositionPathSideId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "PositionTypeId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "PrefixId",
table: "PlacementReceives");
migrationBuilder.RenameColumn(
name: "Lastname",
table: "PlacementReceives",
newName: "lastName");
migrationBuilder.RenameColumn(
name: "Firstname",
table: "PlacementReceives",
newName: "firstName");
migrationBuilder.RenameColumn(
name: "CitizenId",
table: "PlacementReceives",
newName: "citizenId");
migrationBuilder.AlterColumn<string>(
name: "lastName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "นามสกุล",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "นามสกุล")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "firstName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อ",
oldClrType: typeof(string),
oldType: "longtext",
oldComment: "ชื่อ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AlterColumn<string>(
name: "citizenId",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "เลขบัตรประชาชน",
oldClrType: typeof(string),
oldType: "varchar(20)",
oldMaxLength: 20,
oldComment: "เลขประจำตัวประชาชน")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1Id",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child1ShortName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child1")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2Id",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child2ShortName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child2")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3Id",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child3ShortName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child3")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4Id",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "child4ShortName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน child4")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "node",
table: "PlacementReceives",
type: "int",
nullable: true,
comment: "ระดับโครงสร้าง");
migrationBuilder.AddColumn<Guid>(
name: "nodeId",
table: "PlacementReceives",
type: "char(36)",
nullable: true,
comment: "id โครงสร้าง",
collation: "ascii_general_ci");
migrationBuilder.AddColumn<string>(
name: "orgRevisionId",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id revision")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posLevelId",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id ระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posLevelName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อระดับตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<int>(
name: "posMasterNo",
table: "PlacementReceives",
type: "int",
nullable: true,
comment: "เลขที่ตำแหน่ง");
migrationBuilder.AddColumn<string>(
name: "posTypeId",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id ประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posTypeName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อประเภทตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "positionField",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "สายงาน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "positionId",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id ตำแหน่ง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "positionName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อตำแหน่งในสายงาน")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "posmasterId",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id อัตรากำลัง")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "prefix",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "คำนำหน้า")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "profileId",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "profile Id")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "root",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อหน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootId",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "id หน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "rootShortName",
table: "PlacementReceives",
type: "longtext",
nullable: true,
comment: "ชื่อย่อหน่วยงาน root")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "child1",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child1Id",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child1ShortName",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child2",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child2Id",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child2ShortName",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child3",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child3Id",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child3ShortName",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child4",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child4Id",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "child4ShortName",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "node",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "nodeId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "orgRevisionId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "posLevelId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "posLevelName",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "posMasterNo",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "posTypeId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "posTypeName",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "positionField",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "positionId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "positionName",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "posmasterId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "prefix",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "profileId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "root",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "rootId",
table: "PlacementReceives");
migrationBuilder.DropColumn(
name: "rootShortName",
table: "PlacementReceives");
migrationBuilder.RenameColumn(
name: "lastName",
table: "PlacementReceives",
newName: "Lastname");
migrationBuilder.RenameColumn(
name: "firstName",
table: "PlacementReceives",
newName: "Firstname");
migrationBuilder.RenameColumn(
name: "citizenId",
table: "PlacementReceives",
newName: "CitizenId");
migrationBuilder.UpdateData(
table: "PlacementReceives",
keyColumn: "Lastname",
keyValue: null,
column: "Lastname",
value: "");
migrationBuilder.AlterColumn<string>(
name: "Lastname",
table: "PlacementReceives",
type: "longtext",
nullable: false,
comment: "นามสกุล",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "นามสกุล")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "PlacementReceives",
keyColumn: "Firstname",
keyValue: null,
column: "Firstname",
value: "");
migrationBuilder.AlterColumn<string>(
name: "Firstname",
table: "PlacementReceives",
type: "longtext",
nullable: false,
comment: "ชื่อ",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "ชื่อ")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.UpdateData(
table: "PlacementReceives",
keyColumn: "CitizenId",
keyValue: null,
column: "CitizenId",
value: "");
migrationBuilder.AlterColumn<string>(
name: "CitizenId",
table: "PlacementReceives",
type: "varchar(20)",
maxLength: 20,
nullable: false,
comment: "เลขประจำตัวประชาชน",
oldClrType: typeof(string),
oldType: "longtext",
oldNullable: true,
oldComment: "เลขบัตรประชาชน")
.Annotation("MySql:CharSet", "utf8mb4")
.OldAnnotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<Guid>(
name: "OrganizationPositionId",
table: "PlacementReceives",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionLevelId",
table: "PlacementReceives",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionLineId",
table: "PlacementReceives",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionNumberId",
table: "PlacementReceives",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionPathId",
table: "PlacementReceives",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionPathSideId",
table: "PlacementReceives",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PositionTypeId",
table: "PlacementReceives",
type: "char(36)",
nullable: true,
collation: "ascii_general_ci");
migrationBuilder.AddColumn<Guid>(
name: "PrefixId",
table: "PlacementReceives",
type: "char(36)",
nullable: false,
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
collation: "ascii_general_ci");
migrationBuilder.CreateIndex(
name: "IX_PlacementReceives_OrganizationPositionId",
table: "PlacementReceives",
column: "OrganizationPositionId");
migrationBuilder.CreateIndex(
name: "IX_PlacementReceives_PositionLevelId",
table: "PlacementReceives",
column: "PositionLevelId");
migrationBuilder.CreateIndex(
name: "IX_PlacementReceives_PositionLineId",
table: "PlacementReceives",
column: "PositionLineId");
migrationBuilder.CreateIndex(
name: "IX_PlacementReceives_PositionNumberId",
table: "PlacementReceives",
column: "PositionNumberId");
migrationBuilder.CreateIndex(
name: "IX_PlacementReceives_PositionPathId",
table: "PlacementReceives",
column: "PositionPathId");
migrationBuilder.CreateIndex(
name: "IX_PlacementReceives_PositionPathSideId",
table: "PlacementReceives",
column: "PositionPathSideId");
migrationBuilder.CreateIndex(
name: "IX_PlacementReceives_PositionTypeId",
table: "PlacementReceives",
column: "PositionTypeId");
migrationBuilder.CreateIndex(
name: "IX_PlacementReceives_PrefixId",
table: "PlacementReceives",
column: "PrefixId");
migrationBuilder.AddForeignKey(
name: "FK_PlacementReceives_OrganizationPositions_OrganizationPosition~",
table: "PlacementReceives",
column: "OrganizationPositionId",
principalTable: "OrganizationPositions",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementReceives_PositionLevels_PositionLevelId",
table: "PlacementReceives",
column: "PositionLevelId",
principalTable: "PositionLevels",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementReceives_PositionLines_PositionLineId",
table: "PlacementReceives",
column: "PositionLineId",
principalTable: "PositionLines",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementReceives_PositionNumbers_PositionNumberId",
table: "PlacementReceives",
column: "PositionNumberId",
principalTable: "PositionNumbers",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementReceives_PositionPathSides_PositionPathSideId",
table: "PlacementReceives",
column: "PositionPathSideId",
principalTable: "PositionPathSides",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementReceives_PositionPaths_PositionPathId",
table: "PlacementReceives",
column: "PositionPathId",
principalTable: "PositionPaths",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementReceives_PositionTypes_PositionTypeId",
table: "PlacementReceives",
column: "PositionTypeId",
principalTable: "PositionTypes",
principalColumn: "Id");
migrationBuilder.AddForeignKey(
name: "FK_PlacementReceives_Prefixes_PrefixId",
table: "PlacementReceives",
column: "PrefixId",
principalTable: "Prefixes",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}

View file

@ -8,7 +8,9 @@ using BMA.EHR.Placement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.Placement.Service.Controllers
@ -26,18 +28,21 @@ namespace BMA.EHR.Placement.Service.Controllers
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
public PlacementAppointmentController(PlacementRepository repository,
NotificationRepository repositoryNoti,
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -45,6 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
@ -63,35 +69,48 @@ namespace BMA.EHR.Placement.Service.Controllers
{
var placementAppointments = await _context.PlacementAppointments.AsQueryable()
.Where(x => x.Profile.ProfileType == "officer")
.Where(x => x.type == "OFFICER")
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
p.Id,
p.CitizenId,
Prefix = p.Prefix == null ? null : p.Prefix.Name,
p.Firstname,
p.Lastname,
p.DateOfBirth,
Gender = p.Gender == null ? null : p.Gender.Name,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.positionName,
p.posLevelName,
p.posTypeName,
p.rootOld,
p.rootShortNameOld,
p.child1Old,
p.child1ShortNameOld,
p.child2Old,
p.child2ShortNameOld,
p.child3Old,
p.child3ShortNameOld,
p.child4Old,
p.child4ShortNameOld,
p.posMasterNoOld,
p.positionOld,
p.posLevelNameOld,
p.posTypeNameOld,
p.Status,
p.Amount,
p.RecruitDate,
PositionNumber = p.PositionNumber == null ? null : p.PositionNumber.Name,
PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
PositionPathSide = p.PositionPathSide == null ? null : p.PositionPathSide.Name,
PositionType = p.PositionType == null ? null : p.PositionType.Name,
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
p.IsActive,
p.PositionDate,
p.Reason,
@ -105,8 +124,8 @@ namespace BMA.EHR.Placement.Service.Controllers
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
.ToListAsync();
if (PlacementAdmin == true)
placementAppointments.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
// if (PlacementAdmin == true)
// placementAppointments.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
return Success(placementAppointments);
}
@ -124,35 +143,49 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id)
{
var data = await _context.PlacementAppointments.AsQueryable()
.Where(x => x.Profile.ProfileType == "officer")
.Where(x => x.type == "OFFICER")
.Where(x => x.Id == id)
.Select(p => new
{
p.Id,
ProfileId = p.Profile.Id,
p.CitizenId,
Prefix = p.Prefix == null ? null : p.Prefix.Name,
PrefixId = p.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Prefix.Id,
p.Firstname,
p.Lastname,
p.DateOfBirth,
Gender = p.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Gender.Id,
p.Nationality,
p.Race,
Religion = p.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Religion.Id,
BloodGroup = p.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.BloodGroup.Id,
Relationship = p.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Relationship.Id,
p.TelephoneNumber,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.positionName,
p.posLevelName,
p.posTypeName,
p.rootOld,
p.rootShortNameOld,
p.child1Old,
p.child1ShortNameOld,
p.child2Old,
p.child2ShortNameOld,
p.child3Old,
p.child3ShortNameOld,
p.child4Old,
p.child4ShortNameOld,
p.posMasterNoOld,
p.positionOld,
p.posLevelNameOld,
p.posTypeNameOld,
p.Status,
p.Amount,
p.RecruitDate,
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
p.CreatedAt,
p.Reason,
p.EducationOld,
@ -162,66 +195,78 @@ namespace BMA.EHR.Placement.Service.Controllers
p.PositionNumberOld,
p.OrganizationPositionOld,
p.PositionDate,
PlacementAppointmentDocs = p.PlacementAppointmentDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
// PlacementAppointmentDocs = p.PlacementAppointmentDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.DataNotFound, 404);
var placementAppointmentDocs = new List<dynamic>();
foreach (var doc in data.PlacementAppointmentDocs)
{
var _doc = new
{
doc.FileName,
PathName = await _documentService.ImagesPath(doc.Id)
};
placementAppointmentDocs.Add(_doc);
}
var _data = new
{
data.Id,
data.ProfileId,
data.CitizenId,
data.Prefix,
data.PrefixId,
data.Firstname,
data.Lastname,
data.DateOfBirth,
data.Gender,
data.Nationality,
data.Race,
data.Religion,
data.BloodGroup,
data.Relationship,
data.TelephoneNumber,
data.Status,
data.Amount,
data.RecruitDate,
data.PosNoId,
data.PositionId,
data.PositionPathSideId,
data.PositionTypeId,
data.PositionLineId,
data.PositionLevelId,
data.OrganizationPositionId,
data.CreatedAt,
data.Reason,
data.EducationOld,
data.salary,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
data.PositionDate,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
Docs = placementAppointmentDocs,
data.CommandType,
};
// var placementAppointmentDocs = new List<dynamic>();
// foreach (var doc in data.PlacementAppointmentDocs)
// {
// var _doc = new
// {
// doc.FileName,
// PathName = await _documentService.ImagesPath(doc.Id)
// };
// placementAppointmentDocs.Add(_doc);
// }
// var _data = new
// {
// data.Id,
// data.profileId,
// data.prefix,
// data.firstName,
// data.lastName,
// data.root,
// data.rootShortName,
// data.child1,
// data.child1ShortName,
// data.child2,
// data.child2ShortName,
// data.child3,
// data.child3ShortName,
// data.child4,
// data.child4ShortName,
// data.posMasterNo,
// data.positionName,
// data.posLevelName,
// data.posTypeName,
return Success(_data);
// data.rootOld,
// data.rootShortNameOld,
// data.child1Old,
// data.child1ShortNameOld,
// data.child2Old,
// data.child2ShortNameOld,
// data.child3Old,
// data.child3ShortNameOld,
// data.child4Old,
// data.child4ShortNameOld,
// data.posMasterNoOld,
// data.positionOld,
// data.posLevelNameOld,
// data.posTypeNameOld,
// data.Status,
// data.Amount,
// data.RecruitDate,
// data.CreatedAt,
// data.Reason,
// data.EducationOld,
// data.salary,
// data.PositionTypeOld,
// data.PositionLevelOld,
// data.PositionNumberOld,
// data.OrganizationPositionOld,
// data.PositionDate,
// Docs = placementAppointmentDocs,
// data.CommandType,
// };
return Success(data);
}
/// <summary>
@ -235,42 +280,29 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{
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)
.Include(x => x.Gender)
.Include(x => x.Prefix)
.Where(x => x.ProfileType == "officer")
.FirstOrDefaultAsync(x => x.Id == req.Id);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var placementAppointment = new PlacementAppointment
{
Profile = profile,
CitizenId = profile.CitizenId,
Prefix = profile.Prefix,
Firstname = profile.FirstName,
Lastname = profile.LastName,
DateOfBirth = profile.BirthDate,
Gender = profile.Gender,
Nationality = profile.Nationality,
Race = profile.Race,
Religion = await _context.Religions.FindAsync(profile.ReligionId),
BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
TelephoneNumber = profile.TelephoneNumber,
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
PositionDate = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Date,
// Profile = profile,
// CitizenId = profile.CitizenId,
// Prefix = profile.Prefix,
// Firstname = profile.FirstName,
// Lastname = profile.LastName,
// DateOfBirth = profile.BirthDate,
// Gender = profile.Gender,
// Nationality = profile.Nationality,
// Race = profile.Race,
// Religion = await _context.Religions.FindAsync(profile.ReligionId),
// BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
// Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
// TelephoneNumber = profile.TelephoneNumber,
// EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
// PositionDate = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Date,
type = "OFFICER",
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
@ -279,35 +311,75 @@ namespace BMA.EHR.Placement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.Id}";
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)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
placementAppointment.profileId = org.result.profileId;
placementAppointment.prefix = org.result.prefix;
placementAppointment.firstName = org.result.firstName;
placementAppointment.lastName = org.result.lastName;
placementAppointment.citizenId = org.result.citizenId;
placementAppointment.rootOld = org.result.root;
placementAppointment.rootOldId = org.result.rootId;
placementAppointment.rootShortNameOld = org.result.rootShortName;
placementAppointment.child1Old = org.result.child1;
placementAppointment.child1OldId = org.result.child1Id;
placementAppointment.child1ShortNameOld = org.result.child1ShortName;
placementAppointment.child2Old = org.result.child2;
placementAppointment.child2OldId = org.result.child2Id;
placementAppointment.child2ShortNameOld = org.result.child2ShortName;
placementAppointment.child3Old = org.result.child3;
placementAppointment.child3OldId = org.result.child3Id;
placementAppointment.child3ShortNameOld = org.result.child3ShortName;
placementAppointment.child4Old = org.result.child4;
placementAppointment.child4OldId = org.result.child4Id;
placementAppointment.child4ShortNameOld = org.result.child4ShortName;
placementAppointment.posMasterNoOld = org.result.posMasterNo;
placementAppointment.positionOld = org.result.position;
placementAppointment.posTypeOldId = org.result.posTypeId;
placementAppointment.posTypeNameOld = org.result.posTypeName;
placementAppointment.posLevelOldId = org.result.posLevelId;
placementAppointment.posLevelNameOld = org.result.posLevelName;
}
await _context.PlacementAppointments.AddAsync(placementAppointment);
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
foreach (var file in Request.Form.Files)
{
var fileExtension = Path.GetExtension(file.FileName);
// if (Request.Form.Files != null && Request.Form.Files.Count != 0)
// {
// foreach (var file in Request.Form.Files)
// {
// var fileExtension = Path.GetExtension(file.FileName);
var doc = await _documentService.UploadFileAsync(file, file.FileName);
var _doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
{
var placementAppointmentDoc = new PlacementAppointmentDoc
{
PlacementAppointment = placementAppointment,
Document = _doc,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementAppointmentDocs.AddAsync(placementAppointmentDoc);
// var doc = await _documentService.UploadFileAsync(file, file.FileName);
// var _doc = await _context.Documents.AsQueryable()
// .FirstOrDefaultAsync(x => x.Id == doc.Id);
// if (_doc != null)
// {
// var placementAppointmentDoc = new PlacementAppointmentDoc
// {
// PlacementAppointment = placementAppointment,
// Document = _doc,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// };
// await _context.PlacementAppointmentDocs.AddAsync(placementAppointmentDoc);
}
}
}
// }
// }
// }
await _context.SaveChangesAsync();
return Success();
@ -326,63 +398,56 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> UpdatePositionPlacementAppointment([FromBody] PersonSelectPositionAppointmentRequest req, Guid id)
{
var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "officer")
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
if (req.PosNoId != null)
{
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
if (save_posNo == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
uppdated.PositionNumber = save_posNo;
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
if (save_orgPosition == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
uppdated.OrganizationPosition = save_orgPosition;
}
if (req.PositionId != null)
{
var save = await _context.PositionPaths.FindAsync(req.PositionId);
if (save == null)
return Error(GlobalMessages.PositionPathNotFound, 404);
uppdated.PositionPath = save;
}
if (req.PositionLevelId != null)
{
var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
if (save == null)
return Error(GlobalMessages.PositionLevelNotFound, 404);
uppdated.PositionLevel = save;
}
if (req.PositionLineId != null)
{
var save = await _context.PositionLines.FindAsync(req.PositionLineId);
if (save == null)
return Error(GlobalMessages.PositionLineNotFound, 404);
uppdated.PositionLine = save;
}
if (req.PositionPathSideId != null)
{
var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
if (save == null)
return Error(GlobalMessages.PositionPathSideNotFound, 404);
uppdated.PositionPathSide = save;
}
if (req.PositionTypeId != null)
{
var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
if (save == null)
return Error(GlobalMessages.PositionTypeNotFound, 404);
uppdated.PositionType = save;
var apiUrl = $"{_configuration["API"]}org/find/all";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
node = req.node,
nodeId = req.nodeId,
});
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
uppdated.root = org.result.root;
uppdated.rootId = org.result.rootId;
uppdated.rootShortName = org.result.rootShortName;
uppdated.child1 = req.node <= 0 ? null : org.result.child1;
uppdated.child1Id = req.node <= 0 ? null : org.result.child1Id;
uppdated.child1ShortName = req.node <= 0 ? null : org.result.child1ShortName;
uppdated.child2 = req.node <= 1 ? null : org.result.child2;
uppdated.child2Id = req.node <= 1 ? null : org.result.child2Id;
uppdated.child2ShortName = req.node <= 1 ? null : org.result.child2ShortName;
uppdated.child3 = req.node <= 2 ? null : org.result.child3;
uppdated.child3Id = req.node <= 2 ? null : org.result.child3Id;
uppdated.child3ShortName = req.node <= 2 ? null : org.result.child3ShortName;
uppdated.child4 = req.node <= 3 ? null : org.result.child4;
uppdated.child4Id = req.node <= 3 ? null : org.result.child4Id;
uppdated.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName;
}
uppdated.posmasterId = req.posmasterId;
uppdated.node = req.node;
uppdated.nodeId = req.nodeId;
uppdated.orgRevisionId = req.orgRevisionId;
uppdated.positionId = req.positionId;
uppdated.posMasterNo = req.posMasterNo;
uppdated.positionName = req.positionName;
uppdated.positionField = req.positionField;
uppdated.posTypeId = req.posTypeId;
uppdated.posTypeName = req.posTypeName;
uppdated.posLevelId = req.posLevelId;
uppdated.posLevelName = req.posLevelName;
uppdated.Amount = req.Amount;
uppdated.RecruitDate = req.RecruitDate;
uppdated.Status = "PENDING";
@ -406,58 +471,22 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementAppointmentEditRequest req, Guid id)
{
var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "officer")
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
if (req.PrefixId != null)
{
var save = await _context.Prefixes.FindAsync(req.PrefixId);
if (save == null)
return Error(GlobalMessages.PrefixNotFound, 404);
uppdated.Prefix = save;
}
// if (req.RelationshipId != null)
// if (req.PrefixId != null)
// {
// var save = await _context.Relationships.FindAsync(req.RelationshipId);
// var save = await _context.Prefixes.FindAsync(req.PrefixId);
// if (save == null)
// return Error(GlobalMessages.RelationshipNotFound, 404);
// uppdated.Relationship = save;
// return Error(GlobalMessages.PrefixNotFound, 404);
// uppdated.Prefix = save;
// }
// uppdated.CitizenId = req.CitizenId;
// uppdated.Firstname = req.Firstname;
// uppdated.Lastname = req.Lastname;
// if (req.ReligionId != null)
// {
// var save = await _context.Religions.FindAsync(req.ReligionId);
// if (save == null)
// return Error(GlobalMessages.ReligionNotFound, 404);
// uppdated.Religion = save;
// }
// if (req.BloodGroupId != null)
// {
// var save = await _context.BloodGroups.FindAsync(req.BloodGroupId);
// if (save == null)
// return Error(GlobalMessages.BloodGroupNotFound, 404);
// uppdated.BloodGroup = save;
// }
// if (req.GenderId != null)
// {
// var save = await _context.Genders.FindAsync(req.GenderId);
// if (save == null)
// return Error(GlobalMessages.GenderNotFound, 404);
// uppdated.Gender = save;
// }
uppdated.CitizenId = req.CitizenId;
uppdated.Firstname = req.Firstname;
uppdated.Lastname = req.Lastname;
// uppdated.DateOfBirth = req.DateOfBirth;
// uppdated.Nationality = req.Nationality;
// uppdated.Race = req.Race;
// uppdated.TelephoneNumber = req.TelephoneNumber;
uppdated.EducationOld = req.EducationOld;
uppdated.Reason = req.Reason;
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
@ -489,25 +518,24 @@ namespace BMA.EHR.Placement.Service.Controllers
var deleted = await _context.PlacementAppointments.AsQueryable()
.Include(x => x.PlacementAppointmentDocs)
.ThenInclude(x => x.Document)
.Where(x => x.Profile.ProfileType == "officer")
.FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null)
return NotFound();
var placementAppointmentDocs = new List<dynamic>();
foreach (var doc in deleted.PlacementAppointmentDocs)
{
if (doc.Document != null)
placementAppointmentDocs.Add(doc.Document.Id);
}
// var placementAppointmentDocs = new List<dynamic>();
// foreach (var doc in deleted.PlacementAppointmentDocs)
// {
// if (doc.Document != null)
// placementAppointmentDocs.Add(doc.Document.Id);
// }
_context.PlacementAppointmentDocs.RemoveRange(deleted.PlacementAppointmentDocs);
await _context.SaveChangesAsync();
_context.PlacementAppointments.Remove(deleted);
foreach (var doc in placementAppointmentDocs)
{
if (doc != null)
await _documentService.DeleteFileAsync(doc);
}
await _context.SaveChangesAsync();
// _context.PlacementAppointments.Remove(deleted);
// foreach (var doc in placementAppointmentDocs)
// {
// if (doc != null)
// await _documentService.DeleteFileAsync(doc);
// }
// await _context.SaveChangesAsync();
return Success();
}
@ -526,7 +554,7 @@ namespace BMA.EHR.Placement.Service.Controllers
foreach (var item in req.Id)
{
var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "officer")
// .Where(x => x.Profile.ProfileType == "officer")
.FirstOrDefaultAsync(x => x.Id == item);
if (uppdated == null)
continue;
@ -543,24 +571,24 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
/// <summary>
/// หน่วยงานที่ถูกเลือกไปแล้ว
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("use")]
public async Task<ActionResult<ResponseObject>> GetAppointmentsUse()
{
var appointments = await _context.PlacementAppointments
.Where(x => x.PositionNumber != null)
.Where(x => x.Profile.ProfileType == "officer")
.Select(x => x.PositionNumber.Id)
.ToListAsync();
// /// <summary>
// /// หน่วยงานที่ถูกเลือกไปแล้ว
// /// </summary>
// /// <returns></returns>
// /// <response code="200"></response>
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
// [HttpGet("use")]
// public async Task<ActionResult<ResponseObject>> GetAppointmentsUse()
// {
// var appointments = await _context.PlacementAppointments
// // .Where(x => x.PositionNumber != null)
// // .Where(x => x.Profile.ProfileType == "officer")
// // .Select(x => x.PositionNumber.Id)
// .ToListAsync();
return Success(appointments);
}
// return Success(appointments);
// }
}
}

View file

@ -8,7 +8,9 @@ using BMA.EHR.Placement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.Placement.Service.Controllers
@ -26,18 +28,21 @@ namespace BMA.EHR.Placement.Service.Controllers
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
public PlacementAppointmentEmployeeController(PlacementRepository repository,
NotificationRepository repositoryNoti,
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -45,6 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
@ -63,47 +69,48 @@ namespace BMA.EHR.Placement.Service.Controllers
{
var placementAppointments = await _context.PlacementAppointments.AsQueryable()
.Where(x => x.type == "EMPLOYEE")
.OrderByDescending(x => x.CreatedAt)
.Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.Select(p => new
{
p.Id,
p.CitizenId,
Prefix = p.Prefix == null ? null : p.Prefix.Name,
p.Firstname,
p.Lastname,
p.DateOfBirth,
Gender = p.Gender == null ? null : p.Gender.Name,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.positionName,
p.posLevelName,
p.posTypeName,
p.rootOld,
p.rootShortNameOld,
p.child1Old,
p.child1ShortNameOld,
p.child2Old,
p.child2ShortNameOld,
p.child3Old,
p.child3ShortNameOld,
p.child4Old,
p.child4ShortNameOld,
p.posMasterNoOld,
p.positionOld,
p.posLevelNameOld,
p.posTypeNameOld,
p.Status,
p.Amount,
p.RecruitDate,
// PositionNumber = p.PositionNumber == null ? null : p.PositionNumber.Name,
// PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
// PositionPathSide = p.PositionPathSide == null ? null : p.PositionPathSide.Name,
// PositionType = p.PositionType == null ? null : p.PositionType.Name,
// PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
// PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
// PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
// PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
// PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
// PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
// PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
// PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
OrgEmployeeId = p.OrgEmployee == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrgEmployee.Id,
PositionEmployeeStatusId = p.PositionEmployeeStatus == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionEmployeeStatus.Id,
PositionEmployeeLineId = p.PositionEmployeeLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionEmployeeLine.Id,
PositionEmployeePositionId = p.PositionEmployeePosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionEmployeePosition.Id,
PositionEmployeeStatus = p.PositionEmployeeStatus == null ? null : p.PositionEmployeeStatus.Name,
PositionEmployeeLine = p.PositionEmployeeLine == null ? null : p.PositionEmployeeLine.Name,
PositionEmployeePosition = p.PositionEmployeePosition == null ? null : p.PositionEmployeePosition.Name,
// OrganizationShortName = x.OrganizationShortName == null ? null : x.OrganizationShortName.Name,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
// OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationName = p.OrgEmployee == null ? null : (p.OrgEmployee.OrganizationOrganization == null ? null : p.OrgEmployee.OrganizationOrganization.Name),
OrganizationShortName = p.OrgEmployee == null ? null : (p.OrgEmployee.OrganizationShortName == null ? null : p.OrgEmployee.OrganizationShortName.Name),
p.IsActive,
p.PositionDate,
p.Reason,
@ -117,8 +124,6 @@ namespace BMA.EHR.Placement.Service.Controllers
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
.ToListAsync();
if (PlacementAdmin == true)
placementAppointments.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
return Success(placementAppointments);
}
@ -136,36 +141,49 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> GetDetailByUser(Guid id)
{
var data = await _context.PlacementAppointments.AsQueryable()
.Where(x => x.type == "EMPLOYEE")
.Where(x => x.Id == id)
.Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.Select(p => new
{
p.Id,
ProfileId = p.Profile.Id,
p.CitizenId,
Prefix = p.Prefix == null ? null : p.Prefix.Name,
PrefixId = p.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Prefix.Id,
p.Firstname,
p.Lastname,
p.DateOfBirth,
Gender = p.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Gender.Id,
p.Nationality,
p.Race,
Religion = p.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Religion.Id,
BloodGroup = p.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.BloodGroup.Id,
Relationship = p.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Relationship.Id,
p.TelephoneNumber,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.positionName,
p.posLevelName,
p.posTypeName,
p.rootOld,
p.rootShortNameOld,
p.child1Old,
p.child1ShortNameOld,
p.child2Old,
p.child2ShortNameOld,
p.child3Old,
p.child3ShortNameOld,
p.child4Old,
p.child4ShortNameOld,
p.posMasterNoOld,
p.positionOld,
p.posLevelNameOld,
p.posTypeNameOld,
p.Status,
p.Amount,
p.RecruitDate,
OrgEmployeeId = p.OrgEmployee == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrgEmployee.Id,
PositionEmployeeStatusId = p.PositionEmployeeStatus == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionEmployeeStatus.Id,
PositionEmployeeLineId = p.PositionEmployeeLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionEmployeeLine.Id,
PositionEmployeePositionId = p.PositionEmployeePosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionEmployeePosition.Id,
// PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
// PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
// PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
p.CreatedAt,
p.Reason,
p.EducationOld,
@ -175,67 +193,78 @@ namespace BMA.EHR.Placement.Service.Controllers
p.PositionNumberOld,
p.OrganizationPositionOld,
p.PositionDate,
PlacementAppointmentDocs = p.PlacementAppointmentDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
// PlacementAppointmentDocs = p.PlacementAppointmentDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.DataNotFound, 404);
var placementAppointmentDocs = new List<dynamic>();
foreach (var doc in data.PlacementAppointmentDocs)
{
var _doc = new
{
doc.FileName,
PathName = await _documentService.ImagesPath(doc.Id)
};
placementAppointmentDocs.Add(_doc);
}
var _data = new
{
data.Id,
data.ProfileId,
data.CitizenId,
data.Prefix,
data.PrefixId,
data.Firstname,
data.Lastname,
data.DateOfBirth,
data.Gender,
data.Nationality,
data.Race,
data.Religion,
data.BloodGroup,
data.Relationship,
data.TelephoneNumber,
data.Status,
data.Amount,
data.RecruitDate,
// data.PosNoId,
// data.PositionId,
// data.PositionPathSideId,
data.OrgEmployeeId,
data.PositionEmployeeStatusId,
data.PositionEmployeeLineId,
data.PositionEmployeePositionId,
data.OrganizationPositionId,
data.CreatedAt,
data.Reason,
data.EducationOld,
data.salary,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
data.PositionDate,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
Docs = placementAppointmentDocs,
data.CommandType,
};
// var placementAppointmentDocs = new List<dynamic>();
// foreach (var doc in data.PlacementAppointmentDocs)
// {
// var _doc = new
// {
// doc.FileName,
// PathName = await _documentService.ImagesPath(doc.Id)
// };
// placementAppointmentDocs.Add(_doc);
// }
// var _data = new
// {
// data.Id,
// data.profileId,
// data.prefix,
// data.firstName,
// data.lastName,
// data.root,
// data.rootShortName,
// data.child1,
// data.child1ShortName,
// data.child2,
// data.child2ShortName,
// data.child3,
// data.child3ShortName,
// data.child4,
// data.child4ShortName,
// data.posMasterNo,
// data.positionName,
// data.posLevelName,
// data.posTypeName,
return Success(_data);
// data.rootOld,
// data.rootShortNameOld,
// data.child1Old,
// data.child1ShortNameOld,
// data.child2Old,
// data.child2ShortNameOld,
// data.child3Old,
// data.child3ShortNameOld,
// data.child4Old,
// data.child4ShortNameOld,
// data.posMasterNoOld,
// data.positionOld,
// data.posLevelNameOld,
// data.posTypeNameOld,
// data.Status,
// data.Amount,
// data.RecruitDate,
// data.CreatedAt,
// data.Reason,
// data.EducationOld,
// data.salary,
// data.PositionTypeOld,
// data.PositionLevelOld,
// data.PositionNumberOld,
// data.OrganizationPositionOld,
// data.PositionDate,
// Docs = placementAppointmentDocs,
// data.CommandType,
// };
return Success(data);
}
/// <summary>
@ -249,42 +278,29 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{
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)
.Include(x => x.Gender)
.Include(x => x.Prefix)
.Where(x => x.ProfileType == "employee" && x.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == req.Id);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var placementAppointment = new PlacementAppointment
{
Profile = profile,
CitizenId = profile.CitizenId,
Prefix = profile.Prefix,
Firstname = profile.FirstName,
Lastname = profile.LastName,
DateOfBirth = profile.BirthDate,
Gender = profile.Gender,
Nationality = profile.Nationality,
Race = profile.Race,
Religion = await _context.Religions.FindAsync(profile.ReligionId),
BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
TelephoneNumber = profile.TelephoneNumber,
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
PositionDate = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Date,
// Profile = profile,
// CitizenId = profile.CitizenId,
// Prefix = profile.Prefix,
// Firstname = profile.FirstName,
// Lastname = profile.LastName,
// DateOfBirth = profile.BirthDate,
// Gender = profile.Gender,
// Nationality = profile.Nationality,
// Race = profile.Race,
// Religion = await _context.Religions.FindAsync(profile.ReligionId),
// BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
// Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
// TelephoneNumber = profile.TelephoneNumber,
// EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
// PositionDate = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Date,
type = "EMPLOYEE",
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
@ -293,36 +309,76 @@ namespace BMA.EHR.Placement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}org/profile/profileempid/position/{req.Id}";
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)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
placementAppointment.profileId = org.result.profileId;
placementAppointment.prefix = org.result.prefix;
placementAppointment.firstName = org.result.firstName;
placementAppointment.lastName = org.result.lastName;
placementAppointment.citizenId = org.result.citizenId;
placementAppointment.rootOld = org.result.root;
placementAppointment.rootOldId = org.result.rootId;
placementAppointment.rootShortNameOld = org.result.rootShortName;
placementAppointment.child1Old = org.result.child1;
placementAppointment.child1OldId = org.result.child1Id;
placementAppointment.child1ShortNameOld = org.result.child1ShortName;
placementAppointment.child2Old = org.result.child2;
placementAppointment.child2OldId = org.result.child2Id;
placementAppointment.child2ShortNameOld = org.result.child2ShortName;
placementAppointment.child3Old = org.result.child3;
placementAppointment.child3OldId = org.result.child3Id;
placementAppointment.child3ShortNameOld = org.result.child3ShortName;
placementAppointment.child4Old = org.result.child4;
placementAppointment.child4OldId = org.result.child4Id;
placementAppointment.child4ShortNameOld = org.result.child4ShortName;
placementAppointment.posMasterNoOld = org.result.posMasterNo;
placementAppointment.positionOld = org.result.position;
placementAppointment.posTypeOldId = org.result.posTypeId;
placementAppointment.posTypeNameOld = org.result.posTypeName;
placementAppointment.posLevelOldId = org.result.posLevelId;
placementAppointment.posLevelNameOld = org.result.posLevelName;
}
await _context.PlacementAppointments.AddAsync(placementAppointment);
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
foreach (var file in Request.Form.Files)
{
var fileExtension = Path.GetExtension(file.FileName);
// if (Request.Form.Files != null && Request.Form.Files.Count != 0)
// {
// foreach (var file in Request.Form.Files)
// {
// var fileExtension = Path.GetExtension(file.FileName);
var doc = await _documentService.UploadFileAsync(file, file.FileName);
var _doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
{
var placementAppointmentDoc = new PlacementAppointmentDoc
{
PlacementAppointment = placementAppointment,
Document = _doc,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.PlacementAppointmentDocs.AddAsync(placementAppointmentDoc);
// var doc = await _documentService.UploadFileAsync(file, file.FileName);
// var _doc = await _context.Documents.AsQueryable()
// .FirstOrDefaultAsync(x => x.Id == doc.Id);
// if (_doc != null)
// {
// var placementAppointmentDoc = new PlacementAppointmentDoc
// {
// PlacementAppointment = placementAppointment,
// Document = _doc,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// };
// await _context.PlacementAppointmentDocs.AddAsync(placementAppointmentDoc);
}
}
}
await _context.SaveChangesAsync();
// }
// }
// }
// await _context.SaveChangesAsync();
return Success();
}
@ -340,76 +396,58 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> UpdatePositionPlacementAppointment([FromBody] PersonSelectPositionAppointmentEmployeeRequest req, Guid id)
{
var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
// if (req.PosNoId != null)
// {
// var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
// if (save_posNo == null)
// return Error(GlobalMessages.PositionPosNoNotFound, 404);
// uppdated.PositionNumber = save_posNo;
// var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
// if (save_orgPosition == null)
// return Error(GlobalMessages.PositionPosNoNotFound, 404);
// uppdated.OrganizationPosition = save_orgPosition;
// }
var apiUrl = $"{_configuration["API"]}org/find/all";
// if (req.PositionId != null)
// {
// var save = await _context.PositionPaths.FindAsync(req.PositionId);
// if (save == null)
// return Error(GlobalMessages.PositionPathNotFound, 404);
// uppdated.PositionPath = save;
// }
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
node = req.node,
nodeId = req.nodeId,
});
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
// if (req.PositionLevelId != null)
// {
// var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
// if (save == null)
// return Error(GlobalMessages.PositionLevelNotFound, 404);
// uppdated.PositionLevel = save;
// }
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
// if (req.PositionLineId != null)
// {
// var save = await _context.PositionLines.FindAsync(req.PositionLineId);
// if (save == null)
// return Error(GlobalMessages.PositionLineNotFound, 404);
// uppdated.PositionLine = save;
// }
uppdated.root = org.result.root;
uppdated.rootId = org.result.rootId;
uppdated.rootShortName = org.result.rootShortName;
uppdated.child1 = req.node <= 0 ? null : org.result.child1;
uppdated.child1Id = req.node <= 0 ? null : org.result.child1Id;
uppdated.child1ShortName = req.node <= 0 ? null : org.result.child1ShortName;
uppdated.child2 = req.node <= 1 ? null : org.result.child2;
uppdated.child2Id = req.node <= 1 ? null : org.result.child2Id;
uppdated.child2ShortName = req.node <= 1 ? null : org.result.child2ShortName;
uppdated.child3 = req.node <= 2 ? null : org.result.child3;
uppdated.child3Id = req.node <= 2 ? null : org.result.child3Id;
uppdated.child3ShortName = req.node <= 2 ? null : org.result.child3ShortName;
uppdated.child4 = req.node <= 3 ? null : org.result.child4;
uppdated.child4Id = req.node <= 3 ? null : org.result.child4Id;
uppdated.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName;
}
// if (req.PositionPathSideId != null)
// {
// var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
// if (save == null)
// return Error(GlobalMessages.PositionPathSideNotFound, 404);
// uppdated.PositionPathSide = save;
// }
// if (req.PositionTypeId != null)
// {
// var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
// if (save == null)
// return Error(GlobalMessages.PositionTypeNotFound, 404);
// uppdated.PositionType = save;
// }
var organizationEmployee = await _context.OrganizationEmployees
.Include(x => x.PositionEmployeeStatus)
.Include(x => x.PositionEmployeeLine)
.Include(x => x.PositionEmployeePosition)
.FirstOrDefaultAsync(x => x.Id == req.OrganizationEmployeeId);
if (organizationEmployee == null)
return Error(GlobalMessages.OrganizationEmployeeNotFound, 404);
uppdated.OrgEmployee = organizationEmployee;
uppdated.PositionEmployeeStatus = organizationEmployee.PositionEmployeeStatus;
uppdated.PositionEmployeeLine = organizationEmployee.PositionEmployeeLine;
uppdated.PositionEmployeePosition = organizationEmployee.PositionEmployeePosition;
// uppdated.Amount = req.Amount;
// uppdated.RecruitDate = req.RecruitDate;
uppdated.posmasterId = req.posmasterId;
uppdated.node = req.node;
uppdated.nodeId = req.nodeId;
uppdated.orgRevisionId = req.orgRevisionId;
uppdated.positionId = req.positionId;
uppdated.posMasterNo = req.posMasterNo;
uppdated.positionName = req.positionName;
uppdated.positionField = req.positionField;
uppdated.posTypeId = req.posTypeId;
uppdated.posTypeName = req.posTypeName;
uppdated.posLevelId = req.posLevelId;
uppdated.posLevelName = req.posLevelName;
uppdated.Amount = req.Amount;
uppdated.RecruitDate = req.RecruitDate;
uppdated.Status = "PENDING";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
@ -431,58 +469,11 @@ namespace BMA.EHR.Placement.Service.Controllers
public async Task<ActionResult<ResponseObject>> Put([FromBody] PlacementAppointmentEditRequest req, Guid id)
{
var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementAppointmentNotFound, 404);
if (req.PrefixId != null)
{
var save = await _context.Prefixes.FindAsync(req.PrefixId);
if (save == null)
return Error(GlobalMessages.PrefixNotFound, 404);
uppdated.Prefix = save;
}
// if (req.RelationshipId != null)
// {
// var save = await _context.Relationships.FindAsync(req.RelationshipId);
// if (save == null)
// return Error(GlobalMessages.RelationshipNotFound, 404);
// uppdated.Relationship = save;
// }
// if (req.ReligionId != null)
// {
// var save = await _context.Religions.FindAsync(req.ReligionId);
// if (save == null)
// return Error(GlobalMessages.ReligionNotFound, 404);
// uppdated.Religion = save;
// }
// if (req.BloodGroupId != null)
// {
// var save = await _context.BloodGroups.FindAsync(req.BloodGroupId);
// if (save == null)
// return Error(GlobalMessages.BloodGroupNotFound, 404);
// uppdated.BloodGroup = save;
// }
// if (req.GenderId != null)
// {
// var save = await _context.Genders.FindAsync(req.GenderId);
// if (save == null)
// return Error(GlobalMessages.GenderNotFound, 404);
// uppdated.Gender = save;
// }
uppdated.CitizenId = req.CitizenId;
uppdated.Firstname = req.Firstname;
uppdated.Lastname = req.Lastname;
// uppdated.DateOfBirth = req.DateOfBirth;
// uppdated.Nationality = req.Nationality;
// uppdated.Race = req.Race;
// uppdated.TelephoneNumber = req.TelephoneNumber;
uppdated.EducationOld = req.EducationOld;
uppdated.Reason = req.Reason;
uppdated.OrganizationPositionOld = req.OrganizationPositionOld;
@ -514,25 +505,24 @@ namespace BMA.EHR.Placement.Service.Controllers
var deleted = await _context.PlacementAppointments.AsQueryable()
.Include(x => x.PlacementAppointmentDocs)
.ThenInclude(x => x.Document)
.Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == id);
if (deleted == null)
return NotFound();
var placementAppointmentDocs = new List<dynamic>();
foreach (var doc in deleted.PlacementAppointmentDocs)
{
if (doc.Document != null)
placementAppointmentDocs.Add(doc.Document.Id);
}
// var placementAppointmentDocs = new List<dynamic>();
// foreach (var doc in deleted.PlacementAppointmentDocs)
// {
// if (doc.Document != null)
// placementAppointmentDocs.Add(doc.Document.Id);
// }
_context.PlacementAppointmentDocs.RemoveRange(deleted.PlacementAppointmentDocs);
await _context.SaveChangesAsync();
_context.PlacementAppointments.Remove(deleted);
foreach (var doc in placementAppointmentDocs)
{
if (doc != null)
await _documentService.DeleteFileAsync(doc);
}
await _context.SaveChangesAsync();
// _context.PlacementAppointments.Remove(deleted);
// foreach (var doc in placementAppointmentDocs)
// {
// if (doc != null)
// await _documentService.DeleteFileAsync(doc);
// }
// await _context.SaveChangesAsync();
return Success();
}
@ -551,7 +541,7 @@ namespace BMA.EHR.Placement.Service.Controllers
foreach (var item in req.Id)
{
var uppdated = await _context.PlacementAppointments
.Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
// .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.FirstOrDefaultAsync(x => x.Id == item);
if (uppdated == null)
continue;
@ -568,24 +558,24 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
/// <summary>
/// หน่วยงานที่ถูกเลือกไปแล้ว
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("use")]
public async Task<ActionResult<ResponseObject>> GetAppointmentsUse()
{
var appointments = await _context.PlacementAppointments
.Where(x => x.PositionNumber != null)
.Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
.Select(x => x.PositionNumber.Id)
.ToListAsync();
// /// <summary>
// /// หน่วยงานที่ถูกเลือกไปแล้ว
// /// </summary>
// /// <returns></returns>
// /// <response code="200"></response>
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
// [HttpGet("use")]
// public async Task<ActionResult<ResponseObject>> GetAppointmentsUse()
// {
// var appointments = await _context.PlacementAppointments
// .Where(x => x.PositionNumber != null)
// .Where(x => x.Profile.ProfileType == "employee" && x.Profile.EmployeeClass == "perm")
// .Select(x => x.PositionNumber.Id)
// .ToListAsync();
return Success(appointments);
}
// return Success(appointments);
// }
}
}

View file

@ -50,7 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor.HttpContext.Request.Headers["Authorization"];
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
@ -67,141 +67,6 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpGet()]
public async Task<ActionResult<ResponseObject>> GetListByAdmin()
{
var placementOfficers = await _context.PlacementOfficers.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
p.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName,
p.Profile.LastName,
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : (p.Profile.PositionEmployeePosition == null ? null : p.Profile.PositionEmployeePosition.Name),
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : (p.Profile.PositionEmployeeLevel == null ? null : p.Profile.PositionEmployeeLevel.Name),
p.CreatedAt,
p.Organization,
p.Reason,
p.Status,
p.DateStart,
p.DateEnd,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
})
.ToListAsync();
if (PlacementAdmin == true)
placementOfficers.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
return Success(placementOfficers);
}
/// <summary>
/// get รายละเอียดช่วยราชการเจ้าหน้าที่
/// </summary>
/// <param name="id">Id ช่วยราชการ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
{
var data = await _context.PlacementOfficers.AsQueryable()
.Where(x => x.Id == id)
.Where(x => x.Profile != null)
.Select(p => new
{
p.Id,
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName,
p.Profile.LastName,
ProfileId = p.Profile.Id,
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : (p.Profile.PositionEmployeePosition == null ? null : p.Profile.PositionEmployeePosition.Name),
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : (p.Profile.PositionEmployeeLevel == null ? null : p.Profile.PositionEmployeeLevel.Name),
organizationOrganization = p.Profile.OrganizationOrganization,
p.Reason,
p.Status,
p.Organization,
p.DateStart,
p.DateEnd,
salary = p.AmountOld,
p.CreatedAt,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.DataNotFound, 404);
var _data = new
{
data.Id,
data.PrefixId,
data.Prefix,
data.FirstName,
data.LastName,
data.ProfileId,
data.position,
data.posNo,
data.positionLevel,
data.organizationOrganization,
data.Reason,
data.Status,
data.Organization,
data.DateStart,
data.DateEnd,
data.salary,
data.CreatedAt,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
};
return Success(_data);
}
/// <summary>
/// สร้างช่วยราชการ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{
var placementOfficer = new PlacementOfficer
{
// Profile = profile,
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
// Date = req.Date,
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var rootId = "";
var child1Id = "";
var child2Id = "";
@ -219,7 +84,142 @@ namespace BMA.EHR.Placement.Service.Controllers
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 placementOfficers = await _context.PlacementOfficers.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.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.CreatedAt,
p.Reason,
p.Status,
p.DateStart,
p.DateEnd,
p.Organization,
p.OrganizationPositionOld,
p.IsActive,
})
.ToListAsync();
return Success(placementOfficers);
}
}
/// <summary>
/// get รายละเอียดช่วยราชการเจ้าหน้าที่
/// </summary>
/// <param name="id">Id ช่วยราชการ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetDetailAdmin(Guid id)
{
var data = await _context.PlacementOfficers.AsQueryable()
.Where(x => x.Id == id)
.Select(p => new
{
p.Id,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.CreatedAt,
p.Reason,
p.Status,
p.DateStart,
p.DateEnd,
p.Organization,
p.OrganizationPositionOld,
p.IsActive,
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.DataNotFound, 404);
return Success(data);
}
/// <summary>
/// สร้างช่วยราชการ
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{
var placementOfficer = new PlacementOfficer
{
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.Id}";
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)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
placementOfficer.profileId = org.result.profileId;
placementOfficer.prefix = org.result.prefix;
placementOfficer.firstName = org.result.firstName;
placementOfficer.lastName = org.result.lastName;
placementOfficer.citizenId = org.result.citizenId;
placementOfficer.root = org.result.root;
placementOfficer.rootId = org.result.rootId;
placementOfficer.rootShortName = org.result.rootShortName;
@ -235,6 +235,12 @@ namespace BMA.EHR.Placement.Service.Controllers
placementOfficer.child4 = org.result.child4;
placementOfficer.child4Id = org.result.child4Id;
placementOfficer.child4ShortName = org.result.child4ShortName;
placementOfficer.posMasterNo = org.result.posMasterNo;
placementOfficer.position = org.result.position;
placementOfficer.posTypeId = org.result.posTypeId;
placementOfficer.posTypeName = org.result.posTypeName;
placementOfficer.posLevelId = org.result.posLevelId;
placementOfficer.posLevelName = org.result.posLevelName;
}
await _context.PlacementOfficers.AddAsync(placementOfficer);
await _context.SaveChangesAsync();

View file

@ -8,7 +8,9 @@ using BMA.EHR.Placement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.Placement.Service.Controllers
@ -26,18 +28,21 @@ namespace BMA.EHR.Placement.Service.Controllers
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
public PlacementReceiveController(PlacementRepository repository,
NotificationRepository repositoryNoti,
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -45,6 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
@ -61,51 +67,84 @@ 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 placementReceives = await _context.PlacementReceives.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
p.Id,
p.CitizenId,
Prefix = p.Prefix.Name,
p.Firstname,
p.Lastname,
p.DateOfBirth,
Gender = p.Gender == null ? null : p.Gender.Name,
p.Status,
p.Amount,
p.RecruitDate,
PositionNumber = p.PositionNumber == null ? null : p.PositionNumber.Name,
PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
PositionPathSide = p.PositionPathSide == null ? null : p.PositionPathSide.Name,
PositionType = p.PositionType == null ? null : p.PositionType.Name,
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
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"));
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
return Success(placementReceives);
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()
.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"));
return Success(placementReceives);
}
}
/// <summary>
@ -126,11 +165,10 @@ namespace BMA.EHR.Placement.Service.Controllers
{
p.Id,
// ProfileId = p.Profile.Id,
p.CitizenId,
Prefix = p.Prefix.Name,
PrefixId = p.Prefix.Id,
p.Firstname,
p.Lastname,
p.citizenId,
p.prefix,
p.firstName,
p.lastName,
p.DateOfBirth,
Gender = p.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Gender.Id,
p.Nationality,
@ -142,13 +180,30 @@ namespace BMA.EHR.Placement.Service.Controllers
p.Status,
p.Amount,
p.RecruitDate,
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
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.CreatedAt,
p.Reason,
p.EducationOld,
@ -157,7 +212,7 @@ namespace BMA.EHR.Placement.Service.Controllers
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
Avatar = p.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Avatar.Id,
// 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 }),
})
.FirstOrDefaultAsync();
@ -178,11 +233,10 @@ namespace BMA.EHR.Placement.Service.Controllers
{
data.Id,
// data.ProfileId,
data.CitizenId,
data.Prefix,
data.PrefixId,
data.Firstname,
data.Lastname,
data.citizenId,
data.prefix,
data.firstName,
data.lastName,
data.DateOfBirth,
data.Gender,
data.Nationality,
@ -194,13 +248,30 @@ namespace BMA.EHR.Placement.Service.Controllers
data.Status,
data.Amount,
data.RecruitDate,
data.PosNoId,
data.PositionId,
data.PositionPathSideId,
data.PositionTypeId,
data.PositionLineId,
data.PositionLevelId,
data.OrganizationPositionId,
data.root,
data.rootId,
data.rootShortName,
data.child1,
data.child1Id,
data.child1ShortName,
data.child2,
data.child2Id,
data.child2ShortName,
data.child3,
data.child3Id,
data.child3ShortName,
data.child4,
data.child4Id,
data.child4ShortName,
data.orgRevisionId,
data.positionId,
data.posMasterNo,
data.positionName,
data.positionField,
data.posTypeId,
data.posTypeName,
data.posLevelId,
data.posLevelName,
data.CreatedAt,
data.Reason,
data.EducationOld,
@ -209,7 +280,7 @@ namespace BMA.EHR.Placement.Service.Controllers
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
// Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
Docs = placementReceiveDocs,
};
@ -227,17 +298,13 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementReceiveRequest req)
{
var prefix = await _context.Prefixes.FindAsync(req.Prefix);
if (prefix == null)
return Error(GlobalMessages.PrefixNotFound, 404);
var placementReceive = new PlacementReceive
{
// Profile = profile,
CitizenId = req.CitizenId,
Prefix = prefix,
Firstname = req.Firstname,
Lastname = req.Lastname,
citizenId = req.citizenId,
prefix = req.prefix,
firstName = req.firstName,
lastName = req.lastName,
DateOfBirth = req.BirthDate,
Gender = await _context.Genders.FindAsync(req.GenderId),
Nationality = req.Nationality,
@ -254,30 +321,28 @@ 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 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}";
// }
await _context.PlacementReceives.AddAsync(placementReceive);
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
// foreach (var file in Request.Form.Files)
// {
var file = Request.Form.Files[0];
var fileExtension = Path.GetExtension(file.FileName);
@ -286,21 +351,8 @@ namespace BMA.EHR.Placement.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
{
// var placementReceiveDoc = new PlacementReceiveDoc
// {
// PlacementReceive = placementReceive,
// Document = _doc,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// };
// await _context.PlacementReceiveDocs.AddAsync(placementReceiveDoc);
placementReceive.Avatar = _doc;
}
// }
}
await _context.SaveChangesAsync();
@ -385,59 +437,54 @@ namespace BMA.EHR.Placement.Service.Controllers
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.PlacementReceiveNotFound, 404);
if (req.PosNoId != null)
{
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
if (save_posNo == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
uppdated.PositionNumber = save_posNo;
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
if (save_orgPosition == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
uppdated.OrganizationPosition = save_orgPosition;
}
if (req.PositionId != null)
{
var save = await _context.PositionPaths.FindAsync(req.PositionId);
if (save == null)
return Error(GlobalMessages.PositionPathNotFound, 404);
uppdated.PositionPath = save;
}
if (req.PositionLevelId != null)
{
var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
if (save == null)
return Error(GlobalMessages.PositionLevelNotFound, 404);
uppdated.PositionLevel = save;
}
if (req.PositionLineId != null)
{
var save = await _context.PositionLines.FindAsync(req.PositionLineId);
if (save == null)
return Error(GlobalMessages.PositionLineNotFound, 404);
uppdated.PositionLine = save;
}
if (req.PositionPathSideId != null)
{
var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
if (save == null)
return Error(GlobalMessages.PositionPathSideNotFound, 404);
uppdated.PositionPathSide = save;
}
if (req.PositionTypeId != null)
{
var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
if (save == null)
return Error(GlobalMessages.PositionTypeNotFound, 404);
uppdated.PositionType = save;
var apiUrl = $"{_configuration["API"]}org/find/all";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
node = req.node,
nodeId = req.nodeId,
});
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
uppdated.root = org.result.root;
uppdated.rootId = org.result.rootId;
uppdated.rootShortName = org.result.rootShortName;
uppdated.child1 = req.node <= 0 ? null : org.result.child1;
uppdated.child1Id = req.node <= 0 ? null : org.result.child1Id;
uppdated.child1ShortName = req.node <= 0 ? null : org.result.child1ShortName;
uppdated.child2 = req.node <= 1 ? null : org.result.child2;
uppdated.child2Id = req.node <= 1 ? null : org.result.child2Id;
uppdated.child2ShortName = req.node <= 1 ? null : org.result.child2ShortName;
uppdated.child3 = req.node <= 2 ? null : org.result.child3;
uppdated.child3Id = req.node <= 2 ? null : org.result.child3Id;
uppdated.child3ShortName = req.node <= 2 ? null : org.result.child3ShortName;
uppdated.child4 = req.node <= 3 ? null : org.result.child4;
uppdated.child4Id = req.node <= 3 ? null : org.result.child4Id;
uppdated.child4ShortName = req.node <= 3 ? null : org.result.child4ShortName;
}
uppdated.posmasterId = req.posmasterId;
uppdated.node = req.node;
uppdated.nodeId = req.nodeId;
uppdated.orgRevisionId = req.orgRevisionId;
uppdated.positionId = req.positionId;
uppdated.posMasterNo = req.posMasterNo;
uppdated.positionName = req.positionName;
uppdated.positionField = req.positionField;
uppdated.posTypeId = req.posTypeId;
uppdated.posTypeName = req.posTypeName;
uppdated.posLevelId = req.posLevelId;
uppdated.posLevelName = req.posLevelName;
uppdated.Amount = req.Amount;
uppdated.RecruitDate = req.RecruitDate;
uppdated.Status = "PENDING";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
@ -464,14 +511,6 @@ namespace BMA.EHR.Placement.Service.Controllers
if (uppdated == null)
return Error(GlobalMessages.PlacementReceiveNotFound, 404);
if (req.PrefixId != null)
{
var save = await _context.Prefixes.FindAsync(req.PrefixId);
if (save == null)
return Error(GlobalMessages.PrefixNotFound, 404);
uppdated.Prefix = save;
}
if (req.RelationshipId != null)
{
var save = await _context.Relationships.FindAsync(req.RelationshipId);
@ -503,9 +542,10 @@ namespace BMA.EHR.Placement.Service.Controllers
return Error(GlobalMessages.GenderNotFound, 404);
uppdated.Gender = save;
}
uppdated.CitizenId = req.CitizenId;
uppdated.Firstname = req.Firstname;
uppdated.Lastname = req.Lastname;
uppdated.citizenId = req.citizenId;
uppdated.prefix = req.prefix;
uppdated.firstName = req.firstName;
uppdated.lastName = req.lastName;
uppdated.DateOfBirth = req.DateOfBirth;
uppdated.Nationality = req.Nationality;
uppdated.Race = req.Race;
@ -591,23 +631,23 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success();
}
/// <summary>
/// หน่วยงานที่ถูกเลือกไปแล้ว
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("use")]
public async Task<ActionResult<ResponseObject>> GetReceiveUse()
{
var receives = await _context.PlacementReceives
.Where(x => x.PositionNumber != null)
.Select(x => x.PositionNumber.Id)
.ToListAsync();
// /// <summary>
// /// หน่วยงานที่ถูกเลือกไปแล้ว
// /// </summary>
// /// <returns></returns>
// /// <response code="200"></response>
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
// [HttpGet("use")]
// public async Task<ActionResult<ResponseObject>> GetReceiveUse()
// {
// var receives = await _context.PlacementReceives
// .Where(x => x.PositionNumber != null)
// .Select(x => x.PositionNumber.Id)
// .ToListAsync();
return Success(receives);
}
// return Success(receives);
// }
}
}

View file

@ -8,7 +8,9 @@ using BMA.EHR.Placement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.Placement.Service.Controllers
@ -26,18 +28,21 @@ namespace BMA.EHR.Placement.Service.Controllers
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
public PlacementRepatriationController(PlacementRepository repository,
NotificationRepository repositoryNoti,
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -45,6 +50,7 @@ namespace BMA.EHR.Placement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private bool? PlacementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
@ -61,36 +67,70 @@ 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 placementRepatriations = await _context.PlacementRepatriations.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
p.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName,
p.Profile.LastName,
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : (p.Profile.PositionEmployeePosition == null ? null : p.Profile.PositionEmployeePosition.Name),
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : (p.Profile.PositionEmployeeLevel == null ? null : p.Profile.PositionEmployeeLevel.Name),
p.CreatedAt,
p.Organization,
p.Reason,
p.Status,
p.Date,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
p.DateRepatriation,
})
.ToListAsync();
if (PlacementAdmin == true)
placementRepatriations.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
return Success(placementRepatriations);
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 placementRepatriations = await _context.PlacementRepatriations.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.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.CreatedAt,
p.Organization,
p.Reason,
p.Status,
p.Date,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
p.DateRepatriation,
})
.ToListAsync();
return Success(placementRepatriations);
}
}
/// <summary>
@ -107,19 +147,27 @@ namespace BMA.EHR.Placement.Service.Controllers
{
var data = await _context.PlacementRepatriations.AsQueryable()
.Where(x => x.Id == id)
.Where(x => x.Profile != null)
.Select(p => new
{
p.Id,
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName,
p.Profile.LastName,
ProfileId = p.Profile.Id,
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : (p.Profile.PositionEmployeePosition == null ? null : p.Profile.PositionEmployeePosition.Name),
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : (p.Profile.PositionEmployeeLevel == null ? null : p.Profile.PositionEmployeeLevel.Name),
organizationOrganization = p.Profile.OrganizationOrganization,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.Reason,
p.Status,
p.Organization,
@ -131,38 +179,12 @@ namespace BMA.EHR.Placement.Service.Controllers
p.PositionNumberOld,
p.OrganizationPositionOld,
p.DateRepatriation,
Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.DataNotFound, 404);
var _data = new
{
data.Id,
data.PrefixId,
data.Prefix,
data.FirstName,
data.LastName,
data.ProfileId,
data.position,
data.posNo,
data.positionLevel,
data.organizationOrganization,
data.Reason,
data.Status,
data.Organization,
data.Date,
data.salary,
data.CreatedAt,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
data.DateRepatriation,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
};
return Success(_data);
return Success(data);
}
/// <summary>
@ -176,27 +198,10 @@ namespace BMA.EHR.Placement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] PlacementAddProfileRequest req)
{
var profile = await _context.Profiles
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
.Include(x => x.Position)
.FirstOrDefaultAsync(x => x.Id == req.Id);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var placementRepatriation = new PlacementRepatriation
{
Profile = profile,
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
// Date = req.Date,
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
@ -205,6 +210,46 @@ namespace BMA.EHR.Placement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.Id}";
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)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
placementRepatriation.profileId = org.result.profileId;
placementRepatriation.prefix = org.result.prefix;
placementRepatriation.firstName = org.result.firstName;
placementRepatriation.lastName = org.result.lastName;
placementRepatriation.citizenId = org.result.citizenId;
placementRepatriation.root = org.result.root;
placementRepatriation.rootId = org.result.rootId;
placementRepatriation.rootShortName = org.result.rootShortName;
placementRepatriation.child1 = org.result.child1;
placementRepatriation.child1Id = org.result.child1Id;
placementRepatriation.child1ShortName = org.result.child1ShortName;
placementRepatriation.child2 = org.result.child2;
placementRepatriation.child2Id = org.result.child2Id;
placementRepatriation.child2ShortName = org.result.child2ShortName;
placementRepatriation.child3 = org.result.child3;
placementRepatriation.child3Id = org.result.child3Id;
placementRepatriation.child3ShortName = org.result.child3ShortName;
placementRepatriation.child4 = org.result.child4;
placementRepatriation.child4Id = org.result.child4Id;
placementRepatriation.child4ShortName = org.result.child4ShortName;
placementRepatriation.posMasterNo = org.result.posMasterNo;
placementRepatriation.position = org.result.position;
placementRepatriation.posTypeId = org.result.posTypeId;
placementRepatriation.posTypeName = org.result.posTypeName;
placementRepatriation.posLevelId = org.result.posLevelId;
placementRepatriation.posLevelName = org.result.posLevelName;
}
await _context.PlacementRepatriations.AddAsync(placementRepatriation);
await _context.SaveChangesAsync();

View file

@ -9,6 +9,11 @@ namespace BMA.EHR.Placement.Service.Requests
}
public class OrgRequestData
{
public string? profileId { get; set; }
public string? prefix { get; set; }
public string? firstName { get; set; }
public string? lastName { get; set; }
public string? citizenId { get; set; }
public string? root { get; set; }
public string? rootId { get; set; }
public string? rootShortName { get; set; }
@ -24,5 +29,11 @@ namespace BMA.EHR.Placement.Service.Requests
public string? child4 { get; set; }
public string? child4Id { get; set; }
public string? child4ShortName { get; set; }
public int? posMasterNo { get; set; }
public string? position { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
}
}

View file

@ -5,6 +5,29 @@ namespace BMA.EHR.Placement.Service.Requests
{
public class PersonSelectPositionAppointmentEmployeeRequest
{
public Guid? OrganizationEmployeeId { get; set; }
public DateTime? RecruitDate { get; set; }
// public Guid? PosNoId { get; set; }
// public Guid? PositionId { get; set; }
// public Guid? PositionLevelId { get; set; }
// public Guid? PositionLineId { get; set; }
// public Guid? PositionPathSideId { get; set; }
// public Guid? PositionTypeId { get; set; }
public double? Amount { get; set; }
public string? posmasterId { get; set; }
public Guid? personalId { get; set; }
public DateTime? reportingDate { get; set; }
public int? node { get; set; }
public Guid? nodeId { get; set; }
public string? orgRevisionId { get; set; }
public int? posMasterNo { get; set; }
public string? positionId { get; set; }
public string? positionName { get; set; }
public string? positionField { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public string? typeCommand { get; set; }
}
}

View file

@ -6,12 +6,28 @@ namespace BMA.EHR.Placement.Service.Requests
public class PersonSelectPositionAppointmentRequest
{
public DateTime? RecruitDate { get; set; }
public Guid? PosNoId { get; set; }
public Guid? PositionId { get; set; }
public Guid? PositionLevelId { get; set; }
public Guid? PositionLineId { get; set; }
public Guid? PositionPathSideId { get; set; }
public Guid? PositionTypeId { get; set; }
// public Guid? PosNoId { get; set; }
// public Guid? PositionId { get; set; }
// public Guid? PositionLevelId { get; set; }
// public Guid? PositionLineId { get; set; }
// public Guid? PositionPathSideId { get; set; }
// public Guid? PositionTypeId { get; set; }
public double? Amount { get; set; }
public string? posmasterId { get; set; }
public Guid? personalId { get; set; }
public DateTime? reportingDate { get; set; }
public int? node { get; set; }
public Guid? nodeId { get; set; }
public string? orgRevisionId { get; set; }
public int? posMasterNo { get; set; }
public string? positionId { get; set; }
public string? positionName { get; set; }
public string? positionField { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public string? typeCommand { get; set; }
}
}

View file

@ -6,11 +6,28 @@ namespace BMA.EHR.Placement.Service.Requests
public class PersonSelectPositionReceiveRequest
{
public DateTime? RecruitDate { get; set; }
public Guid? PosNoId { get; set; }
public Guid? PositionId { get; set; }
public Guid? PositionLevelId { get; set; }
public Guid? PositionLineId { get; set; }
public Guid? PositionPathSideId { get; set; }
public Guid? PositionTypeId { get; set; }
// public Guid? PosNoId { get; set; }
// public Guid? PositionId { get; set; }
// public Guid? PositionLevelId { get; set; }
// public Guid? PositionLineId { get; set; }
// public Guid? PositionPathSideId { get; set; }
// public Guid? PositionTypeId { get; set; }
public double? Amount { get; set; }
public string? posmasterId { get; set; }
public Guid? personalId { get; set; }
public DateTime? reportingDate { get; set; }
public int? node { get; set; }
public Guid? nodeId { get; set; }
public string? orgRevisionId { get; set; }
public int? posMasterNo { get; set; }
public string? positionId { get; set; }
public string? positionName { get; set; }
public string? positionField { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
public string? typeCommand { get; set; }
}
}

View file

@ -5,10 +5,10 @@ namespace BMA.EHR.Placement.Service.Requests
{
public class PlacementReceiveEditRequest
{
public string CitizenId { get; set; }
public Guid PrefixId { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
public string citizenId { get; set; }
public string prefix { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public DateTime DateOfBirth { get; set; }
public Guid? GenderId { get; set; }
public string? Nationality { get; set; }

View file

@ -5,10 +5,10 @@ namespace BMA.EHR.Placement.Service.Requests
{
public class PlacementReceiveRequest
{
public string CitizenId { get; set; }
public Guid Prefix { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
public string citizenId { get; set; }
public string prefix { get; set; }
public string firstName { get; set; }
public string lastName { get; set; }
public DateTime BirthDate { get; set; }
public Guid? GenderId { get; set; }
public string? Nationality { get; set; }

View file

@ -16,6 +16,7 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Reflection.Metadata;
using System.Security.Claims;
using System.Security.Cryptography;
@ -60,7 +61,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private bool? RetirementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
#endregion
/// <summary>
@ -74,64 +77,87 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpGet()]
public async Task<ActionResult<ResponseObject>> GetList()
{
var retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
p.Id,
ProfileId = p.Profile.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName,
p.Profile.LastName,
Position = p.Profile.Position == null ? null : p.Profile.Position.Name,
PositionType = p.Profile.PositionType == null ? null : p.Profile.PositionType.Name,
p.Profile.PositionLine,
// PositionLine = p.Profile.PositionLine == null ? null : p.Profile.PositionLine.Name,
PositionLevel = p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name,
p.Profile.PositionExecutive,
// PositionExecutive = p.Profile.PositionExecutive == null ? null : p.Profile.PositionExecutive.Name,
Organization = p.Profile.Oc,
// Organization = p.Profile.Oc == null ? null : p.Profile.Oc.Name,
p.Number,
p.Date,
p.Location,
p.Reason,
FileName = p.Document == null ? null : p.Document.FileName,
PathName = p.Document == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Document.Id,
p.IsActive,
p.CreatedAt,
})
.ToListAsync();
var _retirementDeceaseds = new List<dynamic>();
foreach (var data in retirementDeceaseds)
var rootId = "";
var child1Id = "";
var child2Id = "";
var child3Id = "";
var child4Id = "";
var apiUrl = $"{_configuration["API"]}org/profile/keycloak/position";
using (var client = new HttpClient())
{
var _data = new
{
data.Id,
data.ProfileId,
data.Prefix,
data.FirstName,
data.LastName,
data.Position,
data.PositionExecutive,
data.PositionType,
data.PositionLine,
data.PositionLevel,
data.Organization,
data.Number,
data.Date,
data.Location,
data.Reason,
data.FileName,
PathName = data.PathName == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.PathName),
data.IsActive,
data.CreatedAt,
};
_retirementDeceaseds.Add(_data);
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)
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 retirementDeceaseds = await _context.RetirementDeceaseds.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Where(x => RetirementAdmin == 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.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.CreatedAt,
p.IsActive,
})
.ToListAsync();
// var _retirementDeceaseds = new List<dynamic>();
// foreach (var data in retirementDeceaseds)
// {
// var _data = new
// {
// data.Id,
// data.ProfileId,
// data.Prefix,
// data.FirstName,
// data.LastName,
// data.Position,
// data.PositionExecutive,
// data.PositionType,
// data.PositionLine,
// data.PositionLevel,
// data.Organization,
// data.Number,
// data.Date,
// data.Location,
// data.Reason,
// data.FileName,
// PathName = data.PathName == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.PathName),
// data.IsActive,
// data.CreatedAt,
// };
// _retirementDeceaseds.Add(_data);
// }
return Success(retirementDeceaseds);
}
return Success(_retirementDeceaseds);
}
/// <summary>
@ -151,26 +177,24 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
p.Id,
ProfileId = p.Profile.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
p.Profile.FirstName,
p.Profile.LastName,
Position = p.Profile.Position == null ? null : p.Profile.Position.Name,
PositionId = p.Profile.Position == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Position.Id,
PositionType = p.Profile.PositionType == null ? null : p.Profile.PositionType.Name,
PositionTypeId = p.Profile.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionType.Id,
p.Profile.PositionLine,
p.Profile.PositionLineId,
// PositionLine = p.Profile.PositionLine == null ? null : p.Profile.PositionLine.Name,
PositionLevel = p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name,
PositionLevelId = p.Profile.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.PositionLevel.Id,
p.Profile.PositionExecutive,
p.Profile.PositionExecutiveId,
// PositionExecutive = p.Profile.PositionExecutive == null ? null : p.Profile.PositionExecutive.Name,
Organization = p.Profile.Oc,
OrganizationId = p.Profile.OcId,
// Organization = p.Profile.Oc == null ? null : p.Profile.Oc.Name,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.Number,
p.Date,
p.Location,
@ -179,7 +203,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
PathName = p.Document == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Document.Id,
p.IsActive,
p.CreatedAt,
Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
// Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
})
.FirstOrDefaultAsync();
if (data == null)
@ -187,32 +211,32 @@ namespace BMA.EHR.Retirement.Service.Controllers
var _data = new
{
data.Id,
data.ProfileId,
data.Prefix,
data.PrefixId,
data.FirstName,
data.LastName,
data.Position,
data.PositionExecutive,
data.PositionType,
data.PositionLine,
data.PositionLevel,
data.Organization,
data.PositionId,
data.PositionExecutiveId,
data.PositionTypeId,
data.PositionLineId,
data.PositionLevelId,
data.OrganizationId,
data.profileId,
data.prefix,
data.firstName,
data.lastName,
data.root,
data.rootShortName,
data.child1,
data.child1ShortName,
data.child2,
data.child2ShortName,
data.child3,
data.child3ShortName,
data.child4,
data.child4ShortName,
data.posMasterNo,
data.position,
data.posLevelName,
data.posTypeName,
data.Number,
data.Date,
data.Location,
data.Reason,
data.FileName,
PathName = data.PathName == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.PathName),
data.IsActive,
data.CreatedAt,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
// Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
};
return Success(_data);
@ -229,18 +253,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementDeceasedRequest req)
{
var profile = await _context.Profiles
.Include(x => x.Prefix)
.FirstOrDefaultAsync(x => x.Id == req.ProfileId);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
profile.LeaveDate = DateTime.Now;
profile.IsLeave = true;
profile.LeaveReason = "DEATH";
// var profile = await _context.Profiles
// .Include(x => x.Prefix)
// .FirstOrDefaultAsync(x => x.Id == req.ProfileId);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
// profile.LeaveDate = DateTime.Now;
// profile.IsLeave = true;
// profile.LeaveReason = "DEATH";
var retirementDeceased = new RetirementDeceased
{
Profile = profile,
// Profile = profile,
Number = req.Number,
Date = req.Date,
Location = req.Location,
@ -253,6 +278,46 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.ProfileId}";
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)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementDeceased.profileId = org.result.profileId;
retirementDeceased.prefix = org.result.prefix;
retirementDeceased.firstName = org.result.firstName;
retirementDeceased.lastName = org.result.lastName;
retirementDeceased.citizenId = org.result.citizenId;
retirementDeceased.root = org.result.root;
retirementDeceased.rootId = org.result.rootId;
retirementDeceased.rootShortName = org.result.rootShortName;
retirementDeceased.child1 = org.result.child1;
retirementDeceased.child1Id = org.result.child1Id;
retirementDeceased.child1ShortName = org.result.child1ShortName;
retirementDeceased.child2 = org.result.child2;
retirementDeceased.child2Id = org.result.child2Id;
retirementDeceased.child2ShortName = org.result.child2ShortName;
retirementDeceased.child3 = org.result.child3;
retirementDeceased.child3Id = org.result.child3Id;
retirementDeceased.child3ShortName = org.result.child3ShortName;
retirementDeceased.child4 = org.result.child4;
retirementDeceased.child4Id = org.result.child4Id;
retirementDeceased.child4ShortName = org.result.child4ShortName;
retirementDeceased.posMasterNo = org.result.posMasterNo;
retirementDeceased.position = org.result.position;
retirementDeceased.posTypeId = org.result.posTypeId;
retirementDeceased.posTypeName = org.result.posTypeName;
retirementDeceased.posLevelId = org.result.posLevelId;
retirementDeceased.posLevelName = org.result.posLevelName;
}
await _context.RetirementDeceaseds.AddAsync(retirementDeceased);
await _context.SaveChangesAsync();
var _doc = new Domain.Models.Documents.Document();
@ -267,16 +332,68 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (_doc != null)
retirementDeceased.Document = _doc;
}
await _context.ProfileSalaries.AddAsync(new ProfileSalary
// await _context.ProfileSalaries.AddAsync(new ProfileSalary
// {
// Date = req.Date,
// SalaryRef = req.Number,
// CommandNo = "-",
// SalaryClass = "-",
// PosNoEmployee = "-",
// CommandTypeName = "-",
// SalaryStatus = "DEATH",
// Profile = profile,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// });
// if (_doc != null)
// {
// await _context.ProfilePapers.AddAsync(new ProfilePaper
// {
// Detail = "ถึงแก่กรรม",
// CategoryName = "DEATH",
// Document = _doc,
// Profile = profile,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// });
// }
// var orgPos = await _context.ProfilePositions
// .Include(x => x.Profile)
// .ThenInclude(x => x!.Prefix)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x!.Organization)
// .ThenInclude(x => x!.OrganizationOrganization)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x!.PositionMaster)
// .ThenInclude(x => x!.PositionPath)
// .Where(x => x.OrganizationPosition!.IsDirector! == true)
// .Where(x => x.OrganizationPosition!.Organization!.Id == profile.OcId)
// .FirstOrDefaultAsync();
// if (orgPos != null)
// {
// if (orgPos.Profile != null)
// {
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
{
Date = req.Date,
SalaryRef = req.Number,
CommandNo = "-",
SalaryClass = "-",
PosNoEmployee = "-",
CommandTypeName = "-",
SalaryStatus = "DEATH",
Profile = profile,
CitizenId = retirementDeceased.citizenId,
Prefix = retirementDeceased.prefix,
FirstName = retirementDeceased.firstName,
LastName = retirementDeceased.lastName,
IsSendMail = true,
IsSendInbox = true,
IsSendNotification = true,
// OrganizationName = retirementDeceased.OrganizationName,
// PositionName = retirementDeceased.PositionName,
// ReceiveUser = profile,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
@ -284,60 +401,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
if (_doc != null)
{
await _context.ProfilePapers.AddAsync(new ProfilePaper
{
Detail = "ถึงแก่กรรม",
CategoryName = "DEATH",
Document = _doc,
Profile = profile,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
var orgPos = await _context.ProfilePositions
.Include(x => x.Profile)
.ThenInclude(x => x!.Prefix)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.Organization)
.ThenInclude(x => x!.OrganizationOrganization)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x!.PositionMaster)
.ThenInclude(x => x!.PositionPath)
.Where(x => x.OrganizationPosition!.IsDirector! == true)
.Where(x => x.OrganizationPosition!.Organization!.Id == profile.OcId)
.FirstOrDefaultAsync();
if (orgPos != null)
{
if (orgPos.Profile != null)
{
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
{
CitizenId = orgPos!.Profile!.CitizenId!,
Prefix = orgPos!.Profile!.Prefix!.Name,
FirstName = orgPos!.Profile!.FirstName!,
LastName = orgPos!.Profile!.LastName!,
IsSendMail = true,
IsSendInbox = true,
IsSendNotification = true,
OrganizationName = orgPos!.OrganizationPosition!.Organization!.OrganizationOrganization!.Name,
PositionName = orgPos!.OrganizationPosition!.PositionMaster!.PositionPath!.Name,
ReceiveUser = profile,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
}
}
// }
// }
await _context.SaveChangesAsync();
return Success();
@ -532,8 +597,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
var items = await _context.RetirementDeceasedNotis.AsQueryable()
.Include(x => x.ReceiveUser)
.Include(x => x.RetirementDeceased)
.ThenInclude(x => x.Profile)
.ThenInclude(x => x.Prefix)
// .ThenInclude(x => x.Profile)
// .ThenInclude(x => x.Prefix)
.Where(x => x.RetirementDeceased.Id == id)
.ToListAsync();
@ -562,14 +627,14 @@ namespace BMA.EHR.Retirement.Service.Controllers
var payload_str = JsonConvert.SerializeObject(payload);
foreach (var item in items)
{
var prefix = item.RetirementDeceased.Profile.Prefix == null ? "" : item.RetirementDeceased.Profile.Prefix.Name;
var prefix = item.RetirementDeceased.prefix;
var profile = req.Persons.FirstOrDefault(x => x.ProfileId == item.ReceiveUser.Id);
if (profile != null)
{
await _repositoryNoti.PushNotificationAsync(
item.ReceiveUser.Id,
$"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
$"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
$"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
$"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
payload_str,
profile.IsSendInbox,
profile.IsSendMail
@ -582,8 +647,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
await _repositoryNoti.PushNotificationAsync(
item.ReceiveUser.Id,
$"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
$"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.Profile.FirstName} {item.RetirementDeceased.Profile.LastName}",
$"หนังสือเวียนถึงแก่กรรมของ {prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
$"แจ้งข่าวการถึงแก่กรรมของ {prefix}{item.RetirementDeceased.firstName} {item.RetirementDeceased.lastName}",
payload_str,
item.IsSendInbox,
item.IsSendMail

View file

@ -8,7 +8,9 @@ using BMA.EHR.Retirement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.Retirement.Service.Controllers
@ -26,18 +28,21 @@ namespace BMA.EHR.Retirement.Service.Controllers
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
public RetirementOtherController(RetirementRepository repository,
NotificationRepository repositoryNoti,
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -45,6 +50,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private bool? RetirementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
@ -61,54 +67,70 @@ namespace BMA.EHR.Retirement.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 retirementOthers = await _context.RetirementOthers.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
p.Id,
p.CitizenId,
Prefix = p.Prefix == null ? null : p.Prefix.Name,
p.Firstname,
p.Lastname,
p.DateOfBirth,
Gender = p.Gender == null ? null : p.Gender.Name,
p.Status,
p.Amount,
p.RecruitDate,
PositionNumber = p.PositionNumber == null ? null : p.PositionNumber.Name,
PositionPath = p.PositionPath == null ? null : p.PositionPath.Name,
PositionPathSide = p.PositionPathSide == null ? null : p.PositionPathSide.Name,
PositionType = p.PositionType == null ? null : p.PositionType.Name,
PositionLine = p.PositionLine == null ? null : p.PositionLine.Name,
PositionLevel = p.PositionLevel == null ? null : p.PositionLevel.Name,
PosNoId = p.PositionNumber == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionNumber.Id,
PositionId = p.PositionPath == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPath.Id,
PositionPathSideId = p.PositionPathSide == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionPathSide.Id,
PositionTypeId = p.PositionType == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionType.Id,
PositionLineId = p.PositionLine == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLine.Id,
PositionLevelId = p.PositionLevel == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.PositionLevel.Id,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
OrganizationName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationOrganization == null ? null : p.OrganizationPosition.Organization.OrganizationOrganization.Name)),////
OrganizationShortName = p.OrganizationPosition == null ? null : (p.OrganizationPosition.Organization == null ? null : (p.OrganizationPosition.Organization.OrganizationShortName == null ? null : p.OrganizationPosition.Organization.OrganizationShortName.Name)),////
p.IsActive,
p.PositionDate,
p.Reason,
p.MilitaryDate,
p.EducationOld,
p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.CreatedAt,
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
.ToListAsync();
if (RetirementAdmin == true)
retirementOthers.Where(x => x.Status.Trim().ToUpper().Contains("PENDING"));
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
return Success(retirementOthers);
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 retirementOthers = await _context.RetirementOthers.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Where(x => RetirementAdmin == 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.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.Status,
p.CreatedAt,
p.Reason,
p.MilitaryDate,
p.EducationOld,
p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.PositionDate,
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
.ToListAsync();
return Success(retirementOthers);
}
}
/// <summary>
@ -128,30 +150,25 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
p.Id,
ProfileId = p.Profile.Id,
p.CitizenId,
Prefix = p.Prefix == null ? null : p.Prefix.Name,
PrefixId = p.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Prefix.Id,
p.Firstname,
p.Lastname,
p.DateOfBirth,
Gender = p.Gender == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Gender.Id,
p.Nationality,
p.Race,
Religion = p.Religion == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Religion.Id,
BloodGroup = p.BloodGroup == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.BloodGroup.Id,
Relationship = p.Relationship == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Relationship.Id,
p.TelephoneNumber,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.Status,
p.Amount,
p.RecruitDate,
PosNo = p.PositionNumber == null ? "-" : p.PositionNumber.Name,
Position = p.PositionPath == null ? "-" : p.PositionPath.Name,
PositionPathSide = p.PositionPathSide == null ? "-" : p.PositionPathSide.Name,
PositionType = p.PositionType == null ? "-" : p.PositionType.Name,
PositionLine = p.PositionLine == null ? "-" : p.PositionLine.Name,
PositionLevel = p.PositionLevel == null ? "-" : p.PositionLevel.Name,
OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
p.CreatedAt,
p.Reason,
p.MilitaryDate,
@ -162,67 +179,67 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.PositionNumberOld,
p.OrganizationPositionOld,
p.PositionDate,
Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
RetirementOtherDocs = p.RetirementOtherDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
// Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
// RetirementOtherDocs = p.RetirementOtherDocs.Where(d => d.Document != null).Select(d => new { d.Document.Id, d.Document.FileName }),
CommandType = p.CommandType == null ? null : p.CommandType.Name,
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.DataNotFound, 404);
var retirementOtherDocs = new List<dynamic>();
foreach (var doc in data.RetirementOtherDocs)
{
var _doc = new
{
doc.FileName,
PathName = await _documentService.ImagesPath(doc.Id)
};
retirementOtherDocs.Add(_doc);
}
var _data = new
{
data.Id,
data.ProfileId,
data.CitizenId,
data.Prefix,
data.PrefixId,
data.Firstname,
data.Lastname,
data.DateOfBirth,
data.Gender,
data.Nationality,
data.Race,
data.Religion,
data.BloodGroup,
data.Relationship,
data.TelephoneNumber,
data.Status,
data.Amount,
data.RecruitDate,
data.PosNo,
data.Position,
data.PositionPathSide,
data.PositionType,
data.PositionLine,
data.PositionLevel,
data.OrganizationPositionId,
data.CreatedAt,
data.Reason,
data.MilitaryDate,
data.EducationOld,
data.AmountOld,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
data.PositionDate,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
Docs = retirementOtherDocs,
data.CommandType,
};
// var retirementOtherDocs = new List<dynamic>();
// foreach (var doc in data.RetirementOtherDocs)
// {
// var _doc = new
// {
// doc.FileName,
// PathName = await _documentService.ImagesPath(doc.Id)
// };
// retirementOtherDocs.Add(_doc);
// }
// var _data = new
// {
// data.Id,
// data.ProfileId,
// data.CitizenId,
// data.Prefix,
// data.PrefixId,
// data.Firstname,
// data.Lastname,
// data.DateOfBirth,
// data.Gender,
// data.Nationality,
// data.Race,
// data.Religion,
// data.BloodGroup,
// data.Relationship,
// data.TelephoneNumber,
// data.Status,
// data.Amount,
// data.RecruitDate,
// data.PosNo,
// data.Position,
// data.PositionPathSide,
// data.PositionType,
// data.PositionLine,
// data.PositionLevel,
// data.OrganizationPositionId,
// data.CreatedAt,
// data.Reason,
// data.MilitaryDate,
// data.EducationOld,
// data.AmountOld,
// data.PositionTypeOld,
// data.PositionLevelOld,
// data.PositionNumberOld,
// data.OrganizationPositionOld,
// data.PositionDate,
// // Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
// // Docs = retirementOtherDocs,
// data.CommandType,
// };
return Success(_data);
return Success(data);
}
/// <summary>
@ -236,46 +253,33 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
{
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)
.Include(x => x.Gender)
.Include(x => x.Prefix)
.FirstOrDefaultAsync(x => x.Id == req.Id);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
var retirementOther = new RetirementOther
{
Profile = profile,
CitizenId = profile.CitizenId,
Prefix = profile.Prefix,
Firstname = profile.FirstName,
Lastname = profile.LastName,
DateOfBirth = profile.BirthDate,
Gender = profile.Gender,
Nationality = profile.Nationality,
Race = profile.Race,
Religion = await _context.Religions.FindAsync(profile.ReligionId),
BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
TelephoneNumber = profile.TelephoneNumber,
EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
PositionNumber = profile.PosNo,
PositionPath = profile.Position,
PositionPathSide = await _context.PositionPathSides.FindAsync(profile.PositionPathSideId),
PositionType = profile.PositionType,
PositionLine = await _context.PositionLines.FindAsync(profile.PositionLineId),
PositionLevel = profile.PositionLevel,
// Profile = profile,
// CitizenId = profile.CitizenId,
// Prefix = profile.Prefix,
// Firstname = profile.FirstName,
// Lastname = profile.LastName,
// DateOfBirth = profile.BirthDate,
// Gender = profile.Gender,
// Nationality = profile.Nationality,
// Race = profile.Race,
// Religion = await _context.Religions.FindAsync(profile.ReligionId),
// BloodGroup = await _context.BloodGroups.FindAsync(profile.BloodGroupId),
// Relationship = await _context.Relationships.FindAsync(profile.RelationshipId),
// TelephoneNumber = profile.TelephoneNumber,
// EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}",
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
// PositionNumber = profile.PosNo,
// PositionPath = profile.Position,
// PositionPathSide = await _context.PositionPathSides.FindAsync(profile.PositionPathSideId),
// PositionType = profile.PositionType,
// PositionLine = await _context.PositionLines.FindAsync(profile.PositionLineId),
// PositionLevel = profile.PositionLevel,
// OrganizationPositionId = p.OrganizationPosition == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.OrganizationPosition.Id,
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
@ -285,118 +289,158 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.Id}";
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)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementOther.profileId = org.result.profileId;
retirementOther.prefix = org.result.prefix;
retirementOther.firstName = org.result.firstName;
retirementOther.lastName = org.result.lastName;
retirementOther.citizenId = org.result.citizenId;
retirementOther.root = org.result.root;
retirementOther.rootId = org.result.rootId;
retirementOther.rootShortName = org.result.rootShortName;
retirementOther.child1 = org.result.child1;
retirementOther.child1Id = org.result.child1Id;
retirementOther.child1ShortName = org.result.child1ShortName;
retirementOther.child2 = org.result.child2;
retirementOther.child2Id = org.result.child2Id;
retirementOther.child2ShortName = org.result.child2ShortName;
retirementOther.child3 = org.result.child3;
retirementOther.child3Id = org.result.child3Id;
retirementOther.child3ShortName = org.result.child3ShortName;
retirementOther.child4 = org.result.child4;
retirementOther.child4Id = org.result.child4Id;
retirementOther.child4ShortName = org.result.child4ShortName;
retirementOther.posMasterNo = org.result.posMasterNo;
retirementOther.position = org.result.position;
retirementOther.posTypeId = org.result.posTypeId;
retirementOther.posTypeName = org.result.posTypeName;
retirementOther.posLevelId = org.result.posLevelId;
retirementOther.posLevelName = org.result.posLevelName;
}
await _context.RetirementOthers.AddAsync(retirementOther);
await _context.SaveChangesAsync();
if (Request.Form.Files != null && Request.Form.Files.Count != 0)
{
foreach (var file in Request.Form.Files)
{
var fileExtension = Path.GetExtension(file.FileName);
// if (Request.Form.Files != null && Request.Form.Files.Count != 0)
// {
// foreach (var file in Request.Form.Files)
// {
// var fileExtension = Path.GetExtension(file.FileName);
var doc = await _documentService.UploadFileAsync(file, file.FileName);
var _doc = await _context.Documents.AsQueryable()
.FirstOrDefaultAsync(x => x.Id == doc.Id);
if (_doc != null)
{
var retirementOtherDoc = new RetirementOtherDoc
{
RetirementOther = retirementOther,
Document = _doc,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
await _context.RetirementOtherDocs.AddAsync(retirementOtherDoc);
// var doc = await _documentService.UploadFileAsync(file, file.FileName);
// var _doc = await _context.Documents.AsQueryable()
// .FirstOrDefaultAsync(x => x.Id == doc.Id);
// if (_doc != null)
// {
// var retirementOtherDoc = new RetirementOtherDoc
// {
// RetirementOther = retirementOther,
// Document = _doc,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// };
// await _context.RetirementOtherDocs.AddAsync(retirementOtherDoc);
}
}
}
await _context.SaveChangesAsync();
// }
// }
// }
// await _context.SaveChangesAsync();
return Success();
}
/// <summary>
/// เลือกหน่วยงาน
/// </summary>
/// <param name="id">Id อื่นๆ</param>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPut("position/{id:length(36)}")]
public async Task<ActionResult<ResponseObject>> UpdatePositionRetirementOther([FromBody] PersonSelectPositionOtherRequest req, Guid id)
{
var uppdated = await _context.RetirementOthers
.FirstOrDefaultAsync(x => x.Id == id);
if (uppdated == null)
return Error(GlobalMessages.RetirementOtherNotFound, 404);
if (req.PosNoId != null)
{
var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
if (save_posNo == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
uppdated.PositionNumber = save_posNo;
// /// <summary>
// /// เลือกหน่วยงาน
// /// </summary>
// /// <param name="id">Id อื่นๆ</param>
// /// <returns></returns>
// /// <response code="200"></response>
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
// [HttpPut("position/{id:length(36)}")]
// public async Task<ActionResult<ResponseObject>> UpdatePositionRetirementOther([FromBody] PersonSelectPositionOtherRequest req, Guid id)
// {
// var uppdated = await _context.RetirementOthers
// .FirstOrDefaultAsync(x => x.Id == id);
// if (uppdated == null)
// return Error(GlobalMessages.RetirementOtherNotFound, 404);
// if (req.PosNoId != null)
// {
// var save_posNo = await _context.PositionNumbers.FindAsync(req.PosNoId);
// if (save_posNo == null)
// return Error(GlobalMessages.PositionPosNoNotFound, 404);
// uppdated.PositionNumber = save_posNo;
var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
if (save_orgPosition == null)
return Error(GlobalMessages.PositionPosNoNotFound, 404);
uppdated.OrganizationPosition = save_orgPosition;
}
// var save_orgPosition = await _context.OrganizationPositions.FirstOrDefaultAsync(x => x.PositionNumber == save_posNo);
// if (save_orgPosition == null)
// return Error(GlobalMessages.PositionPosNoNotFound, 404);
// uppdated.OrganizationPosition = save_orgPosition;
// }
if (req.PositionId != null)
{
var save = await _context.PositionPaths.FindAsync(req.PositionId);
if (save == null)
return Error(GlobalMessages.PositionPathNotFound, 404);
uppdated.PositionPath = save;
}
// if (req.PositionId != null)
// {
// var save = await _context.PositionPaths.FindAsync(req.PositionId);
// if (save == null)
// return Error(GlobalMessages.PositionPathNotFound, 404);
// uppdated.PositionPath = save;
// }
if (req.PositionLevelId != null)
{
var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
if (save == null)
return Error(GlobalMessages.PositionLevelNotFound, 404);
uppdated.PositionLevel = save;
}
// if (req.PositionLevelId != null)
// {
// var save = await _context.PositionLevels.FindAsync(req.PositionLevelId);
// if (save == null)
// return Error(GlobalMessages.PositionLevelNotFound, 404);
// uppdated.PositionLevel = save;
// }
if (req.PositionLineId != null)
{
var save = await _context.PositionLines.FindAsync(req.PositionLineId);
if (save == null)
return Error(GlobalMessages.PositionLineNotFound, 404);
uppdated.PositionLine = save;
}
// if (req.PositionLineId != null)
// {
// var save = await _context.PositionLines.FindAsync(req.PositionLineId);
// if (save == null)
// return Error(GlobalMessages.PositionLineNotFound, 404);
// uppdated.PositionLine = save;
// }
if (req.PositionPathSideId != null)
{
var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
if (save == null)
return Error(GlobalMessages.PositionPathSideNotFound, 404);
uppdated.PositionPathSide = save;
}
// if (req.PositionPathSideId != null)
// {
// var save = await _context.PositionPathSides.FindAsync(req.PositionPathSideId);
// if (save == null)
// return Error(GlobalMessages.PositionPathSideNotFound, 404);
// uppdated.PositionPathSide = save;
// }
if (req.PositionTypeId != null)
{
var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
if (save == null)
return Error(GlobalMessages.PositionTypeNotFound, 404);
uppdated.PositionType = save;
}
// if (req.PositionTypeId != null)
// {
// var save = await _context.PositionTypes.FindAsync(req.PositionTypeId);
// if (save == null)
// return Error(GlobalMessages.PositionTypeNotFound, 404);
// uppdated.PositionType = save;
// }
uppdated.RecruitDate = req.RecruitDate;
uppdated.Status = "PENDING";
uppdated.LastUpdateFullName = FullName ?? "System Administrator";
uppdated.LastUpdateUserId = UserId ?? "";
uppdated.LastUpdatedAt = DateTime.Now;
await _context.SaveChangesAsync();
// uppdated.RecruitDate = req.RecruitDate;
// uppdated.Status = "PENDING";
// uppdated.LastUpdateFullName = FullName ?? "System Administrator";
// uppdated.LastUpdateUserId = UserId ?? "";
// uppdated.LastUpdatedAt = DateTime.Now;
// await _context.SaveChangesAsync();
return Success();
}
// return Success();
// }
/// <summary>
/// แก้ไขอื่นๆ
@ -414,53 +458,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (uppdated == null)
return Error(GlobalMessages.RetirementOtherNotFound, 404);
if (req.PrefixId != null)
{
var save = await _context.Prefixes.FindAsync(req.PrefixId);
if (save == null)
return Error(GlobalMessages.PrefixNotFound, 404);
uppdated.Prefix = save;
}
if (req.RelationshipId != null)
{
var save = await _context.Relationships.FindAsync(req.RelationshipId);
if (save == null)
return Error(GlobalMessages.RelationshipNotFound, 404);
uppdated.Relationship = save;
}
if (req.ReligionId != null)
{
var save = await _context.Religions.FindAsync(req.ReligionId);
if (save == null)
return Error(GlobalMessages.ReligionNotFound, 404);
uppdated.Religion = save;
}
if (req.BloodGroupId != null)
{
var save = await _context.BloodGroups.FindAsync(req.BloodGroupId);
if (save == null)
return Error(GlobalMessages.BloodGroupNotFound, 404);
uppdated.BloodGroup = save;
}
if (req.GenderId != null)
{
var save = await _context.Genders.FindAsync(req.GenderId);
if (save == null)
return Error(GlobalMessages.GenderNotFound, 404);
uppdated.Gender = save;
}
uppdated.CitizenId = req.CitizenId;
uppdated.Firstname = req.Firstname;
uppdated.Lastname = req.Lastname;
uppdated.DateOfBirth = req.DateOfBirth;
uppdated.Nationality = req.Nationality;
uppdated.Race = req.Race;
uppdated.TelephoneNumber = req.TelephoneNumber;
uppdated.EducationOld = req.EducationOld;
uppdated.Reason = req.Reason;
uppdated.MilitaryDate = req.MilitaryDate;
@ -468,7 +465,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
uppdated.PositionTypeOld = req.PositionTypeOld;
uppdated.PositionLevelOld = req.PositionLevelOld;
uppdated.PositionNumberOld = req.PositionNumberOld;
uppdated.Amount = req.Amount;
uppdated.AmountOld = req.AmountOld;
uppdated.PositionDate = req.PositionDate;
uppdated.LastUpdateFullName = FullName ?? "System Administrator";

View file

@ -8,7 +8,9 @@ using BMA.EHR.Retirement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net.Http.Headers;
using System.Security.Claims;
namespace BMA.EHR.Retirement.Service.Controllers
@ -26,18 +28,21 @@ namespace BMA.EHR.Retirement.Service.Controllers
private readonly ApplicationDBContext _context;
private readonly MinIOService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
public RetirementOutController(RetirementRepository repository,
NotificationRepository repositoryNoti,
ApplicationDBContext context,
MinIOService documentService,
IHttpContextAccessor httpContextAccessor)
IHttpContextAccessor httpContextAccessor,
IConfiguration configuration)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#region " Properties "
@ -45,6 +50,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
private bool? RetirementAdmin => _httpContextAccessor?.HttpContext?.User?.IsInRole("placement1");
@ -61,35 +67,69 @@ namespace BMA.EHR.Retirement.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 retirementOuts = await _context.RetirementOuts.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Select(p => new
{
p.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName,
p.Profile.LastName,
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : (p.Profile.PositionEmployeePosition == null ? null : p.Profile.PositionEmployeePosition.Name),
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : (p.Profile.PositionEmployeeLevel == null ? null : p.Profile.PositionEmployeeLevel.Name),
p.CreatedAt,
p.Organization,
p.Reason,
p.Status,
p.Date,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
})
.ToListAsync();
if (RetirementAdmin == true)
retirementOuts.Where(x => x.Status.Trim().ToUpper().Contains("APPROVE"));
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
return Success(retirementOuts);
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 retirementOuts = await _context.RetirementOuts.AsQueryable()
.OrderByDescending(x => x.CreatedAt)
.Where(x => RetirementAdmin == 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.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.CreatedAt,
p.Organization,
p.Reason,
p.Status,
p.Date,
salary = p.AmountOld,
p.PositionTypeOld,
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
p.IsActive,
})
.ToListAsync();
return Success(retirementOuts);
}
}
/// <summary>
@ -106,19 +146,27 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
var data = await _context.RetirementOuts.AsQueryable()
.Where(x => x.Id == id)
.Where(x => x.Profile != null)
.Select(p => new
{
p.Id,
PrefixId = p.Profile.Prefix == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Prefix.Id,
Prefix = p.Profile.Prefix == null ? null : p.Profile.Prefix.Name,
p.Profile.FirstName,
p.Profile.LastName,
ProfileId = p.Profile.Id,
position = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.Position == null ? null : p.Profile.Position.Name) : (p.Profile.PositionEmployeePosition == null ? null : p.Profile.PositionEmployeePosition.Name),
posNo = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PosNo == null ? null : p.Profile.PosNo.Name) : p.Profile.PosNoEmployee,
positionLevel = p.Profile.ProfileType.Trim().ToUpper().Contains("OFFICER") ? (p.Profile.PositionLevel == null ? null : p.Profile.PositionLevel.Name) : (p.Profile.PositionEmployeeLevel == null ? null : p.Profile.PositionEmployeeLevel.Name),
organizationOrganization = p.Profile.OrganizationOrganization,
p.profileId,
p.prefix,
p.firstName,
p.lastName,
p.root,
p.rootShortName,
p.child1,
p.child1ShortName,
p.child2,
p.child2ShortName,
p.child3,
p.child3ShortName,
p.child4,
p.child4ShortName,
p.posMasterNo,
p.position,
p.posLevelName,
p.posTypeName,
p.Reason,
p.Status,
p.Organization,
@ -129,37 +177,37 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.PositionLevelOld,
p.PositionNumberOld,
p.OrganizationPositionOld,
Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
// Avatar = p.Profile.Avatar == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : p.Profile.Avatar.Id,
})
.FirstOrDefaultAsync();
if (data == null)
return Error(GlobalMessages.DataNotFound, 404);
var _data = new
{
data.Id,
data.PrefixId,
data.Prefix,
data.FirstName,
data.LastName,
data.ProfileId,
data.position,
data.posNo,
data.positionLevel,
data.organizationOrganization,
data.Reason,
data.Status,
data.Organization,
data.Date,
data.salary,
data.CreatedAt,
data.PositionTypeOld,
data.PositionLevelOld,
data.PositionNumberOld,
data.OrganizationPositionOld,
Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
};
// var _data = new
// {
// data.Id,
// data.PrefixId,
// data.Prefix,
// data.FirstName,
// data.LastName,
// data.ProfileId,
// data.position,
// data.posNo,
// data.positionLevel,
// data.organizationOrganization,
// data.Reason,
// data.Status,
// data.Organization,
// data.Date,
// data.salary,
// data.CreatedAt,
// data.PositionTypeOld,
// data.PositionLevelOld,
// data.PositionNumberOld,
// data.OrganizationPositionOld,
// Avatar = data.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(data.Avatar),
// };
return Success(_data);
return Success(data);
}
/// <summary>
@ -173,27 +221,27 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
{
var profile = await _context.Profiles
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
.Include(x => x.Position)
.FirstOrDefaultAsync(x => x.Id == req.Id);
if (profile == null)
return Error(GlobalMessages.DataNotFound, 404);
// var profile = await _context.Profiles
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionType)
// .Include(x => x.PosNo)
// .Include(x => x.Salaries)
// .Include(x => x.Position)
// .FirstOrDefaultAsync(x => x.Id == req.Id);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
var retirementOut = new RetirementOut
{
Profile = profile,
Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
// Date = req.Date,
AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
// Profile = profile,
// Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
// Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
// // Date = req.Date,
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
@ -202,6 +250,46 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}org/profile/profileid/position/{req.Id}";
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)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementOut.profileId = org.result.profileId;
retirementOut.prefix = org.result.prefix;
retirementOut.firstName = org.result.firstName;
retirementOut.lastName = org.result.lastName;
retirementOut.citizenId = org.result.citizenId;
retirementOut.root = org.result.root;
retirementOut.rootId = org.result.rootId;
retirementOut.rootShortName = org.result.rootShortName;
retirementOut.child1 = org.result.child1;
retirementOut.child1Id = org.result.child1Id;
retirementOut.child1ShortName = org.result.child1ShortName;
retirementOut.child2 = org.result.child2;
retirementOut.child2Id = org.result.child2Id;
retirementOut.child2ShortName = org.result.child2ShortName;
retirementOut.child3 = org.result.child3;
retirementOut.child3Id = org.result.child3Id;
retirementOut.child3ShortName = org.result.child3ShortName;
retirementOut.child4 = org.result.child4;
retirementOut.child4Id = org.result.child4Id;
retirementOut.child4ShortName = org.result.child4ShortName;
retirementOut.posMasterNo = org.result.posMasterNo;
retirementOut.position = org.result.position;
retirementOut.posTypeId = org.result.posTypeId;
retirementOut.posTypeName = org.result.posTypeName;
retirementOut.posLevelId = org.result.posLevelId;
retirementOut.posLevelName = org.result.posLevelName;
}
await _context.RetirementOuts.AddAsync(retirementOut);
await _context.SaveChangesAsync();

View file

@ -0,0 +1,39 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class OrgRequest
{
public OrgRequestData result { get; set; } = new();
}
public class OrgRequestData
{
public string? profileId { get; set; }
public string? prefix { get; set; }
public string? firstName { get; set; }
public string? lastName { get; set; }
public string? citizenId { get; set; }
public string? root { get; set; }
public string? rootId { get; set; }
public string? rootShortName { get; set; }
public string? child1 { get; set; }
public string? child1Id { get; set; }
public string? child1ShortName { get; set; }
public string? child2 { get; set; }
public string? child2Id { get; set; }
public string? child2ShortName { get; set; }
public string? child3 { get; set; }
public string? child3Id { get; set; }
public string? child3ShortName { get; set; }
public string? child4 { get; set; }
public string? child4Id { get; set; }
public string? child4ShortName { get; set; }
public int? posMasterNo { get; set; }
public string? position { get; set; }
public string? posTypeId { get; set; }
public string? posTypeName { get; set; }
public string? posLevelId { get; set; }
public string? posLevelName { get; set; }
}
}

View file

@ -5,25 +5,25 @@ namespace BMA.EHR.Retirement.Service.Requests
{
public class RetirementOtherEditRequest
{
public string CitizenId { get; set; }
public Guid PrefixId { get; set; }
public string Firstname { get; set; }
public string Lastname { get; set; }
public DateTime DateOfBirth { get; set; }
public Guid? GenderId { get; set; }
public string? Nationality { get; set; }
public string? Race { get; set; }
public Guid? ReligionId { get; set; }
public Guid? BloodGroupId { get; set; }
public Guid? RelationshipId { get; set; }
public string? TelephoneNumber { get; set; }
// public string CitizenId { get; set; }
// public Guid PrefixId { get; set; }
// public string Firstname { get; set; }
// public string Lastname { get; set; }
// public DateTime DateOfBirth { get; set; }
// public Guid? GenderId { get; set; }
// public string? Nationality { get; set; }
// public string? Race { get; set; }
// public Guid? ReligionId { get; set; }
// public Guid? BloodGroupId { get; set; }
// public Guid? RelationshipId { get; set; }
// public string? TelephoneNumber { get; set; }
public string? Reason { get; set; }
public string? EducationOld { get; set; }
public string? OrganizationPositionOld { get; set; }
public string? PositionTypeOld { get; set; }
public string? PositionLevelOld { get; set; }
public string? PositionNumberOld { get; set; }
public double? Amount { get; set; }
// public double? Amount { get; set; }
public double? AmountOld { get; set; }
public DateTime? PositionDate { get; set; }
public DateTime? MilitaryDate { get; set; }