fix bug api ออกคำสั่ง

และ รายงานคำสั่ง
This commit is contained in:
Suphonchai Phoonsawat 2023-09-06 13:25:50 +07:00
parent e340beb79d
commit ac07b6d07d
9 changed files with 130 additions and 60 deletions

View file

@ -57,7 +57,7 @@ namespace BMA.EHR.Application.Repositories.Commands
#region " Methods "
public async Task<List<dynamic>> GetCommandType01AttachmentAsync(Guid id)
public async Task<List<CommandType01Response>> GetCommandType01AttachmentAsync(Guid id)
{
try
{
@ -70,18 +70,33 @@ namespace BMA.EHR.Application.Repositories.Commands
throw new Exception(GlobalMessages.CommandNotFound);
}
var ret = new List<dynamic>();
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementProfile>()
.Include(x => x.Placement)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
.Include(x => x.PositionLevel)
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
select new CommandType01Response
{
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Oc = _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
PositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
PositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
PositionType = p.PositionType == null ? "" : p.PositionType.Name,
PositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name,
Salary = p.Amount == null ? 0 : p.Amount.Value,
AppointDate = p.RecruitDate == null ? "" : p.RecruitDate.Value.ToThaiFullDate3(),
ExamNumber = p.ExamNumber == null ? 0 : p.ExamNumber.Value,
PlacementName = $"{p.Placement.Name} ครั้งที่ {p.Placement.Round}/{p.Placement.Year.ToThaiYear()}"
}).ToList();
foreach (var c in raw_data)
{
ret.Add(new
{
FullName = $"{c.Prefix}{c.FirstName} {c.LastName}",
PositionName = ""
});
}
return ret;
return report_data;
}
catch
{
@ -89,7 +104,7 @@ namespace BMA.EHR.Application.Repositories.Commands
}
}
public async Task<List<dynamic>> GetCommandType02AttachmentAsync(Guid id)
public async Task<List<CommandType01Response>> GetCommandType02AttachmentAsync(Guid id)
{
try
{
@ -102,18 +117,32 @@ namespace BMA.EHR.Application.Repositories.Commands
throw new Exception(GlobalMessages.CommandNotFound);
}
var ret = new List<dynamic>();
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementProfile>()
.Include(x => x.Placement)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
.Include(x => x.PositionLevel)
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
select new CommandType01Response
{
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Oc = _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
PositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
PositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
PositionType = p.PositionType == null ? "" : p.PositionType.Name,
PositionNumber = p.PositionNumber == null ? "" : p.PositionNumber.Name,
Salary = p.Amount == null ? 0 : p.Amount.Value,
AppointDate = p.RecruitDate == null ? "" : p.RecruitDate.Value.ToThaiFullDate3(),
ExamNumber = p.ExamNumber == null ? 0 : p.ExamNumber.Value,
PlacementName = $"{p.Placement.Name} ครั้งที่ {p.Placement.Round}/{p.Placement.Year.ToThaiYear()}"
}).ToList();
foreach (var c in raw_data)
{
ret.Add(new
{
FullName = $"{c.Prefix}{c.FirstName} {c.LastName}",
PositionName = ""
});
}
return ret;
return report_data;
}
catch
{
@ -306,7 +335,7 @@ namespace BMA.EHR.Application.Repositories.Commands
}
var report_data = (from r in raw_data
join p in _dbContext.Set<PlacementProfile>()
join p in _dbContext.Set<PlacementAppointment>()
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
@ -364,6 +393,17 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<RetirementOther>()
.Include(x => x.Profile)
.ThenInclude(x => x.Salaries)
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionType)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
@ -371,24 +411,17 @@ namespace BMA.EHR.Application.Repositories.Commands
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
join pf in _dbContext.Set<Profile>()
.Include(x => x.Position)
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
on r.CitizenId equals pf.CitizenId
select new CommandType03Response
{
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
OldPositionName = pf.Position == null ? "" : pf.Position.Name,
OldPositionLevel = pf.PositionLevel == null ? "" : pf.PositionLevel.Name,
OldPositionType = pf.PositionType == null ? "" : pf.PositionType.Name,
OldPositionNumber = pf.PosNo == null ? "" : pf.PosNo.Name,
OldSalary = pf.Salaries == null || pf.Salaries.Count == 0 ? 0 : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value,
NewOc = _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
OldOc = p.Profile.Oc == null ? "" : p.Profile.Oc.Replace("/", " "),
OldPositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
OldPositionLevel = p.Profile.PositionLevel == null ? "" : p.Profile.PositionLevel.Name,
OldPositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name,
OldPositionNumber = p.Profile.PosNo == null ? "" : p.Profile.PosNo.Name,
OldSalary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? 0 : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value,
NewOc = p.OrganizationPosition == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
@ -421,6 +454,17 @@ namespace BMA.EHR.Application.Repositories.Commands
var report_data = (from r in raw_data
join p in _dbContext.Set<RetirementOther>()
.Include(x => x.Profile)
.ThenInclude(x => x.Salaries)
.Include(x => x.Profile)
.ThenInclude(x => x.Position)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionLevel)
.Include(x => x.Profile)
.ThenInclude(x => x.PositionType)
.Include(x => x.Profile)
.ThenInclude(x => x.PosNo)
.Include(x => x.OrganizationPosition)
.ThenInclude(x => x.Organization)
.Include(x => x.PositionPath)
@ -428,24 +472,17 @@ namespace BMA.EHR.Application.Repositories.Commands
.Include(x => x.PositionNumber)
.Include(x => x.PositionType)
on r.RefPlacementProfileId equals p.Id
join pf in _dbContext.Set<Profile>()
.Include(x => x.Position)
.Include(x => x.PositionLevel)
.Include(x => x.PositionType)
.Include(x => x.PosNo)
.Include(x => x.Salaries)
on r.CitizenId equals pf.CitizenId
select new CommandType03Response
{
CitizenId = r.CitizenId,
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
OldOc = pf.Oc == null ? "" : pf.Oc.Replace("/", " "),
OldPositionName = pf.Position == null ? "" : pf.Position.Name,
OldPositionLevel = pf.PositionLevel == null ? "" : pf.PositionLevel.Name,
OldPositionType = pf.PositionType == null ? "" : pf.PositionType.Name,
OldPositionNumber = pf.PosNo == null ? "" : pf.PosNo.Name,
OldSalary = pf.Salaries == null || pf.Salaries.Count == 0 ? 0 : pf.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value,
NewOc = _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
OldOc = p.Profile.Oc == null ? "" : p.Profile.Oc.Replace("/", " "),
OldPositionName = p.Profile.Position == null ? "" : p.Profile.Position.Name,
OldPositionLevel = p.Profile.PositionLevel == null ? "" : p.Profile.PositionLevel.Name,
OldPositionType = p.Profile.PositionType == null ? "" : p.Profile.PositionType.Name,
OldPositionNumber = p.Profile.PosNo == null ? "" : p.Profile.PosNo.Name,
OldSalary = p.Profile.Salaries == null || p.Profile.Salaries.Count == 0 ? 0 : p.Profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value,
NewOc = p.OrganizationPosition == null ? "" : _organizationCommonRepository.GetOrganizationNameFullPath(p.OrganizationPosition!.Organization!.Id, false, false, "/"),
NewPositionName = p.PositionPath == null ? "" : p.PositionPath!.Name,
NewPositionLevel = p.PositionLevel == null ? "" : p.PositionLevel.Name,
NewPositionType = p.PositionType == null ? "" : p.PositionType.Name,
@ -473,7 +510,7 @@ namespace BMA.EHR.Application.Repositories.Commands
.Select(r => new CommandType11Response
{
CommandNo = r.Command.CommandNo,
CommandYear = r.Command.CommandYear,
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString(),
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(),
IssuerOrganizationName = r.Command.IssuerOrganizationName,
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
@ -508,7 +545,7 @@ namespace BMA.EHR.Application.Repositories.Commands
.Select(r => new CommandType11Response
{
CommandNo = r.Command.CommandNo,
CommandYear = r.Command.CommandYear,
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString(),
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(),
IssuerOrganizationName = r.Command.IssuerOrganizationName,
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
@ -724,7 +761,7 @@ namespace BMA.EHR.Application.Repositories.Commands
select new CommandType18Response
{
CommandNo = r.Command.CommandNo,
CommandYear = r.Command.CommandYear,
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString(),
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(),
IssuerOrganizationName = r.Command.IssuerOrganizationName,
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
@ -776,7 +813,7 @@ namespace BMA.EHR.Application.Repositories.Commands
select new CommandType18Response
{
CommandNo = r.Command.CommandNo,
CommandYear = r.Command.CommandYear,
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString(),
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(),
IssuerOrganizationName = r.Command.IssuerOrganizationName,
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,
@ -828,7 +865,7 @@ namespace BMA.EHR.Application.Repositories.Commands
select new CommandType18Response
{
CommandNo = r.Command.CommandNo,
CommandYear = r.Command.CommandYear,
CommandYear = r.Command.CommandYear.ToInteger().ToThaiYear().ToString(),
CommandAffectDate = r.Command.CommandAffectDate == null ? "" : r.Command.CommandAffectDate.Value.ToThaiFullDate3(),
IssuerOrganizationName = r.Command.IssuerOrganizationName,
AuthorizedUserFullName = r.Command.AuthorizedUserFullName,

View file

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BMA.EHR.Application.Responses.Reports
{
public class CommandType01Response
{
public string CitizenId { get; set; } = string.Empty;
public string FullName { get; set; } = string.Empty;
public string Oc { get; set; } = string.Empty;
public string PositionName { get; set; } = string.Empty;
public string PositionLevel { get; set; } = string.Empty;
public string PositionType { get; set; } = string.Empty;
public string PositionNumber { get; set; } = string.Empty;
public double Salary { get; set; } = 0;
public string AppointDate { get; set; } = string.Empty;
public int ExamNumber { get; set; } = 0;
public string PlacementName { get; set;} = string.Empty;
}
}

View file

@ -2747,7 +2747,7 @@ namespace BMA.EHR.Command.Service.Controllers
case "C-PM-01":
case "C-PM-02":
case "C-PM-03":
case "c-PM-04":
case "C-PM-04":
{
foreach (var r in receivers)
{

View file

@ -836,7 +836,7 @@ namespace BMA.EHR.Report.Service.Controllers
throw new Exception(GlobalMessages.CommandNotFound);
}
var data = await _commandReportRepository.GetCommandType05_06AttachmentAsync(commandId);
var data = await _commandReportRepository.GetCommandType07AttachmentAsync(commandId);
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Reports", $"07-แนบท้ายคำสั่งย้าย.trdp");