Merge branch 'develop' into adiDev
Some checks failed
release-dev / release-dev (push) Failing after 11s

This commit is contained in:
AdisakKanthawilang 2025-01-21 12:47:09 +07:00
commit 43fb8a3b61
34 changed files with 39978 additions and 288 deletions

View file

@ -82,6 +82,15 @@ namespace BMA.EHR.Application.Repositories.Reports
: (Regex.Replace(x.description, "<.*?>", string.Empty)).Replace("&nbsp;", " ").ToString().ToThaiNumber(),
}).ToList();
var competencyGroups = probation_assign.result.competency_groups.Select(x => new
{
name = string.IsNullOrEmpty(x.name) ? string.Empty : x.name.ToThaiNumber(),
level = string.IsNullOrEmpty(x.level) ? string.Empty : x.level.ToThaiNumber(),
description = string.IsNullOrEmpty(x.description)
? string.Empty
: (Regex.Replace(x.description, "<.*?>", string.Empty)).Replace("&nbsp;", " ").ToString().ToThaiNumber(),
}).ToList();
var outputs = probation_assign.result.outputs.Select(x => new
{
id = string.IsNullOrEmpty(x.id.ToString()) ? string.Empty : x.id.ToString().ToThaiNumber(),
@ -126,6 +135,7 @@ namespace BMA.EHR.Application.Repositories.Reports
Jobs = jobs,
Knowledges = knowledges,
Competencys = competencys,
CompetencyGroups = competencyGroups,
Outputs = outputs,
Skills = skills,
Laws = laws,

View file

@ -14,6 +14,7 @@
public List<Job> jobs { get; set; }
public List<Knowledge> knowledges { get; set; }
public List<Competency> competencys { get; set; }
public List<Competency> competency_groups { get; set; }
public List<Output> outputs { get; set; }
public List<Law> laws { get; set; }
public List<Skill> skills { get; set; }

View file

@ -9,10 +9,12 @@ namespace BMA.EHR.Application.Responses.Profiles
public string? Prefix { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? CitizenId { get; set; }
public Guid? Keycloak { get; set; }
public string? PosNo { get; set; }
public string? Position { get; set; }
public string? PositionLevel { get; set; }
public string? PositionType { get; set; }
public string? Oc { get; set; }
}
}

View file

@ -348,6 +348,7 @@ namespace BMA.EHR.DisciplineComplaint_Appeal.Service.Controllers
ProfileId = id,
Position = req.Position,
Oc = req.Oc,
profileType = org.result.profileType,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,

View file

@ -1,9 +1,12 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Application.Responses;
using BMA.EHR.Application.Responses.Profiles;
using BMA.EHR.Discipline.Service.Requests;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Models.Discipline;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Infrastructure.Persistence;
// using BMA.EHR.Placement.Service.Requests;
using Microsoft.AspNetCore.Authorization;
@ -28,17 +31,20 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
private readonly MinIODisciplineService _documentService;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly PermissionRepository _permission;
private readonly UserProfileRepository _userProfileRepository;
public DisciplineReportController(DisciplineDbContext context,
MinIODisciplineService documentService,
IHttpContextAccessor httpContextAccessor,
PermissionRepository permission)
PermissionRepository permission,
UserProfileRepository userProfileRepository)
{
// _repository = repository;
_context = context;
_documentService = documentService;
_httpContextAccessor = httpContextAccessor;
_permission = permission;
_userProfileRepository = userProfileRepository;
}
#region " Properties "
@ -46,6 +52,8 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
private string? UserId => _httpContextAccessor?.HttpContext?.User?.FindFirst(ClaimTypes.NameIdentifier)?.Value;
private string? FullName => _httpContextAccessor?.HttpContext?.User?.FindFirst("name")?.Value;
private string? AccessToken => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
#endregion
@ -60,39 +68,99 @@ namespace BMA.EHR.DisciplineSuspend.Service.Controllers
[HttpPost("{type}")]
public async Task<ActionResult<ResponseObject>> GetReportDiscipline([FromBody] DisciplineReportRequest req, string type)
{
// var data = await _context.DisciplineDisciplinary_ProfileComplaintInvestigates
// .Include(x => x.DisciplineDisciplinary)
// .Where(x => x.Id == d.id)
// .FirstOrDefaultAsync();
var getPermission = await _permission.GetPermissionAPIAsync("LIST", "SYS_DISCIPLINE_REPORT");
var jsonData = JsonConvert.DeserializeObject<JObject>(getPermission);
if (jsonData["status"]?.ToString() != "200")
{
return Error(jsonData["message"]?.ToString(), StatusCodes.Status403Forbidden);
}
var profile = new List<GetProfileByKeycloakIdRootDto>();
if (type.Trim().ToUpper() == "OFFICER")
{
profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
}
else
{
profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
}
// var profile = new List<GetProfileByKeycloakIdRootDto>();
// if (type.Trim().ToUpper() == "OFFICER")
// {
// profile = await _userProfileRepository.GetProfileWithKeycloakAllOfficer(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
// }
// else
// {
// profile = await _userProfileRepository.GetProfileWithKeycloakAllEmployee(AccessToken, req.node, req.nodeId, jsonData["result"] == "OWNER" || jsonData["result"] == "CHILD");
// }
if (req.posLevel != null || req.posType != null)
{
profile = profile.Where(x => x.PositionType == req.posType || x.PositionLevel == req.posLevel).ToList();
}
var data_search = await _context.DisciplineDisciplinarys
.Include(x => x.DisciplineDisciplinary_ProfileComplaintInvestigates)
.OrderByDescending(x => x.CreatedAt)
.ToListAsync();
if (req.status.Trim().ToUpper() != "ALL")
data_search = data_search.Where(x => x.Status.Contains(req.status.Trim().ToUpper())).ToList();
if (req.offenseDetail.Trim().ToUpper() != "ALL")
data_search = data_search.Where(x => x.OffenseDetails.Contains(req.status.Trim().ToUpper())).ToList();
if (req.disciplinaryFaultLevel.Trim().ToUpper() != "ALL")
data_search = data_search.Where(x => x.DisciplinaryFaultLevel.Contains(req.status.Trim().ToUpper())).ToList();
var mapData = data_search
.SelectMany((d) => d.DisciplineDisciplinary_ProfileComplaintInvestigates.Select((profile) => new
{
fullName = $"{profile.Prefix}{profile.FirstName} {profile.LastName}",
citizenId = profile.CitizenId,
position = profile.Position,
posLevel = profile.posLevelName,
oc = profile.Organization,
CreatedAt = profile.CreatedAt,
offense = d.OffenseDetails != null && d.OffenseDetails != ""
? d.OffenseDetails == "NOT_SPECIFIED"
? "ความผิดวินัยยังไม่ระบุ"
: d.OffenseDetails == "NOT_DEADLY"
? "ความผิดวินัยไม่ร้ายแรง"
: d.OffenseDetails == "DEADLY"
? "ความผิดวินัยร้ายแรง"
: ""
: "",
faultLevel = d.DisciplinaryFaultLevel,
}))
.Where(x =>
x.citizenId != null && profile.Any(p => p.CitizenId == x.citizenId))
.OrderByDescending(x => x.CreatedAt)
.ToList();
var count = 1;
var employees = new List<dynamic>();
foreach (var p in mapData)
{
var emp = new
{
no = count,
fullName = p.fullName,
citizenId = p.citizenId,
position = p.position,
posLevel = p.posLevel,
oc = profile.FirstOrDefault(x => x.CitizenId == p.citizenId)?.Oc ?? "",
offense = p.offense,
faultLevel = p.faultLevel,
one = 0,
two = 0,
three = 0,
};
employees.Add(emp);
count++;
}
var result = new
{
template = "reportDiscipline",
reportName = "reportDiscipline",
reportName = "xlsx-report",
data = new
{
year = req.year + 543,
data = new List<dynamic>()
year = (req.year + 543).ToString().ToThaiNumber(),
dateCurrent = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}",
data = employees
}
};
return Success(result);
}
}

View file

@ -468,7 +468,8 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
foreach (var data in data1)
{
data2.Add(data);
};
}
;
return Success(data2);
}
@ -820,6 +821,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งลงโทษ ปลดออกจากราชการ",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
isGovernment = false,
@ -920,6 +922,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งลงโทษ ไล่ออกจากราชการ",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
isGovernment = false,
@ -1034,7 +1037,8 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
positionno = p.PosNo,
organizationname = p.Organization,
salary = r.Amount,
RemarkHorizontal = r.RemarkHorizontal
RemarkVertical = r.RemarkVertical,
RemarkHorizontal = r.RemarkHorizontal,
}).ToList();
var result = new List<dynamic>();
@ -1097,6 +1101,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งลงโทษ พักจากราชการ",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
isGovernment = false,
@ -1213,6 +1218,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งลงโทษ ให้ออกจากราชการไว้ก่อน",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
isGovernment = false,
@ -1328,6 +1334,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งลงโทษ ลงโทษ ภาคทัณฑ์",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
profileType = p.profileType,
@ -1442,6 +1449,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งลงโทษ ตัดเงินเดือน",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
profileType = p.profileType,
@ -1556,6 +1564,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งลงโทษ ลดขั้นเงินเดือน",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
profileType = p.profileType,
@ -1670,6 +1679,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งเพิ่มโทษ",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
profileType = p.profileType,
@ -1784,6 +1794,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = p.DisciplineDisciplinary.DisciplinaryFaultLevel,
unStigma = "คำสั่งงดโทษ",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
profileType = p.profileType,
@ -1914,6 +1925,7 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
level = "",
unStigma = "คำสั่งยุติเรื่อง",
amount = r.amount,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
profileType = p.profileType,

View file

@ -17,8 +17,8 @@ namespace BMA.EHR.Discipline.Service.Requests
public string status { get; set; }
public string posType { get; set; }
public string? posType { get; set; }
public string posLevel { get; set; }
public string? posLevel { get; set; }
}
}

View file

@ -16,6 +16,7 @@ namespace BMA.EHR.Discipline.Service.Requests
public int commandYear { get; set; }
public string? templateDoc { get; set; }
public double? amount { get; set; }
public double? amountSpecial { get; set; }
public double? positionSalaryAmount { get; set; }
public double? mouthSalaryAmount { get; set; }
public string? refCommandCode { get; set; }

View file

@ -82,6 +82,9 @@ namespace BMA.EHR.Domain.Models.Retirement
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
[Comment("สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)")]
public string? profileType { get; set; }
public virtual List<RetirementDeceasedNoti> RetirementDeceasedNotis { get; set; } = new List<RetirementDeceasedNoti>();
}
}

View file

@ -89,5 +89,8 @@ namespace BMA.EHR.Domain.Models.Retirement
[Comment("สถานะการใช้งาน")]
public bool IsActive { get; set; } = true;
[Comment("สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)")]
public string? profileType { get; set; }
}
}

View file

@ -18,6 +18,8 @@ namespace BMA.EHR.Domain.Models.Retirement
[Comment("วันที่ขอออกราชการ")]
public DateTime? ActiveDate { get; set; }
[Comment("เหตุผลที่ลาออกจากราชการ")]
public string? ReasonResign { get; set; } = string.Empty;
[Comment("เหตุผลที่ลาออกจากราชการ")]
public string? Reason { get; set; } = string.Empty;
[Comment("เหตุผลที่ลาออกจากราชการ(อื่นๆ)")]
public string? Remark { get; set; } = string.Empty;

View file

@ -18,6 +18,8 @@ namespace BMA.EHR.Domain.Models.Retirement
[Comment("วันที่ขอออกราชการ")]
public DateTime? ActiveDate { get; set; }
[Comment("เหตุผลที่ลาออกจากราชการ")]
public string? ReasonResign { get; set; } = string.Empty;
[Comment("เหตุผลที่ลาออกจากราชการ")]
public string? Reason { get; set; } = string.Empty;
[Comment("เหตุผลที่ลาออกจากราชการ(อื่นๆ)")]
public string? Remark { get; set; } = string.Empty;

View file

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableRetirementResignsaddReasonResign : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "ReasonResign",
table: "RetirementResigns",
type: "longtext",
nullable: true,
comment: "เหตุผลที่ลาออกจากราชการ")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "ReasonResign",
table: "RetirementResignEmployees",
type: "longtext",
nullable: true,
comment: "เหตุผลที่ลาออกจากราชการ")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ReasonResign",
table: "RetirementResigns");
migrationBuilder.DropColumn(
name: "ReasonResign",
table: "RetirementResignEmployees");
}
}
}

View file

@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace BMA.EHR.Infrastructure.Migrations
{
/// <inheritdoc />
public partial class updatetableRetirementResignsaddprofiletype : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "profileType",
table: "RetirementOuts",
type: "longtext",
nullable: true,
comment: "สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)")
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<string>(
name: "profileType",
table: "RetirementDeceaseds",
type: "longtext",
nullable: true,
comment: "สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)")
.Annotation("MySql:CharSet", "utf8mb4");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "profileType",
table: "RetirementOuts");
migrationBuilder.DropColumn(
name: "profileType",
table: "RetirementDeceaseds");
}
}
}

View file

@ -14324,6 +14324,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("profile Id");
b.Property<string>("profileType")
.HasColumnType("longtext")
.HasComment("สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)");
b.Property<string>("root")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน root");
@ -15121,6 +15125,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("profile Id");
b.Property<string>("profileType")
.HasColumnType("longtext")
.HasComment("สถานภาพ (OFFICER->ข้าราชการ EMPLOYEE->ลูกจ้างประจำ)");
b.Property<string>("rootOld")
.HasColumnType("longtext")
.HasComment("ชื่อหน่วยงาน root old");
@ -16021,6 +16029,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("เหตุผลที่ลาออกจากราชการ");
b.Property<string>("ReasonResign")
.HasColumnType("longtext")
.HasComment("เหตุผลที่ลาออกจากราชการ");
b.Property<string>("RejectReason")
.HasColumnType("longtext")
.HasComment("เหตุผลไม่อนุมัติ");
@ -16722,6 +16734,10 @@ namespace BMA.EHR.Infrastructure.Migrations
.HasColumnType("longtext")
.HasComment("เหตุผลที่ลาออกจากราชการ");
b.Property<string>("ReasonResign")
.HasColumnType("longtext")
.HasComment("เหตุผลที่ลาออกจากราชการ");
b.Property<string>("RejectReason")
.HasColumnType("longtext")
.HasComment("เหตุผลไม่อนุมัติ");

View file

@ -397,6 +397,50 @@ namespace BMA.EHR.Placement.Service.Controllers
return Success(new List<dynamic>());
}
[HttpGet("exam-probation/{citizenId:length(13)}")]
public async Task<ActionResult<ResponseObject>> GetDataExamByPlacement(string citizenId)
{
var dateAppoint = string.Empty;
var apiUrl = $"{_configuration["API"]}/org/profile/citizenid/position/{citizenId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
if (_res.IsSuccessStatusCode)
{
var json = JObject.Parse(_result);
var dateAppointToken = json["result"]?["dateAppoint"];
if (dateAppointToken != null)
{
dateAppoint = dateAppointToken.ToString();
}
}
}
var placementProfile = await _context.PlacementProfiles
.Include(x => x.Placement)
.Select(x => new
{
fullName = $"{x.Prefix}{x.Firstname} {x.Lastname}",
citizenId = x.CitizenId,
examName = x.Placement.Name,
})
.Where(x => x.citizenId == citizenId.ToString())
.FirstOrDefaultAsync();
var data = new
{
fullName = placementProfile != null ? placementProfile.fullName : "",
citizenId = placementProfile != null ? placementProfile.citizenId : "",
examName = placementProfile != null ? placementProfile.examName : "",
dateAppoint = dateAppoint
};
return Success(data);
}
[HttpGet("personal/{personalId:length(36)}")]
public async Task<ActionResult<ResponseObject>> GetProfileByUser(Guid personalId)
{
@ -1529,7 +1573,7 @@ namespace BMA.EHR.Placement.Service.Controllers
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "-" :
p.PlacementEducations.FirstOrDefault().Degree,
$"{p.PlacementEducations.FirstOrDefault().Degree} {p.PlacementEducations.FirstOrDefault().Field}",
PositionName = p.positionName == null ? "-" : p.positionName,
ExamNumber = p.ExamNumber == null ? "-" : p.ExamNumber.Value.ToString().ToThaiNumber(),
PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}",
@ -1849,7 +1893,7 @@ namespace BMA.EHR.Placement.Service.Controllers
No = r.Sequence.ToString().ToThaiNumber(),
FullName = $"{r.Prefix}{r.FirstName} {r.LastName}",
Education = p.PlacementEducations == null || p.PlacementEducations.Count == 0 ? "-" :
p.PlacementEducations.FirstOrDefault().Degree,
$"{p.PlacementEducations.FirstOrDefault().Degree} {p.PlacementEducations.FirstOrDefault().Field}",
PositionName = p.positionName == null ? "-" : p.positionName,
ExamNumber = p.ExamNumber == null ? "-" : p.ExamNumber.Value.ToString().ToThaiNumber(),
PlacementName = $"{p.Placement.Name.ToThaiNumber()} ครั้งที่ {p.Placement.Round.ToThaiNumber()}/{p.Placement.Year.ToThaiYear().ToString().ToThaiNumber()}",
@ -1956,7 +2000,7 @@ namespace BMA.EHR.Placement.Service.Controllers
posLevelId = p.posLevelId == null ? string.Empty : p.posLevelId,
posTypeId = p.posTypeId == null ? string.Empty : p.posTypeId,
email = p.Email == null ? string.Empty : p.Email,
phone = p.MobilePhone == null ? string.Empty : p.MobilePhone,
phone = p.Telephone == null ? string.Empty : p.Telephone,
keycloak = string.Empty,
isProbation = true,
isLeave = false,
@ -2773,15 +2817,285 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("report1")]
public async Task<ActionResult<ResponseObject>> report1(string? nodeId = null, int? node = 0, DateOnly? startDate = null, DateOnly? startEnd = null)
public async Task<ActionResult<ResponseObject>> report1(string nodeId = "", int? node = null, DateTime? startDate = null, DateTime? endDate = null)
{
var data = new
var apiUrl = $"{_configuration["API"]}/org/find/node-all";
var data = new object();
var data1 = new List<dynamic>();
var data2 = new List<dynamic>();
using (var client = new HttpClient())
{
template = "placement01",
reportName = "xlsx-report",
data = ""
};
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
node,
nodeId,
});
var _result = await _res.Content.ReadAsStringAsync();
var orgs = JsonConvert.DeserializeObject<NodeAllRequest>(_result);
if (orgs == null || orgs.result == null)
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
int no = 1;
foreach (var item in orgs.result.isRootTrue)
{
var placementProfiles = _context.PlacementProfiles
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootId.Contains(item.rootId) &&
x.PlacementStatus.Trim().ToUpper() == "DONE")
.GroupBy(x => x.typeCommand.Trim().ToUpper())
.Select(g => new
{
TypeCommand = g.Key,
Count = g.Count()
})
.ToList();
var placementAppointments = _context.PlacementAppointments
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE" &&
x.type.Trim().ToUpper() == "OFFICER")
.GroupBy(x => x.typeCommand.Trim().ToUpper())
.Select(g => new
{
TypeCommand = g.Key,
Count = g.Count()
})
.ToList();
var pt_count = _context.PlacementTransfers
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var pr_count = _context.PlacementReceives
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var po_count = _context.PlacementOfficers
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var prp_count = _context.PlacementRepatriations
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var ro_count = _context.RetirementOthers
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var pp_appoint = placementProfiles.FirstOrDefault(x => x.TypeCommand == "APPOINT")?.Count ?? 0;
var pp_slip = placementProfiles.FirstOrDefault(x => x.TypeCommand == "SLIP")?.Count ?? 0;
var pp_move = placementProfiles.FirstOrDefault(x => x.TypeCommand == "MOVE")?.Count ?? 0;
var pa_appoint = placementAppointments.FirstOrDefault(x => x.TypeCommand == "APPOINT")?.Count ?? 0;
var pa_slip = placementAppointments.FirstOrDefault(x => x.TypeCommand == "SLIP")?.Count ?? 0;
var pa_move = placementAppointments.FirstOrDefault(x => x.TypeCommand == "MOVE")?.Count ?? 0;
data1.Add(new
{
no = no,
rootName = item.name,
pp_appoint = pp_appoint,
pp_slip = pp_slip,
pp_move = pp_move,
pa_appoint = pa_appoint,
pa_slip = pa_slip,
pa_move = pa_move,
pt_count = pt_count,
pr_count = pr_count,
po_count = po_count,
prp_count = prp_count,
ro_count = ro_count,
total = (pp_appoint + pp_slip + pp_move + pa_appoint + pa_slip + pa_move + pt_count + pr_count + po_count + prp_count + ro_count)
});
no++;
}
no = 1;
foreach (var item in orgs.result.isRootFalse)
{
var placementProfiles = _context.PlacementProfiles
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootId.Contains(item.rootId) &&
x.PlacementStatus.Trim().ToUpper() == "DONE")
.GroupBy(x => x.typeCommand.Trim().ToUpper())
.Select(g => new
{
TypeCommand = g.Key,
Count = g.Count()
})
.ToList();
var placementAppointments = _context.PlacementAppointments
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE" &&
x.type.Trim().ToUpper() == "OFFICER")
.GroupBy(x => x.typeCommand.Trim().ToUpper())
.Select(g => new
{
TypeCommand = g.Key,
Count = g.Count()
})
.ToList();
var pt_count = _context.PlacementTransfers
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var pr_count = _context.PlacementReceives
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var po_count = _context.PlacementOfficers
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var prp_count = _context.PlacementRepatriations
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var ro_count = _context.RetirementOthers
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
var pp_appoint = placementProfiles.FirstOrDefault(x => x.TypeCommand == "APPOINT")?.Count ?? 0;
var pp_slip = placementProfiles.FirstOrDefault(x => x.TypeCommand == "SLIP")?.Count ?? 0;
var pp_move = placementProfiles.FirstOrDefault(x => x.TypeCommand == "MOVE")?.Count ?? 0;
var pa_appoint = placementAppointments.FirstOrDefault(x => x.TypeCommand == "APPOINT")?.Count ?? 0;
var pa_slip = placementAppointments.FirstOrDefault(x => x.TypeCommand == "SLIP")?.Count ?? 0;
var pa_move = placementAppointments.FirstOrDefault(x => x.TypeCommand == "MOVE")?.Count ?? 0;
data2.Add(new
{
no = no,
rootName = item.name,
pp_appoint = pp_appoint,
pp_slip = pp_slip,
pp_move = pp_move,
pa_appoint = pa_appoint,
pa_slip = pa_slip,
pa_move = pa_move,
pt_count = pt_count,
pr_count = pr_count,
po_count = po_count,
prp_count = prp_count,
ro_count = ro_count,
total = (pp_appoint + pp_slip + pp_move + pa_appoint + pa_slip + pa_move + pt_count + pr_count + po_count + prp_count + ro_count)
});
no++;
}
}
data = new
{
template = "reportPlacement01All",
reportName = "xlsx-report",
data = new
{
date = $"ตั้งแต่วันที่ {startDate.Value.Date.ToThaiShortDate().ToThaiNumber()} ถึง {endDate.Value.Date.ToThaiShortDate().ToThaiNumber()}",
dateCurrent = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}",
data1,
data1Count = new
{
pp_appoint = data1.Where(x => x.pp_appoint > 0).Sum(x => x.pp_appoint),
pp_slip = data1.Where(x => x.pp_slip > 0).Sum(x => x.pp_slip),
pp_move = data1.Where(x => x.pp_move > 0).Sum(x => x.pp_move),
pa_appoint = data1.Where(x => x.pa_appoint > 0).Sum(x => x.pa_appoint),
pa_slip = data1.Where(x => x.pa_slip > 0).Sum(x => x.pa_slip),
pa_move = data1.Where(x => x.pa_move > 0).Sum(x => x.pa_move),
pt_count = data1.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
pr_count = data1.Where(x => x.pr_count > 0).Sum(x => x.pr_count),
po_count = data1.Where(x => x.po_count > 0).Sum(x => x.po_count),
prp_count = data1.Where(x => x.prp_count > 0).Sum(x => x.prp_count),
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
total = data1.Where(x => x.total > 0).Sum(x => x.total)
},
data2,
data2Count = new
{
pp_appoint = data2.Where(x => x.pp_appoint > 0).Sum(x => x.pp_appoint),
pp_slip = data2.Where(x => x.pp_slip > 0).Sum(x => x.pp_slip),
pp_move = data2.Where(x => x.pp_move > 0).Sum(x => x.pp_move),
pa_appoint = data2.Where(x => x.pa_appoint > 0).Sum(x => x.pa_appoint),
pa_slip = data2.Where(x => x.pa_slip > 0).Sum(x => x.pa_slip),
pa_move = data2.Where(x => x.pa_move > 0).Sum(x => x.pa_move),
pt_count = data2.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
pr_count = data2.Where(x => x.pr_count > 0).Sum(x => x.pr_count),
po_count = data2.Where(x => x.po_count > 0).Sum(x => x.po_count),
prp_count = data2.Where(x => x.prp_count > 0).Sum(x => x.prp_count),
ro_count = data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
total = data2.Where(x => x.total > 0).Sum(x => x.total)
},
sum = new
{
pp_appoint = data1.Where(x => x.pp_appoint > 0).Sum(x => x.pp_appoint) + data2.Where(x => x.pp_appoint > 0).Sum(x => x.pp_appoint),
pp_slip = data1.Where(x => x.pp_slip > 0).Sum(x => x.pp_slip) + data2.Where(x => x.pp_slip > 0).Sum(x => x.pp_slip),
pp_move = data1.Where(x => x.pp_move > 0).Sum(x => x.pp_move) + data2.Where(x => x.pp_move > 0).Sum(x => x.pp_move),
pa_appoint = data1.Where(x => x.pa_appoint > 0).Sum(x => x.pa_appoint) + data2.Where(x => x.pa_appoint > 0).Sum(x => x.pa_appoint),
pa_slip = data1.Where(x => x.pa_slip > 0).Sum(x => x.pa_slip) + data2.Where(x => x.pa_slip > 0).Sum(x => x.pa_slip),
pa_move = data1.Where(x => x.pa_move > 0).Sum(x => x.pa_move) + data2.Where(x => x.pa_move > 0).Sum(x => x.pa_move),
pt_count = data1.Where(x => x.pt_count > 0).Sum(x => x.pt_count) + data2.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
pr_count = data1.Where(x => x.pr_count > 0).Sum(x => x.pr_count) + data2.Where(x => x.pr_count > 0).Sum(x => x.pr_count),
po_count = data1.Where(x => x.po_count > 0).Sum(x => x.po_count) + data2.Where(x => x.po_count > 0).Sum(x => x.po_count),
prp_count = data1.Where(x => x.prp_count > 0).Sum(x => x.prp_count) + data2.Where(x => x.prp_count > 0).Sum(x => x.prp_count),
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count) + data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
total = data1.Where(x => x.total > 0).Sum(x => x.total) + data2.Where(x => x.total > 0).Sum(x => x.total)
}
}
};
return Success(data);
}
@ -2794,17 +3108,129 @@ namespace BMA.EHR.Placement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("report2")]
public async Task<ActionResult<ResponseObject>> report2(string? nodeId = null, int? node = 0, DateOnly? startDate = null, DateOnly? startEnd = null)
public async Task<ActionResult<ResponseObject>> report2(string nodeId = "", int? node = null, DateTime? startDate = null, DateTime? endDate = null)
{
var data = new
var apiUrl = $"{_configuration["API"]}/org/find/node-all";
var data = new object();
var data1 = new List<dynamic>();
var data2 = new List<dynamic>();
using (var client = new HttpClient())
{
template = "placement02",
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
node,
nodeId,
});
var _result = await _res.Content.ReadAsStringAsync();
var orgs = JsonConvert.DeserializeObject<NodeAllRequest>(_result);
if (orgs == null || orgs.result == null)
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
int no = 1;
foreach (var item in orgs.result.isRootTrue)
{
var placementAppointments = _context.PlacementAppointments
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE" &&
x.type.Trim().ToUpper() == "OFFICER")
.GroupBy(x => x.typeCommand.Trim().ToUpper())
.Select(g => new
{
TypeCommand = g.Key,
Count = g.Count()
})
.ToList();
var pa_appoint = placementAppointments.FirstOrDefault(x => x.TypeCommand == "APPOINT")?.Count ?? 0;
var pa_slip = placementAppointments.FirstOrDefault(x => x.TypeCommand == "SLIP")?.Count ?? 0;
var pa_move = placementAppointments.FirstOrDefault(x => x.TypeCommand == "MOVE")?.Count ?? 0;
data1.Add(new
{
no = no,
rootName = item.name,
pa_appoint = pa_appoint,
pa_slip = pa_slip,
pa_move = pa_move,
total = (pa_appoint + pa_slip + pa_move)
});
no++;
}
no = 1;
foreach (var item in orgs.result.isRootFalse)
{
var placementAppointments = _context.PlacementAppointments
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootId.Contains(item.rootId) &&
x.Status.Trim().ToUpper() == "DONE" &&
x.type.Trim().ToUpper() == "OFFICER")
.GroupBy(x => x.typeCommand.Trim().ToUpper())
.Select(g => new
{
TypeCommand = g.Key,
Count = g.Count()
})
.ToList();
var pa_appoint = placementAppointments.FirstOrDefault(x => x.TypeCommand == "APPOINT")?.Count ?? 0;
var pa_slip = placementAppointments.FirstOrDefault(x => x.TypeCommand == "SLIP")?.Count ?? 0;
var pa_move = placementAppointments.FirstOrDefault(x => x.TypeCommand == "MOVE")?.Count ?? 0;
data2.Add(new
{
no = no,
rootName = item.name,
pa_appoint = pa_appoint,
pa_slip = pa_slip,
pa_move = pa_move,
total = (pa_appoint + pa_slip + pa_move)
});
no++;
}
}
data = new
{
template = "reportPlacement02All",
reportName = "xlsx-report",
data = ""
data = new
{
date = $"ตั้งแต่วันที่ {startDate.Value.Date.ToThaiShortDate().ToThaiNumber()} ถึง {endDate.Value.Date.ToThaiShortDate().ToThaiNumber()}",
dateCurrent = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}",
data1,
data1Count = new
{
pa_appoint = data1.Where(x => x.pa_appoint > 0).Sum(x => x.pa_appoint),
pa_slip = data1.Where(x => x.pa_slip > 0).Sum(x => x.pa_slip),
pa_move = data1.Where(x => x.pa_move > 0).Sum(x => x.pa_move),
total = data1.Where(x => x.total > 0).Sum(x => x.total)
},
data2,
data2Count = new
{
pa_appoint = data2.Where(x => x.pa_appoint > 0).Sum(x => x.pa_appoint),
pa_slip = data2.Where(x => x.pa_slip > 0).Sum(x => x.pa_slip),
pa_move = data2.Where(x => x.pa_move > 0).Sum(x => x.pa_move),
total = data2.Where(x => x.total > 0).Sum(x => x.total)
},
sum = new
{
pa_appoint = data1.Where(x => x.pa_appoint > 0).Sum(x => x.pa_appoint) + data2.Where(x => x.pa_appoint > 0).Sum(x => x.pa_appoint),
pa_slip = data1.Where(x => x.pa_slip > 0).Sum(x => x.pa_slip) + data2.Where(x => x.pa_slip > 0).Sum(x => x.pa_slip),
pa_move = data1.Where(x => x.pa_move > 0).Sum(x => x.pa_move) + data2.Where(x => x.pa_move > 0).Sum(x => x.pa_move),
total = data1.Where(x => x.total > 0).Sum(x => x.total) + data2.Where(x => x.total > 0).Sum(x => x.total)
}
}
};
return Success(data);
}
}

View file

@ -675,6 +675,7 @@ namespace BMA.EHR.Placement.Service.Controllers
date = r.commandAffectDate,
amount = r.amount,
commandId = r.commandId,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
posNo = p.PositionNumberOld,

View file

@ -500,6 +500,7 @@ namespace BMA.EHR.Placement.Service.Controllers
date = r.commandAffectDate,
amount = r.amount,
commandId = r.commandId,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
posNo = p.PositionNumberOld,

View file

@ -0,0 +1,24 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Placement.Service.Requests
{
public class NodeAllRequest
{
public NodeAllResult result { get; set; } = new();
}
public class NodeAllResult
{
public List<NodeAllRequestData> isRootTrue { get; set; } = new();
public List<NodeAllRequestData> isRootFalse { get; set; } = new();
}
public class NodeAllRequestData
{
public string? name { get; set; }
public string? rootId { get; set; }
public string? child1Id { get; set; }
public string? child2Id { get; set; }
public string? child3Id { get; set; }
public string? child4Id { get; set; }
}
}

View file

@ -33,7 +33,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IConfiguration _configuration;
private readonly PermissionRepository _permission;
private readonly DisciplineDbContext _contextDiscipline;
public RetirementController(RetirementRepository repository,
NotificationRepository repositoryNoti,
ApplicationDBContext context,
@ -41,7 +41,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
IConfiguration configuration,
OrganizationCommonRepository organizationCommonRepository,
IHttpContextAccessor httpContextAccessor,
PermissionRepository permission)
PermissionRepository permission,
DisciplineDbContext contextDiscipline)
{
_repository = repository;
_repositoryNoti = repositoryNoti;
@ -51,6 +52,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
_permission = permission;
_contextDiscipline = contextDiscipline;
}
#region " Properties "
@ -1290,15 +1292,286 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("report1")]
public async Task<ActionResult<ResponseObject>> report1(string? nodeId = null, int? node = 0, DateOnly? startDate = null, DateOnly? startEnd = null)
public async Task<ActionResult<ResponseObject>> report1(string nodeId = "", int? node = null, DateTime? startDate = null, DateTime? endDate = null)
{
var data = new
{
template = "retirement01",
reportName = "xlsx-report",
data = ""
};
var apiUrl = $"{_configuration["API"]}/org/find/node-all";
var data = new object();
var data1 = new List<dynamic>();
var data2 = new List<dynamic>();
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
node,
nodeId
});
var _result = await _res.Content.ReadAsStringAsync();
var orgs = JsonConvert.DeserializeObject<NodeAllRequest>(_result);
if (orgs == null || orgs.result == null)
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
int no = 1;
foreach (var org in orgs.result.isRootTrue)
{
//เกษียณ
var retire = _context.RetirementPeriods
.Include(x => x.RetirementProfiles.Where(x => x.rootId == org.rootId))
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Type.Trim().ToUpper() == "OFFICER")
.FirstOrDefault();
var rt_count = retire != null ? retire.RetirementProfiles.Count() : 0;
//ลาออก
var retirementResigns = _context.RetirementResigns
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId == org.rootId &&
x.IsCancel == false && x.Status == "DONE")
.ToList();
var career_count = retirementResigns.Where(x => x.Reason == "CAREER").Count();
var move_count = retirementResigns.Where(x => x.Reason == "MOVE").Count();
var family_count = retirementResigns.Where(x => x.Reason == "FAMILY").Count();
var education_count = retirementResigns.Where(x => x.Reason == "EDUCATION").Count();
var other_count = retirementResigns.Where(x => x.Reason == "OTHER").Count();
//ขอโอน
var pt_count = _context.PlacementTransfers
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(org.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
//ถึงแก่กรรม
var rd_count = _context.RetirementDeceaseds
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.rootId.Contains(org.rootId))
.Count();
//ให้ออก
var ro_count = _context.RetirementOuts
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.rootOldId.Contains(org.rootId))
.Count();
//ปลดออก
var dl_cm19_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.CommandTypeId == Guid.Parse("ef8db4d7-1472-4c1d-b73f-9114e618a96f") &&
x.rootId.Contains(org.rootId))
.Count();
//ไล่ออก
var dl_cm20_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.CommandTypeId == Guid.Parse("d9dee5c3-b75a-4927-9ce2-51e2233cf20b") &&
x.rootId.Contains(org.rootId))
.Count();
data1.Add(new
{
no = no,
rootName = org.name,
rt_count,
career_count,
move_count,
family_count,
education_count,
other_count,
pt_count,
rd_count,
ro_count,
dl_cm19_count,
dl_cm20_count,
total = (rt_count + career_count + move_count + family_count + education_count + other_count + pt_count + rd_count + ro_count + dl_cm19_count + dl_cm20_count)
});
no++;
}
no = 1;
foreach (var org in orgs.result.isRootFalse)
{
//เกษียณ
var retire = _context.RetirementPeriods
.Include(x => x.RetirementProfiles.Where(x => x.rootId == org.rootId))
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Type.Trim().ToUpper() == "OFFICER")
.FirstOrDefault();
var rt_count = retire != null ? retire.RetirementProfiles.Count() : 0;
//ลาออก
var retirementResigns = _context.RetirementResigns
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId == org.rootId &&
x.IsCancel == false && x.Status == "DONE")
.ToList();
var career_count = retirementResigns.Where(x => x.Reason == "CAREER").Count();
var move_count = retirementResigns.Where(x => x.Reason == "MOVE").Count();
var family_count = retirementResigns.Where(x => x.Reason == "FAMILY").Count();
var education_count = retirementResigns.Where(x => x.Reason == "EDUCATION").Count();
var other_count = retirementResigns.Where(x => x.Reason == "OTHER").Count();
//ขอโอน
var pt_count = _context.PlacementTransfers
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId.Contains(org.rootId) &&
x.Status.Trim().ToUpper() == "DONE")
.Count();
//ถึงแก่กรรม
var rd_count = _context.RetirementDeceaseds
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.rootId.Contains(org.rootId))
.Count();
//ให้ออก
var ro_count = _context.RetirementOuts
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.rootOldId.Contains(org.rootId))
.Count();
//ปลดออก
var dl_cm19_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.CommandTypeId == Guid.Parse("ef8db4d7-1472-4c1d-b73f-9114e618a96f") &&
x.rootId.Contains(org.rootId))
.Count();
//ไล่ออก
var dl_cm20_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.CommandTypeId == Guid.Parse("d9dee5c3-b75a-4927-9ce2-51e2233cf20b") &&
x.rootId.Contains(org.rootId))
.Count();
data2.Add(new
{
no = no,
rootName = org.name,
rt_count,
career_count,
move_count,
family_count,
education_count,
other_count,
pt_count,
rd_count,
ro_count,
dl_cm19_count,
dl_cm20_count,
total = (rt_count + career_count + move_count + family_count + education_count + other_count + pt_count + rd_count + ro_count + dl_cm19_count + dl_cm20_count)
});
no++;
}
}
data = new
{
template = "reportRetirement01All",
reportName = "xlsx-report",
data = new
{
date = $"ตั้งแต่วันที่ {startDate.Value.Date.ToThaiShortDate().ToThaiNumber()} ถึง {endDate.Value.Date.ToThaiShortDate().ToThaiNumber()}",
dateCurrent = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}",
data1,
data1Count = new
{
rt_count = data1.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
career_count = data1.Where(x => x.career_count > 0).Sum(x => x.career_count),
move_count = data1.Where(x => x.move_count > 0).Sum(x => x.move_count),
family_count = data1.Where(x => x.family_count > 0).Sum(x => x.family_count),
education_count = data1.Where(x => x.education_count > 0).Sum(x => x.education_count),
other_count = data1.Where(x => x.other_count > 0).Sum(x => x.other_count),
pt_count = data1.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
rd_count = data1.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
dl_cm19_count = data1.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
dl_cm20_count = data1.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
total = data1.Where(x => x.total > 0).Sum(x => x.total)
},
data2,
data2Count = new
{
rt_count = data2.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
career_count = data2.Where(x => x.career_count > 0).Sum(x => x.career_count),
move_count = data2.Where(x => x.move_count > 0).Sum(x => x.move_count),
family_count = data2.Where(x => x.family_count > 0).Sum(x => x.family_count),
education_count = data2.Where(x => x.education_count > 0).Sum(x => x.education_count),
other_count = data2.Where(x => x.other_count > 0).Sum(x => x.other_count),
pt_count = data2.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
rd_count = data2.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
ro_count = data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
dl_cm19_count = data2.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
dl_cm20_count = data2.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
total = data2.Where(x => x.total > 0).Sum(x => x.total)
},
sum = new
{
rt_count = data1.Where(x => x.rt_count > 0).Sum(x => x.rt_count) + data2.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
career_count = data1.Where(x => x.career_count > 0).Sum(x => x.career_count) + data2.Where(x => x.career_count > 0).Sum(x => x.career_count),
move_count = data1.Where(x => x.move_count > 0).Sum(x => x.move_count) + data2.Where(x => x.move_count > 0).Sum(x => x.move_count),
family_count = data1.Where(x => x.family_count > 0).Sum(x => x.family_count) + data2.Where(x => x.family_count > 0).Sum(x => x.family_count),
education_count = data1.Where(x => x.education_count > 0).Sum(x => x.education_count) + data2.Where(x => x.education_count > 0).Sum(x => x.education_count),
other_count = data1.Where(x => x.other_count > 0).Sum(x => x.other_count) + data2.Where(x => x.other_count > 0).Sum(x => x.other_count),
pt_count = data1.Where(x => x.pt_count > 0).Sum(x => x.pt_count) + data2.Where(x => x.pt_count > 0).Sum(x => x.pt_count),
rd_count = data1.Where(x => x.rd_count > 0).Sum(x => x.rd_count) + data2.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count) + data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
dl_cm19_count = data1.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count) + data2.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
dl_cm20_count = data1.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count) + data2.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
total = data1.Where(x => x.total > 0).Sum(x => x.total) + data2.Where(x => x.total > 0).Sum(x => x.total)
}
}
};
return Success(data);
}
@ -1311,17 +1584,263 @@ namespace BMA.EHR.Retirement.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpGet("report2")]
public async Task<ActionResult<ResponseObject>> report2(string? nodeId = null, int? node = 0, DateOnly? startDate = null, DateOnly? startEnd = null)
public async Task<ActionResult<ResponseObject>> report2(string nodeId = "", int? node = null, DateTime? startDate = null, DateTime? endDate = null)
{
var data = new
var apiUrl = $"{_configuration["API"]}/org/find/node-all";
var data = new object();
var data1 = new List<dynamic>();
var data2 = new List<dynamic>();
using (var client = new HttpClient())
{
template = "retirement02",
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Post, apiUrl);
var _res = await client.PostAsJsonAsync(apiUrl, new
{
node,
nodeId
});
var _result = await _res.Content.ReadAsStringAsync();
var orgs = JsonConvert.DeserializeObject<NodeAllRequest>(_result);
if (orgs == null || orgs.result == null)
return Error("ไม่พบหน่วยงานนี้ในระบบ", 404);
int no = 1;
foreach (var org in orgs.result.isRootTrue)
{
//เกษียณ
var retire = _context.RetirementPeriods
.Include(x => x.RetirementProfiles.Where(x => x.rootId == org.rootId))
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Type.Trim().ToUpper() == "OFFICER")
.FirstOrDefault();
var rt_count = retire != null ? retire.RetirementProfiles.Count() : 0;
//ลาออก
var retirementResigns = _context.RetirementResigns
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId == org.rootId &&
x.IsCancel == false && x.Status == "DONE")
.ToList();
var career_count = retirementResigns.Where(x => x.Reason == "CAREER").Count();
var move_count = retirementResigns.Where(x => x.Reason == "MOVE").Count();
var family_count = retirementResigns.Where(x => x.Reason == "FAMILY").Count();
var education_count = retirementResigns.Where(x => x.Reason == "EDUCATION").Count();
var other_count = retirementResigns.Where(x => x.Reason == "OTHER").Count();
//ถึงแก่กรรม
var rd_count = _context.RetirementDeceaseds
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.rootId.Contains(org.rootId))
.Count();
//ให้ออก
var ro_count = _context.RetirementOuts
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.rootOldId.Contains(org.rootId))
.Count();
//ปลดออก
var dl_cm19_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.CommandTypeId == Guid.Parse("ef8db4d7-1472-4c1d-b73f-9114e618a96f") &&
x.rootId.Contains(org.rootId))
.Count();
//ไล่ออก
var dl_cm20_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.CommandTypeId == Guid.Parse("d9dee5c3-b75a-4927-9ce2-51e2233cf20b") &&
x.rootId.Contains(org.rootId))
.Count();
data1.Add(new
{
no = no,
rootName = org.name,
rt_count,
career_count,
move_count,
family_count,
education_count,
other_count,
rd_count,
ro_count,
dl_cm19_count,
dl_cm20_count,
total = (rt_count + career_count + move_count + family_count + education_count + other_count + rd_count + ro_count + dl_cm19_count + dl_cm20_count)
});
no++;
}
no = 1;
foreach (var org in orgs.result.isRootFalse)
{
//เกษียณ
var retire = _context.RetirementPeriods
.Include(x => x.RetirementProfiles.Where(x => x.rootId == org.rootId))
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Type.Trim().ToUpper() == "OFFICER")
.FirstOrDefault();
var rt_count = retire != null ? retire.RetirementProfiles.Count() : 0;
//ลาออก
var retirementResigns = _context.RetirementResigns
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.rootOldId == org.rootId &&
x.IsCancel == false && x.Status == "DONE")
.ToList();
var career_count = retirementResigns.Where(x => x.Reason == "CAREER").Count();
var move_count = retirementResigns.Where(x => x.Reason == "MOVE").Count();
var family_count = retirementResigns.Where(x => x.Reason == "FAMILY").Count();
var education_count = retirementResigns.Where(x => x.Reason == "EDUCATION").Count();
var other_count = retirementResigns.Where(x => x.Reason == "OTHER").Count();
//ถึงแก่กรรม
var rd_count = _context.RetirementDeceaseds
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.rootId.Contains(org.rootId))
.Count();
//ให้ออก
var ro_count = _context.RetirementOuts
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.rootOldId.Contains(org.rootId))
.Count();
//ปลดออก
var dl_cm19_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.CommandTypeId == Guid.Parse("ef8db4d7-1472-4c1d-b73f-9114e618a96f") &&
x.rootId.Contains(org.rootId))
.Count();
//ไล่ออก
var dl_cm20_count = _contextDiscipline.DisciplineDisciplinary_ProfileComplaintInvestigates
.Where(x =>
x.CreatedAt.Date >= startDate &&
x.CreatedAt.Date <= endDate &&
x.Status.Trim().ToUpper() == "DONE" &&
x.profileType.Trim().ToUpper() == "OFFICER" &&
x.CommandTypeId == Guid.Parse("d9dee5c3-b75a-4927-9ce2-51e2233cf20b") &&
x.rootId.Contains(org.rootId))
.Count();
data2.Add(new
{
no = no,
rootName = org.name,
rt_count,
career_count,
move_count,
family_count,
education_count,
other_count,
rd_count,
ro_count,
dl_cm19_count,
dl_cm20_count,
total = (rt_count + career_count + move_count + family_count + education_count + other_count + rd_count + ro_count + dl_cm19_count + dl_cm20_count)
});
no++;
}
}
data = new
{
template = "reportRetirement02All",
reportName = "xlsx-report",
data = ""
data = new
{
date = $"ตั้งแต่วันที่ {startDate.Value.Date.ToThaiShortDate().ToThaiNumber()} ถึง {endDate.Value.Date.ToThaiShortDate().ToThaiNumber()}",
dateCurrent = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}",
data1,
data1Count = new
{
rt_count = data1.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
career_count = data1.Where(x => x.career_count > 0).Sum(x => x.career_count),
move_count = data1.Where(x => x.move_count > 0).Sum(x => x.move_count),
family_count = data1.Where(x => x.family_count > 0).Sum(x => x.family_count),
education_count = data1.Where(x => x.education_count > 0).Sum(x => x.education_count),
other_count = data1.Where(x => x.other_count > 0).Sum(x => x.other_count),
rd_count = data1.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
dl_cm19_count = data1.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
dl_cm20_count = data1.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
total = data1.Where(x => x.total > 0).Sum(x => x.total)
},
data2,
data2Count = new
{
rt_count = data2.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
career_count = data2.Where(x => x.career_count > 0).Sum(x => x.career_count),
move_count = data2.Where(x => x.move_count > 0).Sum(x => x.move_count),
family_count = data2.Where(x => x.family_count > 0).Sum(x => x.family_count),
education_count = data2.Where(x => x.education_count > 0).Sum(x => x.education_count),
other_count = data2.Where(x => x.other_count > 0).Sum(x => x.other_count),
rd_count = data2.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
ro_count = data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
dl_cm19_count = data2.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
dl_cm20_count = data2.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
total = data2.Where(x => x.total > 0).Sum(x => x.total)
},
sum = new
{
rt_count = data1.Where(x => x.rt_count > 0).Sum(x => x.rt_count) + data2.Where(x => x.rt_count > 0).Sum(x => x.rt_count),
career_count = data1.Where(x => x.career_count > 0).Sum(x => x.career_count) + data2.Where(x => x.career_count > 0).Sum(x => x.career_count),
move_count = data1.Where(x => x.move_count > 0).Sum(x => x.move_count) + data2.Where(x => x.move_count > 0).Sum(x => x.move_count),
family_count = data1.Where(x => x.family_count > 0).Sum(x => x.family_count) + data2.Where(x => x.family_count > 0).Sum(x => x.family_count),
education_count = data1.Where(x => x.education_count > 0).Sum(x => x.education_count) + data2.Where(x => x.education_count > 0).Sum(x => x.education_count),
other_count = data1.Where(x => x.other_count > 0).Sum(x => x.other_count) + data2.Where(x => x.other_count > 0).Sum(x => x.other_count),
rd_count = data1.Where(x => x.rd_count > 0).Sum(x => x.rd_count) + data2.Where(x => x.rd_count > 0).Sum(x => x.rd_count),
ro_count = data1.Where(x => x.ro_count > 0).Sum(x => x.ro_count) + data2.Where(x => x.ro_count > 0).Sum(x => x.ro_count),
dl_cm19_count = data1.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count) + data2.Where(x => x.dl_cm19_count > 0).Sum(x => x.dl_cm19_count),
dl_cm20_count = data1.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count) + data2.Where(x => x.dl_cm20_count > 0).Sum(x => x.dl_cm20_count),
total = data1.Where(x => x.total > 0).Sum(x => x.total) + data2.Where(x => x.total > 0).Sum(x => x.total)
}
}
};
return Success(data);
}
}

View file

@ -103,6 +103,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
p.Id,
p.profileType,
p.citizenId,
p.profileId,
p.prefix,
@ -126,7 +127,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.IsActive,
})
.ToListAsync();
return Success(retirementDeceaseds);
return Success(retirementDeceaseds);
}
/// <summary>
@ -147,6 +148,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
p.Id,
p.profileId,
p.profileType,
p.prefix,
p.firstName,
p.lastName,
@ -184,6 +186,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.prefix,
data.firstName,
data.lastName,
data.profileType,
data.root,
data.rootShortName,
data.child1,
@ -236,6 +239,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
{
// Profile = profile,
Number = req.Number,
profileType = req.profileType.Trim().ToUpper(),
Date = req.Date,
Location = req.Location,
Reason = req.Reason,
@ -247,65 +251,129 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.ProfileId}";
using (var client = new HttpClient())
if (req.profileType.Trim().ToUpper() == "OFFICER")
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementDeceased.profileId = org.result.profileId;
retirementDeceased.prefix = org.result.prefix;
retirementDeceased.firstName = org.result.firstName;
retirementDeceased.lastName = org.result.lastName;
retirementDeceased.citizenId = org.result.citizenId;
retirementDeceased.root = org.result.root;
retirementDeceased.rootId = org.result.rootId;
retirementDeceased.rootShortName = org.result.rootShortName;
retirementDeceased.child1 = org.result.child1;
retirementDeceased.child1Id = org.result.child1Id;
retirementDeceased.child1ShortName = org.result.child1ShortName;
retirementDeceased.child2 = org.result.child2;
retirementDeceased.child2Id = org.result.child2Id;
retirementDeceased.child2ShortName = org.result.child2ShortName;
retirementDeceased.child3 = org.result.child3;
retirementDeceased.child3Id = org.result.child3Id;
retirementDeceased.child3ShortName = org.result.child3ShortName;
retirementDeceased.child4 = org.result.child4;
retirementDeceased.child4Id = org.result.child4Id;
retirementDeceased.child4ShortName = org.result.child4ShortName;
retirementDeceased.posMasterNo = org.result.posMasterNo;
retirementDeceased.position = org.result.position;
retirementDeceased.posTypeId = org.result.posTypeId;
retirementDeceased.posTypeName = org.result.posTypeName;
retirementDeceased.posLevelId = org.result.posLevelId;
retirementDeceased.posLevelName = org.result.posLevelName;
}
await _context.RetirementDeceaseds.AddAsync(retirementDeceased);
//await _context.SaveChangesAsync();
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/org/profile/leave/{req.ProfileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, _apiUrl);
var _res = await client.PostAsJsonAsync(_apiUrl, new
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.ProfileId}";
using (var client = new HttpClient())
{
isLeave = true,
leaveReason = "ถึงแก่กรรม",
dateLeave = req.Date,
});
var _result = await _res.Content.ReadAsStringAsync();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementDeceased.profileId = org.result.profileId;
retirementDeceased.prefix = org.result.prefix;
retirementDeceased.firstName = org.result.firstName;
retirementDeceased.lastName = org.result.lastName;
retirementDeceased.citizenId = org.result.citizenId;
retirementDeceased.root = org.result.root;
retirementDeceased.rootId = org.result.rootId;
retirementDeceased.rootShortName = org.result.rootShortName;
retirementDeceased.child1 = org.result.child1;
retirementDeceased.child1Id = org.result.child1Id;
retirementDeceased.child1ShortName = org.result.child1ShortName;
retirementDeceased.child2 = org.result.child2;
retirementDeceased.child2Id = org.result.child2Id;
retirementDeceased.child2ShortName = org.result.child2ShortName;
retirementDeceased.child3 = org.result.child3;
retirementDeceased.child3Id = org.result.child3Id;
retirementDeceased.child3ShortName = org.result.child3ShortName;
retirementDeceased.child4 = org.result.child4;
retirementDeceased.child4Id = org.result.child4Id;
retirementDeceased.child4ShortName = org.result.child4ShortName;
retirementDeceased.posMasterNo = org.result.posMasterNo;
retirementDeceased.position = org.result.position;
retirementDeceased.posTypeId = org.result.posTypeId;
retirementDeceased.posTypeName = $"{org.result.posTypeShortName} {org.result.posTypeName}";
retirementDeceased.posLevelId = org.result.posLevelId;
retirementDeceased.posLevelName = org.result.posLevelName;
}
await _context.RetirementDeceaseds.AddAsync(retirementDeceased);
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/org/profile/leave/{req.ProfileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, _apiUrl);
var _res = await client.PostAsJsonAsync(_apiUrl, new
{
isLeave = true,
leaveReason = "ถึงแก่กรรม",
dateLeave = req.Date,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
else
{
var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{req.ProfileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementDeceased.profileId = org.result.profileId;
retirementDeceased.prefix = org.result.prefix;
retirementDeceased.firstName = org.result.firstName;
retirementDeceased.lastName = org.result.lastName;
retirementDeceased.citizenId = org.result.citizenId;
retirementDeceased.root = org.result.root;
retirementDeceased.rootId = org.result.rootId;
retirementDeceased.rootShortName = org.result.rootShortName;
retirementDeceased.child1 = org.result.child1;
retirementDeceased.child1Id = org.result.child1Id;
retirementDeceased.child1ShortName = org.result.child1ShortName;
retirementDeceased.child2 = org.result.child2;
retirementDeceased.child2Id = org.result.child2Id;
retirementDeceased.child2ShortName = org.result.child2ShortName;
retirementDeceased.child3 = org.result.child3;
retirementDeceased.child3Id = org.result.child3Id;
retirementDeceased.child3ShortName = org.result.child3ShortName;
retirementDeceased.child4 = org.result.child4;
retirementDeceased.child4Id = org.result.child4Id;
retirementDeceased.child4ShortName = org.result.child4ShortName;
retirementDeceased.posMasterNo = org.result.posMasterNo;
retirementDeceased.position = org.result.position;
retirementDeceased.posTypeId = org.result.posTypeId;
retirementDeceased.posTypeName = org.result.posTypeName;
retirementDeceased.posLevelId = org.result.posLevelId;
retirementDeceased.posLevelName = org.result.posLevelName;
}
await _context.RetirementDeceaseds.AddAsync(retirementDeceased);
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/org/profile-employee/leave/{req.ProfileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Post, _apiUrl);
var _res = await client.PostAsJsonAsync(_apiUrl, new
{
isLeave = true,
leaveReason = "ถึงแก่กรรม",
dateLeave = req.Date,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
var _doc = new Domain.Models.Documents.Document();
@ -320,56 +388,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
if (_doc != null)
retirementDeceased.Document = _doc;
}
// await _context.ProfileSalaries.AddAsync(new ProfileSalary
// {
// Date = req.Date,
// SalaryRef = req.Number,
// CommandNo = "-",
// SalaryClass = "-",
// PosNoEmployee = "-",
// CommandTypeName = "-",
// SalaryStatus = "DEATH",
// Profile = profile,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// });
// if (_doc != null)
// {
// await _context.ProfilePapers.AddAsync(new ProfilePaper
// {
// Detail = "ถึงแก่กรรม",
// CategoryName = "DEATH",
// Document = _doc,
// Profile = profile,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
// });
// }
// var orgPos = await _context.ProfilePositions
// .Include(x => x.Profile)
// .ThenInclude(x => x!.Prefix)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x!.Organization)
// .ThenInclude(x => x!.OrganizationOrganization)
// .Include(x => x.OrganizationPosition)
// .ThenInclude(x => x!.PositionMaster)
// .ThenInclude(x => x!.PositionPath)
// .Where(x => x.OrganizationPosition!.IsDirector! == true)
// .Where(x => x.OrganizationPosition!.Organization!.Id == profile.OcId)
// .FirstOrDefaultAsync();
// if (orgPos != null)
// {
// if (orgPos.Profile != null)
// {
retirementDeceased.RetirementDeceasedNotis.Add(new RetirementDeceasedNoti
{
CitizenId = retirementDeceased.citizenId == null ? "" : retirementDeceased.citizenId,
@ -389,8 +408,6 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
// }
// }
await _context.SaveChangesAsync();
return Success();
@ -552,32 +569,63 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.ProfileId}";
using (var client = new HttpClient())
if (retirementDeceased.profileType.Trim().ToUpper() == "OFFICER")
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{item.ProfileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
if (org == null || org.result == null)
continue;
if (org == null || org.result == null)
continue;
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
}
}
else
{
var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{item.ProfileId}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<Requests.OrgRequest>(_result);
if (org == null || org.result == null)
continue;
retirementDeceasedNoti.Prefix = org.result.prefix == null ? "" : org.result.prefix;
retirementDeceasedNoti.FirstName = org.result.firstName == null ? "" : org.result.firstName;
retirementDeceasedNoti.LastName = org.result.lastName == null ? "" : org.result.lastName;
retirementDeceasedNoti.CitizenId = org.result.citizenId == null ? "" : org.result.citizenId;
retirementDeceasedNoti.PositionName = org.result.position == null ? "" : org.result.position;
retirementDeceasedNoti.OrganizationName = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementDeceased.RetirementDeceasedNotis.Add(retirementDeceasedNoti);
}
}
await _context.SaveChangesAsync();

View file

@ -107,6 +107,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
p.Id,
p.profileType,
p.citizenId,
p.profileId,
p.prefix,
@ -178,6 +179,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
.Select(p => new
{
p.Id,
p.profileType,
p.profileId,
p.prefix,
p.firstName,
@ -258,27 +260,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementAddProfileRequest req)
{
// var profile = await _context.Profiles
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionType)
// .Include(x => x.PosNo)
// .Include(x => x.Salaries)
// .Include(x => x.Position)
// .FirstOrDefaultAsync(x => x.Id == req.Id);
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
var retirementOut = new RetirementOut
{
// Profile = profile,
// Organization = Request.Form.ContainsKey("Organization") ? Request.Form["Organization"] : "",
// Reason = Request.Form.ContainsKey("Reason") ? Request.Form["Reason"] : "",
// // Date = req.Date,
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
Status = "WAITTING",
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
@ -287,57 +270,115 @@ namespace BMA.EHR.Retirement.Service.Controllers
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
};
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.Id}";
using (var client = new HttpClient())
if (req.profileType.Trim().ToUpper() == "OFFICER")
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var apiUrl = $"{_configuration["API"]}/org/profile/profileid/position/{req.Id}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementOut.profileId = org.result.profileId;
retirementOut.prefix = org.result.prefix;
retirementOut.firstName = org.result.firstName;
retirementOut.lastName = org.result.lastName;
retirementOut.citizenId = org.result.citizenId;
retirementOut.rootOld = org.result.root;
retirementOut.rootOldId = org.result.rootId;
retirementOut.rootShortNameOld = org.result.rootShortName;
retirementOut.child1Old = org.result.child1;
retirementOut.child1OldId = org.result.child1Id;
retirementOut.child1ShortNameOld = org.result.child1ShortName;
retirementOut.child2Old = org.result.child2;
retirementOut.child2OldId = org.result.child2Id;
retirementOut.child2ShortNameOld = org.result.child2ShortName;
retirementOut.child3Old = org.result.child3;
retirementOut.child3OldId = org.result.child3Id;
retirementOut.child3ShortNameOld = org.result.child3ShortName;
retirementOut.child4Old = org.result.child4;
retirementOut.child4OldId = org.result.child4Id;
retirementOut.child4ShortNameOld = org.result.child4ShortName;
retirementOut.posMasterNoOld = org.result.posMasterNo;
retirementOut.posTypeOldId = org.result.posTypeId;
retirementOut.posTypeNameOld = org.result.posTypeName;
retirementOut.posLevelOldId = org.result.posLevelId;
retirementOut.posLevelNameOld = org.result.posLevelName;
retirementOut.profileId = org.result.profileId;
retirementOut.prefix = org.result.prefix;
retirementOut.firstName = org.result.firstName;
retirementOut.lastName = org.result.lastName;
retirementOut.citizenId = org.result.citizenId;
retirementOut.rootOld = org.result.root;
retirementOut.rootOldId = org.result.rootId;
retirementOut.rootShortNameOld = org.result.rootShortName;
retirementOut.child1Old = org.result.child1;
retirementOut.child1OldId = org.result.child1Id;
retirementOut.child1ShortNameOld = org.result.child1ShortName;
retirementOut.child2Old = org.result.child2;
retirementOut.child2OldId = org.result.child2Id;
retirementOut.child2ShortNameOld = org.result.child2ShortName;
retirementOut.child3Old = org.result.child3;
retirementOut.child3OldId = org.result.child3Id;
retirementOut.child3ShortNameOld = org.result.child3ShortName;
retirementOut.child4Old = org.result.child4;
retirementOut.child4OldId = org.result.child4Id;
retirementOut.child4ShortNameOld = org.result.child4ShortName;
retirementOut.posMasterNoOld = org.result.posMasterNo;
retirementOut.posTypeOldId = org.result.posTypeId;
retirementOut.posTypeNameOld = org.result.posTypeName;
retirementOut.posLevelOldId = org.result.posLevelId;
retirementOut.posLevelNameOld = org.result.posLevelName;
retirementOut.PositionOld = org.result.position;
retirementOut.PositionLevelOld = org.result.posLevelName;
retirementOut.PositionTypeOld = org.result.posTypeName;
retirementOut.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
retirementOut.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementOut.OrganizationPositionOld = org.result.position + "/" + retirementOut.OrganizationOld;
retirementOut.AmountOld = org.result.salary;
retirementOut.PositionOld = org.result.position;
retirementOut.PositionLevelOld = org.result.posLevelName;
retirementOut.PositionTypeOld = org.result.posTypeName;
retirementOut.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
retirementOut.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementOut.OrganizationPositionOld = org.result.position + "/" + retirementOut.OrganizationOld;
retirementOut.AmountOld = org.result.salary;
}
}
else
{
var apiUrl = $"{_configuration["API"]}/org/profile-employee/profileid/position/{req.Id}";
using (var client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
client.DefaultRequestHeaders.Add("api_key", _configuration["API_KEY"]);
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<OrgRequest>(_result);
if (org == null || org.result == null)
return Error("ไม่พบหน่วยงานของผู้ใช้งานคนนี้", 404);
retirementOut.profileId = org.result.profileId;
retirementOut.prefix = org.result.prefix;
retirementOut.firstName = org.result.firstName;
retirementOut.lastName = org.result.lastName;
retirementOut.citizenId = org.result.citizenId;
retirementOut.rootOld = org.result.root;
retirementOut.rootOldId = org.result.rootId;
retirementOut.rootShortNameOld = org.result.rootShortName;
retirementOut.child1Old = org.result.child1;
retirementOut.child1OldId = org.result.child1Id;
retirementOut.child1ShortNameOld = org.result.child1ShortName;
retirementOut.child2Old = org.result.child2;
retirementOut.child2OldId = org.result.child2Id;
retirementOut.child2ShortNameOld = org.result.child2ShortName;
retirementOut.child3Old = org.result.child3;
retirementOut.child3OldId = org.result.child3Id;
retirementOut.child3ShortNameOld = org.result.child3ShortName;
retirementOut.child4Old = org.result.child4;
retirementOut.child4OldId = org.result.child4Id;
retirementOut.child4ShortNameOld = org.result.child4ShortName;
retirementOut.posMasterNoOld = org.result.posMasterNo;
retirementOut.posTypeOldId = org.result.posTypeId;
retirementOut.posTypeNameOld = org.result.posTypeName;
retirementOut.posLevelOldId = org.result.posLevelId;
retirementOut.posLevelNameOld = org.result.posLevelName;
retirementOut.PositionOld = org.result.position;
retirementOut.PositionLevelOld = org.result.posLevelName;
retirementOut.PositionTypeOld = org.result.posTypeName;
retirementOut.PositionNumberOld = org.result.nodeShortName + org.result.posMasterNo;
retirementOut.OrganizationOld = (org.result.child4 == null ? "" : org.result.child4 + "/") +
(org.result.child3 == null ? "" : org.result.child3 + "/") +
(org.result.child2 == null ? "" : org.result.child2 + "/") +
(org.result.child1 == null ? "" : org.result.child1 + "/") +
(org.result.root == null ? "" : org.result.root);
retirementOut.OrganizationPositionOld = org.result.position + "/" + retirementOut.OrganizationOld;
retirementOut.AmountOld = org.result.salary;
}
}
await _context.RetirementOuts.AddAsync(retirementOut);
await _context.SaveChangesAsync();
@ -533,6 +574,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
date = r.commandAffectDate,
amount = r.amount,
commandId = r.commandId,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
posNo = p.PositionNumberOld,

View file

@ -149,6 +149,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.SendDate,
p.ActiveDate,
p.Reason,
p.ReasonResign,
p.Remark,
p.ApproveReason,
p.RejectReason,
@ -243,6 +244,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.SendDate,
p.ActiveDate,
p.Reason,
p.ReasonResign,
p.Remark,
p.Status,
salary = p.AmountOld,
@ -366,6 +368,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.SendDate,
p.ActiveDate,
p.Reason,
p.ReasonResign,
p.Remark,
p.Status,
salary = p.AmountOld,
@ -458,6 +461,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.SendDate,
data.ActiveDate,
data.Reason,
data.ReasonResign,
data.Remark,
data.Status,
data.salary,
@ -873,30 +877,27 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementResignRequest req)
{
// var profile = await _context.Profiles
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionType)
// .Include(x => x.PosNo)
// .Include(x => x.Salaries)
// .Include(x => x.Position)
// .Include(x => x.Prefix)
// .FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
var Remark = req.Remark;
if (req.Reason != null)
{
switch (req.Reason.Trim().ToUpper())
{
case "CAREER": Remark = $"ประกอบอาชีพอื่น" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
case "MOVE": Remark = $"รับราชการสังกัดอื่น" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
case "FAMILY": Remark = $"ดูแลบิดามารดา" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
case "EDUCATION": Remark = $"ศึกษาต่อ" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
case "OTHER": Remark = $"อื่น ๆ" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
}
}
var retirementResign = new RetirementResign
{
// Profile = profile,
Location = req.Location,
SendDate = DateTime.Now,
ActiveDate = req.ActiveDate,
Reason = req.Reason,
ReasonResign = Remark,
Remark = req.Remark,
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
Status = "WAITTING",
IsActive = true,
CreatedFullName = FullName ?? "System Administrator",
@ -1028,8 +1029,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.Location = req.Location;
updated.ActiveDate = req.ActiveDate;
updated.Reason = req.Reason;
// updated.Reason = req.Reason;
updated.Remark = req.Remark;
updated.ReasonResign = req.Reason;
updated.OrganizationPositionOld = req.OrganizationPositionOld;
updated.RemarkHorizontal = req.RemarkHorizontal;
updated.PositionTypeOld = req.PositionTypeOld;
@ -1180,7 +1182,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
Location = updated.Location,
SendDate = updated.SendDate,
ActiveDate = updated.ActiveDate,
Reason = updated.Reason,
Reason = updated.ReasonResign,
Remark = updated.Remark,
OrganizationPositionOld = updated.OrganizationPositionOld,
PositionTypeOld = updated.PositionTypeOld,
@ -2445,6 +2447,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
date = r.commandAffectDate,
amount = r.amount,
commandId = r.commandId,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
posNo = p.PositionNumberOld,
@ -2633,6 +2636,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
date = r.commandAffectDate,
amount = r.amount,
commandId = r.commandId,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
posNo = p.PositionNumberOld,

View file

@ -93,6 +93,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.SendDate,
p.ActiveDate,
p.Reason,
p.ReasonResign,
p.Remark,
p.ApproveReason,
p.RejectReason,
@ -187,6 +188,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.SendDate,
p.ActiveDate,
p.Reason,
p.ReasonResign,
p.Remark,
p.Status,
salary = p.AmountOld,
@ -309,6 +311,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
p.SendDate,
p.ActiveDate,
p.Reason,
p.ReasonResign,
p.Remark,
p.Status,
salary = p.AmountOld,
@ -401,6 +404,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
data.SendDate,
data.ActiveDate,
data.Reason,
data.ReasonResign,
data.Remark,
data.Status,
data.salary,
@ -816,30 +820,26 @@ namespace BMA.EHR.Retirement.Service.Controllers
[HttpPost()]
public async Task<ActionResult<ResponseObject>> Post([FromForm] RetirementResignEmployeeRequest req)
{
// var profile = await _context.Profiles
// .Include(x => x.PositionLevel)
// .Include(x => x.PositionType)
// .Include(x => x.PosNo)
// .Include(x => x.Salaries)
// .Include(x => x.Position)
// .Include(x => x.Prefix)
// .FirstOrDefaultAsync(x => x.KeycloakId == Guid.Parse(UserId));
// if (profile == null)
// return Error(GlobalMessages.DataNotFound, 404);
var Remark = req.Remark;
if (req.Reason != null)
{
switch (req.Reason.Trim().ToUpper())
{
case "CAREER": Remark = $"ประกอบอาชีพอื่น" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
case "MOVE": Remark = $"รับราชการสังกัดอื่น" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
case "FAMILY": Remark = $"ดูแลบิดามารดา" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
case "EDUCATION": Remark = $"ศึกษาต่อ" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
case "OTHER": Remark = $"อื่น ๆ" + (req.Remark == null || req.Remark == "" ? $"{req.Remark}" : ""); break;
}
}
var retirementResignEmployee = new RetirementResignEmployee
{
// Profile = profile,
Location = req.Location,
SendDate = DateTime.Now,
ActiveDate = req.ActiveDate,
Reason = req.Reason,
ReasonResign = Remark,
Remark = req.Remark,
// AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
// PositionLevelOld = profile.PositionLevel == null ? null : profile.PositionLevel.Name,
// PositionTypeOld = profile.PositionType == null ? null : profile.PositionType.Name,
// PositionNumberOld = profile.PosNo == null ? null : profile.PosNo.Name,
// OrganizationPositionOld = profile.Position == null ? profile.Oc : $"{profile.Position.Name}-{profile.Oc}",
Status = "WAITTING",
IsActive = true,
CreatedFullName = FullName ?? "System Administrator",
@ -971,8 +971,9 @@ namespace BMA.EHR.Retirement.Service.Controllers
updated.Location = req.Location;
updated.ActiveDate = req.ActiveDate;
updated.Reason = req.Reason;
// updated.Reason = req.Reason;
updated.Remark = req.Remark;
updated.ReasonResign = req.Reason;
updated.OrganizationPositionOld = req.OrganizationPositionOld;
updated.RemarkHorizontal = req.RemarkHorizontal;
updated.PositionTypeOld = req.PositionTypeOld;
@ -1123,7 +1124,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
Location = updated.Location,
SendDate = updated.SendDate,
ActiveDate = updated.ActiveDate,
Reason = updated.Reason,
Reason = updated.ReasonResign,
Remark = updated.Remark,
OrganizationPositionOld = updated.OrganizationPositionOld,
PositionTypeOld = updated.PositionTypeOld,
@ -2388,6 +2389,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
date = r.commandAffectDate,
amount = r.amount,
commandId = r.commandId,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
posNo = p.PositionNumberOld,
@ -2576,6 +2578,7 @@ namespace BMA.EHR.Retirement.Service.Controllers
date = r.commandAffectDate,
amount = r.amount,
commandId = r.commandId,
amountSpecial = r.amountSpecial,
positionSalaryAmount = r.positionSalaryAmount,
mouthSalaryAmount = r.mouthSalaryAmount,
posNo = p.PositionNumberOld,

View file

@ -101,6 +101,11 @@ var builder = WebApplication.CreateBuilder(args);
var defaultConnection = builder.Configuration.GetConnectionString("DefaultConnection");
builder.Services.AddDbContext<ApplicationDBContext>(options =>
options.UseMySql(defaultConnection, ServerVersion.AutoDetect(defaultConnection)));
// Register DisciplineDbContext
var disciplineConnection = builder.Configuration.GetConnectionString("DisciplineConnection");
builder.Services.AddDbContext<DisciplineDbContext>(options =>
options.UseMySql(disciplineConnection, ServerVersion.AutoDetect(disciplineConnection)));
builder.Services.AddHealthChecks();
// Add Hangfire services.
builder.Services.AddHangfire(configuration => configuration

View file

@ -0,0 +1,24 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class NodeAllRequest
{
public NodeAllResult result { get; set; } = new();
}
public class NodeAllResult
{
public List<NodeAllRequestData> isRootTrue { get; set; } = new();
public List<NodeAllRequestData> isRootFalse { get; set; } = new();
}
public class NodeAllRequestData
{
public string? name { get; set; }
public string? rootId { get; set; }
public string? child1Id { get; set; }
public string? child2Id { get; set; }
public string? child3Id { get; set; }
public string? child4Id { get; set; }
}
}

View file

@ -38,6 +38,7 @@ namespace BMA.EHR.Retirement.Service.Requests
public string? posTypeName { get; set; }
public int? posTypeRank { get; set; }
public string? posLevelId { get; set; }
public string? posTypeShortName { get; set; }
public string? posLevelName { get; set; }
public int? posLevelRank { get; set; }
public string? posExecutiveId { get; set; }

View file

@ -6,5 +6,6 @@ namespace BMA.EHR.Retirement.Service.Requests
public class RetirementAddProfileRequest
{
public Guid Id { get; set; }
public string profileType { get; set; }
}
}

View file

@ -11,5 +11,6 @@ namespace BMA.EHR.Retirement.Service.Requests
public string? Location { get; set; }
public string? Reason { get; set; }
public string ProfileId { get; set; }
public string profileType { get; set; }
}
}

View file

@ -10,6 +10,7 @@ namespace BMA.EHR.Retirement.Service.Requests
public DateTime? ActiveDate { get; set; }
public string? Reason { get; set; }
public string? Remark { get; set; }
public string? ReasonResign { get; set; }
public string? OrganizationPositionOld { get; set; }
public string? PositionTypeOld { get; set; }
public string? PositionLevelOld { get; set; }

View file

@ -10,6 +10,7 @@ namespace BMA.EHR.Retirement.Service.Requests
public DateTime? ActiveDate { get; set; }
public string? Reason { get; set; }
public string? Remark { get; set; }
public string? ReasonResign { get; set; }
public string? OrganizationPositionOld { get; set; }
public string? PositionTypeOld { get; set; }
public string? PositionLevelOld { get; set; }

View file

@ -15,7 +15,8 @@
"ConnectionStrings": {
//"DefaultConnection": "User Id=sys;Password=P@ssw0rd;DBA Privilege=SYSDBA;Data Source=localhost:1521/ORCLCDB",
// "DefaultConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
"DefaultConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"DisciplineConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_discipline_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",