fix : Insignia Request Controlle
(แสดงข้อมูลของผู้ขอ)
This commit is contained in:
parent
cdfb282c32
commit
da6e4acc52
2 changed files with 457 additions and 432 deletions
|
|
@ -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
|
||||
}
|
||||
|
|
@ -635,34 +643,34 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
|
||||
#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 +853,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>
|
||||
/// ย้ายขอมูลไปเป็น คนที่ไม่ยื่นขอ
|
||||
|
|
@ -1061,7 +1070,9 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
var insigniaRequestProfile = await _context.InsigniaRequestProfiles.FirstOrDefaultAsync(x => x.ProfileId == profile.Id && x.Request.Period == insigniaPeriod);
|
||||
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 +1082,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.FirstOrDefaultAsync(x => x.Period == insigniaPeriod && x.OrganizationId == insigniaRequestProfile!.Request.OrganizationId);
|
||||
if (insigniaRequest == null)
|
||||
{
|
||||
//var orgProfile = await _context.ProfilePositions
|
||||
|
|
@ -1086,43 +1097,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 = org!.RootId.Value,
|
||||
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 +1279,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 +1531,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 +1550,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();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue