Merge branch 'develop' into working
Some checks failed
release-dev / release-dev (push) Failing after 12s
Some checks failed
release-dev / release-dev (push) Failing after 12s
This commit is contained in:
commit
449e31ba2a
10 changed files with 20017 additions and 204 deletions
|
|
@ -553,24 +553,53 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
|||
// };
|
||||
// _appDbContext.Set<ProfileLeave>().Add(profileLeave);
|
||||
var _baseAPI = _configuration["API"];
|
||||
var apiUrlSalary = $"{_baseAPI}/org/profile/leave";
|
||||
using (var client = new HttpClient())
|
||||
var apiUrlSalary = string.Empty;
|
||||
if (profile.ProfileType == "OFFICER")
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||
apiUrlSalary = $"{_baseAPI}/org/profile/leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
profileId = profile.Id,
|
||||
leaveTypeId = rawData?.Type?.Id ?? null,
|
||||
dateLeaveStart = rawData.LeaveStartDate,
|
||||
dateLeaveEnd = rawData.LeaveEndDate,
|
||||
totalLeave = 0,//หน้า fe ไม่ได้ใช้
|
||||
leaveCount = 0,//หน้า fe ไม่ได้ใช้
|
||||
leaveDays = rawData.LeaveTotal,
|
||||
status = "approve",
|
||||
reason = rawData.LeaveDetail,
|
||||
});
|
||||
// var _result = await _res.Content.ReadAsStringAsync();
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||
{
|
||||
profileId = profile.Id,
|
||||
leaveTypeId = rawData?.Type?.Id ?? null,
|
||||
dateLeaveStart = rawData.LeaveStartDate,
|
||||
dateLeaveEnd = rawData.LeaveEndDate,
|
||||
totalLeave = 0,//หน้า fe ไม่ได้ใช้
|
||||
leaveCount = 0,//หน้า fe ไม่ได้ใช้
|
||||
leaveDays = rawData.LeaveTotal,
|
||||
status = "approve",
|
||||
reason = rawData.LeaveDetail,
|
||||
});
|
||||
// var _result = await _res.Content.ReadAsStringAsync();
|
||||
}
|
||||
}
|
||||
else if (profile.ProfileType == "EMPLOYEE")
|
||||
{
|
||||
apiUrlSalary = $"{_baseAPI}/org/profile-employee/leave";
|
||||
using (var client = new HttpClient())
|
||||
{
|
||||
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken.Replace("Bearer ", ""));
|
||||
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
|
||||
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
|
||||
{
|
||||
profileEmployeeId = profile.Id,
|
||||
leaveTypeId = rawData?.Type?.Id ?? null,
|
||||
dateLeaveStart = rawData.LeaveStartDate,
|
||||
dateLeaveEnd = rawData.LeaveEndDate,
|
||||
totalLeave = 0,
|
||||
leaveCount = 0,
|
||||
leaveDays = rawData.LeaveTotal,
|
||||
status = "approve",
|
||||
reason = rawData.LeaveDetail,
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("ไม่สามารถทำรายการได้");
|
||||
}
|
||||
await _appDbContext.SaveChangesAsync();
|
||||
|
||||
|
|
|
|||
|
|
@ -243,6 +243,66 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetProfileByKeycloakIdDto>> GetProfileWithKeycloakAllOfficer(string? accessToken, string? node, string? nodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-officer";
|
||||
var apiKey = _configuration["API_KEY"];
|
||||
var body = new
|
||||
{
|
||||
node = node,
|
||||
nodeId = nodeId,
|
||||
};
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
|
||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdResultDto>(apiResult);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetProfileByKeycloakIdDto>> GetProfileWithKeycloakAllEmployee(string? accessToken, string? node, string? nodeId)
|
||||
{
|
||||
try
|
||||
{
|
||||
var apiPath = $"{_configuration["API"]}/org/dotnet/keycloak-all-employee";
|
||||
var apiKey = _configuration["API_KEY"];
|
||||
var body = new
|
||||
{
|
||||
node = node,
|
||||
nodeId = nodeId,
|
||||
};
|
||||
|
||||
var profiles = new List<SearchProfileDto>();
|
||||
|
||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||
if (apiResult != null)
|
||||
{
|
||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdResultDto>(apiResult);
|
||||
if (raw != null)
|
||||
return raw.Result;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
catch
|
||||
{
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<List<SearchProfileDto>> SearchProfile(string? citizenId, string? firstName, string? lastName, string accessToken)
|
||||
{
|
||||
try
|
||||
|
|
@ -568,7 +628,7 @@ namespace BMA.EHR.Application.Repositories
|
|||
}
|
||||
}
|
||||
|
||||
public async Task<List<GetActiveRootDto>> GetActiveRootAsync(string? accessToken,Guid? revisionId)
|
||||
public async Task<List<GetActiveRootDto>> GetActiveRootAsync(string? accessToken, Guid? revisionId)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
|||
|
|
@ -82,5 +82,13 @@ namespace BMA.EHR.Domain.Models.Insignias
|
|||
public double? PositionSalaryAmount { get; set; }
|
||||
public Guid? RootId { get; set; }
|
||||
public string? Root { get; set; }
|
||||
public Guid? Child1Id { get; set; }
|
||||
public string? Child1 { get; set; }
|
||||
public Guid? Child2Id { get; set; }
|
||||
public string? Child2 { get; set; }
|
||||
public Guid? Child3Id { get; set; }
|
||||
public string? Child3 { get; set; }
|
||||
public Guid? Child4Id { get; set; }
|
||||
public string? Child4 { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,5 +74,13 @@ namespace BMA.EHR.Domain.Models.Insignias
|
|||
public string? LastInsigniaName { get; set; }
|
||||
public Guid? RootId { get; set; }
|
||||
public string? Root { get; set; }
|
||||
public Guid? Child1Id { get; set; }
|
||||
public string? Child1 { get; set; }
|
||||
public Guid? Child2Id { get; set; }
|
||||
public string? Child2 { get; set; }
|
||||
public Guid? Child3Id { get; set; }
|
||||
public string? Child3 { get; set; }
|
||||
public Guid? Child4Id { get; set; }
|
||||
public string? Child4 { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
19220
BMA.EHR.Infrastructure/Migrations/20241210153801_update table insigniaprofile add child.Designer.cs
generated
Normal file
19220
BMA.EHR.Infrastructure/Migrations/20241210153801_update table insigniaprofile add child.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,195 @@
|
|||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace BMA.EHR.Infrastructure.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class updatetableinsigniaprofileaddchild : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Child1",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Child1Id",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Child2",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Child2Id",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Child3",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Child3Id",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Child4",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Child4Id",
|
||||
table: "InsigniaRequestProfiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Child1",
|
||||
table: "InsigniaNoteProfiles",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Child1Id",
|
||||
table: "InsigniaNoteProfiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Child2",
|
||||
table: "InsigniaNoteProfiles",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Child2Id",
|
||||
table: "InsigniaNoteProfiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Child3",
|
||||
table: "InsigniaNoteProfiles",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Child3Id",
|
||||
table: "InsigniaNoteProfiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddColumn<string>(
|
||||
name: "Child4",
|
||||
table: "InsigniaNoteProfiles",
|
||||
type: "longtext",
|
||||
nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "Child4Id",
|
||||
table: "InsigniaNoteProfiles",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child1",
|
||||
table: "InsigniaRequestProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child1Id",
|
||||
table: "InsigniaRequestProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child2",
|
||||
table: "InsigniaRequestProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child2Id",
|
||||
table: "InsigniaRequestProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child3",
|
||||
table: "InsigniaRequestProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child3Id",
|
||||
table: "InsigniaRequestProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child4",
|
||||
table: "InsigniaRequestProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child4Id",
|
||||
table: "InsigniaRequestProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child1",
|
||||
table: "InsigniaNoteProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child1Id",
|
||||
table: "InsigniaNoteProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child2",
|
||||
table: "InsigniaNoteProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child2Id",
|
||||
table: "InsigniaNoteProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child3",
|
||||
table: "InsigniaNoteProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child3Id",
|
||||
table: "InsigniaNoteProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child4",
|
||||
table: "InsigniaNoteProfiles");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "Child4Id",
|
||||
table: "InsigniaNoteProfiles");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -6018,6 +6018,30 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Property<DateTime?>("BirthDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Child1")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("Child1Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Child2")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("Child2Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Child3")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("Child3Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Child4")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("Child4Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CitizenId")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
|
|
@ -6403,6 +6427,30 @@ namespace BMA.EHR.Infrastructure.Migrations
|
|||
b.Property<DateTime?>("BirthDate")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<string>("Child1")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("Child1Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Child2")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("Child2Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Child3")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("Child3Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Child4")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("Child4Id")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("CitizenId")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
|
|
|
|||
|
|
@ -933,6 +933,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
LastInsigniaName = lastInsignia,
|
||||
Root = profile.Root,
|
||||
RootId = profile.RootId,
|
||||
Child1 = profile.Child1,
|
||||
Child1Id = profile.Child1Id,
|
||||
Child2 = profile.Child2,
|
||||
Child2Id = profile.Child2Id,
|
||||
Child3 = profile.Child3,
|
||||
Child3Id = profile.Child3Id,
|
||||
Child4 = profile.Child4,
|
||||
Child4Id = profile.Child4Id,
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
@ -1080,6 +1088,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
PositionSalaryAmount = profileOld.PositionSalaryAmount,
|
||||
Root = profileOld.Root,
|
||||
RootId = profileOld.RootId,
|
||||
Child1 = profileOld.Child1,
|
||||
Child1Id = profileOld.Child1Id,
|
||||
Child2 = profileOld.Child2,
|
||||
Child2Id = profileOld.Child2Id,
|
||||
Child3 = profileOld.Child3,
|
||||
Child3Id = profileOld.Child3Id,
|
||||
Child4 = profileOld.Child4,
|
||||
Child4Id = profileOld.Child4Id,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -1838,6 +1854,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
PositionSalaryAmount = pf.PositionSalaryAmount,
|
||||
RootId = pf.RootId,
|
||||
Root = pf.Root,
|
||||
Child1 = pf.Child1,
|
||||
Child1Id = pf.Child1Id,
|
||||
Child2 = pf.Child2,
|
||||
Child2Id = pf.Child2Id,
|
||||
Child3 = pf.Child3,
|
||||
Child3Id = pf.Child3Id,
|
||||
Child4 = pf.Child4,
|
||||
Child4Id = pf.Child4Id,
|
||||
LastUpdateFullName = FullName ?? "System Administrator",
|
||||
LastUpdateUserId = UserId ?? "",
|
||||
LastUpdatedAt = DateTime.Now,
|
||||
|
|
@ -2014,6 +2038,14 @@ namespace BMA.EHR.Insignia.Service.Controllers
|
|||
PositionSalaryAmount = _profile.PositionSalaryAmount,
|
||||
Root = _profile.Root,
|
||||
RootId = _profile.RootId,
|
||||
Child1 = _profile.Child1,
|
||||
Child1Id = _profile.Child1Id,
|
||||
Child2 = _profile.Child2,
|
||||
Child2Id = _profile.Child2Id,
|
||||
Child3 = _profile.Child3,
|
||||
Child3Id = _profile.Child3Id,
|
||||
Child4 = _profile.Child4,
|
||||
Child4Id = _profile.Child4Id,
|
||||
};
|
||||
}
|
||||
else
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ using Newtonsoft.Json;
|
|||
using Swashbuckle.AspNetCore.Annotations;
|
||||
using System.Globalization;
|
||||
using System.Security.Claims;
|
||||
using BMA.EHR.Application.Responses.Profiles;
|
||||
|
||||
namespace BMA.EHR.Leave.Service.Controllers
|
||||
{
|
||||
|
|
@ -731,20 +732,19 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LV2_035 - รายงานบัญชีแสดงวันลา ขรก
|
||||
/// LV2_035 - รายงานสำหรับการลางานของข้าราชการ-กรุงเทพมหานครสามัญ และลูกจ้างประจำกรุงเทพมหานคร
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("leaveday/officer")]
|
||||
[HttpPost("leaveday/{type:string}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetOfficerLeaveDayReport([FromBody] GetLeaveReportDto req)
|
||||
public async Task<ActionResult<ResponseObject>> GetLeaveDayReport([FromBody] GetLeaveDetailByNodeReportDto req, string type)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -754,8 +754,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
//var profile = await _userProfileRepository.SearchProfile(null, null, null);
|
||||
var profile = await _userProfileRepository.GetProfileWithKeycloak(AccessToken);
|
||||
var profile = new List<GetProfileByKeycloakIdDto>();
|
||||
if (type.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId);
|
||||
}
|
||||
if (profile.Count > 0)
|
||||
{
|
||||
profile = profile.Where(p => p.IsLeave == false).ToList();
|
||||
|
|
@ -767,8 +774,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
var count = 1;
|
||||
var employees = new List<dynamic>();
|
||||
|
||||
|
||||
|
||||
foreach (var p in profile)
|
||||
{
|
||||
var keycloakUserId = p.Keycloak ?? Guid.Empty;
|
||||
|
|
@ -810,7 +815,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
{
|
||||
|
|
@ -889,19 +893,17 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
var result = new
|
||||
{
|
||||
template = "LeaveHalfYear-ขรก",
|
||||
reportName = "LeaveHalfYear-Officer",
|
||||
template = type.Trim().ToUpper() == "OFFICER" ? "LeaveHalfYear-ขรก" : "LeaveHalfYear-ลูกจ้าง",
|
||||
reportName = type.Trim().ToUpper() == "OFFICER" ? "LeaveHalfYear-Officer" : "LeaveHalfYear-Employee",
|
||||
data = new
|
||||
{
|
||||
leaveDateStart = req.StartDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
leaveDateEnd = req.EndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
organizationName = profile.First().Oc ?? "",
|
||||
leaveTitleType = req.Type == "FULL" ? "หนึ่งปี" : "ครึ่งปี",
|
||||
employees = employees
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
|
@ -911,18 +913,18 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_036 - รายงานบัญชีแสดงวันลา ลูกจ้าง
|
||||
/// LV2_037 - รายงานการเข้างานจำแนกรายวัน รายสัปดาห์ รายเดือน แยกรายหน่วยงาน/ส่วนราชการ
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("leaveday/employee")]
|
||||
[HttpPost("time-records/{type:string}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetEmployeeLeaveDayReport([FromBody] GetLeaveReportDto req)
|
||||
public async Task<ActionResult<ResponseObject>> GetTimeRecordsOfficerReport([FromBody] GetLeaveDetailByNodeReportDto req, string type)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -932,158 +934,15 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var profile = await _userProfileRepository.SearchProfileEmployee(null, null, null, AccessToken ?? "");
|
||||
var count = 1;
|
||||
var employees = new List<dynamic>();
|
||||
|
||||
// get leave day
|
||||
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
||||
var leaveCounts = await _leaveRequestRepository.GetCountApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
||||
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
|
||||
|
||||
|
||||
|
||||
foreach (var p in profile)
|
||||
var profile = new List<GetProfileByKeycloakIdDto>();
|
||||
if (type.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
var keycloakUserId = p.Keycloak ?? Guid.Empty;
|
||||
|
||||
var sickDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-001");
|
||||
var sickDayCount = sickDay != null ? sickDay.SumLeaveDay : 0;
|
||||
var sickCountData = leaveCounts.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-001");
|
||||
var sickCount = sickCountData != null ? sickCountData.CountLeave : 0;
|
||||
|
||||
var personalDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-002");
|
||||
var personalDayCount = personalDay != null ? personalDay.SumLeaveDay : 0;
|
||||
var personalCountData = leaveCounts.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-002");
|
||||
var personalCount = personalCountData != null ? personalCountData.CountLeave : 0;
|
||||
|
||||
var maternityDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-003");
|
||||
var maternityDayCount = maternityDay != null ? maternityDay.SumLeaveDay : 0;
|
||||
var maternityCountData = leaveCounts.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-003");
|
||||
var maternityCount = maternityCountData != null ? maternityCountData.CountLeave : 0;
|
||||
|
||||
var wifeDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-004");
|
||||
var wifeDayCount = wifeDay != null ? wifeDay.SumLeaveDay : 0;
|
||||
var wifeCountData = leaveCounts.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-004");
|
||||
var wifeCount = wifeCountData != null ? wifeCountData.CountLeave : 0;
|
||||
|
||||
var restDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-005");
|
||||
var restDayCount = restDay != null ? restDay.SumLeaveDay : 0;
|
||||
var restCountData = leaveCounts.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-005");
|
||||
var restCount = restCountData != null ? restCountData.CountLeave : 0;
|
||||
|
||||
var ordainDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-006");
|
||||
var ordainDayCount = ordainDay != null ? ordainDay.SumLeaveDay : 0;
|
||||
var ordainCountData = leaveCounts.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-006");
|
||||
var ordainCount = ordainCountData != null ? ordainCountData.CountLeave : 0;
|
||||
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.Keycloak ?? Guid.Empty,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
{
|
||||
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
var duty = userRound ?? defaultRound;
|
||||
|
||||
var processTimeStamps = timeStamps
|
||||
.Select(d => new
|
||||
{
|
||||
d.Id,
|
||||
CheckInStatus = DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
||||
"LATE" :
|
||||
"NORMAL",
|
||||
CheckOutStatus = d.CheckOut == null ? "" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
"LATE" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"NORMAL",
|
||||
});
|
||||
|
||||
var absentCount = processTimeStamps.Count(x => x.CheckOutStatus == "ABSENT");
|
||||
var lateCount = processTimeStamps.Count(x => x.CheckInStatus == "LATE");
|
||||
|
||||
|
||||
|
||||
var emp = new
|
||||
{
|
||||
no = count,
|
||||
fullName = $"{p.Prefix}{p.FirstName} {p.LastName}",// _userProfileRepository.GetUserFullName(p.Keycloak ?? Guid.Empty, AccessToken),
|
||||
posNo = p.PosNo ?? "",
|
||||
reason = "",
|
||||
|
||||
sickDay = sickDayCount,
|
||||
sickDayCount = sickCount,
|
||||
personalDay = personalDayCount,
|
||||
personalDayCount = personalCount,
|
||||
leaveDay = sickDayCount + personalDayCount,
|
||||
leaveTotal = sickCount + personalCount, //*รวมจำนวนครั้งลาป่วยและลากิจ(13)
|
||||
maternityDay = maternityDayCount,
|
||||
wifeDay = wifeDayCount,
|
||||
ordainDay = ordainDayCount,
|
||||
absentTotal = absentCount,
|
||||
lateTotal = lateCount,
|
||||
leaveTotalText = $"{sickDayCount + personalDayCount}/{sickCount + personalCount}"
|
||||
};
|
||||
|
||||
employees.Add(emp);
|
||||
count++;
|
||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId);
|
||||
}
|
||||
|
||||
var result = new
|
||||
else
|
||||
{
|
||||
template = "LeaveHalfYear-ลูกจ้าง",
|
||||
reportName = "LeaveHalfYear-Employee",
|
||||
data = new
|
||||
{
|
||||
leaveDateStart = req.StartDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
leaveDateEnd = req.EndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
organizationName = profile.First().Oc ?? "",
|
||||
leaveTitleType = req.Type == "FULL" ? "หนึ่งปี" : "ครึ่งปี",
|
||||
employees = employees
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
return Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// LV2_037 - รายงานการลงเวลาประจำวัน
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("time-records/officer")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetTimeRecordsOfficerReport([FromBody] GetLeaveDetailReportDto req)
|
||||
{
|
||||
try
|
||||
{
|
||||
//var profile = await _userProfileRepository.SearchProfile(null, null, null);
|
||||
var profile = await _userProfileRepository.GetProfileWithKeycloak(AccessToken);
|
||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId);
|
||||
}
|
||||
if (profile.Count > 0)
|
||||
{
|
||||
profile = profile.Where(p => p.IsLeave == false).ToList();
|
||||
|
|
@ -1267,26 +1126,9 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
|
||||
}
|
||||
|
||||
var dateStamp = "";
|
||||
var reportName = "";
|
||||
switch (req.Type.ToUpper())
|
||||
{
|
||||
case "MONTH":
|
||||
{
|
||||
var dd = req.StartDate.Date;
|
||||
reportName = "TimeStamp-Month";
|
||||
dateStamp = $"เดือน {dd.ToString("MMMM", _culture.DateTimeFormat)} พ.ศ. {dd.Year.ToThaiYear()}".ToThaiNumber();
|
||||
break;
|
||||
}
|
||||
default:
|
||||
dateStamp = req.StartDate.Date.ToThaiFullDate().ToThaiNumber();
|
||||
reportName = "TimeStamp-Day";
|
||||
break;
|
||||
}
|
||||
|
||||
var item = new
|
||||
{
|
||||
DateTimeStamp = dateStamp,
|
||||
DateTimeStamp = req.StartDate.Date.ToThaiFullDate().ToThaiNumber() + "-" + req.EndDate.Date.ToThaiFullDate().ToThaiNumber(),
|
||||
officerTotal = profile.Count,
|
||||
workTotal = workTotal,
|
||||
restTotal = restTotal,
|
||||
|
|
@ -1298,12 +1140,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
employees = employees
|
||||
};
|
||||
|
||||
|
||||
|
||||
var result = new
|
||||
{
|
||||
template = reportName,
|
||||
reportName = reportName,
|
||||
template = "TimeStamp-Day",
|
||||
reportName = "TimeStamp-Day",
|
||||
data = item
|
||||
};
|
||||
|
||||
|
|
@ -1315,6 +1155,367 @@ namespace BMA.EHR.Leave.Service.Controllers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_035 - รายงานการเข้างานสาย จำแนกเป็นรายบุคคลและหรือรายหน่วยงาน/ส่วนราชการ
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("late/{type:string}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetLateReport([FromBody] GetLeaveDetailByNodeReportDto req, string type)
|
||||
{
|
||||
try
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_REPORT");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var profile = new List<GetProfileByKeycloakIdDto>();
|
||||
if (type.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId);
|
||||
}
|
||||
if (profile.Count > 0)
|
||||
{
|
||||
profile = profile.Where(p => p.IsLeave == false).ToList();
|
||||
}
|
||||
// get leave day
|
||||
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
||||
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
|
||||
|
||||
var count = 1;
|
||||
var employees = new List<dynamic>();
|
||||
|
||||
foreach (var p in profile)
|
||||
{
|
||||
var keycloakUserId = p.Keycloak ?? Guid.Empty;
|
||||
|
||||
var sickDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-001");
|
||||
var sickDayCount = sickDay != null ? sickDay.SumLeaveDay : 0;
|
||||
|
||||
var personalDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-002");
|
||||
var personalDayCount = personalDay != null ? personalDay.SumLeaveDay : 0;
|
||||
|
||||
var maternityDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-003");
|
||||
var maternityDayCount = maternityDay != null ? maternityDay.SumLeaveDay : 0;
|
||||
|
||||
var wifeDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-004");
|
||||
var wifeDayCount = wifeDay != null ? wifeDay.SumLeaveDay : 0;
|
||||
|
||||
var restDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-005");
|
||||
var restDayCount = restDay != null ? restDay.SumLeaveDay : 0;
|
||||
|
||||
var ordainDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-006");
|
||||
var ordainDayCount = ordainDay != null ? ordainDay.SumLeaveDay : 0;
|
||||
|
||||
var absentDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-007");
|
||||
var absentDayCount = absentDay != null ? absentDay.SumLeaveDay : 0;
|
||||
|
||||
var studyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-008");
|
||||
var studyDayCount = studyDay != null ? studyDay.SumLeaveDay : 0;
|
||||
|
||||
var agencyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-009");
|
||||
var agencyDayCount = agencyDay != null ? agencyDay.SumLeaveDay : 0;
|
||||
|
||||
var coupleDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-010");
|
||||
var coupleDayCount = coupleDay != null ? coupleDay.SumLeaveDay : 0;
|
||||
|
||||
var therapyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-011");
|
||||
var therapyDayCount = therapyDay != null ? therapyDay.SumLeaveDay : 0;
|
||||
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.Keycloak ?? Guid.Empty,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
{
|
||||
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
var duty = userRound ?? defaultRound;
|
||||
|
||||
var processTimeStamps = timeStamps
|
||||
.Select(d => new
|
||||
{
|
||||
d.Id,
|
||||
CheckInStatus = DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
||||
"LATE" :
|
||||
"NORMAL",
|
||||
CheckOutStatus = d.CheckOut == null ? "" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
"LATE" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"NORMAL",
|
||||
});
|
||||
|
||||
var absentCount = processTimeStamps.Count(x => x.CheckOutStatus == "ABSENT");
|
||||
var lateCount = processTimeStamps.Count(x => x.CheckInStatus == "LATE");
|
||||
|
||||
var emp = new
|
||||
{
|
||||
no = count,
|
||||
fullName = $"{p.Prefix}{p.FirstName} {p.LastName}",// _userProfileRepository.GetUserFullName(p.Keycloak ?? Guid.Empty, AccessToken),
|
||||
position = p.Position == null ? "" : p.Position,
|
||||
//positionLevel = p.PosLevel == null ? "" : p.PosLevel,
|
||||
//posNo = p.ProfileSalary == null ? "" : p.ProfileSalary.PosNo,
|
||||
positionLevel = p.PositionLevel == null ? "" : p.PositionLevel,
|
||||
posNo = p.PosNo == null ? "" : p.PosNo,
|
||||
reason = "",
|
||||
|
||||
sickDayCount = sickDayCount,
|
||||
maternityDayCount = maternityDayCount,
|
||||
wifeDayCount = wifeDayCount,
|
||||
personalDayCount = personalDayCount,
|
||||
restDayCount = restDayCount,
|
||||
ordainDayCount = ordainDayCount,
|
||||
absentDayCount = absentDayCount,
|
||||
studyDayCount = studyDayCount,
|
||||
agencyDayCount = agencyDayCount,
|
||||
coupleDayCount = coupleDayCount,
|
||||
therapyDayCount = therapyDayCount,
|
||||
absentTotal = absentCount,
|
||||
lateTotal = lateCount,
|
||||
|
||||
leaveTotal = sickDayCount +
|
||||
maternityDayCount +
|
||||
wifeDayCount +
|
||||
personalDayCount +
|
||||
restDayCount +
|
||||
ordainDayCount +
|
||||
absentDayCount +
|
||||
studyDayCount +
|
||||
agencyDayCount +
|
||||
coupleDayCount +
|
||||
therapyDayCount
|
||||
};
|
||||
|
||||
employees.Add(emp);
|
||||
count++;
|
||||
}
|
||||
|
||||
var result = new
|
||||
{
|
||||
template = "LeaveHalfYear-Officer",
|
||||
reportName = "LeaveHalfYear-Officer",
|
||||
data = new
|
||||
{
|
||||
leaveDateStart = req.StartDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
leaveDateEnd = req.EndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
organizationName = profile.First().Oc ?? "",
|
||||
employees = employees,
|
||||
headerText = type.Trim().ToUpper() == "OFFICER" ? "ข้าราชการสามัญ" : "ลูกจ้างประจำ"
|
||||
}
|
||||
};
|
||||
|
||||
return Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// LV2_035 - รายงานการลางาน จำแนกตามเพศ ประเภทการลา หน่วยงาน/ส่วนราชการ
|
||||
/// </summary>
|
||||
/// <returns>
|
||||
/// </returns>
|
||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpPost("leave2/{type:string}")]
|
||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||
public async Task<ActionResult<ResponseObject>> GetLeave2Report([FromBody] GetLeaveDetailByNodeReportDto req, string type)
|
||||
{
|
||||
try
|
||||
{
|
||||
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_LEAVE_REPORT");
|
||||
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
|
||||
if (jsonData["status"]?.ToString() != "200")
|
||||
{
|
||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||
}
|
||||
var profile = new List<GetProfileByKeycloakIdDto>();
|
||||
if (type.Trim().ToUpper() == "OFFICER")
|
||||
{
|
||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId);
|
||||
}
|
||||
else
|
||||
{
|
||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId);
|
||||
}
|
||||
if (profile.Count > 0)
|
||||
{
|
||||
profile = profile.Where(p => p.IsLeave == false).ToList();
|
||||
}
|
||||
// get leave day
|
||||
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
||||
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
|
||||
|
||||
var count = 1;
|
||||
var employees = new List<dynamic>();
|
||||
|
||||
foreach (var p in profile)
|
||||
{
|
||||
var keycloakUserId = p.Keycloak ?? Guid.Empty;
|
||||
|
||||
var sickDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-001");
|
||||
var sickDayCount = sickDay != null ? sickDay.SumLeaveDay : 0;
|
||||
|
||||
var personalDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-002");
|
||||
var personalDayCount = personalDay != null ? personalDay.SumLeaveDay : 0;
|
||||
|
||||
var maternityDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-003");
|
||||
var maternityDayCount = maternityDay != null ? maternityDay.SumLeaveDay : 0;
|
||||
|
||||
var wifeDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-004");
|
||||
var wifeDayCount = wifeDay != null ? wifeDay.SumLeaveDay : 0;
|
||||
|
||||
var restDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-005");
|
||||
var restDayCount = restDay != null ? restDay.SumLeaveDay : 0;
|
||||
|
||||
var ordainDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-006");
|
||||
var ordainDayCount = ordainDay != null ? ordainDay.SumLeaveDay : 0;
|
||||
|
||||
var absentDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-007");
|
||||
var absentDayCount = absentDay != null ? absentDay.SumLeaveDay : 0;
|
||||
|
||||
var studyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-008");
|
||||
var studyDayCount = studyDay != null ? studyDay.SumLeaveDay : 0;
|
||||
|
||||
var agencyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-009");
|
||||
var agencyDayCount = agencyDay != null ? agencyDay.SumLeaveDay : 0;
|
||||
|
||||
var coupleDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-010");
|
||||
var coupleDayCount = coupleDay != null ? coupleDay.SumLeaveDay : 0;
|
||||
|
||||
var therapyDay = leaveDays.FirstOrDefault(x => x.KeycloakUserId == keycloakUserId && x.LeaveTypeCode == "LV-011");
|
||||
var therapyDayCount = therapyDay != null ? therapyDay.SumLeaveDay : 0;
|
||||
|
||||
var timeStamps = await _processUserTimeStampRepository.GetTimeStampHistoryByRangeForUserAsync(p.Keycloak ?? Guid.Empty,
|
||||
req.StartDate,
|
||||
req.EndDate);
|
||||
|
||||
var defaultRound = await _dutyTimeRepository.GetDefaultAsync();
|
||||
if (defaultRound == null)
|
||||
{
|
||||
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
|
||||
}
|
||||
|
||||
//var userRound = await _dutyTimeRepository.GetByIdAsync(profile.DutyTimeId ?? Guid.Empty);
|
||||
var effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||
|
||||
var duty = userRound ?? defaultRound;
|
||||
|
||||
var processTimeStamps = timeStamps
|
||||
.Select(d => new
|
||||
{
|
||||
d.Id,
|
||||
CheckInStatus = DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
||||
"LATE" :
|
||||
"NORMAL",
|
||||
CheckOutStatus = d.CheckOut == null ? "" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeAfternoon}") ?
|
||||
"LATE" :
|
||||
DateTime.Parse(d.CheckOut.Value.ToString("yyyy-MM-dd HH:mm")) <
|
||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.EndTimeMorning}") ?
|
||||
"ABSENT" :
|
||||
"NORMAL",
|
||||
});
|
||||
|
||||
var absentCount = processTimeStamps.Count(x => x.CheckOutStatus == "ABSENT");
|
||||
var lateCount = processTimeStamps.Count(x => x.CheckInStatus == "LATE");
|
||||
|
||||
var emp = new
|
||||
{
|
||||
no = count,
|
||||
fullName = $"{p.Prefix}{p.FirstName} {p.LastName}",// _userProfileRepository.GetUserFullName(p.Keycloak ?? Guid.Empty, AccessToken),
|
||||
position = p.Position == null ? "" : p.Position,
|
||||
//positionLevel = p.PosLevel == null ? "" : p.PosLevel,
|
||||
//posNo = p.ProfileSalary == null ? "" : p.ProfileSalary.PosNo,
|
||||
positionLevel = p.PositionLevel == null ? "" : p.PositionLevel,
|
||||
posNo = p.PosNo == null ? "" : p.PosNo,
|
||||
reason = "",
|
||||
|
||||
sickDayCount = sickDayCount,
|
||||
maternityDayCount = maternityDayCount,
|
||||
wifeDayCount = wifeDayCount,
|
||||
personalDayCount = personalDayCount,
|
||||
restDayCount = restDayCount,
|
||||
ordainDayCount = ordainDayCount,
|
||||
absentDayCount = absentDayCount,
|
||||
studyDayCount = studyDayCount,
|
||||
agencyDayCount = agencyDayCount,
|
||||
coupleDayCount = coupleDayCount,
|
||||
therapyDayCount = therapyDayCount,
|
||||
absentTotal = absentCount,
|
||||
lateTotal = lateCount,
|
||||
|
||||
leaveTotal = sickDayCount +
|
||||
maternityDayCount +
|
||||
wifeDayCount +
|
||||
personalDayCount +
|
||||
restDayCount +
|
||||
ordainDayCount +
|
||||
absentDayCount +
|
||||
studyDayCount +
|
||||
agencyDayCount +
|
||||
coupleDayCount +
|
||||
therapyDayCount
|
||||
};
|
||||
|
||||
employees.Add(emp);
|
||||
count++;
|
||||
}
|
||||
|
||||
var result = new
|
||||
{
|
||||
template = type.Trim().ToUpper() == "OFFICER" ? "LeaveHalfYear-ขรก" : "LeaveHalfYear-ลูกจ้าง",
|
||||
reportName = type.Trim().ToUpper() == "OFFICER" ? "LeaveHalfYear-Officer" : "LeaveHalfYear-Employee",
|
||||
data = new
|
||||
{
|
||||
leaveDateStart = req.StartDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
leaveDateEnd = req.EndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||
organizationName = profile.First().Oc ?? "",
|
||||
employees = employees
|
||||
}
|
||||
};
|
||||
|
||||
return Success(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return Error(ex);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
12
BMA.EHR.Leave/DTOs/Reports/GetLeaveDetailByNodeReportDto.cs
Normal file
12
BMA.EHR.Leave/DTOs/Reports/GetLeaveDetailByNodeReportDto.cs
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
namespace BMA.EHR.Leave.Service.DTOs.Reports
|
||||
{
|
||||
public class GetLeaveDetailByNodeReportDto
|
||||
{
|
||||
public DateTime StartDate { get; set; } = DateTime.MinValue;
|
||||
|
||||
public DateTime EndDate { get; set; } = DateTime.MinValue;
|
||||
|
||||
public string? node { get; set; } = string.Empty;
|
||||
public string? nodeId { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue