no message

This commit is contained in:
kittapath 2024-10-02 15:14:37 +07:00
parent 874d310b35
commit bce6732bdb
7 changed files with 284 additions and 3 deletions

View file

@ -3,10 +3,10 @@ using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.Commands;
using BMA.EHR.Application.Requests.Commands;
using BMA.EHR.Application.Responses;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Command.Service.Requests;
using BMA.EHR.Command.Service.Responses;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Commands.Core;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
@ -16,10 +16,8 @@ using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Swashbuckle.AspNetCore.Annotations;
using System.Net;
using System.Net.Http.Headers;
using System.Security.Claims;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace BMA.EHR.Command.Service.Controllers
@ -6575,5 +6573,73 @@ namespace BMA.EHR.Command.Service.Controllers
}
#endregion
/// <summary>
/// ออกคำสั่ง C-PM-11
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command11/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand11Execute([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/command11/{recv.refId}";
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
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
/// <summary>
/// ออกคำสั่ง C-PM-12
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("command12/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportCommand12Execute([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var baseAPI = _configuration["API"];
var apiUrl = $"{baseAPI}/org/profile/command12/{recv.refId}";
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
{
profileId = recv.refId,
date = recv.commandAffectDate,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
salaryRef = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
}
return Success();
}
}
}

View file

@ -0,0 +1,21 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Command.Service.Requests
{
public class ReportExecuteRequest
{
public ReportExecuteRequestObj[] refIds { get; set; }
}
public class ReportExecuteRequestObj
{
public string? refId { get; set; }
public DateTime commandAffectDate { get; set; }
public string? commandNo { get; set; }
public int commandYear { get; set; }
public string? templateDoc { get; set; }
public double? amount { get; set; }
public double? positionSalaryAmount { get; set; }
public double? mouthSalaryAmount { get; set; }
}
}

View file

@ -0,0 +1,10 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Command.Service.Requests
{
public class ReportPersonRequest
{
public string[] refIds { get; set; }
}
}

View file

@ -142,10 +142,15 @@ namespace BMA.EHR.Placement.Service.Controllers
{
var data = await _context.PlacementProfiles.Where(x => x.Placement.Id == examId).Select(x => new
{
Id = x.Id,
PersonalId = x.Id,
Avatar = x.ProfileImg == null ? Guid.Parse("00000000-0000-0000-0000-000000000000") : x.ProfileImg.Id,
FullName = $"{x.Prefix}{x.Firstname} {x.Lastname}",
Prefix = x.Prefix,
Firstname = x.Firstname,
Lastname = x.Lastname,
IdCard = x.CitizenId,
CitizenId = x.CitizenId,
ExamNumber = x.ExamNumber,
posmasterId = x.posmasterId,
root = x.root,
@ -189,10 +194,15 @@ namespace BMA.EHR.Placement.Service.Controllers
{
var _data = new
{
p.Id,
p.PersonalId,
Avatar = p.Avatar == Guid.Parse("00000000-0000-0000-0000-000000000000") ? null : await _documentService.ImagesPath(p.Avatar),
p.FullName,
p.Prefix,
p.Firstname,
p.Lastname,
p.IdCard,
p.CitizenId,
p.ExamNumber,
p.posmasterId,
p.root,

View file

@ -1,6 +1,7 @@
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.Retirement;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
@ -623,5 +624,147 @@ namespace BMA.EHR.Retirement.Service.Controllers
return Success();
}
/// <summary>
/// ออกคำสั่ง C-PM-08
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("appoint/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecuteAppoint([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var placementProfile = await _context.RetirementOthers
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
if (placementProfile == null)
throw new Exception(GlobalMessages.DataNotFound);
var baseAPI = _configuration["API"];
var apiUrlSalary = $"{baseAPI}/org/profile/salary";
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, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileId = placementProfile.profileId,
date = recv.commandAffectDate,
amount = recv.amount,
positionSalaryAmount = recv.positionSalaryAmount,
mouthSalaryAmount = recv.mouthSalaryAmount,
posNo = placementProfile.PositionNumberOld,
position = placementProfile.PositionOld,
positionLine = "",
positionPathSide = "",
positionExecutive = "",
positionType = placementProfile.PositionTypeOld,
positionLevel = placementProfile.PositionLevelOld,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
templateDoc = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
var baseAPILeave = _configuration["API"];
var apiUrlLeave = $"{baseAPI}/org/profile/leave/{placementProfile.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, apiUrlLeave);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrlLeave, new
{
isLeave = false,
leaveReason = _null,
dateLeave = _null,
});
var _result = await _res.Content.ReadAsStringAsync();
}
// update placementstatus
placementProfile.Status = "DONE";
await _context.SaveChangesAsync();
}
return Success();
}
/// <summary>
/// ออกคำสั่ง C-PM-09
/// </summary>
/// <returns></returns>
/// <response code="200"></response>
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
[HttpPost("out/report/excecute")]
public async Task<ActionResult<ResponseObject>> PostReportExecuteOut([FromBody] ReportExecuteRequest req)
{
// create new profile
foreach (var recv in req.refIds)
{
var placementProfile = await _context.RetirementOthers
.FirstOrDefaultAsync(x => x.Id == Guid.Parse(recv.refId));
if (placementProfile == null)
throw new Exception(GlobalMessages.DataNotFound);
var baseAPI = _configuration["API"];
var apiUrlSalary = $"{baseAPI}/org/profile/salary";
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, apiUrlSalary);
var _res = await client.PostAsJsonAsync(apiUrlSalary, new
{
profileId = placementProfile.profileId,
date = recv.commandAffectDate,
amount = recv.amount,
positionSalaryAmount = recv.positionSalaryAmount,
mouthSalaryAmount = recv.mouthSalaryAmount,
posNo = placementProfile.PositionNumberOld,
position = placementProfile.PositionOld,
positionLine = "",
positionPathSide = "",
positionExecutive = "",
positionType = placementProfile.PositionTypeOld,
positionLevel = placementProfile.PositionLevelOld,
refCommandNo = $"{recv.commandNo}/{recv.commandYear.ToThaiYear()}",
templateDoc = recv.templateDoc,
});
var _result = await _res.Content.ReadAsStringAsync();
}
var baseAPILeave = _configuration["API"];
var apiUrlLeave = $"{baseAPI}/org/profile/leave/{placementProfile.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, apiUrlLeave);
string? _null = null;
var _res = await client.PostAsJsonAsync(apiUrlLeave, new
{
isLeave = false,
leaveReason = _null,
dateLeave = _null,
});
var _result = await _res.Content.ReadAsStringAsync();
}
// update placementstatus
placementProfile.Status = "DONE";
await _context.SaveChangesAsync();
}
return Success();
}
}
}

View file

@ -0,0 +1,21 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class ReportExecuteRequest
{
public ReportExecuteRequestObj[] refIds { get; set; }
}
public class ReportExecuteRequestObj
{
public string? refId { get; set; }
public DateTime commandAffectDate { get; set; }
public string? commandNo { get; set; }
public int commandYear { get; set; }
public string? templateDoc { get; set; }
public double? amount { get; set; }
public double? positionSalaryAmount { get; set; }
public double? mouthSalaryAmount { get; set; }
}
}

View file

@ -0,0 +1,10 @@
using BMA.EHR.Domain.Models.MetaData;
using Microsoft.EntityFrameworkCore;
namespace BMA.EHR.Retirement.Service.Requests
{
public class ReportPersonRequest
{
public string[] refIds { get; set; }
}
}