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