From 6c42209217d566721f899b8071a50ed1b38ef925 Mon Sep 17 00:00:00 2001 From: Suphonchai Phoonsawat Date: Mon, 1 Jul 2024 21:19:46 +0700 Subject: [PATCH] =?UTF-8?q?fix=20import=20=E0=B9=80=E0=B8=84=E0=B8=A3?= =?UTF-8?q?=E0=B8=B7=E0=B9=88=E0=B8=AD=E0=B8=87=E0=B8=A3=E0=B8=B2=E0=B8=8A?= =?UTF-8?q?=E0=B8=A2=E0=B9=8C=20=E0=B9=81=E0=B8=A5=E0=B8=B0=20=E0=B9=83?= =?UTF-8?q?=E0=B8=9A=E0=B8=81=E0=B8=B3=E0=B8=81=E0=B8=B1=E0=B8=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/InsigniaRequestController.cs | 99 +++++++++++++++---- 1 file changed, 80 insertions(+), 19 deletions(-) diff --git a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs index bca4efeb..7a898b6b 100644 --- a/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs +++ b/BMA.EHR.Insignia.Service/Controllers/InsigniaRequestController.cs @@ -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,