From 60db153dfef2843b525ade66040dc58a93917d18 Mon Sep 17 00:00:00 2001 From: MahanCh Date: Mon, 14 Apr 2025 20:24:55 +0330 Subject: [PATCH] finish list of files --- Company.Domain/File1/IFileRepository.cs | 6 +- .../File1/FileSearchModel.cs | 6 + .../File1/IFileApplication.cs | 153 ++++++++++++++++++ .../FileApplication.cs | 18 ++- .../Repository/FileRepository.cs | 142 +++++++++++++++- ServiceHost/Pages/Index.cshtml.cs | 7 +- 6 files changed, 321 insertions(+), 11 deletions(-) diff --git a/Company.Domain/File1/IFileRepository.cs b/Company.Domain/File1/IFileRepository.cs index da88974a..9cb15905 100644 --- a/Company.Domain/File1/IFileRepository.cs +++ b/Company.Domain/File1/IFileRepository.cs @@ -20,9 +20,9 @@ public interface IFileRepository : IRepository #region Mahan - List GetFileList(FileSearchModel searchModel); - - #endregion Task> GetExcelDetails(); + Task> GetList(GetFileSearchModel searchModel); + #endregion + } \ No newline at end of file diff --git a/CompanyManagment.App.Contracts/File1/FileSearchModel.cs b/CompanyManagment.App.Contracts/File1/FileSearchModel.cs index 86aac457..374ea6c1 100644 --- a/CompanyManagment.App.Contracts/File1/FileSearchModel.cs +++ b/CompanyManagment.App.Contracts/File1/FileSearchModel.cs @@ -33,7 +33,13 @@ public class FileSearchModel public List ArchiveNo_FileClass_UserIdList { get; set; } //public List Users { get; set; } + /// + /// هیئت تشخیص + /// public BoardSearchModel diagnosisBoard { get; set; } + /// + /// هیئت حل اختلاف + /// public BoardSearchModel disputeResolutionBoard { get; set; } public ProceedingSessionSearchModel diagnosisProceedingSession { get; set; } public ProceedingSessionSearchModel disputeResolutionProceedingSession { get; set; } diff --git a/CompanyManagment.App.Contracts/File1/IFileApplication.cs b/CompanyManagment.App.Contracts/File1/IFileApplication.cs index 972b4f50..f7a32b95 100644 --- a/CompanyManagment.App.Contracts/File1/IFileApplication.cs +++ b/CompanyManagment.App.Contracts/File1/IFileApplication.cs @@ -24,5 +24,158 @@ public interface IFileApplication List GetAllEmploees(bool filter = true); List GetAllEmployers(bool filter = true); //bool CheckValue(string viewModel, string searchModel); + + #region Mahan + /// + /// اطلاعات برای نمایش اکسل + /// + /// Task> GetExcelDetails(); + + + Task> GetList(GetFileSearchModel searchModel); + + #endregion +} + +public class GetFileSearchModel +{ + /// + /// شماره بایگانی + /// + public long ArchiveNumber { get; set; } + + /// + /// کلاسه پرونده + /// + public string FileClass { get; set; } = string.Empty; + + /// + /// اصیل دعوی (شامل جمع خواهان ها و خوانده ها)ء + /// + public (long id, bool IsRequester) ClientOrLitigationParty { get; set; } + /// + /// شعبه هیئت تشخیص + /// + public string DiagnosisBoardBranch { get; set; } + + /// + /// شعبه هیئت حل اختلاف + /// + public string DisputeResolutionBranch { get; set; } + + /// + /// رییس هیئت تشخیص + /// + public string DiagnosisBoardChairMan { get; set; } + + /// + /// رییس هیئت حل اختلاف + /// + public string DisputeResolutionBoardChairMan { get; set; } + + /// + /// تاریخ رسیدگی هیئت تشخیص - از + /// + public string DiagnosisBoardFromDate { get; set; } + + /// + /// تاریخ رسیدگی هیئت تشخیص - تا + /// + public string DiagnosisBoardToDate { get; set; } + + /// + /// تاریخ رسیدگی هیئت حل اختلاف - از + /// + public string DisputeResolutionBoardFromDate{ get; set; } + /// + /// تاریخ رسیدگی هیئت حل اختلاف - تا + /// + public string DisputeResolutionBoardToDate{ get; set; } + + + public int PageIndex { get; set; } +} + +public class FileListViewModel +{ + public long Id { get; set; } + + /// + /// شماره بایگانی + /// + public long ArchiveNumber { get; set; } + + /// + /// کلاسه پرونده + /// + public string FileClass { get; set; } = string.Empty; + + /// + /// موکل + /// + public string Client { get; set; } = string.Empty; + + /// + /// طرف دعوی + /// + public string LitigationParty { get; set; } = string.Empty; + + /// + /// هیئت تشخیص + /// + public FileListBoardViewModel DiagnosisBoard { get; set; } + /// + /// هیئت حل اختلاف + /// + public FileListBoardViewModel DisputeResolutionBoard { get; set; } + + /// + /// وضعیت پرونده. یک به معنی غیرفعال. دو به معنی فعال. سه به معنی خروج موقت + /// + public int Status { get; set; } +} + +public class FileListBoardViewModel +{ + /// + /// تاریخ دادخواست + /// + public string PetitionDate { get; set; } + + /// + /// اولین تاریخ رسیدگی + /// + public string FirstResolutionPetitionDate { get; set; } + + /// + /// آخرین تاریخ رسیدگی + /// + public string LastResolutionPetitionDate { get; set; } + + /// + /// آخرین نوبت تاریخ رسیدگی + /// + public string LastResolutionPetitionTurn { get; set; } + + /// + /// تاریخ دادنامه + /// + public string PetitionIssuanceDate { get; set; } + + + /// + /// مبلغ جریمه + /// + public string TotalPenalty { get; set; } + + /// + /// شعبه + /// + public string Branch { get; set; } + + /// + /// رئیس هیئت مدیره + /// + public string BoardChairman { get; set; } } \ No newline at end of file diff --git a/CompanyManagment.Application/FileApplication.cs b/CompanyManagment.Application/FileApplication.cs index 9f110cbe..ed0a0770 100644 --- a/CompanyManagment.Application/FileApplication.cs +++ b/CompanyManagment.Application/FileApplication.cs @@ -200,10 +200,9 @@ public class FileApplication : IFileApplication return employers; } - public async Task> GetExcelDetails() - { - return await _fileRepository.GetExcelDetails(); - } + + + public FileViewModel GetFileDetails(FileViewModel file) { @@ -518,4 +517,15 @@ public class FileApplication : IFileApplication //return file; } + + #region Mahan + public async Task> GetExcelDetails() + { + return await _fileRepository.GetExcelDetails(); + } + public async Task> GetList(GetFileSearchModel searchModel) + { + return await _fileRepository.GetList(searchModel); + } + #endregion } \ No newline at end of file diff --git a/CompanyManagment.EFCore/Repository/FileRepository.cs b/CompanyManagment.EFCore/Repository/FileRepository.cs index e2b641e6..6857d22e 100644 --- a/CompanyManagment.EFCore/Repository/FileRepository.cs +++ b/CompanyManagment.EFCore/Repository/FileRepository.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; using System.Linq; using System.Threading.Tasks; using _0_Framework_b.InfraStructure; @@ -8,6 +10,7 @@ using CompanyManagment.App.Contracts.Employee; using CompanyManagment.App.Contracts.Employer; using CompanyManagment.App.Contracts.File1; using Microsoft.EntityFrameworkCore; +using PersianTools.Core; namespace CompanyManagment.EFCore.Repository; @@ -390,8 +393,143 @@ public class FileRepository : RepositoryBase, MclsPassword = x.Client == 1 ? requester?.MclsPassword : summoned?.MclsPassword ?? "-", Status = x.Status }; - }).OrderBy(x=>x.Status ==1).ThenBy(x=>x.Status == 3).ThenBy(x=>x.Status==2); + }).OrderBy(x => x.Status == 1).ThenBy(x => x.Status == 3).ThenBy(x => x.Status == 2); return res.ToList(); } + + public async Task> GetList(GetFileSearchModel searchModel) + { + + var fileQuery = _context.Files.Include(x => x.PetitionsList).Include(x => x.BoardsList).ThenInclude(x => x.ProceedingSessionsList).AsQueryable(); + + #region Search + + if (searchModel.ArchiveNumber > 0) + { + fileQuery = fileQuery.Where(x => x.ArchiveNo == searchModel.ArchiveNumber); + } + + if (!string.IsNullOrWhiteSpace(searchModel.FileClass)) + { + fileQuery = fileQuery.Where(x => x.FileClass.Contains(searchModel.FileClass)); + } + + if (searchModel.ClientOrLitigationParty.id > 0) + { + if (searchModel.ClientOrLitigationParty.IsRequester) + { + fileQuery = fileQuery.Where(x => x.Reqester == searchModel.ClientOrLitigationParty.id); + } + else + { + fileQuery = fileQuery.Where(x => x.Summoned == searchModel.ClientOrLitigationParty.id); + } + } + + if (!string.IsNullOrWhiteSpace(searchModel.DiagnosisBoardBranch)) + { + fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.Branch.Contains(searchModel.DiagnosisBoardBranch) && b.BoardType_Id == 1)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.DisputeResolutionBranch)) + { + fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.Branch.Contains(searchModel.DisputeResolutionBranch) && b.BoardType_Id == 2)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.DiagnosisBoardChairMan)) + { + fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardChairman.Contains(searchModel.DiagnosisBoardChairMan) && b.BoardType_Id == 1)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.DisputeResolutionBoardChairMan)) + { + fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardChairman.Contains(searchModel.DisputeResolutionBoardChairMan) && b.BoardType_Id == 2)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.DiagnosisBoardFromDate)) + { + var fromDate = searchModel.DiagnosisBoardFromDate.ToGeorgianDateTime(); + fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardType_Id == 1 && b.DisputeResolutionPetitionDate >= fromDate)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.DiagnosisBoardToDate)) + { + var toDate = searchModel.DiagnosisBoardToDate.ToGeorgianDateTime(); + fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardType_Id == 1 && b.DisputeResolutionPetitionDate <= toDate)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.DisputeResolutionBoardFromDate)) + { + var fromDate = searchModel.DisputeResolutionBoardFromDate.ToGeorgianDateTime(); + fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardType_Id == 2 && b.DisputeResolutionPetitionDate >= fromDate)); + } + + if (!string.IsNullOrWhiteSpace(searchModel.DisputeResolutionBoardToDate)) + { + var toDate = searchModel.DisputeResolutionBoardToDate.ToGeorgianDateTime(); + fileQuery = fileQuery.Where(x => x.BoardsList.Any(b => b.BoardType_Id == 2 && b.DisputeResolutionPetitionDate <= toDate)); + } + + + #endregion + fileQuery = fileQuery.Skip(searchModel.PageIndex).Take(30); + + var requesterEmployeeQuery = await _context.Employees.Where(x => fileQuery.Any(f => f.Reqester == x.id)).ToListAsync(); + var summonedEmployerQuery = await _context.Employers.Where(x => fileQuery.Any(f => f.Summoned == x.id)).ToListAsync(); + + var result = (await fileQuery.ToListAsync()).Select(x => + { + var requester = requesterEmployeeQuery.FirstOrDefault(e => e.id == x.Reqester); + var summoned = summonedEmployerQuery.FirstOrDefault(e => e.id == x.Summoned); + var diagnosisBoard = x.BoardsList.FirstOrDefault(b => b.BoardType_Id == 1); + var disputeResolutionBoard = x.BoardsList.FirstOrDefault(b => b.BoardType_Id == 2); + var diagnosisPetition = x.PetitionsList.FirstOrDefault(p => p.BoardType_Id == 1); + var disputeResolutionPetition = x.PetitionsList.FirstOrDefault(p => p.BoardType_Id == 2); + return new FileListViewModel() + { + ArchiveNumber = x.ArchiveNo, + FileClass = x.FileClass, + Client = x.Client == 1 ? requester?.FullName : summoned?.FullName ?? "-", + LitigationParty = x.Client == 1 ? summoned?.FullName : requester?.FullName ?? "-", + Status = x.Status, + DiagnosisBoard = new FileListBoardViewModel() + { + BoardChairman = diagnosisBoard?.BoardChairman ?? "-", + Branch = diagnosisBoard?.Branch ?? "-", + PetitionDate = diagnosisBoard?.DisputeResolutionPetitionDate.ToFarsi() ?? "-", + PetitionIssuanceDate = diagnosisPetition?.PetitionIssuanceDate.ToFarsi() ?? "-", + FirstResolutionPetitionDate = + diagnosisBoard?.ProceedingSessionsList.FirstOrDefault()?.Date.ToFarsi() ?? "-", + LastResolutionPetitionDate = diagnosisBoard?.ProceedingSessionsList.Count > 1 + ? diagnosisBoard.ProceedingSessionsList.Last().Date.ToFarsi() + : "-", + LastResolutionPetitionTurn = diagnosisBoard?.ProceedingSessionsList.Count > 1 + ? CharacterUtil.Convert((int)diagnosisBoard?.ProceedingSessionsList.Count) + : "-", + TotalPenalty = diagnosisPetition?.TotalPenalty ?? "-" + }, + DisputeResolutionBoard = new FileListBoardViewModel() + { + BoardChairman = disputeResolutionBoard?.BoardChairman ?? "-", + Branch = disputeResolutionBoard?.Branch ?? "-", + PetitionDate = disputeResolutionBoard?.DisputeResolutionPetitionDate.ToFarsi() ?? "-", + PetitionIssuanceDate = disputeResolutionPetition?.PetitionIssuanceDate.ToFarsi() ?? "-", + FirstResolutionPetitionDate = + disputeResolutionBoard?.ProceedingSessionsList.FirstOrDefault()?.Date.ToFarsi() ?? "-", + LastResolutionPetitionDate = disputeResolutionBoard?.ProceedingSessionsList.Count > 1 + ? disputeResolutionBoard.ProceedingSessionsList.Last().Date.ToFarsi() + : "-", + LastResolutionPetitionTurn = disputeResolutionBoard?.ProceedingSessionsList.Count > 1 + ? CharacterUtil.Convert((int)disputeResolutionBoard?.ProceedingSessionsList.Count) + : "-", + TotalPenalty = diagnosisPetition?.TotalPenalty ?? "-" + } + + }; + }).ToList(); + return result; + + + } } \ No newline at end of file diff --git a/ServiceHost/Pages/Index.cshtml.cs b/ServiceHost/Pages/Index.cshtml.cs index de27019a..3cb568be 100644 --- a/ServiceHost/Pages/Index.cshtml.cs +++ b/ServiceHost/Pages/Index.cshtml.cs @@ -17,6 +17,7 @@ using Company.Domain.RollCallAgg; using Company.Domain.RollCallAgg.DomainService; using Company.Domain.YearlySalaryAgg; using CompanyManagment.App.Contracts.AndroidApkVersion; +using CompanyManagment.App.Contracts.File1; using CompanyManagment.App.Contracts.InstitutionPlan; using CompanyManagment.App.Contracts.TemporaryClientRegistration; using Microsoft.EntityFrameworkCore; @@ -53,13 +54,14 @@ namespace ServiceHost.Pages private readonly ITemporaryClientRegistrationApplication _clientRegistrationApplication; private readonly IYearlySalaryRepository _yearlySalaryRepository; private readonly IEmployeeComputeOptionsRepository _computeOptions; + private readonly IFileApplication _fileApplication; public IndexModel(ILogger logger, IAccountApplication accountApplication, IGoogleRecaptcha googleRecaptcha, ISmsService smsService, IWorker worker, IAuthHelper authHelper, ICameraAccountApplication cameraAccountApplication, IWebHostEnvironment webHostEnvironment, - IAndroidApkVersionApplication androidApkVersionApplication, ITemporaryClientRegistrationApplication clientRegistrationApplication, IYearlySalaryRepository yearlySalaryRepository, IEmployeeComputeOptionsRepository computeOptions) + IAndroidApkVersionApplication androidApkVersionApplication, ITemporaryClientRegistrationApplication clientRegistrationApplication, IYearlySalaryRepository yearlySalaryRepository, IEmployeeComputeOptionsRepository computeOptions, IFileApplication fileApplication) { _logger = logger; _accountApplication = accountApplication; @@ -73,9 +75,10 @@ namespace ServiceHost.Pages _clientRegistrationApplication = clientRegistrationApplication; _yearlySalaryRepository = yearlySalaryRepository; _computeOptions = computeOptions; + _fileApplication = fileApplication; } - public IActionResult OnGet() + public async Task OnGet() { // _computeOptions.GetAllByWorkshopId(170); //_yearlySalaryRepository.TestDayliFeeCompute();