report leave
This commit is contained in:
parent
12448ba0a4
commit
771b9b940a
17 changed files with 2109 additions and 305 deletions
|
|
@ -663,7 +663,7 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable().AsNoTracking()
|
||||||
.Include(x => x.Type)
|
.Include(x => x.Type)
|
||||||
//.Where(x => x.LeaveStartDate.Year == year)
|
//.Where(x => x.LeaveStartDate.Year == year)
|
||||||
.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate )
|
.Where(x => x.LeaveStartDate.Date >= startFiscalDate && x.LeaveStartDate.Date <= endFiscalDate)
|
||||||
.Where(x => x.LeaveStatus == "NEW") // fix issue : #729
|
.Where(x => x.LeaveStatus == "NEW") // fix issue : #729
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
|
|
@ -826,6 +826,64 @@ namespace BMA.EHR.Application.Repositories.Leaves.LeaveRequests
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<GetSumApproveLeaveByRootDto>> GetSumApproveLeaveByRootAndRange(DateTime startDate, DateTime endDate, string type)
|
||||||
|
{
|
||||||
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||||
|
.Include(x => x.Type)
|
||||||
|
.Where(x => x.ProfileType == type.Trim().ToUpper())
|
||||||
|
.Where(x => x.LeaveStartDate.Date >= startDate.Date && x.LeaveStartDate.Date <= endDate.Date)
|
||||||
|
.Where(x => x.LeaveStatus == "APPROVE").ToListAsync();
|
||||||
|
|
||||||
|
var res = (from d in data
|
||||||
|
group d by new { d.Root, d.Child1, d.Child2, d.Child3, d.Child4, LeaveTypeId = d.Type.Id, LeaveTypeCode = d.Type.Code } into grp
|
||||||
|
select new GetSumApproveLeaveByRootDto
|
||||||
|
{
|
||||||
|
Root = grp.Key.Root,
|
||||||
|
LeaveTypeId = grp.Key.LeaveTypeId,
|
||||||
|
LeaveTypeCode = grp.Key.LeaveTypeCode,
|
||||||
|
SumLeaveDay = grp.Sum(x => x.LeaveTotal),
|
||||||
|
|
||||||
|
sickDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
maternityDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
wifeDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
personalDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
restDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
ordainDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
absentDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
studyDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
agencyDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
coupleDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
therapyDayCountMale = grp.Where(x => x.Gender == "ชาย").Sum(x => x.LeaveTotal),
|
||||||
|
|
||||||
|
sickDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
maternityDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
wifeDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
personalDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
restDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
ordainDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
absentDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
studyDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
agencyDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
coupleDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
therapyDayCountFemale = grp.Where(x => x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
|
||||||
|
sickDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
maternityDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
wifeDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
personalDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
restDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
ordainDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
absentDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
studyDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
agencyDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
coupleDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
therapyDayCountNo = grp.Where(x => x.Gender == "ชาย" && x.Gender == "หญิง").Sum(x => x.LeaveTotal),
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<List<GetCountApproveLeaveByTypeDto>> GetCountApproveLeaveByTypeAndRange(DateTime startDate, DateTime endDate)
|
public async Task<List<GetCountApproveLeaveByTypeDto>> GetCountApproveLeaveByTypeAndRange(DateTime startDate, DateTime endDate)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
var data = await _dbContext.Set<LeaveRequest>().AsQueryable()
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,15 @@ namespace BMA.EHR.Application.Repositories.Leaves.TimeAttendants
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<List<ProcessUserTimeStamp>> GetTimestampByDateLateAsync(string type)
|
||||||
|
{
|
||||||
|
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||||
|
.Where(x => x.CheckInStatus == "LATE")
|
||||||
|
.Where(x => x.ProfileType == type.Trim().ToUpper())
|
||||||
|
.ToListAsync();
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<ProcessUserTimeStamp?> GetLastRecord(Guid keycloakId)
|
public async Task<ProcessUserTimeStamp?> GetLastRecord(Guid keycloakId)
|
||||||
{
|
{
|
||||||
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
var data = await _dbContext.Set<ProcessUserTimeStamp>()
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<GetProfileByKeycloakIdDto>> GetProfileWithKeycloakAllOfficer(string? accessToken, string? node, string? nodeId)
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllOfficer(string? accessToken, string? node, string? nodeId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -260,7 +260,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||||
if (apiResult != null)
|
if (apiResult != null)
|
||||||
{
|
{
|
||||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdResultDto>(apiResult);
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
||||||
if (raw != null)
|
if (raw != null)
|
||||||
return raw.Result;
|
return raw.Result;
|
||||||
}
|
}
|
||||||
|
|
@ -273,7 +273,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<GetProfileByKeycloakIdDto>> GetProfileWithKeycloakAllEmployee(string? accessToken, string? node, string? nodeId)
|
public async Task<List<GetProfileByKeycloakIdRootDto>> GetProfileWithKeycloakAllEmployee(string? accessToken, string? node, string? nodeId)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -290,7 +290,7 @@ namespace BMA.EHR.Application.Repositories
|
||||||
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
var apiResult = await PostExternalAPIAsync(apiPath, accessToken, body, apiKey);
|
||||||
if (apiResult != null)
|
if (apiResult != null)
|
||||||
{
|
{
|
||||||
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdResultDto>(apiResult);
|
var raw = JsonConvert.DeserializeObject<GetListProfileByKeycloakIdRootResultDto>(apiResult);
|
||||||
if (raw != null)
|
if (raw != null)
|
||||||
return raw.Result;
|
return raw.Result;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
namespace BMA.EHR.Application.Responses.Leaves
|
||||||
|
{
|
||||||
|
public class GetSumApproveLeaveByRootDto
|
||||||
|
{
|
||||||
|
public string Root { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public Guid LeaveTypeId { get; set; }
|
||||||
|
|
||||||
|
public string LeaveTypeCode { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public double SumLeaveDay { get; set; }
|
||||||
|
|
||||||
|
public double sickDayCountMale { get; set; }
|
||||||
|
public double maternityDayCountMale { get; set; }
|
||||||
|
public double wifeDayCountMale { get; set; }
|
||||||
|
public double personalDayCountMale { get; set; }
|
||||||
|
public double restDayCountMale { get; set; }
|
||||||
|
public double ordainDayCountMale { get; set; }
|
||||||
|
public double absentDayCountMale { get; set; }
|
||||||
|
public double studyDayCountMale { get; set; }
|
||||||
|
public double agencyDayCountMale { get; set; }
|
||||||
|
public double coupleDayCountMale { get; set; }
|
||||||
|
public double therapyDayCountMale { get; set; }
|
||||||
|
public double sickDayCountFemale { get; set; }
|
||||||
|
public double maternityDayCountFemale { get; set; }
|
||||||
|
public double wifeDayCountFemale { get; set; }
|
||||||
|
public double personalDayCountFemale { get; set; }
|
||||||
|
public double restDayCountFemale { get; set; }
|
||||||
|
public double ordainDayCountFemale { get; set; }
|
||||||
|
public double absentDayCountFemale { get; set; }
|
||||||
|
public double studyDayCountFemale { get; set; }
|
||||||
|
public double agencyDayCountFemale { get; set; }
|
||||||
|
public double coupleDayCountFemale { get; set; }
|
||||||
|
public double therapyDayCountFemale { get; set; }
|
||||||
|
public double sickDayCountNo { get; set; }
|
||||||
|
public double maternityDayCountNo { get; set; }
|
||||||
|
public double wifeDayCountNo { get; set; }
|
||||||
|
public double personalDayCountNo { get; set; }
|
||||||
|
public double restDayCountNo { get; set; }
|
||||||
|
public double ordainDayCountNo { get; set; }
|
||||||
|
public double absentDayCountNo { get; set; }
|
||||||
|
public double studyDayCountNo { get; set; }
|
||||||
|
public double agencyDayCountNo { get; set; }
|
||||||
|
public double coupleDayCountNo { get; set; }
|
||||||
|
public double therapyDayCountNo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,11 @@
|
||||||
|
namespace BMA.EHR.Application.Responses.Profiles
|
||||||
|
{
|
||||||
|
public class GetListProfileByKeycloakIdRootResultDto
|
||||||
|
{
|
||||||
|
public string Message { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
public int Status { get; set; } = -1;
|
||||||
|
|
||||||
|
public List<GetProfileByKeycloakIdRootDto> Result { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,18 @@
|
||||||
|
using BMA.EHR.Domain.Models.HR;
|
||||||
|
|
||||||
|
namespace BMA.EHR.Application.Responses.Profiles
|
||||||
|
{
|
||||||
|
public class GetProfileByKeycloakIdRootDto
|
||||||
|
{
|
||||||
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public string? Prefix { get; set; }
|
||||||
|
public string? FirstName { get; set; }
|
||||||
|
public string? LastName { get; set; }
|
||||||
|
public Guid? Keycloak { get; set; }
|
||||||
|
public string? PosNo { get; set; }
|
||||||
|
public string? Position { get; set; }
|
||||||
|
public string? PositionLevel { get; set; }
|
||||||
|
public string? Oc { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -163,7 +163,9 @@ namespace BMA.EHR.Domain.Models.Leave.Requests
|
||||||
|
|
||||||
public string? CitizenId { get; set; }
|
public string? CitizenId { get; set; }
|
||||||
|
|
||||||
public string? Root { get; set; }
|
public string? Gender { get; set; }
|
||||||
|
|
||||||
|
public string? Root { get; set; }
|
||||||
|
|
||||||
public string? Child1 { get; set; }
|
public string? Child1 { get; set; }
|
||||||
|
|
||||||
|
|
@ -173,6 +175,16 @@ namespace BMA.EHR.Domain.Models.Leave.Requests
|
||||||
|
|
||||||
public string? Child4 { get; set; }
|
public string? Child4 { get; set; }
|
||||||
|
|
||||||
|
public Guid? RootId { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child1Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child2Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child3Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child4Id { get; set; }
|
||||||
|
|
||||||
public Guid? ProfileId { get; set; }
|
public Guid? ProfileId { get; set; }
|
||||||
public string? ProfileType { get; set; }
|
public string? ProfileType { get; set; }
|
||||||
public double? Amount { get; set; }
|
public double? Amount { get; set; }
|
||||||
|
|
|
||||||
|
|
@ -77,5 +77,32 @@ namespace BMA.EHR.Domain.Models.Leave.TimeAttendants
|
||||||
public string? FirstName { get; set; }
|
public string? FirstName { get; set; }
|
||||||
|
|
||||||
public string? LastName { get; set; }
|
public string? LastName { get; set; }
|
||||||
|
|
||||||
|
public string? CitizenId { get; set; }
|
||||||
|
|
||||||
|
public string? Gender { get; set; }
|
||||||
|
|
||||||
|
public string? Root { get; set; }
|
||||||
|
|
||||||
|
public string? Child1 { get; set; }
|
||||||
|
|
||||||
|
public string? Child2 { get; set; }
|
||||||
|
|
||||||
|
public string? Child3 { get; set; }
|
||||||
|
|
||||||
|
public string? Child4 { get; set; }
|
||||||
|
|
||||||
|
public Guid? RootId { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child1Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child2Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child3Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child4Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? ProfileId { get; set; }
|
||||||
|
public string? ProfileType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -65,5 +65,32 @@ namespace BMA.EHR.Domain.Models.Leave.TimeAttendants
|
||||||
public string? FirstName { get; set; }
|
public string? FirstName { get; set; }
|
||||||
|
|
||||||
public string? LastName { get; set; }
|
public string? LastName { get; set; }
|
||||||
|
|
||||||
|
public string? CitizenId { get; set; }
|
||||||
|
|
||||||
|
public string? Gender { get; set; }
|
||||||
|
|
||||||
|
public string? Root { get; set; }
|
||||||
|
|
||||||
|
public string? Child1 { get; set; }
|
||||||
|
|
||||||
|
public string? Child2 { get; set; }
|
||||||
|
|
||||||
|
public string? Child3 { get; set; }
|
||||||
|
|
||||||
|
public string? Child4 { get; set; }
|
||||||
|
|
||||||
|
public Guid? RootId { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child1Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child2Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child3Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? Child4Id { get; set; }
|
||||||
|
|
||||||
|
public Guid? ProfileId { get; set; }
|
||||||
|
public string? ProfileType { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
1284
BMA.EHR.Infrastructure/Migrations/LeaveDb/20241212072757_update table leaveRequest add rootId.Designer.cs
generated
Normal file
1284
BMA.EHR.Infrastructure/Migrations/LeaveDb/20241212072757_update table leaveRequest add rootId.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -0,0 +1,393 @@
|
||||||
|
using System;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class updatetableleaveRequestaddrootId : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Child1",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child1Id",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Child2",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child2Id",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Child3",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child3Id",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Child4",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child4Id",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "CitizenId",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Gender",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "ProfileId",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ProfileType",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Root",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "RootId",
|
||||||
|
table: "UserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Child1",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child1Id",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Child2",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child2Id",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Child3",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child3Id",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Child4",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child4Id",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "CitizenId",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Gender",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "ProfileId",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "ProfileType",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Root",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "RootId",
|
||||||
|
table: "ProcessUserTimeStamps",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child1Id",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child2Id",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child3Id",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "Child4Id",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<string>(
|
||||||
|
name: "Gender",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "longtext",
|
||||||
|
nullable: true)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "RootId",
|
||||||
|
table: "LeaveRequests",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child1",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child1Id",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child2",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child2Id",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child3",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child3Id",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child4",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child4Id",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CitizenId",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Gender",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ProfileId",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ProfileType",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Root",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RootId",
|
||||||
|
table: "UserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child1",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child1Id",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child2",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child2Id",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child3",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child3Id",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child4",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child4Id",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "CitizenId",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Gender",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ProfileId",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "ProfileType",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Root",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RootId",
|
||||||
|
table: "ProcessUserTimeStamps");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child1Id",
|
||||||
|
table: "LeaveRequests");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child2Id",
|
||||||
|
table: "LeaveRequests");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child3Id",
|
||||||
|
table: "LeaveRequests");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Child4Id",
|
||||||
|
table: "LeaveRequests");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Gender",
|
||||||
|
table: "LeaveRequests");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "RootId",
|
||||||
|
table: "LeaveRequests");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -226,15 +226,27 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
b.Property<string>("Child1")
|
b.Property<string>("Child1")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("Child1Id")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<string>("Child2")
|
b.Property<string>("Child2")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("Child2Id")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<string>("Child3")
|
b.Property<string>("Child3")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("Child3Id")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<string>("Child4")
|
b.Property<string>("Child4")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("Child4Id")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<string>("CitizenId")
|
b.Property<string>("CitizenId")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
|
@ -298,6 +310,9 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
b.Property<string>("FirstName")
|
b.Property<string>("FirstName")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Gender")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<bool>("HajjDayStatus")
|
b.Property<bool>("HajjDayStatus")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
|
@ -464,6 +479,9 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
b.Property<string>("Root")
|
b.Property<string>("Root")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("RootId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<string>("StudyDayCountry")
|
b.Property<string>("StudyDayCountry")
|
||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
@ -768,6 +786,33 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("สถานะ Check-Out");
|
.HasComment("สถานะ Check-Out");
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("datetime(6)")
|
.HasColumnType("datetime(6)")
|
||||||
.HasColumnOrder(100)
|
.HasColumnOrder(100)
|
||||||
|
|
@ -798,6 +843,9 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
b.Property<string>("FirstName")
|
b.Property<string>("FirstName")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Gender")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<bool>("IsLocationCheckIn")
|
b.Property<bool>("IsLocationCheckIn")
|
||||||
.HasColumnType("tinyint(1)")
|
.HasColumnType("tinyint(1)")
|
||||||
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In");
|
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In");
|
||||||
|
|
@ -839,6 +887,18 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
b.Property<string>("Prefix")
|
b.Property<string>("Prefix")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ProfileId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
|
b.Property<string>("ProfileType")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Root")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("RootId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("ProcessUserTimeStamps");
|
b.ToTable("ProcessUserTimeStamps");
|
||||||
|
|
@ -1048,6 +1108,33 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
.HasColumnType("longtext")
|
.HasColumnType("longtext")
|
||||||
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out");
|
.HasComment("ข้อความหมายเหตุที่ต้องการระบุเพิ่ม(มีเผื่อไว้อาจไม่ได้ใช้) Check-Out");
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
b.Property<DateTime>("CreatedAt")
|
b.Property<DateTime>("CreatedAt")
|
||||||
.HasColumnType("datetime(6)")
|
.HasColumnType("datetime(6)")
|
||||||
.HasColumnOrder(100)
|
.HasColumnOrder(100)
|
||||||
|
|
@ -1070,6 +1157,9 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
b.Property<string>("FirstName")
|
b.Property<string>("FirstName")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Gender")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
b.Property<bool>("IsLocationCheckIn")
|
b.Property<bool>("IsLocationCheckIn")
|
||||||
.HasColumnType("tinyint(1)")
|
.HasColumnType("tinyint(1)")
|
||||||
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In");
|
.HasComment("true คือ ณ สถานที่ตั้ง, false คือ นอกสถานที่ตั้ง Check-In");
|
||||||
|
|
@ -1111,6 +1201,18 @@ namespace BMA.EHR.Infrastructure.Migrations.LeaveDb
|
||||||
b.Property<string>("Prefix")
|
b.Property<string>("Prefix")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("ProfileId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
|
b.Property<string>("ProfileType")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<string>("Root")
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid?>("RootId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.ToTable("UserTimeStamps");
|
b.ToTable("UserTimeStamps");
|
||||||
|
|
|
||||||
|
|
@ -635,14 +635,11 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
// validate duplicate check in
|
// validate duplicate check in
|
||||||
var currentCheckIn = await _userTimeStampRepository.GetTimestampByDateAsync(userId, currentDate);
|
var currentCheckIn = await _userTimeStampRepository.GetTimestampByDateAsync(userId, currentDate);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (currentCheckIn != null)
|
if (currentCheckIn != null)
|
||||||
{
|
{
|
||||||
return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
return Error(new Exception("ไม่สามารถลงเวลาได้ เนื่องจากมีการลงเวลาในวันนี้แล้ว!"), StatusCodes.Status400BadRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
var checkin = new UserTimeStamp
|
var checkin = new UserTimeStamp
|
||||||
{
|
{
|
||||||
KeycloakUserId = userId,
|
KeycloakUserId = userId,
|
||||||
|
|
@ -657,6 +654,23 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
Prefix = profile.Prefix,
|
Prefix = profile.Prefix,
|
||||||
FirstName = profile.FirstName,
|
FirstName = profile.FirstName,
|
||||||
LastName = profile.LastName,
|
LastName = profile.LastName,
|
||||||
|
CitizenId = profile.CitizenId,
|
||||||
|
|
||||||
|
Root = profile.Root,
|
||||||
|
Child1 = profile.Child1,
|
||||||
|
Child2 = profile.Child2,
|
||||||
|
Child3 = profile.Child3,
|
||||||
|
Child4 = profile.Child4,
|
||||||
|
|
||||||
|
RootId = profile.RootId,
|
||||||
|
Child1Id = profile.Child1Id,
|
||||||
|
Child2Id = profile.Child2Id,
|
||||||
|
Child3Id = profile.Child3Id,
|
||||||
|
Child4Id = profile.Child4Id,
|
||||||
|
Gender = profile.Gender,
|
||||||
|
|
||||||
|
ProfileId = profile.Id,
|
||||||
|
ProfileType = profile.ProfileType,
|
||||||
};
|
};
|
||||||
|
|
||||||
var checkInStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >
|
var checkInStatus = DateTime.Parse(currentDate.ToString("yyyy-MM-dd HH:mm")) >
|
||||||
|
|
@ -684,6 +698,23 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
Prefix = profile.Prefix,
|
Prefix = profile.Prefix,
|
||||||
FirstName = profile.FirstName,
|
FirstName = profile.FirstName,
|
||||||
LastName = profile.LastName,
|
LastName = profile.LastName,
|
||||||
|
CitizenId = profile.CitizenId,
|
||||||
|
|
||||||
|
Root = profile.Root,
|
||||||
|
Child1 = profile.Child1,
|
||||||
|
Child2 = profile.Child2,
|
||||||
|
Child3 = profile.Child3,
|
||||||
|
Child4 = profile.Child4,
|
||||||
|
|
||||||
|
RootId = profile.RootId,
|
||||||
|
Child1Id = profile.Child1Id,
|
||||||
|
Child2Id = profile.Child2Id,
|
||||||
|
Child3Id = profile.Child3Id,
|
||||||
|
Child4Id = profile.Child4Id,
|
||||||
|
Gender = profile.Gender,
|
||||||
|
|
||||||
|
ProfileId = profile.Id,
|
||||||
|
ProfileType = profile.ProfileType,
|
||||||
};
|
};
|
||||||
|
|
||||||
await _userTimeStampRepository.AddAsync(checkin);
|
await _userTimeStampRepository.AddAsync(checkin);
|
||||||
|
|
|
||||||
|
|
@ -740,7 +740,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPost("leaveday/{type:string}")]
|
[HttpPost("leaveday/{type}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
|
@ -754,7 +754,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
}
|
}
|
||||||
var profile = new List<GetProfileByKeycloakIdDto>();
|
var profile = new List<GetProfileByKeycloakIdRootDto>();
|
||||||
if (type.Trim().ToUpper() == "OFFICER")
|
if (type.Trim().ToUpper() == "OFFICER")
|
||||||
{
|
{
|
||||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId);
|
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId);
|
||||||
|
|
@ -763,10 +763,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId);
|
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId);
|
||||||
}
|
}
|
||||||
if (profile.Count > 0)
|
|
||||||
{
|
|
||||||
profile = profile.Where(p => p.IsLeave == false).ToList();
|
|
||||||
}
|
|
||||||
// get leave day
|
// get leave day
|
||||||
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByTypeAndRange(req.StartDate, req.EndDate);
|
||||||
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
|
var leaveTypes = await _leaveTypeRepository.GetAllAsync();
|
||||||
|
|
@ -891,16 +887,33 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var text = "";
|
||||||
|
if (req.Type.Trim().ToUpper() == "FULL")
|
||||||
|
{
|
||||||
|
text = "หนึ่งปี";
|
||||||
|
}
|
||||||
|
else if (req.Type.Trim().ToUpper() == "HAFT")
|
||||||
|
{
|
||||||
|
text = "ครึ่งปี";
|
||||||
|
}
|
||||||
|
else if (req.Type.Trim().ToUpper() == "MONTH")
|
||||||
|
{
|
||||||
|
text = "หนึ่งเดือน";
|
||||||
|
}
|
||||||
|
var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate().ToThaiNumber()}";
|
||||||
var result = new
|
var result = new
|
||||||
{
|
{
|
||||||
template = type.Trim().ToUpper() == "OFFICER" ? "LeaveHalfYear-ขรก" : "LeaveHalfYear-ลูกจ้าง",
|
template = "LeaveHalfYear-Officer",
|
||||||
reportName = type.Trim().ToUpper() == "OFFICER" ? "LeaveHalfYear-Officer" : "LeaveHalfYear-Employee",
|
reportName = "LeaveHalfYear-Officer",
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
leaveDateStart = req.StartDate.Date.ToThaiShortDate().ToThaiNumber(),
|
leaveDateStart = req.StartDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||||
leaveDateEnd = req.EndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
leaveDateEnd = req.EndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||||
organizationName = profile.First().Oc ?? "",
|
dateTimeStamp = $"ณ วันที่ {req.StartDate.Date.ToThaiShortDate().ToThaiNumber()}{enddate}",
|
||||||
employees = employees
|
organizationName = profile?.FirstOrDefault()?.Oc ?? "",
|
||||||
|
employees = employees,
|
||||||
|
headerText = type.Trim().ToUpper() == "OFFICER" ? "ข้าราชการสามัญ" : "ลูกจ้างประจำ",
|
||||||
|
text = text
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -920,7 +933,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPost("time-records/{type:string}")]
|
[HttpPost("time-records/{type}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
|
@ -934,7 +947,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
}
|
}
|
||||||
var profile = new List<GetProfileByKeycloakIdDto>();
|
var profile = new List<GetProfileByKeycloakIdRootDto>();
|
||||||
if (type.Trim().ToUpper() == "OFFICER")
|
if (type.Trim().ToUpper() == "OFFICER")
|
||||||
{
|
{
|
||||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId);
|
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId);
|
||||||
|
|
@ -943,10 +956,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId);
|
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId);
|
||||||
}
|
}
|
||||||
if (profile.Count > 0)
|
|
||||||
{
|
|
||||||
profile = profile.Where(p => p.IsLeave == false).ToList();
|
|
||||||
}
|
|
||||||
var date = req.StartDate.Date;
|
var date = req.StartDate.Date;
|
||||||
|
|
||||||
var holidays = await _holidayRepository.GetHolidayAsync(req.StartDate.Date, req.EndDate.Date);
|
var holidays = await _holidayRepository.GetHolidayAsync(req.StartDate.Date, req.EndDate.Date);
|
||||||
|
|
@ -1075,7 +1084,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
timeStamps.CheckOut != null ?
|
timeStamps.CheckOut != null ?
|
||||||
$"{timeStamps.CheckOut.Value.ToString("HH:mm")} น." :
|
$"{timeStamps.CheckOut.Value.ToString("HH:mm")} น." :
|
||||||
"",
|
"",
|
||||||
|
|
||||||
//remark = timeStamps == null ? "ขาดราชการ" : "",
|
//remark = timeStamps == null ? "ขาดราชการ" : "",
|
||||||
remark = remarkStr,
|
remark = remarkStr,
|
||||||
|
|
||||||
|
|
@ -1096,8 +1104,6 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
else if (timeStamps.CheckInLocationName == "ไปประชุม/อบรม/สัมมนา/ปฏิบัติงานที่บ้านนอกสถานที่")
|
else if (timeStamps.CheckInLocationName == "ไปประชุม/อบรม/สัมมนา/ปฏิบัติงานที่บ้านนอกสถานที่")
|
||||||
seminarTotal += 1;
|
seminarTotal += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -1126,9 +1132,10 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate().ToThaiNumber()}";
|
||||||
var item = new
|
var item = new
|
||||||
{
|
{
|
||||||
DateTimeStamp = req.StartDate.Date.ToThaiFullDate().ToThaiNumber() + "-" + req.EndDate.Date.ToThaiFullDate().ToThaiNumber(),
|
dateTimeStamp = $"ณ วันที่ {req.StartDate.Date.ToThaiShortDate().ToThaiNumber()}{enddate}",
|
||||||
officerTotal = profile.Count,
|
officerTotal = profile.Count,
|
||||||
workTotal = workTotal,
|
workTotal = workTotal,
|
||||||
restTotal = restTotal,
|
restTotal = restTotal,
|
||||||
|
|
@ -1163,7 +1170,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPost("late/{type:string}")]
|
[HttpPost("late/{type}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
|
@ -1177,155 +1184,63 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
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>();
|
var employees = new List<dynamic>();
|
||||||
|
var count = 1;
|
||||||
|
|
||||||
foreach (var p in profile)
|
var userTimeStamps = await _processUserTimeStampRepository.GetTimestampByDateLateAsync(type.Trim().ToUpper());
|
||||||
|
foreach (var p in userTimeStamps)
|
||||||
{
|
{
|
||||||
var keycloakUserId = p.Keycloak ?? Guid.Empty;
|
var fullName = $"{p.Prefix}{p.FirstName} {p.LastName}";
|
||||||
|
|
||||||
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 effectiveDate = await _userDutyTimeRepository.GetLastEffectRound(p.Id);
|
||||||
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
var roundId = effectiveDate != null ? effectiveDate.DutyTimeId : Guid.Empty;
|
||||||
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
var userRound = await _dutyTimeRepository.GetByIdAsync(roundId);
|
||||||
|
|
||||||
var duty = userRound ?? defaultRound;
|
var duty = userRound;
|
||||||
|
if (duty == null)
|
||||||
var processTimeStamps = timeStamps
|
|
||||||
.Select(d => new
|
|
||||||
{
|
{
|
||||||
d.Id,
|
duty = await _dutyTimeRepository.GetDefaultAsync();
|
||||||
CheckInStatus = DateTime.Parse(d.CheckIn.ToString("yyyy-MM-dd HH:mm")) >
|
if (duty == null)
|
||||||
DateTime.Parse($"{d.CheckIn.Date.ToString("yyyy-MM-dd")} {duty.StartTimeMorning}") ?
|
{
|
||||||
"LATE" :
|
return Error("ไม่พบรอบการลงเวลา Default", StatusCodes.Status404NotFound);
|
||||||
"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
|
var emp = new
|
||||||
{
|
{
|
||||||
no = count,
|
no = count,
|
||||||
fullName = $"{p.Prefix}{p.FirstName} {p.LastName}",// _userProfileRepository.GetUserFullName(p.Keycloak ?? Guid.Empty, AccessToken),
|
fullName = fullName,
|
||||||
position = p.Position == null ? "" : p.Position,
|
dutyTimeName = $"{duty.StartTimeMorning} - {duty.EndTimeAfternoon} น.",
|
||||||
//positionLevel = p.PosLevel == null ? "" : p.PosLevel,
|
checkInLocation = p.CheckInPOI,
|
||||||
//posNo = p.ProfileSalary == null ? "" : p.ProfileSalary.PosNo,
|
checkInTime = $"{p.CheckIn.ToString("HH:mm")} น.",
|
||||||
positionLevel = p.PositionLevel == null ? "" : p.PositionLevel,
|
checkOutLocation = p.CheckOutPOI ?? "",
|
||||||
posNo = p.PosNo == null ? "" : p.PosNo,
|
checkOutTime = p.CheckOut != null ?
|
||||||
reason = "",
|
$"{p.CheckOut.Value.ToString("HH:mm")} น." :
|
||||||
|
"",
|
||||||
sickDayCount = sickDayCount,
|
remark = "",
|
||||||
maternityDayCount = maternityDayCount,
|
checkInDate = p.CheckIn.Date.ToThaiFullDate2().ToThaiNumber(),
|
||||||
wifeDayCount = wifeDayCount,
|
checkedOutDate = p.CheckOut != null ?
|
||||||
personalDayCount = personalDayCount,
|
p.CheckOut.Value.ToThaiFullDate2().ToThaiNumber() :
|
||||||
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);
|
employees.Add(emp);
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate().ToThaiNumber()}";
|
||||||
|
var item = new
|
||||||
|
{
|
||||||
|
dateTimeStamp = $"ณ วันที่ {req.StartDate.Date.ToThaiShortDate().ToThaiNumber()}{enddate}",
|
||||||
|
// officerTotal = profile.Count,
|
||||||
|
employees = employees
|
||||||
|
};
|
||||||
|
|
||||||
var result = new
|
var result = new
|
||||||
{
|
{
|
||||||
template = "LeaveHalfYear-Officer",
|
template = "TimeStamp-Day",
|
||||||
reportName = "LeaveHalfYear-Officer",
|
reportName = "TimeStamp-Day",
|
||||||
data = new
|
data = item
|
||||||
{
|
|
||||||
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);
|
return Success(result);
|
||||||
|
|
@ -1344,7 +1259,7 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
/// <response code="200">เมื่อทำรายการสำเร็จ</response>
|
||||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||||
[HttpPost("leave2/{type:string}")]
|
[HttpPost("leave2/{type}")]
|
||||||
[ProducesResponseType(StatusCodes.Status200OK)]
|
[ProducesResponseType(StatusCodes.Status200OK)]
|
||||||
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
[ProducesResponseType(StatusCodes.Status401Unauthorized)]
|
||||||
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
[ProducesResponseType(StatusCodes.Status500InternalServerError)]
|
||||||
|
|
@ -1358,153 +1273,17 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
{
|
{
|
||||||
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
|
||||||
}
|
}
|
||||||
var profile = new List<GetProfileByKeycloakIdDto>();
|
var leaveDays = await _leaveRequestRepository.GetSumApproveLeaveByRootAndRange(req.StartDate, req.EndDate, type);
|
||||||
if (type.Trim().ToUpper() == "OFFICER")
|
var enddate = req.EndDate.Date == req.StartDate.Date ? "" : $" - {req.EndDate.Date.ToThaiShortDate().ToThaiNumber()}";
|
||||||
{
|
|
||||||
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
|
var result = new
|
||||||
{
|
{
|
||||||
template = type.Trim().ToUpper() == "OFFICER" ? "LeaveHalfYear-ขรก" : "LeaveHalfYear-ลูกจ้าง",
|
template = "LeaveHalfYear-Officer",
|
||||||
reportName = type.Trim().ToUpper() == "OFFICER" ? "LeaveHalfYear-Officer" : "LeaveHalfYear-Employee",
|
reportName = "LeaveHalfYear-Officer",
|
||||||
data = new
|
data = new
|
||||||
{
|
{
|
||||||
leaveDateStart = req.StartDate.Date.ToThaiShortDate().ToThaiNumber(),
|
leaveDateStart = $"ณ วันที่ {req.StartDate.Date.ToThaiShortDate().ToThaiNumber()}{enddate}",
|
||||||
leaveDateEnd = req.EndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
leaveDateEnd = req.EndDate.Date.ToThaiShortDate().ToThaiNumber(),
|
||||||
organizationName = profile.First().Oc ?? "",
|
employees = leaveDays
|
||||||
employees = employees
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -196,6 +196,13 @@ namespace BMA.EHR.Leave.Service.Controllers
|
||||||
Child3 = profile.Child3,
|
Child3 = profile.Child3,
|
||||||
Child4 = profile.Child4,
|
Child4 = profile.Child4,
|
||||||
|
|
||||||
|
RootId = profile.RootId,
|
||||||
|
Child1Id = profile.Child1Id,
|
||||||
|
Child2Id = profile.Child2Id,
|
||||||
|
Child3Id = profile.Child3Id,
|
||||||
|
Child4Id = profile.Child4Id,
|
||||||
|
Gender = profile.Gender,
|
||||||
|
|
||||||
ProfileId = profile.Id,
|
ProfileId = profile.Id,
|
||||||
ProfileType = profile.ProfileType,
|
ProfileType = profile.ProfileType,
|
||||||
Amount = profile.Amount,
|
Amount = profile.Amount,
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,8 @@ namespace BMA.EHR.Leave.Service.DTOs.Reports
|
||||||
public class GetLeaveDetailByNodeReportDto
|
public class GetLeaveDetailByNodeReportDto
|
||||||
{
|
{
|
||||||
public DateTime StartDate { get; set; } = DateTime.MinValue;
|
public DateTime StartDate { get; set; } = DateTime.MinValue;
|
||||||
|
|
||||||
public DateTime EndDate { get; set; } = DateTime.MinValue;
|
public DateTime EndDate { get; set; } = DateTime.MinValue;
|
||||||
|
public string? Type { get; set; } = string.Empty;
|
||||||
public string? node { get; set; } = string.Empty;
|
public string? node { get; set; } = string.Empty;
|
||||||
public string? nodeId { get; set; } = string.Empty;
|
public string? nodeId { get; set; } = string.Empty;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"applicationUrl": "https://localhost:7283;http://localhost:5028"
|
"applicationUrl": "https://localhost:7283;http://localhost:5254"
|
||||||
},
|
},
|
||||||
"http": {
|
"http": {
|
||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
|
|
@ -18,7 +18,7 @@
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"dotnetRunMessages": true,
|
"dotnetRunMessages": true,
|
||||||
"applicationUrl": "http://localhost:5028"
|
"applicationUrl": "http://localhost:5254"
|
||||||
},
|
},
|
||||||
"IIS Express": {
|
"IIS Express": {
|
||||||
"commandName": "IISExpress",
|
"commandName": "IISExpress",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue