Merge branch 'Feature/roll-call/client-api' into Main
# Conflicts: # CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs # CompanyManagment.EFCore/Repository/RollCallRepository.cs
This commit is contained in:
@@ -7,7 +7,7 @@ namespace _0_Framework.Application;
|
||||
public class PagedResult<T> where T : class
|
||||
{
|
||||
public int TotalCount { get; set; }
|
||||
public List<T> List { get; set; }
|
||||
public List<T> List { get; set; } = [];
|
||||
}
|
||||
public class PagedResult<T,TMeta>:PagedResult<T> where T : class
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Domain;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using CompanyManagment.App.Contracts.WorkingHoursTemp;
|
||||
@@ -91,5 +92,9 @@ namespace Company.Domain.RollCallAgg
|
||||
Task<List<RollCall>> GetRollCallsUntilNowWithWorkshopIdEmployeeIds(long workshopId, List<long> employeeIds,
|
||||
DateTime fromDate);
|
||||
#endregion
|
||||
|
||||
Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel);
|
||||
Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId,
|
||||
string titleId, RollCallCaseHistorySearchModel searchModel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Workshop;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.RollCall
|
||||
{
|
||||
@@ -125,6 +127,20 @@ namespace CompanyManagment.App.Contracts.RollCall
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> RecalculateValues(long workshopId, List<ReCalculateRollCallValues> command);
|
||||
|
||||
Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel);
|
||||
Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId, string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel);
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryDetail
|
||||
{
|
||||
public string EmployeeFullName { get; set; }
|
||||
public string PersonnelCode { get; set; }
|
||||
public TimeSpan TotalWorkingTime { get; set; }
|
||||
public List<RollCallCaseHistoryDetailRecord> Records { get; set; }
|
||||
public RollCallRecordStatus Status { get; set; }
|
||||
public long EmployeeId { get; set; }
|
||||
}
|
||||
|
||||
public class WorkshopCurrentDayRollCallSearchModel
|
||||
@@ -133,6 +149,37 @@ namespace CompanyManagment.App.Contracts.RollCall
|
||||
public int PersonnelCode { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public enum RollCallRecordStatus
|
||||
{
|
||||
Worked = 0,
|
||||
Absent = 1,
|
||||
Leaved = 2
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryDetailRecord
|
||||
{
|
||||
public TimeSpan EntryTimeDifference { get; set; }
|
||||
public string StartTime { get; set; }
|
||||
public string EndTime { get; set; }
|
||||
public TimeSpan ExitTimeDifference { get; set; }
|
||||
|
||||
}
|
||||
|
||||
public class RollCallCaseHistorySearchModel:PaginationRequest
|
||||
{
|
||||
public string StartDate { get; set; }
|
||||
public string EndDate { get; set; }
|
||||
public string OneDayDate { get; set; }
|
||||
public long? EmployeeId { get; set; }
|
||||
}
|
||||
|
||||
public class RollCallCaseHistoryTitleDto
|
||||
{
|
||||
public string Id { get; set; }
|
||||
public string Title { get; set; }
|
||||
}
|
||||
|
||||
public class ReCalculateRollCallValues
|
||||
{
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
@@ -858,4 +858,15 @@ public class RollCallApplication : IRollCallApplication
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PagedResult<RollCallCaseHistoryTitleDto>> GetCaseHistoryTitles(long workshopId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallRepository.GetCaseHistoryTitles(workshopId,searchModel);
|
||||
}
|
||||
|
||||
public async Task<List<RollCallCaseHistoryDetail>> GetCaseHistoryDetails(long workshopId,
|
||||
string titleId, RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallRepository.GetCaseHistoryDetails(workshopId, titleId, searchModel);
|
||||
}
|
||||
}
|
||||
@@ -713,10 +713,15 @@ public class EmployeeDocumentsRepository : RepositoryBase<long, EmployeeDocument
|
||||
var itemsQuery = _companyContext.EmployeeDocumentItems
|
||||
.Where(x => x.DocumentStatus != DocumentStatus.Unsubmitted)
|
||||
.Include(x => x.EmployeeDocuments)
|
||||
.ThenInclude(x => x.Workshop).ThenInclude(x => x.WorkshopEmployers).ThenInclude(x => x.Employer)
|
||||
.GroupBy(x => x.WorkshopId).Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
.ThenInclude(x => x.Workshop)
|
||||
.ThenInclude(x => x.WorkshopEmployers)
|
||||
.ThenInclude(x => x.Employer)
|
||||
.GroupBy(x => x.WorkshopId)
|
||||
.Select(x => new WorkshopWithEmployeeDocumentsViewModel()
|
||||
{
|
||||
SubmittedItemsCount = x.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin || y.DocumentStatus == DocumentStatus.SubmittedByClient),
|
||||
SubmittedItemsCount = x
|
||||
.Count(y => y.DocumentStatus == DocumentStatus.SubmittedByAdmin
|
||||
|| y.DocumentStatus == DocumentStatus.SubmittedByClient),
|
||||
WorkshopId = x.Key,
|
||||
WorkshopFullName = x.First().EmployeeDocuments.Workshop.WorkshopName,
|
||||
EmployerName = x.First().EmployeeDocuments.Workshop.WorkshopEmployers.First().Employer.FullName
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,86 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagement.Infrastructure.Excel.RollCall;
|
||||
using CompanyManagment.App.Contracts.RollCall;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
namespace ServiceHost.Areas.Client.Controllers.RollCall;
|
||||
|
||||
public class CaseHistoryController : ClientBaseController
|
||||
{
|
||||
private readonly IRollCallApplication _rollCallApplication;
|
||||
private readonly long _workshopId;
|
||||
|
||||
public CaseHistoryController(IRollCallApplication rollCallApplication,
|
||||
IAuthHelper authHelper)
|
||||
{
|
||||
_rollCallApplication = rollCallApplication;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<PagedResult<RollCallCaseHistoryTitleDto>>> GetTitles(
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryTitles(_workshopId, searchModel);
|
||||
}
|
||||
|
||||
[HttpGet("details")]
|
||||
public async Task<ActionResult<List<RollCallCaseHistoryDetail>>> GetDetails(string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد و ویرایش
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public ActionResult<OperationResult> Upsert(CreateOrEditEmployeeRollCall command)
|
||||
{
|
||||
command.WorkshopId = _workshopId;
|
||||
return _rollCallApplication.ManualEdit(command);
|
||||
}
|
||||
|
||||
[HttpGet("print")]
|
||||
public async Task<ActionResult<List<RollCallCaseHistoryDetail>>> GetPrintDetails(string titleId,
|
||||
RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
return await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
|
||||
}
|
||||
|
||||
[HttpGet("excel")]
|
||||
public async Task<IActionResult> GetDownload(string titleId,RollCallCaseHistorySearchModel searchModel)
|
||||
{
|
||||
var data = await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel);
|
||||
byte[] excelBytes = RollCallExcelGenerator.CaseHistoryExcelForOneDay(data);
|
||||
return File(excelBytes,
|
||||
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
||||
$"{workshopFullName} - {caseHistoryRollCallExcelForOneDay.DayOfWeekFa}،{caseHistoryRollCallExcelForOneDay.DateFa}.xlsx");
|
||||
|
||||
}
|
||||
|
||||
// [HttpGet("edit")]
|
||||
// public ActionResult<> GetEditDetails(string date,long employeeId)
|
||||
// {
|
||||
// var result = _rollCallApplication.GetWorkshopEmployeeRollCallsForDate(_workshopId, employeeId, date);
|
||||
// //var dates = _rollCallApplication.GetEditableDatesForManualEdit(date.ToGeorgianDateTime());
|
||||
// var name = _rollCallEmployeeApplication.GetByEmployeeIdAndWorkshopId(employeeId, _workshopId);
|
||||
//
|
||||
// var total = new TimeSpan(result.Sum(x =>
|
||||
// (x.EndDate!.Value.Ticks - x.StartDate!.Value.Ticks)));
|
||||
//
|
||||
// var command = new EmployeeRollCallsViewModel()
|
||||
// {
|
||||
// EmployeeFullName = name.EmployeeFullName,
|
||||
// EmployeeId = employeeId,
|
||||
// DateFa = date,
|
||||
// //EditableDates = dates,
|
||||
// RollCalls = result,
|
||||
// TotalRollCallsDuration = total.ToFarsiHoursAndMinutes("-")
|
||||
// };
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace ServiceHost.BaseControllers;
|
||||
|
||||
[Authorize(Policy = "AdminArea")]
|
||||
|
||||
Reference in New Issue
Block a user