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;
using BMA.EHR.Application.Repositories.MessageQueue; using BMA.EHR.Application.Repositories.MessageQueue;
using BMA.EHR.Application.Requests; using BMA.EHR.Application.Requests;
using BMA.EHR.Application.Responses.Insignias;
using BMA.EHR.Domain.Common; using BMA.EHR.Domain.Common;
using BMA.EHR.Domain.Extensions; using BMA.EHR.Domain.Extensions;
using BMA.EHR.Domain.Models.HR; using BMA.EHR.Domain.Models.HR;
using BMA.EHR.Domain.Models.Insignias; using BMA.EHR.Domain.Models.Insignias;
using BMA.EHR.Domain.Models.MetaData;
using BMA.EHR.Domain.Shared; using BMA.EHR.Domain.Shared;
using BMA.EHR.Infrastructure.Persistence; using BMA.EHR.Infrastructure.Persistence;
using BMA.EHR.Insignia.Service.Requests; using BMA.EHR.Insignia.Service.Requests;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Internal;
using Newtonsoft.Json; using Newtonsoft.Json;
using OfficeOpenXml; using OfficeOpenXml;
using Swashbuckle.AspNetCore.Annotations; using Swashbuckle.AspNetCore.Annotations;
using static System.Collections.Specialized.BitVector32;
namespace BMA.EHR.Insignia.Service.Controllers namespace BMA.EHR.Insignia.Service.Controllers
{ {
@ -1863,30 +1868,85 @@ namespace BMA.EHR.Insignia.Service.Controllers
// continue; // continue;
if (profile.Status != "DONE") 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"; profile.Status = "DONE";
await _context.ProfileInsignias.AddAsync(new ProfileInsignia
var profileInsignia = new PostProfileInsigniaDto
{ {
ProfileId = profile.ProfileId.Value,
Year = insigniaNote.Year, Year = insigniaNote.Year,
No = profile.No, No = profile.No,
Issue = profile.VolumeNo,
VolumeNo = profile.VolumeNo, VolumeNo = profile.VolumeNo,
// Volume = profile.Volume,
Section = profile.Section, Section = profile.Section,
Page = profile.Page, Page = profile.Page,
DateAnnounce = profile.Date, ReceiveDate = profile.DateReceive.Value,
ReceiveDate = profile.DateReceive, DateAnnounce = profile.Date.Value,
InsigniaType = profile.RequestInsignia.InsigniaType == null ? null : profile.RequestInsignia.InsigniaType.Name, InsigniaId = profile.RequestInsignia.Id,
Insignia = profile.RequestInsignia, Issue = "",
// RefCommandNo = req.RefCommandNo, Note = "",
// RefCommandDate = req.RefCommandDate, RefCommandDate = DateTime.MinValue,
ProfileId = profile.ProfileId.Value, RefCommandNo = "",
CreatedFullName = FullName ?? "System Administrator", Volume = "",
CreatedUserId = UserId ?? "",
CreatedAt = DateTime.Now, };
LastUpdateFullName = FullName ?? "System Administrator", await _userProfileRepository.PostProfileInsigniaAsync(profileInsignia, AccessToken);
LastUpdateUserId = UserId ?? "",
LastUpdatedAt = DateTime.Now, //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(); await _context.SaveChangesAsync();
@ -1926,6 +1986,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
var items = await ReadExcelImportInvoice(file); var items = await ReadExcelImportInvoice(file);
foreach (var item in items) foreach (var item in items)
{ {
if (item.CitizanId == null) continue;
var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken); var pf = _userProfileRepository.GetOfficerProfileByCitizenId(item.CitizanId, AccessToken);
var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id); var profile = insigniaNote.InsigniaNoteProfiles.FirstOrDefault(x => x.ProfileId == pf.Id);
if (profile == null) if (profile == null)
@ -2000,7 +2061,7 @@ namespace BMA.EHR.Insignia.Service.Controllers
profile = new InsigniaNoteProfile profile = new InsigniaNoteProfile
{ {
RequestDate = DateTime.Now, 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, IsApprove = true,
Status = "DONE", Status = "DONE",
Number = item.Number, Number = item.Number,