no message

This commit is contained in:
Kittapath 2024-05-23 17:08:59 +07:00
parent e01747cc0a
commit 9fb82fb45a
5 changed files with 479 additions and 404 deletions

View file

@ -11,12 +11,13 @@ on:
env:
REGISTRY: docker.frappet.com
IMAGE_NAME: ehr/bma-ehr-report-service
DEPLOY_HOST: 49.0.91.80
DEPLOY_HOST: frappet.com
DEPLOY_PORT: 10102
COMPOSE_PATH: /home/frappet/docker/bma/bma-ehr-report
TOKEN_LINE: uxuK5hDzS2DsoC5piJBrWRLiz8GgY7iMZZldOWsDDF0
jobs:
# act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=test-v6.1 -s DOCKER_USER=sorawit -s DOCKER_PASS=P@ssword -s SSH_PASSWORD=P@ssw0rd
# act workflow_dispatch -W .github/workflows/release.yaml --input IMAGE_VER=latest -s DOCKER_USER=admin -s DOCKER_PASS=FPTadmin2357 -s SSH_PASSWORD=FPTadmin2357
release-dev:
runs-on: ubuntu-latest
steps:
@ -60,27 +61,27 @@ jobs:
host: ${{env.DEPLOY_HOST}}
username: frappet
password: ${{ secrets.SSH_PASSWORD }}
port: 10102
port: ${{env.DEPLOY_PORT}}
script: |
cd "${{env.COMPOSE_PATH}}"
docker compose pull
docker compose up -d
echo "${{ steps.gen_ver.outputs.image_ver }}"> success
- uses: snow-actions/line-notify@v1.1.0
if: success()
with:
access_token: ${{ env.TOKEN_LINE }}
message: |
-Success✅✅✅
Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
- uses: snow-actions/line-notify@v1.1.0
if: failure()
with:
access_token: ${{ env.TOKEN_LINE }}
message: |
-Failure❌❌❌
Image: ${{env.IMAGE_NAME}}
Version: ${{ github.event.inputs.IMAGE_VER }}
By: ${{secrets.DOCKER_USER}}
# - uses: snow-actions/line-notify@v1.1.0
# if: success()
# with:
# access_token: ${{ env.TOKEN_LINE }}
# message: |
# -Success✅✅✅
# Image: ${{env.IMAGE_NAME}}
# Version: ${{ github.event.inputs.IMAGE_VER }}
# By: ${{secrets.DOCKER_USER}}
# - uses: snow-actions/line-notify@v1.1.0
# if: failure()
# with:
# access_token: ${{ env.TOKEN_LINE }}
# message: |
# -Failure❌❌❌
# Image: ${{env.IMAGE_NAME}}
# Version: ${{ github.event.inputs.IMAGE_VER }}
# By: ${{secrets.DOCKER_USER}}

View file

@ -10,8 +10,10 @@ using iText.Kernel.Pdf;
using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Drawing;
using System.Net.Http.Headers;
using Telerik.Reporting;
using Telerik.Reporting.Processing;
@ -33,6 +35,7 @@ namespace BMA.EHR.Report.Service.Controllers
private readonly string space = "";
private readonly ProfileService _profileService;
private readonly MinIOService _minioService;
private readonly IHttpContextAccessor _httpContextAccessor;
#endregion
@ -43,14 +46,17 @@ namespace BMA.EHR.Report.Service.Controllers
IWebHostEnvironment hostingEnvironment,
IConfiguration configuration,
ProfileService profileService,
MinIOService minioService)
MinIOService minioService,
IHttpContextAccessor httpContextAccessor)
{
this._context = context;
this._hostingEnvironment = hostingEnvironment;
this._configuration = configuration;
this._profileService = profileService;
this._minioService = minioService;
this._httpContextAccessor = httpContextAccessor;
}
private string? token => _httpContextAccessor?.HttpContext?.Request.Headers["Authorization"];
#endregion
@ -75,180 +81,180 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var profile_salaries = (from ps in _context.ProfileSalaries
join pos in _context.PositionPaths
on ps.PositionId equals pos.Id
where ps.Profile.Id == id
select new
{
ProfileId = ps.Profile.Id,
PositionName = pos.Name,
ps.OcId,
SalaryDateAnnounce = ps.Date,
ps.Amount,
ps.PositionSalaryAmount
}).ToList();
// var profile_salaries = (from ps in _context.ProfileSalaries
// join pos in _context.PositionPaths
// on ps.PositionId equals pos.Id
// where ps.Profile.Id == id
// select new
// {
// ProfileId = ps.Profile.Id,
// PositionName = pos.Name,
// ps.OcId,
// SalaryDateAnnounce = ps.Date,
// ps.Amount,
// ps.PositionSalaryAmount
// }).ToList();
var profiles = _context.Profiles.AsQueryable()
.Include(x => x.Avatar)
.Include(x => x.Salaries)
.Include(x => x.Educations)
.ToList();
var prefixes = _context.Prefixes.ToList();
var profile = (from p in profiles
join pf in prefixes on p.PrefixId equals pf.Id
where p.Id == id
select new
{
CitizenId = p.CitizenId,
Prefix = pf.Name,
p.FirstName,
p.LastName,
DateOfBirth = p.BirthDate.ToThaiShortDate(),
DateRetire = p.BirthDate.CalculateRetireDate().ToThaiShortDate(),
RegistrationAddress = p.RegistrationAddress,
RegistrationProvince = _context.Provinces.AsQueryable().FirstOrDefault(x => x.Id == p.RegistrationProvinceId)?.Name,
RegistrationDistrict = _context.Districts.AsQueryable().FirstOrDefault(x => x.Id == p.RegistrationDistrictId)?.Name,
RegistrationSubDistrict = _context.SubDistricts.AsQueryable().FirstOrDefault(x => x.Id == p.RegistrationSubDistrictId)?.Name,
RegistrationZipCode = p.RegistrationZipCode,
OcFullPath = _profileService.GetOrganizationNameFullPath(p.OcId.Value, false, false),
DateAppoint = p.DateAppoint == null ? "" : p.DateAppoint.Value.ToThaiShortDate(),
Salaries = profile_salaries,
SalaryAmount = p.Salaries.Count == 0 ? "-"
: $"{p.Salaries.OrderByDescending(s => s.Date.Value).FirstOrDefault().Amount.Value.ToString("#,##0")}",
Education = p.Educations.Count == 0 ? "-"
: $"{p.Educations.OrderByDescending(e => e.EndDate.Value.Year).FirstOrDefault().Degree} {p.Educations.OrderByDescending(e => e.EndDate.Value.Year).FirstOrDefault().Field}",
AvatarId = p.Avatar == null ? "" : p.Avatar.Id.ToString("D")
}).FirstOrDefault();
// _context.PositionPaths.AsQueryable().FirstOrDefault(x => x.Id == p.PositionId)?.Name,
// var profiles = _context.Profiles.AsQueryable()
// .Include(x => x.Avatar)
// .Include(x => x.Salaries)
// .Include(x => x.Educations)
// .ToList();
// var prefixes = _context.Prefixes.ToList();
// var profile = (from p in profiles
// join pf in prefixes on p.PrefixId equals pf.Id
// where p.Id == id
// select new
// {
// CitizenId = p.CitizenId,
// Prefix = pf.Name,
// p.FirstName,
// p.LastName,
// DateOfBirth = p.BirthDate.ToThaiShortDate(),
// DateRetire = p.BirthDate.CalculateRetireDate().ToThaiShortDate(),
// RegistrationAddress = p.RegistrationAddress,
// RegistrationProvince = _context.Provinces.AsQueryable().FirstOrDefault(x => x.Id == p.RegistrationProvinceId)?.Name,
// RegistrationDistrict = _context.Districts.AsQueryable().FirstOrDefault(x => x.Id == p.RegistrationDistrictId)?.Name,
// RegistrationSubDistrict = _context.SubDistricts.AsQueryable().FirstOrDefault(x => x.Id == p.RegistrationSubDistrictId)?.Name,
// RegistrationZipCode = p.RegistrationZipCode,
// OcFullPath = _profileService.GetOrganizationNameFullPath(p.OcId.Value, false, false),
// DateAppoint = p.DateAppoint == null ? "" : p.DateAppoint.Value.ToThaiShortDate(),
// Salaries = profile_salaries,
// SalaryAmount = p.Salaries.Count == 0 ? "-"
// : $"{p.Salaries.OrderByDescending(s => s.Date.Value).FirstOrDefault().Amount.Value.ToString("#,##0")}",
// Education = p.Educations.Count == 0 ? "-"
// : $"{p.Educations.OrderByDescending(e => e.EndDate.Value.Year).FirstOrDefault().Degree} {p.Educations.OrderByDescending(e => e.EndDate.Value.Year).FirstOrDefault().Field}",
// AvatarId = p.Avatar == null ? "" : p.Avatar.Id.ToString("D")
// }).FirstOrDefault();
// // _context.PositionPaths.AsQueryable().FirstOrDefault(x => x.Id == p.PositionId)?.Name,
var data = new List<dynamic>();
var c = 1;
if (profile.Salaries.Count == 0)
{
var ret2 = new
{
CitizenId = profile.CitizenId,
Prefix = profile.Prefix,
FirstName = profile.FirstName,
LastName = profile.LastName,
DateOfBirth = profile.DateOfBirth,
DateRetire = profile.DateRetire,
RegistrationAddress = $"{profile.RegistrationAddress}\r\nตำบล/แขวง {profile.RegistrationSubDistrict}\r\nเขต/อำเภอ {profile.RegistrationDistrict}\r\nจังหวัด {profile.RegistrationProvince} รหัสไปรษณีย์ {profile.RegistrationZipCode}",
SalaryAmount = profile.SalaryAmount,
Education = profile.Education,
AppointText = "",
SalaryDate = profile.DateAppoint,
PositionName = "",
OCFullPath = profile.OcFullPath
};
data.Add(ret2);
}
var old_date = DateTime.Now;
var old_position = "";
var old_ocid = Guid.NewGuid();
dynamic ret;
// var data = new List<dynamic>();
// var c = 1;
// if (profile.Salaries.Count == 0)
// {
// var ret2 = new
// {
// CitizenId = profile.CitizenId,
// Prefix = profile.Prefix,
// FirstName = profile.FirstName,
// LastName = profile.LastName,
// DateOfBirth = profile.DateOfBirth,
// DateRetire = profile.DateRetire,
// RegistrationAddress = $"{profile.RegistrationAddress}\r\nตำบล/แขวง {profile.RegistrationSubDistrict}\r\nเขต/อำเภอ {profile.RegistrationDistrict}\r\nจังหวัด {profile.RegistrationProvince} รหัสไปรษณีย์ {profile.RegistrationZipCode}",
// SalaryAmount = profile.SalaryAmount,
// Education = profile.Education,
// AppointText = "",
// SalaryDate = profile.DateAppoint,
// PositionName = "",
// OCFullPath = profile.OcFullPath
// };
// data.Add(ret2);
// }
// var old_date = DateTime.Now;
// var old_position = "";
// var old_ocid = Guid.NewGuid();
// dynamic ret;
//for (int i = 0; i <= 20; i++)
//{
// var s = profile.Salaries[0];
// old_date = s.SalaryDateAnnounce.Value;
// old_position = s.PositionName;
// old_ocid = s.OcId.Value;
// ret = new
// {
// CitizenId = profile.CitizenId,
// Prefix = profile.Prefix,
// FirstName = profile.FirstName,
// LastName = profile.LastName,
// DateOfBirth = profile.DateOfBirth,
// DateRetire = profile.DateRetire,
// RegistrationAddress = $"{profile.RegistrationAddress}\r\nตำบล/แขวง {profile.RegistrationSubDistrict}\r\nเขต/อำเภอ {profile.RegistrationDistrict}\r\nจังหวัด {profile.RegistrationProvince} รหัสไปรษณีย์ {profile.RegistrationZipCode}",
// SalaryAmount = profile.SalaryAmount,
// Education = profile.Education,
// AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
// SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
// PositionName = s.PositionName,
// OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false)
// };
// data.Add(ret);
//}
// //for (int i = 0; i <= 20; i++)
// //{
// // var s = profile.Salaries[0];
// // old_date = s.SalaryDateAnnounce.Value;
// // old_position = s.PositionName;
// // old_ocid = s.OcId.Value;
// // ret = new
// // {
// // CitizenId = profile.CitizenId,
// // Prefix = profile.Prefix,
// // FirstName = profile.FirstName,
// // LastName = profile.LastName,
// // DateOfBirth = profile.DateOfBirth,
// // DateRetire = profile.DateRetire,
// // RegistrationAddress = $"{profile.RegistrationAddress}\r\nตำบล/แขวง {profile.RegistrationSubDistrict}\r\nเขต/อำเภอ {profile.RegistrationDistrict}\r\nจังหวัด {profile.RegistrationProvince} รหัสไปรษณีย์ {profile.RegistrationZipCode}",
// // SalaryAmount = profile.SalaryAmount,
// // Education = profile.Education,
// // AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
// // SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
// // PositionName = s.PositionName,
// // OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false)
// // };
// // data.Add(ret);
// //}
foreach (var s in profile.Salaries)
{
//if((old_date.Date != s.SalaryDateAnnounce.Value.Date))
//{
// old_date = s.SalaryDateAnnounce.Value;
// old_position= s.PositionName;
// old_ocid = s.OcId;
// foreach (var s in profile.Salaries)
// {
// //if((old_date.Date != s.SalaryDateAnnounce.Value.Date))
// //{
// // old_date = s.SalaryDateAnnounce.Value;
// // old_position= s.PositionName;
// // old_ocid = s.OcId;
// ret = new
// {
// CitizenId = profile.CitizenId,
// Prefix = profile.Prefix,
// FirstName = profile.FirstName,
// LastName = profile.LastName,
// DateOfBirth = profile.DateOfBirth,
// RegistrationAddress = profile.RegistrationAddress,
// SalaryAmount = profile.SalaryAmount,
// Education = profile.Education,
// AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
// SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
// PositionName = s.PositionName,
// OCFullPath = CoreCommandReport.GetOrganizationNameFullPath(s.OcId, false, false)
// };
// data.Add(ret);
//}
if (old_position != s.PositionName)
{
old_date = s.SalaryDateAnnounce.Value;
old_position = s.PositionName;
old_ocid = s.OcId.Value;
ret = new
{
CitizenId = profile.CitizenId,
Prefix = profile.Prefix,
FirstName = profile.FirstName,
LastName = profile.LastName,
DateOfBirth = profile.DateOfBirth,
DateRetire = profile.DateRetire,
RegistrationAddress = $"{profile.RegistrationAddress}\r\nตำบล/แขวง {profile.RegistrationSubDistrict}\r\nเขต/อำเภอ {profile.RegistrationDistrict}\r\nจังหวัด {profile.RegistrationProvince} รหัสไปรษณีย์ {profile.RegistrationZipCode}",
SalaryAmount = profile.SalaryAmount,
Education = profile.Education,
AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
PositionName = s.PositionName,
OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false)
};
data.Add(ret);
}
else if (old_ocid != s.OcId)
{
old_date = s.SalaryDateAnnounce.Value;
old_position = s.PositionName;
old_ocid = s.OcId.Value;
ret = new
{
CitizenId = profile.CitizenId,
Prefix = profile.Prefix,
FirstName = profile.FirstName,
LastName = profile.LastName,
DateOfBirth = profile.DateOfBirth,
DateRetire = profile.DateRetire,
RegistrationAddress = $"{profile.RegistrationAddress}\r\nตำบล/แขวง {profile.RegistrationSubDistrict}\r\nเขต/อำเภอ {profile.RegistrationDistrict}\r\nจังหวัด {profile.RegistrationProvince} รหัสไปรษณีย์ {profile.RegistrationZipCode}",
SalaryAmount = profile.SalaryAmount,
Education = profile.Education,
AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
PositionName = s.PositionName,
OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false),
// // ret = new
// // {
// // CitizenId = profile.CitizenId,
// // Prefix = profile.Prefix,
// // FirstName = profile.FirstName,
// // LastName = profile.LastName,
// // DateOfBirth = profile.DateOfBirth,
// // RegistrationAddress = profile.RegistrationAddress,
// // SalaryAmount = profile.SalaryAmount,
// // Education = profile.Education,
// // AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
// // SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
// // PositionName = s.PositionName,
// // OCFullPath = CoreCommandReport.GetOrganizationNameFullPath(s.OcId, false, false)
// // };
// // data.Add(ret);
// //}
// if (old_position != s.PositionName)
// {
// old_date = s.SalaryDateAnnounce.Value;
// old_position = s.PositionName;
// old_ocid = s.OcId.Value;
// ret = new
// {
// CitizenId = profile.CitizenId,
// Prefix = profile.Prefix,
// FirstName = profile.FirstName,
// LastName = profile.LastName,
// DateOfBirth = profile.DateOfBirth,
// DateRetire = profile.DateRetire,
// RegistrationAddress = $"{profile.RegistrationAddress}\r\nตำบล/แขวง {profile.RegistrationSubDistrict}\r\nเขต/อำเภอ {profile.RegistrationDistrict}\r\nจังหวัด {profile.RegistrationProvince} รหัสไปรษณีย์ {profile.RegistrationZipCode}",
// SalaryAmount = profile.SalaryAmount,
// Education = profile.Education,
// AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
// SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
// PositionName = s.PositionName,
// OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false)
// };
// data.Add(ret);
// }
// else if (old_ocid != s.OcId)
// {
// old_date = s.SalaryDateAnnounce.Value;
// old_position = s.PositionName;
// old_ocid = s.OcId.Value;
// ret = new
// {
// CitizenId = profile.CitizenId,
// Prefix = profile.Prefix,
// FirstName = profile.FirstName,
// LastName = profile.LastName,
// DateOfBirth = profile.DateOfBirth,
// DateRetire = profile.DateRetire,
// RegistrationAddress = $"{profile.RegistrationAddress}\r\nตำบล/แขวง {profile.RegistrationSubDistrict}\r\nเขต/อำเภอ {profile.RegistrationDistrict}\r\nจังหวัด {profile.RegistrationProvince} รหัสไปรษณีย์ {profile.RegistrationZipCode}",
// SalaryAmount = profile.SalaryAmount,
// Education = profile.Education,
// AppointText = c == 1 ? "(เริ่มรับราชการ)" : "",
// SalaryDate = s.SalaryDateAnnounce.Value.ToThaiShortDate(),
// PositionName = s.PositionName,
// OCFullPath = _profileService.GetOrganizationNameFullPath(s.OcId.Value, false, false),
};
data.Add(ret);
}
// };
// data.Add(ret);
// }
c++;
}
// c++;
// }
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Profile", $"rptShortKp7.trdp");
@ -258,21 +264,39 @@ namespace BMA.EHR.Report.Service.Controllers
{
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
}
report.DataSource = data;
if (profile.AvatarId != "")
var CitizenId = "";
var apiUrl = $"{_configuration["API"]}org/profile/kp7-short/{id}";
using (var client = new HttpClient())
{
try
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<kp7ShortRequest>(_result);
if (org == null || org.result == null)
{
// Get avatar Image
var picContent = (await _minioService.DownloadFileAsync(Guid.Parse(profile.AvatarId))).FileContent;
var pictureBox = (Telerik.Reporting.PictureBox)report.Items["groupHeaderSection"].Items["picAvatar"];
pictureBox.Value = Image.FromStream(new MemoryStream(picContent));
return Error("ไม่ะบข้อมูลนี้ในระบบ", 404);
}
catch { }
report.DataSource = org.result;
CitizenId = org.result.CitizenId;
}
// report.DataSource = data;
// if (profile.AvatarId != "")
// {
// try
// {
// // Get avatar Image
// var picContent = (await _minioService.DownloadFileAsync(Guid.Parse("00000000-0000-0000-0000-000000000000"))).FileContent;
// var pictureBox = (Telerik.Reporting.PictureBox)report.Items["groupHeaderSection"].Items["picAvatar"];
// pictureBox.Value = Image.FromStream(new MemoryStream(picContent));
// }
// catch { }
// }
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
@ -285,7 +309,7 @@ namespace BMA.EHR.Report.Service.Controllers
RenderingResult result = reportProcessor.RenderReport("PDF", instanceReportSource, deviceInfo);
var content = result.DocumentBytes;
return File(content, "application/pdf", $"ประวัติการรับราชการอย่างย่อ_{profile.CitizenId}.pdf");
return File(content, "application/pdf", $"ประวัติการรับราชการอย่างย่อ_{CitizenId}.pdf");
@ -314,152 +338,152 @@ namespace BMA.EHR.Report.Service.Controllers
{
try
{
var profile = (from p in _context.Profiles
join pf in _context.Prefixes on p.PrefixId equals pf.Id into p_pf_join
from p_pf in p_pf_join.DefaultIfEmpty()
join cpf in _context.Prefixes on p.CouplePrefixId equals cpf.Id into c_pf_join
from c_pf in c_pf_join.DefaultIfEmpty()
join fpf in _context.Prefixes on p.FatherPrefixId equals fpf.Id into f_pf_join
from f_pf in f_pf_join.DefaultIfEmpty()
join mpf in _context.Prefixes on p.MotherPrefixId equals mpf.Id into m_pf_join
from m_pf in m_pf_join.DefaultIfEmpty()
where p.Id == id
select new
{
p.CitizenId,
Prefix = p_pf == null ? "" : p_pf.Name,
p.FirstName,
p.LastName,
FullName = $"{p.FirstName} {p.LastName}",
BirthDay = p.BirthDate.Day,
BirthDayText = Convert.ToDecimal(p.BirthDate.Day).ThaiBahtText(UsesEt.Always, GreatFriends.ThaiBahtText.Unit.Baht, 2, false).Replace("บาท", ""),
BirthMonth = p.BirthDate.Month.ToThaiMonth(),
BirthYear = p.BirthDate.Year.ToThaiYear(),
BirthYearText = Convert.ToDecimal(p.BirthDate.Year.ToThaiYear()).ThaiBahtText(UsesEt.Always, GreatFriends.ThaiBahtText.Unit.Baht, 2, false).Replace("บาท", ""),
Address = "",
District = "",
Area = "",
Province = "",
Telephone = p.TelephoneNumber,
CoupleLastNameOld = p == null ? "" : p.CoupleLastNameOld,
CouplePrefix = c_pf == null ? "" : c_pf.Name,
CoupleFullName = $"{p.CoupleFirstName} {p.CoupleLastName}".Trim(),
FatherPrefix = f_pf == null ? "" : f_pf.Name,
FatherFullName = $"{p.FatherFirstName} {p.FatherLastName}".Trim(),
MotherPrefix = m_pf == null ? "" : m_pf.Name,
MotherFullName = $"{p.MotherFirstName} {p.MotherLastName}".Trim(),
OcId = p.OcId,
OcFullPath = _profileService.GetOrganizationNameFullPath(p.OcId.Value, false, false),
Division = "",
Institute = "",
StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiShortDate(),
AppointDate = p.DateAppoint == null ? "" : p.DateAppoint.Value.ToThaiShortDate(),
BirthDate = p.BirthDate.ToThaiShortDate(),
RetireDate = p.BirthDate.CalculateRetireDate().ToThaiShortDate(),
AvatarId = p.Avatar == null ? "" : p.Avatar.Id.ToString("D")
}).ToList();
// var profile = (from p in _context.Profiles
// join pf in _context.Prefixes on p.PrefixId equals pf.Id into p_pf_join
// from p_pf in p_pf_join.DefaultIfEmpty()
// join cpf in _context.Prefixes on p.CouplePrefixId equals cpf.Id into c_pf_join
// from c_pf in c_pf_join.DefaultIfEmpty()
// join fpf in _context.Prefixes on p.FatherPrefixId equals fpf.Id into f_pf_join
// from f_pf in f_pf_join.DefaultIfEmpty()
// join mpf in _context.Prefixes on p.MotherPrefixId equals mpf.Id into m_pf_join
// from m_pf in m_pf_join.DefaultIfEmpty()
// where p.Id == id
// select new
// {
// p.CitizenId,
// Prefix = p_pf == null ? "" : p_pf.Name,
// p.FirstName,
// p.LastName,
// FullName = $"{p.FirstName} {p.LastName}",
// BirthDay = p.BirthDate.Day,
// BirthDayText = Convert.ToDecimal(p.BirthDate.Day).ThaiBahtText(UsesEt.Always, GreatFriends.ThaiBahtText.Unit.Baht, 2, false).Replace("บาท", ""),
// BirthMonth = p.BirthDate.Month.ToThaiMonth(),
// BirthYear = p.BirthDate.Year.ToThaiYear(),
// BirthYearText = Convert.ToDecimal(p.BirthDate.Year.ToThaiYear()).ThaiBahtText(UsesEt.Always, GreatFriends.ThaiBahtText.Unit.Baht, 2, false).Replace("บาท", ""),
// Address = "",
// District = "",
// Area = "",
// Province = "",
// Telephone = p.TelephoneNumber,
// CoupleLastNameOld = p == null ? "" : p.CoupleLastNameOld,
// CouplePrefix = c_pf == null ? "" : c_pf.Name,
// CoupleFullName = $"{p.CoupleFirstName} {p.CoupleLastName}".Trim(),
// FatherPrefix = f_pf == null ? "" : f_pf.Name,
// FatherFullName = $"{p.FatherFirstName} {p.FatherLastName}".Trim(),
// MotherPrefix = m_pf == null ? "" : m_pf.Name,
// MotherFullName = $"{p.MotherFirstName} {p.MotherLastName}".Trim(),
// OcId = p.OcId,
// OcFullPath = _profileService.GetOrganizationNameFullPath(p.OcId.Value, false, false),
// Division = "",
// Institute = "",
// StartDate = p.DateStart == null ? "" : p.DateStart.Value.ToThaiShortDate(),
// AppointDate = p.DateAppoint == null ? "" : p.DateAppoint.Value.ToThaiShortDate(),
// BirthDate = p.BirthDate.ToThaiShortDate(),
// RetireDate = p.BirthDate.CalculateRetireDate().ToThaiShortDate(),
// AvatarId = p.Avatar == null ? "" : p.Avatar.Id.ToString("D")
// }).ToList();
if (!profile.Any())
return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
// if (!profile.Any())
// return Error(GlobalMessages.DataNotFound, StatusCodes.Status404NotFound);
// certificate
var cert = (from c in _context.ProfileCertificates.AsQueryable()
where c.Profile.Id == id
orderby c.IssueDate.Value.Year
select new
{
c.CertificateType,
c.Issuer,
c.CertificateNo,
IssueDate = c.IssueDate == null ? "" : c.IssueDate.Value.ToThaiShortDate()
}).ToList();
// // certificate
// var cert = (from c in _context.ProfileCertificates.AsQueryable()
// where c.Profile.Id == id
// orderby c.IssueDate.Value.Year
// select new
// {
// c.CertificateType,
// c.Issuer,
// c.CertificateNo,
// IssueDate = c.IssueDate == null ? "" : c.IssueDate.Value.ToThaiShortDate()
// }).ToList();
// add temp rows
while (cert.Count < 3)
{
cert.Add(new
{
CertificateType = "",
Issuer = "",
CertificateNo = "",
IssueDate = ""
});
}
// // add temp rows
// while (cert.Count < 3)
// {
// cert.Add(new
// {
// CertificateType = "",
// Issuer = "",
// CertificateNo = "",
// IssueDate = ""
// });
// }
// training
var training = (from t in _context.ProfileTrainings.AsQueryable()
where t.Profile.Id == id
orderby t.StartDate.Value.Year
select new
{
Institute = t.Department,
Start = t.StartDate == null ? "" : t.StartDate.Value.Year.ToThaiYear().ToString(),
End = t.EndDate == null ? "" : t.EndDate.Value.Year.ToThaiYear().ToString(),
Level = "",
Degree = t.Name,
Field = ""
}).ToList();
// // training
// var training = (from t in _context.ProfileTrainings.AsQueryable()
// where t.Profile.Id == id
// orderby t.StartDate.Value.Year
// select new
// {
// Institute = t.Department,
// Start = t.StartDate == null ? "" : t.StartDate.Value.Year.ToThaiYear().ToString(),
// End = t.EndDate == null ? "" : t.EndDate.Value.Year.ToThaiYear().ToString(),
// Level = "",
// Degree = t.Name,
// Field = ""
// }).ToList();
while (training.Count < 3)
{
training.Add(new
{
Institute = "",
Start = "",
End = "",
Level = "",
Degree = "",
Field = ""
});
}
// while (training.Count < 3)
// {
// training.Add(new
// {
// Institute = "",
// Start = "",
// End = "",
// Level = "",
// Degree = "",
// Field = ""
// });
// }
// disciplines
var discipline = (from d in _context.ProfileDisciplines.AsQueryable()
where d.Profile.Id == id
orderby d.Date.Value.Year
select new
{
DisciplineYear = d.Date == null ? "" : d.Date.Value.Year.ToThaiYear().ToString(),
DisciplineDetail = d.Detail,
RefNo = d.RefCommandNo
}).ToList();
// // disciplines
// var discipline = (from d in _context.ProfileDisciplines.AsQueryable()
// where d.Profile.Id == id
// orderby d.Date.Value.Year
// select new
// {
// DisciplineYear = d.Date == null ? "" : d.Date.Value.Year.ToThaiYear().ToString(),
// DisciplineDetail = d.Detail,
// RefNo = d.RefCommandNo
// }).ToList();
while (discipline.Count < 3)
{
discipline.Add(new
{
DisciplineYear = "",
DisciplineDetail = "",
RefNo = ""
});
}
// while (discipline.Count < 3)
// {
// discipline.Add(new
// {
// DisciplineYear = "",
// DisciplineDetail = "",
// RefNo = ""
// });
// }
// education
var education = (from e in _context.ProfileEducations.AsQueryable()
where e.Profile.Id == id
orderby e.StartDate.Value.Year
select new
{
Institute = e.Institute,
Start = e.StartDate == null ? "" : e.StartDate.Value.Year.ToThaiYear().ToString(),
End = e.EndDate == null ? "" : e.EndDate.Value.Year.ToThaiYear().ToString(),
Level = e.EducationLevel,
Degree = e.Degree,
Field = e.Field.Trim() == "-" ? "" : e.Field
}).ToList();
// // education
// var education = (from e in _context.ProfileEducations.AsQueryable()
// where e.Profile.Id == id
// orderby e.StartDate.Value.Year
// select new
// {
// Institute = e.Institute,
// Start = e.StartDate == null ? "" : e.StartDate.Value.Year.ToThaiYear().ToString(),
// End = e.EndDate == null ? "" : e.EndDate.Value.Year.ToThaiYear().ToString(),
// Level = e.EducationLevel,
// Degree = e.Degree,
// Field = e.Field.Trim() == "-" ? "" : e.Field
// }).ToList();
while (education.Count < 4)
{
education.Add(new
{
Institute = "",
Start = "",
End = "",
Level = "",
Degree = "",
Field = ""
});
}
// while (education.Count < 4)
// {
// education.Add(new
// {
// Institute = "",
// Start = "",
// End = "",
// Level = "",
// Degree = "",
// Field = ""
// });
// }
var rptFile = Path.Combine(_hostingEnvironment.ContentRootPath, "Report", "Profile", $"rptKK1_Page1.trdp");
@ -469,33 +493,56 @@ namespace BMA.EHR.Report.Service.Controllers
{
report = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
}
report.DataSource = profile;
// binding to table
var tblCertificate = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblCertificate"];
tblCertificate.DataSource = cert;
var tblTraining = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblTraining"];
tblTraining.DataSource = training;
var tblDiscipline = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblDiscipline"];
tblDiscipline.DataSource = discipline;
var tblEducation = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblEducation"];
tblEducation.DataSource = education;
if (profile.First().AvatarId != "")
var CitizenId = "";
var FullName = "";
var OcFullPath = "";
var salary = new List<dynamic>();
var apiUrl = $"{_configuration["API"]}org/profile/kk1/{id}";
using (var client = new HttpClient())
{
try
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token.Replace("Bearer ", ""));
var _req = new HttpRequestMessage(HttpMethod.Get, apiUrl);
var _res = await client.SendAsync(_req);
var _result = await _res.Content.ReadAsStringAsync();
var org = JsonConvert.DeserializeObject<dynamic>(_result);
if (org == null || org.result == null)
{
// Get avatar Image
var picContent = (await _minioService.DownloadFileAsync(Guid.Parse(profile.First().AvatarId))).FileContent;
var pictureBox = (Telerik.Reporting.PictureBox)report.Items["pageFooterSection1"].Items["picAvatar"];
pictureBox.Value = Image.FromStream(new MemoryStream(picContent));
return Error("ไม่ะบข้อมูลนี้ในระบบ", 404);
}
catch { }
report.DataSource = org.result.Profile;
// binding to table
var tblCertificate = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblCertificate"];
tblCertificate.DataSource = org.result.Cert;
var tblTraining = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblTraining"];
tblTraining.DataSource = org.result.Training;
var tblDiscipline = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblDiscipline"];
tblDiscipline.DataSource = org.result.Discipline;
var tblEducation = (Telerik.Reporting.Table)report.Items["detailSection1"].Items["tblEducation"];
tblEducation.DataSource = org.result.Education;
salary = org.result.Salary;
CitizenId = org.result.profile.CitizenId;
FullName = org.result.profile.FullName;
OcFullPath = org.result.profile.OcFullPath;
}
// if (profile.First().AvatarId != "")
// {
// try
// {
// // Get avatar Image
// var picContent = (await _minioService.DownloadFileAsync(Guid.Parse(profile.First().AvatarId))).FileContent;
// var pictureBox = (Telerik.Reporting.PictureBox)report.Items["pageFooterSection1"].Items["picAvatar"];
// pictureBox.Value = Image.FromStream(new MemoryStream(picContent));
// }
// catch { }
// }
System.Collections.Hashtable deviceInfo = new System.Collections.Hashtable();
InstanceReportSource instanceReportSource = new InstanceReportSource()
@ -510,39 +557,39 @@ namespace BMA.EHR.Report.Service.Controllers
// byte array waiting for merge pdf
var content = result.DocumentBytes;
// page2
var profile2 = (from p in _context.Profiles
join pf in _context.Prefixes on p.PrefixId equals pf.Id
where p.Id == id
select new
{
FullName = $"{pf.Name}{p.FirstName} {p.LastName}",
OcFullPath = _profileService.GetOrganizationNameFullPath(p.OcId.Value, false, false),
}).FirstOrDefault();
// // page2
// var profile2 = (from p in _context.Profiles
// join pf in _context.Prefixes on p.PrefixId equals pf.Id
// where p.Id == id
// select new
// {
// FullName = $"{pf.Name}{p.FirstName} {p.LastName}",
// OcFullPath = _profileService.GetOrganizationNameFullPath(p.OcId.Value, false, false),
// }).FirstOrDefault();
var salary = (from s in _context.ProfileSalaries
.Include(x => x.PositionLevel)
join pos in _context.PositionPaths.AsQueryable()
on s.PositionId equals pos.Id
join pos_no in _context.PositionNumbers on s.PosNoId equals pos_no.Id
// join pos_lv in _context.PositionLevels on s.PositionLevelId equals pos_lv.Id
join pos_type in _context.PositionTypes on s.PositionTypeId equals pos_type.Id
where s.Profile.Id == id
orderby s.Date.Value
select new
{
SalaryDate = s.Date == null ? "" : s.Date == new DateTime(1, 1, 1) ? "" : s.Date.Value.ToThaiShortDate(),
Position = $"{pos.Name} ประเภท{pos_type.Name} ระดับ{s.PositionLevel.Name}",
PosNo = pos_no.Name,
Rank = s.PositionLevel == null ? null : s.PositionLevel.Name,
Salary = s.Amount == null ? "" : s.Amount == 0 ? "-" : s.Amount.ToString().ToInteger().ToNumericText(),
RefAll = s.SalaryRef,
PositionType = pos_type.Name,
PositionLevel = s.PositionLevel == null ? null : s.PositionLevel.Name,
PositionAmount = s.PositionSalaryAmount == null ? "" : s.PositionSalaryAmount.Value == 0 ? "-" : s.PositionSalaryAmount.Value.ToString().ToInteger().ToNumericText(),
FullName = profile2.FullName,
OcFullPath = profile2.OcFullPath
}).ToList();
// var salary = (from s in _context.ProfileSalaries
// .Include(x => x.PositionLevel)
// join pos in _context.PositionPaths.AsQueryable()
// on s.PositionId equals pos.Id
// join pos_no in _context.PositionNumbers on s.PosNoId equals pos_no.Id
// // join pos_lv in _context.PositionLevels on s.PositionLevelId equals pos_lv.Id
// join pos_type in _context.PositionTypes on s.PositionTypeId equals pos_type.Id
// where s.Profile.Id == id
// orderby s.Date.Value
// select new
// {
// SalaryDate = s.Date == null ? "" : s.Date == new DateTime(1, 1, 1) ? "" : s.Date.Value.ToThaiShortDate(),
// Position = $"{pos.Name} ประเภท{pos_type.Name} ระดับ{s.PositionLevel.Name}",
// PosNo = pos_no.Name,
// Rank = s.PositionLevel == null ? null : s.PositionLevel.Name,
// Salary = s.Amount == null ? "" : s.Amount == 0 ? "-" : s.Amount.ToString().ToInteger().ToNumericText(),
// RefAll = s.SalaryRef,
// PositionType = pos_type.Name,
// PositionLevel = s.PositionLevel == null ? null : s.PositionLevel.Name,
// PositionAmount = s.PositionSalaryAmount == null ? "" : s.PositionSalaryAmount.Value == 0 ? "-" : s.PositionSalaryAmount.Value.ToString().ToInteger().ToNumericText(),
// FullName = profile2.FullName,
// OcFullPath = profile2.OcFullPath
// }).ToList();
//while (salary.Count < 60)
//{
@ -571,8 +618,8 @@ namespace BMA.EHR.Report.Service.Controllers
report2 = (Telerik.Reporting.Report)reportPackager.UnpackageDocument(sourceStream);
}
report2.ReportParameters["FullName"].Value = profile2.FullName;
report2.ReportParameters["OcFullPath"].Value = profile2.OcFullPath;
report2.ReportParameters["FullName"].Value = FullName;
report2.ReportParameters["OcFullPath"].Value = OcFullPath;
// binding to table
var tblSalary = (Telerik.Reporting.Table)report2.Items["detailSection1"].Items["tblSalary"];
@ -626,7 +673,7 @@ namespace BMA.EHR.Report.Service.Controllers
}
var fileContent = ms.ToArray();
return File(fileContent, "application/pdf", $"กก_1_{profile[0].CitizenId}.pdf");
return File(fileContent, "application/pdf", $"กก_1_{CitizenId}.pdf");
}
}
catch (Exception ex)

View file

@ -0,0 +1,25 @@
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Report.Service.Responses
{
public class kp7ShortRequest
{
public OrgRequestData result { get; set; } = new();
}
public class OrgRequestData
{
public string? CitizenId { get; set; }
public string? Prefix { get; set; }
public string? FirstName { get; set; }
public string? LastName { get; set; }
public string? DateOfBirth { get; set; }
public string? DateRetire { get; set; }
public string? RegistrationAddress { get; set; }
public string? SalaryAmount { get; set; }
public string? Education { get; set; }
public string? AppointText { get; set; }
public string? SalaryDate { get; set; }
public string? PositionName { get; set; }
public string? OcFullPath { get; set; }
}
}

View file

@ -14,13 +14,13 @@
"AllowedHosts": "*",
"ConnectionStrings": {
"MongoConnection": "mongodb://admin:adminVM123@127.0.0.1:27017",
"RecruitConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_recruit_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"EHRConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"ExamConnection": "server=192.168.1.9;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
"RecruitConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_recruit_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"EHRConnection": "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;",
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://identity.frappet.com/realms/bma-ehr"
"Issuer": "https://id.frappet.synology.me/realms/bma-ehr"
},
"EPPlus": {
"ExcelPackage": {
@ -32,5 +32,6 @@
"AccessKey": "XCiP1ubSyuGS5yDT",
"SecretKey": "LFnSRyk144oJERvump8UDxPcjjEyzgum",
"BucketName": "bma-recruit"
}
},
"API": "https://bma-ehr.frappet.synology.me/api/v1/"
}

View file

@ -14,14 +14,14 @@
"AllowedHosts": "*",
"ConnectionStrings": {
"MongoConnection": "mongodb://admin:adminVM123@127.0.0.1:27017",
"RecruitConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_recruit;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"EHRConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"ExamConnection": "server=127.0.0.1;user=root;password=P@ssw0rd;port=3308;database=bma_ehr_exam;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
"RecruitConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_recruit_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;",
"EHRConnection": "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;",
"ExamConnection": "server=192.168.1.80;user=root;password=adminVM123;port=3306;database=bma_ehr_exam_demo;Convert Zero Datetime=True;Allow User Variables=true;Pooling=True;"
},
"Jwt": {
"Key": "HP-FnQMUj9msHMSD3T9HtdEnphAKoCJLEl85CIqROFI",
"Issuer": "https://identity.frappet.com/realms/bma-ehr"
"Issuer": "https://id.frappet.synology.me/realms/bma-ehr"
},
"EPPlus": {
"ExcelPackage": {
@ -33,5 +33,6 @@
"AccessKey": "XCiP1ubSyuGS5yDT",
"SecretKey": "LFnSRyk144oJERvump8UDxPcjjEyzgum",
"BucketName": "bma-recruit"
}
},
"API": "https://bma-ehr.frappet.synology.me/api/v1/"
}