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

This commit is contained in:
Suphonchai Phoonsawat 2025-02-12 18:33:54 +07:00
commit f4055d01c3
4 changed files with 286 additions and 58 deletions

View file

@ -13,7 +13,9 @@ using BMA.EHR.Domain.Shared;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Metadata;
using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Net;
@ -30,6 +32,7 @@ namespace BMA.EHR.Application.Repositories.Reports
private readonly OrganizationCommonRepository _organizationCommonRepository;
private readonly NotificationRepository _repositoryNoti;
private readonly InsigniaPeriodsRepository _repositoryInsignia;
private readonly IConfiguration _configuration;
private readonly string CRLF = "\r\n";
private readonly UserProfileRepository _userProfileRepository;
@ -44,6 +47,7 @@ namespace BMA.EHR.Application.Repositories.Reports
InsigniaPeriodsRepository repositoryInsignia,
NotificationRepository repositoryNoti,
IWebHostEnvironment hostEnvironment,
IConfiguration configuration,
UserProfileRepository userProfileRepository,
IHttpContextAccessor httpContextAccessor)
{
@ -54,6 +58,7 @@ namespace BMA.EHR.Application.Repositories.Reports
_repositoryInsignia = repositoryInsignia;
_userProfileRepository = userProfileRepository;
_httpContextAccessor = httpContextAccessor;
_configuration = configuration;
}
#endregion
@ -1070,7 +1075,6 @@ namespace BMA.EHR.Application.Repositories.Reports
.Where(x => x.Status == "PENDING")
.Where(x => x.RequestInsignia.InsigniaType != null);
/*.Where(x => x.RequestInsignia.InsigniaType.Name == "เหรียญบำเหน็จในราชการ");*/
if (type == "officer")
{
data_insigniaQuery = data_insigniaQuery.Where(r => r.ProfileType == "officer");
@ -1080,6 +1084,8 @@ namespace BMA.EHR.Application.Repositories.Reports
data_insigniaQuery = data_insigniaQuery.Where(r => r.ProfileType == "employee");
}
Console.WriteLine(">>>>>>>logs", data_insigniaQuery.ToQueryString);
switch (node)
{
case 0:
@ -1106,63 +1112,84 @@ namespace BMA.EHR.Application.Repositories.Reports
break;
}
var data = await data_insigniaQuery
.Select(x => new
{
FullName = $"{x.Prefix}{x.FirstName} {x.LastName}",
RequestInsigniaName = x.RequestInsignia.Name, // Name of the Insignia
})
.ToListAsync();
/* var seq = 1;
foreach (var d in response!.result)
{
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/org/profile/profileid/position/{d.person.id}";
using (var _client = new HttpClient())
{
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
_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)
continue;
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = org.result.citizenId == null ? "" : org.result.citizenId,
Prefix = org.result.prefix == null ? "" : org.result.prefix,
FirstName = org.result.firstName == null ? "" : org.result.firstName,
LastName = org.result.lastName == null ? "" : org.result.lastName,
RefPlacementProfileId = org.result.profileId == null ? null : Guid.Parse(org.result.profileId),
};
seq++;
resultData.Add(receiver);
}
}*/
var insignia = data.Select((r, index) => new
.Select(x => new
{
RowNo = (index + 1).ToNumericText().ToThaiNumber(),
FullName = r.FullName,
RequestInsigniaName = r.RequestInsigniaName,
ResultY1APR = "-",
ResultY1OCT = "-",
ResultY2APR = "-",
ResultY2OCT = "-",
ResultY3APR = "-",
ResultY3OCT = "-",
ResultY4APR = "-",
ResultY4OCT = "-",
ResultY5APR = "-",
ResultY5OCT = "-",
Remark = "",
}).ToList();
ProfileId = x.ProfileId,
FullName = $"{x.Prefix}{x.FirstName} {x.LastName}",
RequestInsigniaName = x.RequestInsignia.Name, // Name of the Insignia
})
.ToListAsync();
return insignia;
var seq = 1;
foreach (var d in data)
{
var _baseAPI = _configuration["API"];
var _apiUrl = $"{_baseAPI}/org/unauthorize/calculateEvaluation";
using (var _client = new HttpClient())
{
_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 orgResponse = JsonConvert.DeserializeObject<dynamic>(_result);*/
var orgResponse = JObject.Parse(_result);
var resultItems = orgResponse["result"];
/* if (orgResponse != null && orgResponse.result != null)
{*/
var matchedData = resultItems
.Where(item => item["profileId"].ToString() == d.ProfileId.ToString())
.FirstOrDefault();
/*
if (matchedData != null)
{
// แสดงข้อมูลที่ตรงกัน
var receiver = new CommandReceiver
{
Sequence = seq,
CitizenId = matchedData.citizenId ?? "",
Prefix = matchedData.prefix ?? "",
FirstName = matchedData.firstName ?? "",
LastName = matchedData.lastName ?? "",
RefPlacementProfileId = Guid.Parse(matchedData.profileId.ToString()),
};
seq++;
resultData.Add(receiver);
}*/
/*}*/
return matchedData;
}
else
{
return $"Error: {_res.StatusCode} - {_res.ReasonPhrase}";
}
}
}
/* var insignia = data.Select((r, index) => new
{
RowNo = (index + 1).ToNumericText().ToThaiNumber(),
ProfileId = r.,
FullName = r.FullName,
RequestInsigniaName = r.RequestInsigniaName,
ResultY1APR = "-",
ResultY1OCT = "-",
ResultY2APR = "-",
ResultY2OCT = "-",
ResultY3APR = "-",
ResultY3OCT = "-",
ResultY4APR = "-",
ResultY4OCT = "-",
ResultY5APR = "-",
ResultY5OCT = "-",
Remark = "",
}).ToList();*/
return data;
}
//noti ยื่นเสนอคน

View file

@ -17,6 +17,7 @@ using System.Net.Http.Headers;
using System.Security.Claims;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Data;
namespace BMA.EHR.DisciplineResult.Service.Controllers
{
@ -849,6 +850,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
if (_res.IsSuccessStatusCode)
{
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
var _profile = new List<ProfileComplaintInvestigate>();
DateTime _date = DateTime.Now;
foreach (var item in data)
{
_profile.Add(new ProfileComplaintInvestigate
{
PersonId = item.PersonId,
Prefix = item.Prefix,
FirstName = item.FirstName,
LastName = item.LastName,
CitizenId = item.CitizenId,
rootDnaId = item.rootDnaId,
child1DnaId = item.child1DnaId,
child2DnaId = item.child2DnaId,
child3DnaId = item.child3DnaId,
child4DnaId = item.child4DnaId,
profileType = item.profileType,
commandType = "C-PM-19",
CreatedAt = _date,
CreatedUserId = UserId,
CreatedFullName = FullName,
LastUpdatedAt = _date,
LastUpdateUserId = UserId,
LastUpdateFullName = FullName,
});
}
_context.ProfileComplaintInvestigate.AddRange(_profile);
await _context.SaveChangesAsync();
}
}
@ -950,6 +978,33 @@ namespace BMA.EHR.DisciplineResult.Service.Controllers
if (_res.IsSuccessStatusCode)
{
data.ForEach(profile => { profile.Status = "NEW"; profile.CommandTypeId = null; });
var _profile = new List<ProfileComplaintInvestigate>();
DateTime _date = DateTime.Now;
foreach (var item in data)
{
_profile.Add(new ProfileComplaintInvestigate
{
PersonId = item.PersonId,
Prefix = item.Prefix,
FirstName = item.FirstName,
LastName = item.LastName,
CitizenId = item.CitizenId,
rootDnaId = item.rootDnaId,
child1DnaId = item.child1DnaId,
child2DnaId = item.child2DnaId,
child3DnaId = item.child3DnaId,
child4DnaId = item.child4DnaId,
profileType = item.profileType,
commandType = "C-PM-20",
CreatedAt = _date,
CreatedUserId = UserId,
CreatedFullName = FullName,
LastUpdatedAt = _date,
LastUpdateUserId = UserId,
LastUpdateFullName = FullName,
});
}
_context.ProfileComplaintInvestigate.AddRange(_profile);
await _context.SaveChangesAsync();
}
}

View file

@ -219,7 +219,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report2/{type}")]
public async Task<ActionResult<ResponseObject>> GetInsigniaReport3Async([FromBody] GetInsigniaDetailByNodeReportDto req, string type)
public async Task<ActionResult<ResponseObject>> GetInsigniaReport2Async([FromBody] GetInsigniaDetailByNodeReportDto req, string type)
{
try
{
@ -265,7 +265,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report3/{type}")]
public async Task<ActionResult<ResponseObject>> GetInsigniaReport2Async([FromBody] GetInsigniaDetailByNodeReportDto req, string type)
public async Task<ActionResult<ResponseObject>> GetInsigniaReport3Async([FromBody] GetInsigniaDetailByNodeReportDto req, string type)
{
try
{
@ -316,6 +316,151 @@ namespace BMA.EHR.Insignia.Service.Controllers
}
#endregion
#region /
/// <summary>
/// รายชื่อข้าราชการฯ ที่ได้รับ/ไม่ได้รับการจ่ายใบกำกับฯ
/// </summary>
/// <param name="type">type </param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report4/{type}")]
public async Task<ActionResult<ResponseObject>> GetInsigniaReport4Async([FromBody] GetInsigniaDetailByNodeReportDto req, string type)
{
try
{
var date = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}";
var result = new
{
template = "reportInsignia4",
reportName = "reportInsignia4",
data = new
{
yearInsignalPeriod = "",
date = date,
data = "",
}
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// รายงานสถิติการได้รับเครื่องราชอิสริยาภรณ์ข้าราชการ ฯ
/// </summary>
/// <param name="type">type </param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report5/{type}")]
public async Task<ActionResult<ResponseObject>> GetInsigniaReport5Async([FromBody] GetInsigniaDetailByNodeReportDto req, string type)
{
try
{
var date = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}";
var result = new
{
template = "reportInsignia5",
reportName = "reportInsignia5",
data = new
{
yearInsignalPeriod = "",
date = date,
data = "",
}
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// รายงานผลการจ่ายประกาศนียบัตรกำกับเครื่องราชอิสริยาภรณ์ แยกรายหน่วยงาน
/// </summary>
/// <param name="type">type </param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report6/{type}")]
public async Task<ActionResult<ResponseObject>> GetInsigniaReport6Async([FromBody] GetInsigniaDetailByNodeReportDto req, string type)
{
try
{
var date = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}";
var result = new
{
template = "reportInsignia6",
reportName = "reportInsignia6",
data = new
{
yearInsignalPeriod = "",
date = date,
data = "",
}
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
#region
/// <summary>
/// รายงานผลการจ่ายประกาศนียบัตรกำกับเครื่องราชอิสริยาภรณ์ แยกรายหน่วยงาน
/// </summary>
/// <param name="type">type </param>
/// <returns></returns>
/// <response code="200">เมื่อทำการอ่านข้อมูลจาก Relational Database สำเร็จ</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("report7/{type}")]
public async Task<ActionResult<ResponseObject>> GetInsigniaReport7Async([FromBody] GetInsigniaDetailByNodeReportDto req, string type)
{
try
{
var date = $"ณ วันที่ {DateTime.Now.Date.ToThaiShortDate().ToThaiNumber()}";
var result = new
{
template = "reportInsignia7",
reportName = "reportInsignia7",
data = new
{
yearInsignalPeriod = "",
date = date,
data = "",
}
};
return Success(result);
}
catch
{
throw;
}
}
#endregion
}
}

View file

@ -476,6 +476,7 @@ namespace BMA.EHR.Placement.Service.Controllers
placementAppointment.EducationOld = org.result.education;
// placementAppointment.EducationOld = profile.Educations.Count() == 0 ? null : $"{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Degree}-{profile.Educations.OrderByDescending(x => x.FinishDate).FirstOrDefault().Field}";
// placementAppointment.AmountOld = profile.Salaries.Count() == 0 ? null : profile.Salaries.OrderByDescending(x => x.Order).FirstOrDefault().Amount;
placementAppointment.AmountOld = org.result.salary;
placementAppointment.positionOld = org.result.position;
placementAppointment.PositionLevelOld = org.result.posLevelName;