Merge branch 'develop' into working
This commit is contained in:
commit
db3ca47693
4 changed files with 43 additions and 19 deletions
|
|
@ -3,6 +3,7 @@ using Amazon.S3.Model;
|
|||
using BMA.EHR.Domain.Models.Documents;
|
||||
using BMA.EHR.Domain.Shared;
|
||||
using BMA.EHR.Infrastructure.Persistence;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -174,17 +174,19 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
/// <summary>
|
||||
/// สร้างประกาศเกษียณใหม่
|
||||
/// </summary>
|
||||
/// <param name="type">ประเภทUser(officer,employee)(ตัวใหญ่หรือเล็กก็ได้)</param>
|
||||
/// <param name="year">ปีงบประมาณ(ค.ศ.)</param>
|
||||
/// <param name="RetireHistoryId">Id ประวัติรอบพ้นราชการ</param>
|
||||
/// <param name="Option">ประเภทประกาศ</param>
|
||||
/// <param name="Type">ประเภทUser(officer,employee)(ตัวใหญ่หรือเล็กก็ได้)</param>
|
||||
/// <param name="Year">ปีงบประมาณ(ค.ศ.)</param>
|
||||
/// <returns></returns>
|
||||
/// <response code="200"></response>
|
||||
/// <response code="400">ค่าตัวแปรที่ส่งมาไม่ถูกต้อง</response>
|
||||
/// <response code="401">ไม่ได้ Login เข้าระบบ</response>
|
||||
/// <response code="500">เมื่อเกิดข้อผิดพลาดในการทำงาน</response>
|
||||
[HttpGet("profile/{retire_history_id}/{option}/{type}/{year}")]
|
||||
public async Task<ActionResult<ResponseObject>> CreateProfileRetirement(Guid retire_history_id, string option, string type, int year)
|
||||
[HttpPost("profile")]
|
||||
public async Task<ActionResult<ResponseObject>> CreateProfileRetirement([FromBody] PeriodRequest req)
|
||||
{
|
||||
if (!type.Trim().ToUpper().Contains("EMPLOYEE") && !type.Trim().ToUpper().Contains("OFFICER"))
|
||||
if (!req.Type.Trim().ToUpper().Contains("EMPLOYEE") && !req.Type.Trim().ToUpper().Contains("OFFICER"))
|
||||
return Error("ประเภทพ้นราชการไม่ถูกต้อง");
|
||||
|
||||
var round = 1;
|
||||
|
|
@ -192,8 +194,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
.Include(x => x.RetirementPeriodHistorys)
|
||||
.Include(x => x.RetirementProfiles)
|
||||
.ThenInclude(x => x.Profile)
|
||||
.Where(x => x.Year == year)
|
||||
.Where(x => x.Type.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||
.Where(x => x.Year == req.Year)
|
||||
.Where(x => x.Type.Trim().ToUpper().Contains(req.Type.Trim().ToUpper()))
|
||||
.FirstOrDefaultAsync();
|
||||
if (retire == null)
|
||||
{
|
||||
|
|
@ -201,8 +203,8 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
{
|
||||
Round = round,
|
||||
TypeReport = null,
|
||||
Type = type.Trim().ToUpper(),
|
||||
Year = year,
|
||||
Type = req.Type.Trim().ToUpper(),
|
||||
Year = req.Year,
|
||||
CreatedUserId = FullName ?? "",
|
||||
CreatedFullName = UserId ?? "System Administrator",
|
||||
CreatedAt = DateTime.Now,
|
||||
|
|
@ -212,10 +214,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
};
|
||||
await _context.RetirementPeriods.AddAsync(retire);
|
||||
var profiles = await _context.Profiles.AsQueryable()
|
||||
.Where(x => x.ProfileType.Trim().ToUpper().Contains(type.Trim().ToUpper()))
|
||||
.Where(x => x.ProfileType.Trim().ToUpper().Contains(req.Type.Trim().ToUpper()))
|
||||
.ToListAsync();
|
||||
|
||||
profiles = profiles.Where(x => x.BirthDate.CalculateRetireDate().Year == year).ToList();
|
||||
profiles = profiles.Where(x => x.BirthDate.CalculateRetireDate().Year == req.Year).ToList();
|
||||
var order = 1;
|
||||
foreach (var profile in profiles)
|
||||
{
|
||||
|
|
@ -240,8 +242,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
}
|
||||
else
|
||||
{
|
||||
if (req.Option == null)
|
||||
req.Option = "EDIT";
|
||||
var file_name = DateTime.Now.ToString();
|
||||
await _documentService.GenerateJsonFile("xxx", "/retire", file_name);
|
||||
var profile = Newtonsoft.Json.JsonConvert.SerializeObject(retire.RetirementProfiles);
|
||||
await _documentService.GenerateJsonFile(profile, "/retire", file_name);
|
||||
var history = new RetirementPeriodHistory
|
||||
{
|
||||
RetirementPeriod = retire,
|
||||
|
|
@ -262,11 +267,11 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
retire.Round = retire.Round + 1;
|
||||
retire.TypeReport = option.Trim().ToUpper();
|
||||
retire.TypeReport = req.Option.Trim().ToUpper();
|
||||
retire.LastUpdateFullName = FullName ?? "System Administrator";
|
||||
retire.LastUpdateUserId = UserId ?? "";
|
||||
retire.LastUpdatedAt = DateTime.Now;
|
||||
// retire_history_id
|
||||
// RetireHistoryId
|
||||
////ดึงไฟล์json
|
||||
// foreach (var retire_profile in retire.RetirementProfiles)
|
||||
// {
|
||||
|
|
@ -383,10 +388,15 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
retire_profile.LastUpdateUserId = UserId ?? "";
|
||||
retire_profile.LastUpdatedAt = DateTime.Now;
|
||||
}
|
||||
var num = 1;
|
||||
|
||||
var old_retire = retire.RetirementProfiles.OrderByDescending(x => x.Order).FirstOrDefault();
|
||||
if (old_retire != null)
|
||||
num = old_retire.Order + 1;
|
||||
|
||||
var data = new RetirementProfile
|
||||
{
|
||||
Order = 1,
|
||||
Order = num,
|
||||
Remove = "PENDING",
|
||||
RetirementPeriod = retire,
|
||||
Profile = profile,
|
||||
|
|
@ -399,10 +409,10 @@ namespace BMA.EHR.Retirement.Service.Controllers
|
|||
};
|
||||
_context.RetirementProfiles.Add(data);
|
||||
await _context.SaveChangesAsync();
|
||||
// if (retire.RetirementPeriodHistorys.Count() <= 1)
|
||||
// {
|
||||
// await GenOrderByYear(retire.Id);
|
||||
// }
|
||||
if (retire.RetirementPeriodHistorys.Count() == 0)
|
||||
{
|
||||
await GenOrderByYear(retire.Id);
|
||||
}
|
||||
|
||||
return Success();
|
||||
}
|
||||
|
|
|
|||
13
BMA.EHR.Retirement.Service/Requests/PeriodRequest.cs
Normal file
13
BMA.EHR.Retirement.Service/Requests/PeriodRequest.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
using BMA.EHR.Domain.Models.MetaData;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace BMA.EHR.Retirement.Service.Requests
|
||||
{
|
||||
public class PeriodRequest
|
||||
{
|
||||
public Guid? RetireHistoryId { get; set; }
|
||||
public string? Option { get; set; }
|
||||
public string Type { get; set; }
|
||||
public int Year { get; set; }
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue