fix import เครื่องราชย์ และ ใบกำกับ

This commit is contained in:
Suphonchai Phoonsawat 2024-07-01 21:19:46 +07:00
parent d94e54b72d
commit 6c42209217

View file

@ -3,19 +3,24 @@ using System.Security.Claims;
using BMA.EHR.Application.Repositories;
using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Application.Requests;
using BMA.EHR.Application.Responses.Insignias;
using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Insignia.Service.Requests;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Newtonsoft.Json;
using OfficeOpenXml;
using Swashbuckle.AspNetCore.Annotations;
using static System.Collections.Specialized.BitVector32;
namespace BMA.EHR.Insignia.Service.Controllers
{
@ -638,7 +643,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
// if (organization == null)
// continue;
// if(organization.Id != Guid.Parse("e8493cd1-d371-402e-add6-566e68d5d1b3")) continue;
// var result = await _repository.GetInsigniaRequest(insigniaPeriodId, organization.Id);
@ -1863,30 +1868,85 @@ namespace BMA.EHR.Insignia.Service.Controllers
// continue;
if (profile.Status != "DONE")
{
// public class PostProfileInsigniaDto
//{
// public Guid ProfileId { get; set; }
// public int Year { get; set; } = 0;
// public string No { get; set; } = string.Empty;
// public string Volume { get; set; } = string.Empty;
// public string Section { get; set; } = string.Empty;
// public string Page { get; set; } = string.Empty;
// public DateTime ReceiveDate { get; set; } = DateTime.MinValue;
// public Guid InsigniaId { get; set; }
// public DateTime DateAnnounce { get; set; } = DateTime.MinValue;
// public string Issue { get; set; } = string.Empty;
// public string VolumeNo { get; set; } = string.Empty;
// public DateTime? RefCommandDate { get; set; }
// public string RefCommandNo { get; set; } = string.Empty;
// public string Note { get; set; } = string.Empty;
//}
profile.Status = "DONE";
await _context.ProfileInsignias.AddAsync(new ProfileInsignia
var profileInsignia = new PostProfileInsigniaDto
{
ProfileId = profile.ProfileId.Value,
Year = insigniaNote.Year,
No = profile.No,
Issue = profile.VolumeNo,
VolumeNo = profile.VolumeNo,
// Volume = profile.Volume,
Section = profile.Section,
Page = profile.Page,
DateAnnounce = profile.Date,
ReceiveDate = profile.DateReceive,
InsigniaType = profile.RequestInsignia.InsigniaType == null ? null : profile.RequestInsignia.InsigniaType.Name,
Insignia = profile.RequestInsignia,
// RefCommandNo = req.RefCommandNo,
// RefCommandDate = req.RefCommandDate,
ProfileId = profile.ProfileId.Value,
CreatedFullName = FullName ?? "System Administrator",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now,
LastUpdateFullName = FullName ?? "System Administrator",
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now,
});
ReceiveDate = profile.DateReceive.Value,
DateAnnounce = profile.Date.Value,
InsigniaId = profile.RequestInsignia.Id,
Issue = "",
Note = "",
RefCommandDate = DateTime.MinValue,
RefCommandNo = "",
Volume = "",
};
await _userProfileRepository.PostProfileInsigniaAsync(profileInsignia, AccessToken);
//await _context.ProfileInsignias.AddAsync(new ProfileInsignia
//{
// Year = insigniaNote.Year,
// No = profile.No,
// Issue = profile.VolumeNo,
// VolumeNo = profile.VolumeNo,
// // Volume = profile.Volume,
// Section = profile.Section,
// Page = profile.Page,
// DateAnnounce = profile.Date,
// ReceiveDate = profile.DateReceive,
// InsigniaType = profile.RequestInsignia.InsigniaType == null ? null : profile.RequestInsignia.InsigniaType.Name,
// Insignia = profile.RequestInsignia,
// // RefCommandNo = req.RefCommandNo,
// // RefCommandDate = req.RefCommandDate,
// ProfileId = profile.ProfileId.Value,
// CreatedFullName = FullName ?? "System Administrator",
// CreatedUserId = UserId ?? "",
// CreatedAt = DateTime.Now,
// LastUpdateFullName = FullName ?? "System Administrator",
// LastUpdateUserId = UserId ?? "",
// LastUpdatedAt = DateTime.Now,
//});
}
}
await _context.SaveChangesAsync();
@ -1926,6 +1986,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
var items = await ReadExcelImportInvoice(file);
foreach (var item in items)
{
if (item.CitizanId == null) continue;
var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
if (profile == null)
@ -2000,7 +2061,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
profile = new InsigniaNoteProfile
{
RequestDate = DateTime.Now,
Salary = _profile.ProfileSalary == null ? null : _profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
Salary = _profile.ProfileSalary == null || _profile.ProfileSalary.Count == 0 ? null : _profile.ProfileSalary.OrderByDescending(x => x.Order).FirstOrDefault().Amount,
IsApprove = true,
Status = "DONE",
Number = item.Number,