Merge branch 'develop' of github.com:Frappet/BMA-EHR-BackEnd into develop
This commit is contained in:
commit
7c0b7f1aa7
7 changed files with 1405 additions and 778 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -1,4 +1,5 @@
|
||||||
using BMA.EHR.Application.Common.Interfaces;
|
using BMA.EHR.Application.Common.Interfaces;
|
||||||
|
using BMA.EHR.Application.Responses.Insignias;
|
||||||
using BMA.EHR.Application.Responses.Organizations;
|
using BMA.EHR.Application.Responses.Organizations;
|
||||||
using BMA.EHR.Application.Responses.Profiles;
|
using BMA.EHR.Application.Responses.Profiles;
|
||||||
using BMA.EHR.Domain.Models.HR;
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
|
@ -533,6 +534,25 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public async Task PostProfileInsigniaAsync(PostProfileInsigniaDto body, string? accessToken)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var apiPath = $"{_configuration["API"]}/org/profile/insignia";
|
||||||
|
|
||||||
|
var profiles = new List<SearchProfileDto>();
|
||||||
|
|
||||||
|
var apiResult = await PostExternalAPIBooleanAsync(apiPath, accessToken ?? "", body);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace BMA.EHR.Application.Requests
|
||||||
public string InsigniaName { get; set; }
|
public string InsigniaName { get; set; }
|
||||||
public string InsigniaPage { get; set; }
|
public string InsigniaPage { get; set; }
|
||||||
public string InsigniaNo { get; set; }
|
public string InsigniaNo { get; set; }
|
||||||
public int? Kp7InsigniaId { get; set; }
|
public Guid Kp7InsigniaId { get; set; }
|
||||||
}
|
}
|
||||||
public class DocReceive
|
public class DocReceive
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,39 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Application.Responses.Insignias
|
||||||
|
{
|
||||||
|
public class PostProfileInsigniaDto
|
||||||
|
{
|
||||||
|
public Guid ProfileId { get; set; }
|
||||||
|
|
||||||
|
public int Year { get; set; } = 0;
|
||||||
|
|
||||||
|
public string No { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Volume { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Section { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Page { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime ReceiveDate { get; set; } = DateTime.MinValue;
|
||||||
|
|
||||||
|
public Guid InsigniaId { get; set; }
|
||||||
|
|
||||||
|
public DateTime DateAnnounce { get; set; } = DateTime.MinValue;
|
||||||
|
|
||||||
|
public string Issue { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string VolumeNo { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public DateTime? RefCommandDate { get; set; }
|
||||||
|
|
||||||
|
public string RefCommandNo { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public string Note { get; set; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
using BMA.EHR.Application.Repositories;
|
using BMA.EHR.Application.Repositories;
|
||||||
using BMA.EHR.Application.Repositories.MessageQueue;
|
using BMA.EHR.Application.Repositories.MessageQueue;
|
||||||
using BMA.EHR.Application.Requests;
|
using BMA.EHR.Application.Requests;
|
||||||
|
using BMA.EHR.Application.Responses.Insignias;
|
||||||
using BMA.EHR.Domain.Common;
|
using BMA.EHR.Domain.Common;
|
||||||
using BMA.EHR.Domain.Models.Insignias;
|
using BMA.EHR.Domain.Models.Insignias;
|
||||||
using BMA.EHR.Domain.Shared;
|
using BMA.EHR.Domain.Shared;
|
||||||
|
|
@ -26,19 +27,25 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
private readonly InsigniaPeriodsRepository _repository;
|
private readonly InsigniaPeriodsRepository _repository;
|
||||||
private readonly NotificationRepository _repositoryNoti;
|
private readonly NotificationRepository _repositoryNoti;
|
||||||
|
|
||||||
|
private readonly UserProfileRepository _userProfileRepository;
|
||||||
|
|
||||||
public InsigniaReceiveController(ApplicationDBContext context,
|
public InsigniaReceiveController(ApplicationDBContext context,
|
||||||
MinIOService documentService,
|
MinIOService documentService,
|
||||||
InsigniaPeriodsRepository repository,
|
InsigniaPeriodsRepository repository,
|
||||||
NotificationRepository repositoryNoti,
|
NotificationRepository repositoryNoti,
|
||||||
IHttpContextAccessor httpContextAccessor)
|
IHttpContextAccessor httpContextAccessor,
|
||||||
|
UserProfileRepository userProfileRepository)
|
||||||
{
|
{
|
||||||
_context = context;
|
_context = context;
|
||||||
_documentService = documentService;
|
_documentService = documentService;
|
||||||
_repository = repository;
|
_repository = repository;
|
||||||
_repositoryNoti = repositoryNoti;
|
_repositoryNoti = repositoryNoti;
|
||||||
_httpContextAccessor = httpContextAccessor;
|
_httpContextAccessor = httpContextAccessor;
|
||||||
|
_userProfileRepository = userProfileRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
|
||||||
|
|
||||||
[HttpGet("{type}/{ocId:length(36)}")]
|
[HttpGet("{type}/{ocId:length(36)}")]
|
||||||
public async Task<ActionResult<ResponseObject>> GetInsigniaList(string type, Guid id, Guid ocId)
|
public async Task<ActionResult<ResponseObject>> GetInsigniaList(string type, Guid id, Guid ocId)
|
||||||
{
|
{
|
||||||
|
|
@ -151,6 +158,28 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
|
|
||||||
if (items.Profile.Count() != 0)
|
if (items.Profile.Count() != 0)
|
||||||
{
|
{
|
||||||
|
foreach(var p in items.Profile)
|
||||||
|
{
|
||||||
|
await _userProfileRepository.PostProfileInsigniaAsync(new PostProfileInsigniaDto
|
||||||
|
{
|
||||||
|
ProfileId = Guid.Parse(p.FkProfileId),
|
||||||
|
Year = item.InsigniaDateannounce.Value.Year,
|
||||||
|
No = p.InsigniaNo,
|
||||||
|
Volume = item.InsigniaVolume,
|
||||||
|
Section = item.InsigniaSection,
|
||||||
|
Page = p.InsigniaPage,
|
||||||
|
ReceiveDate = item.InsigniaDatereceive.Value,
|
||||||
|
InsigniaId = p.Kp7InsigniaId,
|
||||||
|
DateAnnounce = item.InsigniaDateannounce.Value,
|
||||||
|
Issue = item.InsigniaIssue,
|
||||||
|
VolumeNo = item.InsigniaVolumeno.Value.ToString(),
|
||||||
|
|
||||||
|
|
||||||
|
}, AccessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// foreach (var i in items.Profile)
|
// foreach (var i in items.Profile)
|
||||||
// {
|
// {
|
||||||
// var profile = _context.Profiles.AsQueryable()
|
// var profile = _context.Profiles.AsQueryable()
|
||||||
|
|
@ -208,7 +237,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
// return NotFound("Profile not found!!!");
|
// return NotFound("Profile not found!!!");
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
_context.SaveChanges();
|
//_context.SaveChanges();
|
||||||
|
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -422,10 +422,12 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
|
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
{
|
{
|
||||||
// Guid period = result.PeriodId;
|
Guid period = result.PeriodId;
|
||||||
// var periodName = result.Name;
|
var periodName = result.Name;
|
||||||
// string requestStatus = result.RequestStatus;
|
string requestStatus = result.RequestStatus;
|
||||||
// string requestNote = result.RequestNote;
|
string requestNote = result.RequestNote;
|
||||||
|
|
||||||
|
|
||||||
var resend = new InsigniaResults
|
var resend = new InsigniaResults
|
||||||
{
|
{
|
||||||
PeriodId = result.PeriodId,
|
PeriodId = result.PeriodId,
|
||||||
|
|
@ -444,14 +446,16 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
return Success(resend);
|
return Success(resend);
|
||||||
if (RoleInsignia2 == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2"))
|
if (RoleInsignia2 == true && (result.RequestStatus == "st1" || result.RequestStatus == "st2"))
|
||||||
return Success(resend);
|
return Success(resend);
|
||||||
// var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId);
|
|
||||||
|
|
||||||
// // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
// Jack Remark Remove เพื่อให้เรียกขข้อมูลออกมาเร็สวขึ้น
|
||||||
// if (requestStatus == null)
|
//var candidate = await _repository.GetInsigniaCandidateBKK(period, ocId);
|
||||||
// {
|
|
||||||
// // บันทึกรายชื่อ
|
//// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||||
// await _repository.InsertCandidate(period, ocId, candidate);
|
//if (requestStatus == null)
|
||||||
// }
|
//{
|
||||||
|
// // บันทึกรายชื่อ
|
||||||
|
// await _repository.InsertCandidate(period, ocId, candidate);
|
||||||
|
//}
|
||||||
if (role.Trim().ToUpper() == "OFFICER")
|
if (role.Trim().ToUpper() == "OFFICER")
|
||||||
{
|
{
|
||||||
resend.Items = await _repository.InsigniaHasProfile(result.PeriodId, ocId, status);
|
resend.Items = await _repository.InsigniaHasProfile(result.PeriodId, ocId, status);
|
||||||
|
|
@ -459,132 +463,136 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// var passData = _context.InsigniaRequests.AsQueryable()
|
var passData = _context.InsigniaRequests.AsQueryable()
|
||||||
// .Include(x => x.Organization)
|
//.Include(x => x.Organization)
|
||||||
// .Include(x => x.RequestProfiles)
|
.Include(x => x.RequestProfiles)
|
||||||
// .Where(x => x.Organization.Id == ocId)
|
.Where(x => x.OrganizationId == ocId)
|
||||||
// .Where(x => x.Period.Id == period)
|
.Where(x => x.Period.Id == period)
|
||||||
// .Select(ir => new
|
.Select(ir => new
|
||||||
// {
|
{
|
||||||
// requstID = ir.Id,
|
requstID = ir.Id,
|
||||||
// requstStatus = ir.RequestStatus,
|
requstStatus = ir.RequestStatus,
|
||||||
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||||
// fkInstituteId = -1,
|
fkInstituteId = -1,
|
||||||
// // fkDivisionId = ir.Organization.Id,
|
// fkDivisionId = ir.Organization.Id,
|
||||||
// // fkDivision = ir.Organization.Name,
|
// fkDivision = ir.Organization.Name,
|
||||||
// fkInstitute = "",
|
fkInstitute = "",
|
||||||
// fkPeriodId = ir.Period.Id,
|
fkPeriodId = ir.Period.Id,
|
||||||
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
||||||
// .Include(x => x.Profile)
|
//.Include(x => x.Profile)
|
||||||
// .ThenInclude(x => x.Position)
|
//.ThenInclude(x => x.Position)
|
||||||
// .Include(x => x.Profile)
|
//.Include(x => x.Profile)
|
||||||
// // .ThenInclude(x => x.PositionNumber)
|
// .ThenInclude(x => x.PositionNumber)
|
||||||
// .Include(x => x.Profile)
|
//.Include(x => x.Profile)
|
||||||
// // .ThenInclude(x => x.AcademicStanding)
|
// .ThenInclude(x => x.AcademicStanding)
|
||||||
// .Include(x => x.RequestInsignia)
|
.Include(x => x.RequestInsignia)
|
||||||
// .ThenInclude(x => x.InsigniaType)
|
.ThenInclude(x => x.InsigniaType)
|
||||||
// .Select(irp => new
|
.Select(irp => new
|
||||||
// {
|
{
|
||||||
// request_id = irp.Request.Id,
|
request_id = irp.Request.Id,
|
||||||
// isApprove = irp.IsApprove,
|
isApprove = irp.IsApprove,
|
||||||
// statusInstitute = irp.IsApprove.ToString(),
|
statusInstitute = irp.IsApprove.ToString(),
|
||||||
// request_date = irp.RequestDate,
|
request_date = irp.RequestDate,
|
||||||
// profileId = irp.Profile.Id,
|
profileId = irp.ProfileId,
|
||||||
// // prefix = irp.Profile.Prefix,
|
prefix = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Prefix, //irp.Profile.Prefix,
|
||||||
// firstname = irp.Profile.FirstName,
|
firstname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).FirstName, //irp.Profile.FirstName,
|
||||||
// lastname = irp.Profile.LastName,
|
lastname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).LastName, //irp.Profile.LastName,
|
||||||
// // posno = irp.Profile.PositionNumber.Id,
|
posno = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.Count == 0 ||
|
||||||
// type = irp.Profile.ProfileType,
|
_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary == null ? "" :
|
||||||
// // position = irp.Profile.Position.Name,
|
_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PosNo,// irp.Profile.PositionNumber.Id,
|
||||||
// // rank = $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
|
type = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileType, //irp.Profile.ProfileType,
|
||||||
// instituteName = "",
|
position = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Position, // irp.Profile.Position.Name,
|
||||||
// instituteId = -1,
|
rank = $"{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosType.PosTypeName}/{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosLevel.PosLevelName}", // $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
|
||||||
// // divisionName = irp.Profile.OrganizationOrganization.Name,
|
instituteName = "",
|
||||||
// // divisionId = irp.Profile.OrganizationOrganization.Id,
|
instituteId = -1,
|
||||||
// lastInsigniaName = "",
|
// divisionName = irp.Profile.OrganizationOrganization.Name,
|
||||||
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
// divisionId = irp.Profile.OrganizationOrganization.Id,
|
||||||
// requestInsigniaName = irp.RequestInsignia.Name,
|
lastInsigniaName = "",
|
||||||
// requestQua = irp.QualificationStatus,
|
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
||||||
// requestDoc = irp.DocumentStatus,
|
requestInsigniaName = irp.RequestInsignia.Name,
|
||||||
// requestNote = irp.Note,
|
requestQua = "",// irp.QualificationStatus,
|
||||||
// requestSalary = irp.Salary,
|
requestDoc = "", //irp.DocumentStatus,
|
||||||
// matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
requestNote = "", // irp.Note,
|
||||||
// })
|
requestSalary = irp.Salary,
|
||||||
// .Where(x => x.isApprove)
|
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
||||||
// .OrderBy(y => y.profileId)
|
})
|
||||||
// .ToList()
|
.Where(x => x.isApprove)
|
||||||
// })
|
.OrderBy(y => y.profileId)
|
||||||
// .ToList()
|
.ToList()
|
||||||
// .FirstOrDefault();
|
})
|
||||||
|
.ToList()
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
// var failData = _context.InsigniaRequests.AsQueryable()
|
var failData = _context.InsigniaRequests.AsQueryable()
|
||||||
// .Include(x => x.Organization)
|
//.Include(x => x.Organization)
|
||||||
// .Include(x => x.RequestProfiles)
|
.Include(x => x.RequestProfiles)
|
||||||
// .Where(x => x.Organization.Id == ocId)
|
.Where(x => x.OrganizationId == ocId)
|
||||||
// .Where(x => x.Period.Id == period)
|
.Where(x => x.Period.Id == period)
|
||||||
// .Select(ir => new
|
.Select(ir => new
|
||||||
// {
|
{
|
||||||
// requstID = ir.Id,
|
requstID = ir.Id,
|
||||||
// requstStatus = ir.RequestStatus,
|
requstStatus = ir.RequestStatus,
|
||||||
// requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
requstStatusName = GetRequestlStatusText(ir.RequestStatus),
|
||||||
// fkInstituteId = -1,
|
fkInstituteId = -1,
|
||||||
// // fkDivisionId = ir.Organization.Id,
|
// fkDivisionId = ir.Organization.Id,
|
||||||
// // fkDivision = ir.Organization.Name,
|
// fkDivision = ir.Organization.Name,
|
||||||
// fkInstitute = "",
|
fkInstitute = "",
|
||||||
// fkPeriodId = ir.Period.Id,
|
fkPeriodId = ir.Period.Id,
|
||||||
// insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
insigniaRequestHasProfile = ir.RequestProfiles.AsQueryable()
|
||||||
// .Include(x => x.Profile)
|
//.Include(x => x.Profile)
|
||||||
// .ThenInclude(x => x.Position)
|
//.ThenInclude(x => x.Position)
|
||||||
// .Include(x => x.Profile)
|
//.Include(x => x.Profile)
|
||||||
// // .ThenInclude(x => x.PositionNumber)
|
// .ThenInclude(x => x.PositionNumber)
|
||||||
// .Include(x => x.Profile)
|
//.Include(x => x.Profile)
|
||||||
// // .ThenInclude(x => x.AcademicStanding)
|
// .ThenInclude(x => x.AcademicStanding)
|
||||||
// .Include(x => x.RequestInsignia)
|
.Include(x => x.RequestInsignia)
|
||||||
// .ThenInclude(x => x.InsigniaType)
|
.ThenInclude(x => x.InsigniaType)
|
||||||
// .Select(irp => new
|
.Select(irp => new
|
||||||
// {
|
{
|
||||||
// request_id = irp.Request.Id,
|
request_id = irp.Request.Id,
|
||||||
// isApprove = irp.IsApprove,
|
isApprove = irp.IsApprove,
|
||||||
// statusInstitute = irp.IsApprove.ToString(),
|
statusInstitute = irp.IsApprove.ToString(),
|
||||||
// request_date = irp.RequestDate,
|
request_date = irp.RequestDate,
|
||||||
// profileId = irp.Profile.Id,
|
profileId = irp.ProfileId,
|
||||||
// // prefix = irp.Profile.Prefix,
|
prefix = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Prefix, //irp.Profile.Prefix,
|
||||||
// firstname = irp.Profile.FirstName,
|
firstname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).FirstName, //irp.Profile.FirstName,
|
||||||
// lastname = irp.Profile.LastName,
|
lastname = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).LastName, //irp.Profile.LastName,
|
||||||
// // posno = irp.Profile.PositionNumber.Id,
|
posno = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.Count == 0 ||
|
||||||
// type = irp.Profile.ProfileType,
|
_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary == null ? "" :
|
||||||
// // position = irp.Profile.Position.Name,
|
_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().PosNo,// irp.Profile.PositionNumber.Id,
|
||||||
// // rank = irp.Profile.AcademicStanding.Name,
|
type = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).ProfileType, //irp.Profile.ProfileType,
|
||||||
// instituteName = "",
|
position = _userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).Position, // irp.Profile.Position.Name,
|
||||||
// instituteId = -1,
|
rank = $"{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosType.PosTypeName}/{_userProfileRepository.GetOfficerProfileById(irp.ProfileId, AccessToken).PosLevel.PosLevelName}", // $"{irp.Profile.PositionType.Name}/{irp.Profile.PositionLevel.Name}",
|
||||||
// // divisionName = irp.Profile.OrganizationOrganization.Name,
|
instituteName = "",
|
||||||
// // divisionId = irp.Profile.OrganizationOrganization.Id,
|
instituteId = -1,
|
||||||
// lastInsigniaName = "",
|
// divisionName = irp.Profile.OrganizationOrganization.Name,
|
||||||
// requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
// divisionId = irp.Profile.OrganizationOrganization.Id,
|
||||||
// requestInsigniaName = irp.RequestInsignia.Name,
|
lastInsigniaName = "",
|
||||||
// requestQua = irp.QualificationStatus,
|
requestInsigniaLevel = irp.RequestInsignia.InsigniaType.Name,
|
||||||
// requestDoc = irp.DocumentStatus,
|
requestInsigniaName = irp.RequestInsignia.Name,
|
||||||
// requestNote = irp.Note,
|
requestQua = "", //irp.QualificationStatus,
|
||||||
// requestSalary = irp.Salary,
|
requestDoc = "", //irp.DocumentStatus,
|
||||||
// matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
requestNote = "", //irp.Note,
|
||||||
// })
|
requestSalary = irp.Salary,
|
||||||
// .Where(x => !x.isApprove)
|
matchingConditions = JsonConvert.DeserializeObject<List<MatchingCondition>>(irp.MatchingConditions)
|
||||||
// .OrderBy(y => y.profileId)
|
})
|
||||||
// .ToList()
|
.Where(x => !x.isApprove)
|
||||||
// })
|
.OrderBy(y => y.profileId)
|
||||||
// .ToList()
|
.ToList()
|
||||||
// .FirstOrDefault();
|
})
|
||||||
|
.ToList()
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
// var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
|
var period_data = (from p in _context.InsigniaPeriods.AsQueryable()
|
||||||
// where p.Id == period
|
where p.Id == period
|
||||||
// select new
|
select new
|
||||||
// {
|
{
|
||||||
// periodName = p.Name,
|
periodName = p.Name,
|
||||||
// periodYear = p.Year,
|
periodYear = p.Year,
|
||||||
// }).FirstOrDefault();
|
}).FirstOrDefault();
|
||||||
|
|
||||||
// return Success(new { passData = passData, failData = failData, period = period_data });
|
return Success(new { passData = passData, failData = failData, period = period_data });
|
||||||
return Success();
|
//return Success();
|
||||||
}
|
}
|
||||||
// select data to display
|
// select data to display
|
||||||
}
|
}
|
||||||
|
|
@ -602,67 +610,84 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpGet("{insigniaPeriodId:length(36)}")]
|
[HttpGet("{insigniaPeriodId:length(36)}")]
|
||||||
public async Task<ActionResult<ResponseObject>> UpdateInsignaiRequestBkk(Guid insigniaPeriodId)
|
public async Task<ActionResult<ResponseObject>> UpdateInsigniaRequestBkk(Guid insigniaPeriodId)
|
||||||
{
|
{
|
||||||
//var organizationType = await _context.OrganizationTypes.Where(x => x.Name == "หน่วยงาน").FirstOrDefaultAsync();
|
// jack add เพื่อให้ทำการรันแค่เขตพระนคร
|
||||||
//if (organizationType == null)
|
// TODO : ต้องมาเอาบรรทัดนี้ออกในภายหลัง
|
||||||
// return Error(GlobalMessages.OrganizationNotFound);
|
var ocId = Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3");
|
||||||
//var organizations = await _context.Organizations.Where(x => x.OrganizationType == organizationType).ToListAsync();
|
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, ocId);
|
||||||
|
if (result != null)
|
||||||
var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
|
||||||
|
|
||||||
foreach (var organization in organizations)
|
|
||||||
{
|
{
|
||||||
if (organization == null)
|
Guid period = result.PeriodId;
|
||||||
continue;
|
string requestStatus = result.RequestStatus;
|
||||||
|
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, ocId);
|
||||||
var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
|
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||||
if (result != null)
|
if (requestStatus == null)
|
||||||
{
|
{
|
||||||
Guid period = result.PeriodId;
|
// บันทึกรายชื่อ
|
||||||
string requestStatus = result.RequestStatus;
|
await _repository.InsertCandidate(period, ocId, candidate);
|
||||||
var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
|
|
||||||
// ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
|
||||||
if (requestStatus == null)
|
|
||||||
{
|
|
||||||
// บันทึกรายชื่อ
|
|
||||||
await _repository.InsertCandidate(period, organization.Id, candidate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: original code use this in production
|
||||||
|
|
||||||
|
//var organizations = await _userProfileRepository.GetActiveRootAsync(AccessToken);
|
||||||
|
|
||||||
|
//foreach (var organization in organizations)
|
||||||
|
//{
|
||||||
|
// if (organization == null)
|
||||||
|
// continue;
|
||||||
|
|
||||||
|
|
||||||
|
// if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
|
||||||
|
|
||||||
|
// var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
|
||||||
|
// if (result != null)
|
||||||
|
// {
|
||||||
|
// Guid period = result.PeriodId;
|
||||||
|
// string requestStatus = result.RequestStatus;
|
||||||
|
// var candidate = await _repository.GetInsigniaCandidateBKK(insigniaPeriodId, organization.Id);
|
||||||
|
// // ตรวจสอบว่ารายการอยู่ใน table insignia_request_new
|
||||||
|
// if (requestStatus == null)
|
||||||
|
// {
|
||||||
|
// // บันทึกรายชื่อ
|
||||||
|
// await _repository.InsertCandidate(period, organization.Id, candidate);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// #region " บันทึกหมายเหตุ "
|
#region " บันทึกหมายเหตุ "
|
||||||
|
|
||||||
// [HttpPut("note/{profileId}")]
|
[HttpPut("note/{profileId}")]
|
||||||
// public async Task<ActionResult<ResponseObject>> SaveNote(Guid profileId, SaveRequsetNote items)
|
public async Task<ActionResult<ResponseObject>> SaveNote(Guid profileId, SaveRequsetNote items)
|
||||||
// {
|
{
|
||||||
// var id = await _repository.GetRequestId(items.PeriodId, items.OcId);
|
var id = await _repository.GetRequestId(items.PeriodId, items.OcId);
|
||||||
// var note = _context.InsigniaRequestProfiles.AsQueryable()
|
var note = _context.InsigniaRequestProfiles.AsQueryable()
|
||||||
// .Where(d => d.Profile.Id == profileId && d.Request.Id == id).FirstOrDefault();
|
.Where(d => d.ProfileId == profileId && d.Request.Id == id).FirstOrDefault();
|
||||||
// if (note != null)
|
//if (note != null)
|
||||||
// note.Note = items.Note;
|
// note.Note = items.Note;
|
||||||
// _context.SaveChanges();
|
_context.SaveChanges();
|
||||||
// return Success();
|
return Success();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #endregion
|
#endregion
|
||||||
|
|
||||||
// #region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
|
#region " บันทึกรายชื่อครูในการขอยื่นเครื่องราชฯ เเต่ยังไม่ส่งไปยัง ผอ.โรงเรียน "
|
||||||
|
|
||||||
// [HttpPut("approve/{ocId:length(36)}")]
|
[HttpPut("approve/{ocId:length(36)}")]
|
||||||
// public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
|
public async Task<ActionResult<ResponseObject>> SaveRequestList(Guid id, Guid ocId, InsigniaApproveRequest items)
|
||||||
// {
|
{
|
||||||
// var result = await _repository.GetInsigniaRequest(id, ocId);
|
var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||||
// if (result != null)
|
if (result != null)
|
||||||
// await _repository.SaveAprove(result.PeriodId, ocId, items);
|
await _repository.SaveAprove(result.PeriodId, ocId);
|
||||||
// return Success();
|
return Success();
|
||||||
// }
|
}
|
||||||
|
|
||||||
// #endregion
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// เปลี่ยน status เป็น st3 การเจ้าหน้าที่อนุมัติ "
|
/// เปลี่ยน status เป็น st3 การเจ้าหน้าที่อนุมัติ "
|
||||||
|
|
@ -845,48 +870,49 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
|
|
||||||
// #endregion
|
// #endregion
|
||||||
|
|
||||||
// #region " เปลี่ยน status สำหรับ ผอ.สำนัก "
|
#region " เปลี่ยน status สำหรับ ผอ.สำนัก "
|
||||||
|
|
||||||
// [HttpPost("status/director/approve/{ocId:length(36)}")]
|
[HttpPost("status/director/approve/{ocId:length(36)}")]
|
||||||
// public async Task<ActionResult<ResponseObject>> ChangeStatusToSt5p(Guid id, Guid ocId)
|
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt5p(Guid id, Guid ocId)
|
||||||
// {
|
{
|
||||||
// var result = await _repository.GetInsigniaRequest(id, ocId);
|
var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||||
// if (result == null)
|
if (result == null)
|
||||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
// var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||||
// if (requestId == null)
|
if (requestId == null)
|
||||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
// var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||||
// if (requestNew != null)
|
if (requestNew != null)
|
||||||
// {
|
{
|
||||||
// requestNew.RequestStatus = "st5p";
|
requestNew.RequestStatus = "st5p";
|
||||||
// _context.SaveChanges();
|
_context.SaveChanges();
|
||||||
// return Success();
|
return Success();
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
// }
|
}
|
||||||
|
|
||||||
// [HttpPost("status/director/reject/{ocId:length(36)}")]
|
[HttpPost("status/director/reject/{ocId:length(36)}")]
|
||||||
// public async Task<ActionResult<ResponseObject>> ChangeStatusToSt1(Guid id, Guid ocId)
|
public async Task<ActionResult<ResponseObject>> ChangeStatusToSt1(Guid id, Guid ocId)
|
||||||
// {
|
{
|
||||||
// var result = await _repository.GetInsigniaRequest(id, ocId);
|
var result = await _repository.GetInsigniaRequest(id, ocId);
|
||||||
// if (result == null)
|
if (result == null)
|
||||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
// var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
var requestId = await _repository.GetRequestId(result.PeriodId, ocId);
|
||||||
// if (requestId == null)
|
if (requestId == null)
|
||||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
// var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
var requestNew = await _context.InsigniaRequests.FirstOrDefaultAsync(i => i.Id == requestId);
|
||||||
// if (requestNew != null)
|
if (requestNew != null)
|
||||||
// {
|
{
|
||||||
// requestNew.RequestStatus = "st1";
|
requestNew.RequestStatus = "st1";
|
||||||
// _context.SaveChanges();
|
_context.SaveChanges();
|
||||||
// return Success();
|
return Success();
|
||||||
// }
|
}
|
||||||
// else
|
else
|
||||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
// }
|
}
|
||||||
// #endregion
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// ย้ายขอมูลไปเป็น คนที่ไม่ยื่นขอ
|
/// ย้ายขอมูลไปเป็น คนที่ไม่ยื่นขอ
|
||||||
|
|
@ -1056,12 +1082,19 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound);
|
return Error(GlobalMessages.DataNotFound);
|
||||||
var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
|
var insignia = await _context.Insignias.FirstOrDefaultAsync(x => x.Id == req.insigniaId);
|
||||||
|
|
||||||
if (insignia == null)
|
if (insignia == null)
|
||||||
return Error(GlobalMessages.InsigniaNotFound);
|
return Error(GlobalMessages.InsigniaNotFound);
|
||||||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.ProfileId == profile.Id && x.Request.Period == insigniaPeriod);
|
|
||||||
|
var insigniaRequestProfile = await _context.InsigniaRequestProfiles
|
||||||
|
.Include(x => x.Request)
|
||||||
|
.ThenInclude(x => x.Period)
|
||||||
|
.FirstOrDefaultAsync(x => x.ProfileId == profile.Id && x.Request.Period.Id == insigniaPeriod.Id);
|
||||||
if (insigniaRequestProfile != null)
|
if (insigniaRequestProfile != null)
|
||||||
return Error(GlobalMessages.InsigniaRequestProfileDupicate);
|
return Error(GlobalMessages.InsigniaRequestProfileDupicate);
|
||||||
// var insigniaRequest = await _context.InsigniaRequests.FirstOrDefaultAsync(x => x.Period == insigniaPeriod);
|
|
||||||
|
//var insigniaRequest = await _context.InsigniaRequests.FirstOrDefaultAsync(x => x.Period == insigniaPeriod);
|
||||||
|
|
||||||
//var _orgProfile = await _context.ProfilePositions
|
//var _orgProfile = await _context.ProfilePositions
|
||||||
// .Where(x => x.ProfileId == profile.Id)
|
// .Where(x => x.ProfileId == profile.Id)
|
||||||
// .Where(x => x.OrganizationPosition != null)
|
// .Where(x => x.OrganizationPosition != null)
|
||||||
|
|
@ -1071,7 +1104,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
// .FirstOrDefaultAsync();
|
// .FirstOrDefaultAsync();
|
||||||
//var _org = await _context.Organizations
|
//var _org = await _context.Organizations
|
||||||
// .FirstOrDefaultAsync(x => x.Id == _orgProfile);
|
// .FirstOrDefaultAsync(x => x.Id == _orgProfile);
|
||||||
var insigniaRequest = await _context.InsigniaRequests.FirstOrDefaultAsync(x => x.Period == insigniaPeriod); // && x.OrganizationId == _org);
|
var insigniaRequest = await _context.InsigniaRequests.Include(x => x.Period).FirstOrDefaultAsync(x => x.Period.Id == insigniaPeriod.Id && x.OrganizationId == req.OcId);
|
||||||
if (insigniaRequest == null)
|
if (insigniaRequest == null)
|
||||||
{
|
{
|
||||||
//var orgProfile = await _context.ProfilePositions
|
//var orgProfile = await _context.ProfilePositions
|
||||||
|
|
@ -1086,43 +1119,46 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
//var org = await _context.Organizations
|
//var org = await _context.Organizations
|
||||||
// .FirstOrDefaultAsync(x => x.Id == orgProfile);
|
// .FirstOrDefaultAsync(x => x.Id == orgProfile);
|
||||||
|
|
||||||
// var org = _userProfileRepository.GetOc(orgProfile.Value, 0, AccessToken);
|
//var org = _userProfileRepository.GetOc(insigniaRequestProfile!.Request.OrganizationId, 0, AccessToken);
|
||||||
|
|
||||||
// if (org == null)
|
//if (org == null)
|
||||||
// return Error(GlobalMessages.OrganizationNotFound);
|
// return Error(GlobalMessages.OrganizationNotFound);
|
||||||
// insigniaRequest = new InsigniaRequest
|
insigniaRequest = new InsigniaRequest
|
||||||
// {
|
{
|
||||||
// Period = insigniaPeriod,
|
Period = insigniaPeriod,
|
||||||
// OrganizationId = org.RootId.Value,
|
OrganizationId = req.OcId,
|
||||||
// RequestStatus = "st1",
|
RequestStatus = "st1",
|
||||||
// RequestNote = "",
|
RequestNote = "",
|
||||||
// CreatedFullName = FullName ?? "System Administrator",
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
// CreatedUserId = UserId ?? "",
|
CreatedUserId = UserId ?? "",
|
||||||
// CreatedAt = DateTime.Now,
|
CreatedAt = DateTime.Now,
|
||||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
// LastUpdateUserId = UserId ?? "",
|
LastUpdateUserId = UserId ?? "",
|
||||||
// LastUpdatedAt = DateTime.Now,
|
LastUpdatedAt = DateTime.Now,
|
||||||
// };
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
//await _context.AddAsync(new InsigniaRequestProfile
|
|
||||||
//{
|
await _context.AddAsync(new InsigniaRequestProfile
|
||||||
// Status = "PENDING",
|
{
|
||||||
// Profile = profile,
|
Status = "PENDING",
|
||||||
// RequestInsignia = insignia,
|
ProfileId = profile.Id,
|
||||||
// Request = insigniaRequest,
|
RequestInsignia = insignia,
|
||||||
// Reason = req.Reason,
|
Request = insigniaRequest,
|
||||||
// RequestDate = DateTime.Now,
|
Reason = req.Reason,
|
||||||
// MatchingConditions = System.Text.Json.JsonSerializer.Serialize(new List<dynamic>()), // serialize to string
|
RequestDate = DateTime.Now,
|
||||||
// Salary = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
|
MatchingConditions = System.Text.Json.JsonSerializer.Serialize(new List<dynamic>()), // serialize to string
|
||||||
// CreatedFullName = FullName ?? "System Administrator",
|
Salary = profile.ProfileSalary == null || profile.ProfileSalary.Count == 0 ? 0 :
|
||||||
// CreatedUserId = UserId ?? "",
|
profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount, //profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
|
||||||
// CreatedAt = DateTime.Now,
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
CreatedUserId = UserId ?? "",
|
||||||
// LastUpdateUserId = UserId ?? "",
|
CreatedAt = DateTime.Now,
|
||||||
// LastUpdatedAt = DateTime.Now,
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
//});
|
LastUpdateUserId = UserId ?? "",
|
||||||
//await _context.SaveChangesAsync();
|
LastUpdatedAt = DateTime.Now,
|
||||||
|
});
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1265,26 +1301,26 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
// /// <summary>
|
/// <summary>
|
||||||
// /// รายชื่อผู้ได้รับเครื่องราชส่งข้อมูลไปบันทึกผลได้รับเครื่องราช(อัพเดทstatus)
|
/// รายชื่อผู้ได้รับเครื่องราชส่งข้อมูลไปบันทึกผลได้รับเครื่องราช(อัพเดทstatus)
|
||||||
// /// </summary>
|
/// </summary>
|
||||||
// /// <param name="insigniaPeriodId">Id รอบการยื่นขอ</param>
|
/// <param name="insigniaPeriodId">Id รอบการยื่นขอ</param>
|
||||||
// /// <returns></returns>
|
/// <returns></returns>
|
||||||
// /// <response code="200"></response>
|
/// <response code="200"></response>
|
||||||
// /// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||||
// /// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
// /// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
// [HttpGet("send/note/{insigniaPeriodId:length(36)}")]
|
[HttpGet("send/note/{insigniaPeriodId:length(36)}")]
|
||||||
// public async Task<ActionResult<ResponseObject>> SendPeriodToNoteUpdateStatus(Guid insigniaPeriodId)
|
public async Task<ActionResult<ResponseObject>> SendPeriodToNoteUpdateStatus(Guid insigniaPeriodId)
|
||||||
// {
|
{
|
||||||
// var insigniaPeriod = await _context.InsigniaPeriods
|
var insigniaPeriod = await _context.InsigniaPeriods
|
||||||
// .FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
.FirstOrDefaultAsync(x => x.Id == insigniaPeriodId);
|
||||||
// if (insigniaPeriod == null)
|
if (insigniaPeriod == null)
|
||||||
// return Error(GlobalMessages.InsigniaRequestNotFound);
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
// insigniaPeriod.IsLock = true;
|
insigniaPeriod.IsLock = true;
|
||||||
// await _context.SaveChangesAsync();
|
await _context.SaveChangesAsync();
|
||||||
// return Success();
|
return Success();
|
||||||
// }
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// list รอบบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
|
/// list รอบบันทึกผลการได้รับพระราชทานเครื่องราชอิสริยสภรณ์/การจ่ายใบกำกับ
|
||||||
|
|
@ -1517,16 +1553,18 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
[HttpPut("note/{insigniaNoteId:length(36)}")]
|
[HttpPut("note/{insigniaNoteId:length(36)}")]
|
||||||
public async Task<ActionResult<ResponseObject>> AddNoteProfile([FromBody] InsigniaNoteRequest req, Guid insigniaNoteId)
|
public async Task<ActionResult<ResponseObject>> AddNoteProfile([FromBody] InsigniaNoteRequest req, Guid insigniaNoteId)
|
||||||
{
|
{
|
||||||
var profile = await _context.Profiles
|
var profile = _userProfileRepository.GetOfficerProfileByCitizenId(req.CitizanId, AccessToken);
|
||||||
.Include(x => x.Salaries)
|
|
||||||
.FirstOrDefaultAsync(x => x.CitizenId == req.CitizanId);
|
|
||||||
if (profile == null)
|
if (profile == null)
|
||||||
return Error(GlobalMessages.DataNotFound);
|
return Error(GlobalMessages.DataNotFound);
|
||||||
|
|
||||||
var insignia = await _context.Insignias
|
var insignia = await _context.Insignias
|
||||||
.Include(x => x.InsigniaType)
|
.Include(x => x.InsigniaType)
|
||||||
.FirstOrDefaultAsync(x => x.Id == req.InsigniaId);
|
.FirstOrDefaultAsync(x => x.Id == req.InsigniaId);
|
||||||
if (insignia == null)
|
if (insignia == null)
|
||||||
return Error(GlobalMessages.InsigniaNotFound);
|
return Error(GlobalMessages.InsigniaNotFound);
|
||||||
|
|
||||||
var insigniaNote = await _context.InsigniaNotes
|
var insigniaNote = await _context.InsigniaNotes
|
||||||
.Include(x => x.InsigniaNoteProfiles)
|
.Include(x => x.InsigniaNoteProfiles)
|
||||||
//.ThenInclude(x => x.Profile)
|
//.ThenInclude(x => x.Profile)
|
||||||
|
|
@ -1534,118 +1572,120 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
||||||
if (insigniaNote == null)
|
if (insigniaNote == null)
|
||||||
return Error(GlobalMessages.InsigniaRequestNotFound);
|
return Error(GlobalMessages.InsigniaRequestNotFound);
|
||||||
|
|
||||||
//var profileInsignia = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.Profile.CitizenId == req.CitizanId);
|
var profileInsignia = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == profile.Id);
|
||||||
//if (profileInsignia == null)
|
|
||||||
//{
|
if (profileInsignia == null)
|
||||||
// var insigniaNoteProfile = new InsigniaNoteProfile
|
{
|
||||||
// {
|
var insigniaNoteProfile = new InsigniaNoteProfile
|
||||||
// Salary = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
|
{
|
||||||
// IsApprove = true,
|
Salary = profile.ProfileSalary == null || profile.ProfileSalary.Count() == 0 ? null : profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
|
||||||
// Status = "PENDING",
|
IsApprove = true,
|
||||||
// Profile = profile,
|
Status = "PENDING",
|
||||||
// Issue = req.Issue,
|
ProfileId = profile.Id,
|
||||||
// Number = req.Number,
|
Issue = req.Issue,
|
||||||
// DateReceive = req.DateReceive,
|
Number = req.Number,
|
||||||
// Date = req.Date,
|
DateReceive = req.DateReceive,
|
||||||
// VolumeNo = req.VolumeNo,
|
Date = req.Date,
|
||||||
// Section = req.Section,
|
VolumeNo = req.VolumeNo,
|
||||||
// Page = req.Page,
|
Section = req.Section,
|
||||||
// No = req.No,
|
Page = req.Page,
|
||||||
// DatePayment = req.DatePayment,
|
No = req.No,
|
||||||
// TypePayment = req.TypePayment,
|
DatePayment = req.DatePayment,
|
||||||
// Address = req.Address,
|
TypePayment = req.TypePayment,
|
||||||
// RequestInsignia = insignia,
|
Address = req.Address,
|
||||||
// OrganizationOrganizationReceive = req.OrganizationOrganizationReceive,
|
RequestInsignia = insignia,
|
||||||
// OrganizationOrganizationSend = req.OrganizationOrganizationSend,
|
OrganizationOrganizationReceive = req.OrganizationOrganizationReceive,
|
||||||
// InsigniaNote = insigniaNote,
|
OrganizationOrganizationSend = req.OrganizationOrganizationSend,
|
||||||
// CreatedFullName = FullName ?? "System Administrator",
|
InsigniaNote = insigniaNote,
|
||||||
// CreatedUserId = UserId ?? "",
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
// CreatedAt = DateTime.Now,
|
CreatedUserId = UserId ?? "",
|
||||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
CreatedAt = DateTime.Now,
|
||||||
// LastUpdateUserId = UserId ?? "",
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
// LastUpdatedAt = DateTime.Now,
|
LastUpdateUserId = UserId ?? "",
|
||||||
// };
|
LastUpdatedAt = DateTime.Now,
|
||||||
// if (req.DateReceive != null && req.Date != null)
|
};
|
||||||
// {
|
if (req.DateReceive != null && req.Date != null)
|
||||||
// insigniaNoteProfile.Status = "DONE";
|
{
|
||||||
// await _context.ProfileInsignias.AddAsync(new ProfileInsignia
|
insigniaNoteProfile.Status = "DONE";
|
||||||
// {
|
await _context.ProfileInsignias.AddAsync(new ProfileInsignia
|
||||||
// Year = insigniaNote.Year,
|
{
|
||||||
// No = req.No,
|
Year = insigniaNote.Year,
|
||||||
// Issue = req.VolumeNo,
|
No = req.No,
|
||||||
// VolumeNo = req.VolumeNo,
|
Issue = req.VolumeNo,
|
||||||
// // Volume = req.Volume,
|
VolumeNo = req.VolumeNo,
|
||||||
// Section = req.Section,
|
// Volume = req.Volume,
|
||||||
// Page = req.Page,
|
Section = req.Section,
|
||||||
// DateAnnounce = req.Date,
|
Page = req.Page,
|
||||||
// ReceiveDate = req.DateReceive,
|
DateAnnounce = req.Date,
|
||||||
// InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name,
|
ReceiveDate = req.DateReceive,
|
||||||
// Insignia = insignia,
|
InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name,
|
||||||
// // RefCommandNo = req.RefCommandNo,
|
Insignia = insignia,
|
||||||
// // RefCommandDate = req.RefCommandDate,
|
// RefCommandNo = req.RefCommandNo,
|
||||||
// Profile = profile,
|
// RefCommandDate = req.RefCommandDate,
|
||||||
// CreatedFullName = FullName ?? "System Administrator",
|
ProfileId = profile.Id,
|
||||||
// CreatedUserId = UserId ?? "",
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
// CreatedAt = DateTime.Now,
|
CreatedUserId = UserId ?? "",
|
||||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
CreatedAt = DateTime.Now,
|
||||||
// LastUpdateUserId = UserId ?? "",
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
// LastUpdatedAt = DateTime.Now,
|
LastUpdateUserId = UserId ?? "",
|
||||||
// });
|
LastUpdatedAt = DateTime.Now,
|
||||||
// }
|
});
|
||||||
// await _context.InsigniaNoteProfiles.AddAsync(insigniaNoteProfile);
|
}
|
||||||
//}
|
await _context.InsigniaNoteProfiles.AddAsync(insigniaNoteProfile);
|
||||||
//else
|
}
|
||||||
//{
|
else
|
||||||
// profileInsignia.DatePayment = req.DatePayment;
|
{
|
||||||
// profileInsignia.TypePayment = req.TypePayment;
|
profileInsignia.DatePayment = req.DatePayment;
|
||||||
// profileInsignia.Address = req.Address;
|
profileInsignia.TypePayment = req.TypePayment;
|
||||||
// if (profileInsignia.Status != "DONE")
|
profileInsignia.Address = req.Address;
|
||||||
// {
|
if (profileInsignia.Status != "DONE")
|
||||||
// profileInsignia.Issue = req.Issue;
|
{
|
||||||
// profileInsignia.Number = req.Number;
|
profileInsignia.Issue = req.Issue;
|
||||||
// profileInsignia.DateReceive = req.DateReceive;
|
profileInsignia.Number = req.Number;
|
||||||
// profileInsignia.Date = req.Date;
|
profileInsignia.DateReceive = req.DateReceive;
|
||||||
// profileInsignia.VolumeNo = req.VolumeNo;
|
profileInsignia.Date = req.Date;
|
||||||
// profileInsignia.Section = req.Section;
|
profileInsignia.VolumeNo = req.VolumeNo;
|
||||||
// profileInsignia.Page = req.Page;
|
profileInsignia.Section = req.Section;
|
||||||
// profileInsignia.No = req.No;
|
profileInsignia.Page = req.Page;
|
||||||
// // profileInsignia.DatePayment = req.DatePayment;
|
profileInsignia.No = req.No;
|
||||||
// // profileInsignia.TypePayment = req.TypePayment;
|
// profileInsignia.DatePayment = req.DatePayment;
|
||||||
// // profileInsignia.Address = req.Address;
|
// profileInsignia.TypePayment = req.TypePayment;
|
||||||
// profileInsignia.RequestInsignia = insignia;
|
// profileInsignia.Address = req.Address;
|
||||||
// profileInsignia.LastUpdateFullName = FullName ?? "System Administrator";
|
profileInsignia.RequestInsignia = insignia;
|
||||||
// profileInsignia.LastUpdateUserId = UserId ?? "";
|
profileInsignia.LastUpdateFullName = FullName ?? "System Administrator";
|
||||||
// profileInsignia.LastUpdatedAt = DateTime.Now;
|
profileInsignia.LastUpdateUserId = UserId ?? "";
|
||||||
// if (req.DateReceive != null && req.Date != null)
|
profileInsignia.LastUpdatedAt = DateTime.Now;
|
||||||
// {
|
if (req.DateReceive != null && req.Date != null)
|
||||||
// profileInsignia.Status = "DONE";
|
{
|
||||||
// await _context.ProfileInsignias.AddAsync(new ProfileInsignia
|
profileInsignia.Status = "DONE";
|
||||||
// {
|
await _context.ProfileInsignias.AddAsync(new ProfileInsignia
|
||||||
// Year = insigniaNote.Year,
|
{
|
||||||
// No = req.No,
|
Year = insigniaNote.Year,
|
||||||
// Issue = req.VolumeNo,
|
No = req.No,
|
||||||
// VolumeNo = req.VolumeNo,
|
Issue = req.VolumeNo,
|
||||||
// // Volume = req.Volume,
|
VolumeNo = req.VolumeNo,
|
||||||
// Section = req.Section,
|
//Volume = req.Volume,
|
||||||
// Page = req.Page,
|
Section = req.Section,
|
||||||
// DateAnnounce = req.Date,
|
Page = req.Page,
|
||||||
// ReceiveDate = req.DateReceive,
|
DateAnnounce = req.Date,
|
||||||
// InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name,
|
ReceiveDate = req.DateReceive,
|
||||||
// Insignia = insignia,
|
InsigniaType = insignia.InsigniaType == null ? null : insignia.InsigniaType.Name,
|
||||||
// // RefCommandNo = req.RefCommandNo,
|
Insignia = insignia,
|
||||||
// // RefCommandDate = req.RefCommandDate,
|
// RefCommandNo = req.RefCommandNo,
|
||||||
// ProfileId = profile.Id,
|
// RefCommandDate = req.RefCommandDate,
|
||||||
// CreatedFullName = FullName ?? "System Administrator",
|
ProfileId = profile.Id,
|
||||||
// CreatedUserId = UserId ?? "",
|
CreatedFullName = FullName ?? "System Administrator",
|
||||||
// CreatedAt = DateTime.Now,
|
CreatedUserId = UserId ?? "",
|
||||||
// LastUpdateFullName = FullName ?? "System Administrator",
|
CreatedAt = DateTime.Now,
|
||||||
// LastUpdateUserId = UserId ?? "",
|
LastUpdateFullName = FullName ?? "System Administrator",
|
||||||
// LastUpdatedAt = DateTime.Now,
|
LastUpdateUserId = UserId ?? "",
|
||||||
// });
|
LastUpdatedAt = DateTime.Now,
|
||||||
// }
|
});
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
//await _context.SaveChangesAsync();
|
}
|
||||||
|
|
||||||
|
await _context.SaveChangesAsync();
|
||||||
return Success();
|
return Success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,5 +9,7 @@ namespace BMA.EHR.Insignia.Service.Requests
|
||||||
public Guid insigniaId { get; set; }
|
public Guid insigniaId { get; set; }
|
||||||
public Guid insigniaPeriodId { get; set; }
|
public Guid insigniaPeriodId { get; set; }
|
||||||
public string? Reason { get; set; }
|
public string? Reason { get; set; }
|
||||||
|
|
||||||
|
public Guid OcId { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue