แก้รายงานคำสั่ง
This commit is contained in:
parent
1f5edf20ed
commit
652a9f2b16
11 changed files with 130 additions and 29 deletions
|
|
@ -16,7 +16,9 @@ using Microsoft.AspNetCore.Http;
|
|||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Newtonsoft.Json;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Headers;
|
||||
using System.Text;
|
||||
using Command = BMA.EHR.Domain.Models.Commands.Core.Command;
|
||||
using Profile = BMA.EHR.Domain.Models.HR.Profile;
|
||||
|
||||
|
|
@ -6033,6 +6035,23 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
var seq = 1;
|
||||
foreach (var item in ap)
|
||||
{
|
||||
|
||||
PlacementSalaryResponse salary = new();
|
||||
// ให้ Update Salary เฉพาะของ Command 01-04
|
||||
switch (command.CommandType.CommandCode.ToUpper())
|
||||
{
|
||||
case "C-PM-01":
|
||||
case "C-PM-02":
|
||||
case "C-PM-03":
|
||||
case "c-PM-04":
|
||||
salary = await GetPlacementSalaryAsync(item.RefPlacementProfileId.Value);
|
||||
break;
|
||||
default:
|
||||
salary = await GetCommandReceiverSalary(item.RefPlacementProfileId.Value);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
var receiver = new CommandReceiver
|
||||
{
|
||||
Sequence = seq,
|
||||
|
|
@ -6040,7 +6059,10 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
Prefix = item.Prefix,
|
||||
FirstName = item.FirstName!,
|
||||
LastName = item.LastName!,
|
||||
RefPlacementProfileId = item.RefPlacementProfileId
|
||||
RefPlacementProfileId = item.RefPlacementProfileId,
|
||||
Amount = salary == null ? 0 : salary.SalaryAmount,
|
||||
MouthSalaryAmount = salary == null ? 0 : salary.MonthSalaryAmount,
|
||||
PositionSalaryAmount = salary == null ? 0 : salary.PositionSalaryAmount
|
||||
};
|
||||
|
||||
seq++;
|
||||
|
|
@ -6217,6 +6239,80 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
|
||||
#endregion
|
||||
|
||||
public async Task<string> GetReceiverPositionByCommandIdAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ret = string.Empty;
|
||||
|
||||
var data = await (from r in _dbContext.Set<CommandReceiver>()
|
||||
.Include(x => x.Command)
|
||||
join pf in _dbContext.Set<PlacementProfile>()
|
||||
.Include(x => x.PositionPath)
|
||||
on r.RefPlacementProfileId equals pf.Id
|
||||
where r.Command.Id == id
|
||||
select new
|
||||
{
|
||||
r.RefPlacementProfileId,
|
||||
Position = pf.PositionPath!.Name
|
||||
}).ToListAsync();
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
foreach (var d in data)
|
||||
{
|
||||
if (!ret.Contains($"{d.Position},"))
|
||||
ret += $"{d.Position},";
|
||||
}
|
||||
|
||||
ret = ret.Substring(0, ret.Length - 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> GetReceiverPosition2ByCommandIdAsync(Guid id)
|
||||
{
|
||||
try
|
||||
{
|
||||
var ret = string.Empty;
|
||||
|
||||
var data = await (from r in _dbContext.Set<CommandReceiver>()
|
||||
.Include(x => x.Command)
|
||||
join pf in _dbContext.Set<PlacementAppointment>()
|
||||
.Include(x => x.PositionPath)
|
||||
on r.RefPlacementProfileId equals pf.Id
|
||||
where r.Command.Id == id
|
||||
select new
|
||||
{
|
||||
r.RefPlacementProfileId,
|
||||
Position = pf.PositionPath!.Name
|
||||
}).ToListAsync();
|
||||
|
||||
if (data.Count > 0)
|
||||
{
|
||||
foreach (var d in data)
|
||||
{
|
||||
if (!ret.Contains($"{d.Position},"))
|
||||
ret += $"{d.Position},";
|
||||
}
|
||||
|
||||
ret = ret.Substring(0, ret.Length - 1);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<CommandDeployment>> GetDeploymentByCommandIdAsync(Guid id)
|
||||
{
|
||||
try
|
||||
|
|
@ -6550,12 +6646,12 @@ namespace BMA.EHR.Application.Repositories.Commands
|
|||
|
||||
if (profile != null && profile.Salaries.Count() > 0)
|
||||
{
|
||||
SalaryAmount = cmdReceiver.Amount == null ? profile.Salaries == null ? 0 :
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount != null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value : 0 : 0;
|
||||
SalaryAmount = cmdReceiver.Amount == null ? profile.Salaries == null ? 0 :
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount != null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount.Value : 0 : 0;
|
||||
PositionSalaryAmount = cmdReceiver.PositionSalaryAmount == null ? profile.Salaries == null ? 0 :
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount != null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount.Value : 0 : 0;
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount != null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().PositionSalaryAmount.Value : 0 : 0;
|
||||
MonthSalaryAmount = cmdReceiver.MouthSalaryAmount == null ? profile.Salaries == null ? 0 :
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().MouthSalaryAmount != null ?profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().MouthSalaryAmount.Value : 0 : 0;
|
||||
profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().MouthSalaryAmount != null ? profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().MouthSalaryAmount.Value : 0 : 0;
|
||||
}
|
||||
|
||||
return new PlacementSalaryResponse
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue