Merge From ClientEmployeeApi
This commit is contained in:
@@ -96,6 +96,13 @@ public interface IEmployeeRepository : IRepository<long, Employee>
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی تفکیکی پرسنل
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// سلکت لیست پرسنل های کارگاه کلاینت
|
||||
/// </summary>
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد ترک کار از کلاینت
|
||||
/// api
|
||||
/// </summary>
|
||||
public class CreateLeftWorkTempDtoClient
|
||||
{
|
||||
/// <summary>
|
||||
/// آی دی پرسنل
|
||||
/// </summary>
|
||||
public long EmployeeId { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ ترک کار
|
||||
/// </summary>
|
||||
public string LeftWorkTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ آخرین روز کاری
|
||||
/// </summary>
|
||||
public string LastDayStanding { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
public class GetLeftWorkTempDayOfWeekDtoClient
|
||||
{
|
||||
/// <summary>
|
||||
/// تاریخ ترک کار
|
||||
/// </summary>
|
||||
public string LeftWorkTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// آخرین روز کاری
|
||||
/// </summary>
|
||||
public string LastDayStanding { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// روز هفته ترک کار
|
||||
/// </summary>
|
||||
public string LeftWorkTimeDayOfWeek { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// روز هفته اخرین روز کاری
|
||||
/// </summary>
|
||||
public string LastDayStandingDayOfWeek { get; set; }
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
namespace CompanyManagment.App.Contracts.Employee.DTO;
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی تفکیکی پرسنل
|
||||
/// </summary>
|
||||
public class PrintAllDetailsPersonnelInfoDtoClient
|
||||
{
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// نام کامل پرسنل
|
||||
/// </summary>
|
||||
public string EmployeeFullName { get; set; }
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
///کد ملی
|
||||
/// </summary>
|
||||
public string NationalCode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شماره شناسنامه
|
||||
/// </summary>
|
||||
public string IdNumber { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تاریخ تولد
|
||||
/// </summary>
|
||||
public string DateOfBirth { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// نام پدر
|
||||
/// </summary>
|
||||
public string FatherName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// تعداد فرزندان
|
||||
/// </summary>
|
||||
public string NumberOfChildren { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// استان
|
||||
/// </summary>
|
||||
public string State { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// شهر
|
||||
/// </summary>
|
||||
public string City { get; set; }
|
||||
|
||||
|
||||
public string Address { get; set; }
|
||||
}
|
||||
@@ -125,6 +125,14 @@ public interface IEmployeeApplication
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllEmployeesInfoDtoClient>> PrintAllEmployeesInfoClient(long workshopId);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی تفکیکی پرسنل
|
||||
/// </summary>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient(long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// سلکت لیست پرسنل های کارگاه کلاینت
|
||||
/// </summary>
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
using System;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
|
||||
namespace CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
|
||||
@@ -36,6 +37,27 @@ public interface ILeftWorkTempApplication
|
||||
|
||||
|
||||
List<LeftWorkTempViewModel> GetLeftWorksByWorkshopId(long workshopId);
|
||||
|
||||
#region ForApi
|
||||
|
||||
/// <summary>
|
||||
/// ایجاد ترک کار از کلاینت
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <param name="workshopId"></param>
|
||||
/// <returns></returns>
|
||||
Task<OperationResult> CreateLeftWorkTempClient(CreateLeftWorkTempDtoClient command, long workshopId);
|
||||
|
||||
/// <summary>
|
||||
/// دریافت روز هفته برای ترک کار و اخرین روز کاری
|
||||
/// </summary>
|
||||
/// <param name="leftWorkTime"></param>
|
||||
/// <param name="lastDayStanding"></param>
|
||||
/// <returns></returns>
|
||||
Task<GetLeftWorkTempDayOfWeekDtoClient> GetLeftWorkTempDayOfWeekDtoClient(string leftWorkTime,
|
||||
string lastDayStanding);
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
public class LeftWorkTempViewModel
|
||||
|
||||
@@ -1744,6 +1744,11 @@ public class EmployeeAplication : RepositoryBase<long, Employee>, IEmployeeAppli
|
||||
return await _EmployeeRepository.PrintAllEmployeesInfoClient(workshopId);
|
||||
}
|
||||
|
||||
public async Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient(long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.PrintAllDetailsPersonnelInfoClient(workshopId);
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
|
||||
{
|
||||
return await _EmployeeRepository.GetWorkingEmployeesSelectList(workshopId);
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework.Application;
|
||||
using _0_Framework_b.Application;
|
||||
using Company.Domain.CheckoutAgg;
|
||||
using Company.Domain.ContractAgg;
|
||||
@@ -15,11 +11,17 @@ using Company.Domain.RollCallEmployeeStatusAgg;
|
||||
using Company.Domain.WorkshopAgg;
|
||||
using CompanyManagment.App.Contracts.Checkout;
|
||||
using CompanyManagment.App.Contracts.Contract;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.LeftWork;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using CompanyManagment.App.Contracts.ReportClient;
|
||||
using CompanyManagment.App.Contracts.RollCallEmployee;
|
||||
using CompanyManagment.EFCore.Migrations;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using PersianTools.Core;
|
||||
using OperationResult = _0_Framework.Application.OperationResult;
|
||||
using Tools = _0_Framework.Application.Tools;
|
||||
|
||||
@@ -329,4 +331,112 @@ public class LeftWorkTempApplication : ILeftWorkTempApplication
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
#region ForApi
|
||||
|
||||
public async Task<OperationResult> CreateLeftWorkTempClient(CreateLeftWorkTempDtoClient command, long workshopId)
|
||||
{
|
||||
var op = new OperationResult();
|
||||
|
||||
#region Validation
|
||||
|
||||
if (_leftWorkTempRepository.Exists(x => x.WorkshopId == workshopId && x.EmployeeId == command.EmployeeId))
|
||||
{
|
||||
return op.Failed("برای پرسنل وارد شده قبلا درخواست ترک کار ثبت کرده اید");
|
||||
}
|
||||
|
||||
if (command.LeftWorkTime.TryToGeorgianDateTime(out var leftWorkDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
if (command.LastDayStanding.TryToGeorgianDateTime(out var lastDayStandingDateGr) == false)
|
||||
{
|
||||
return op.Failed("تاریخ شروع به کار وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var leftWork = await _leftWorkRepository.GetLastLeftWork(command.EmployeeId, workshopId);
|
||||
|
||||
if (lastDayStandingDateGr.AddDays(1).Date != leftWorkDateGr)
|
||||
{
|
||||
return op.Failed("تاریخ آخرین روز کاری با تاریخ ترک کار یک روز اختلاف ندارند");
|
||||
}
|
||||
|
||||
if (leftWork == null)
|
||||
{
|
||||
return op.Failed("شروع به کار پرسنل یافت نشد");
|
||||
}
|
||||
|
||||
if (leftWork.HasLeft)
|
||||
{
|
||||
return op.Failed("پرسنل وارد شده قبلا ترک کار ثبت شده است");
|
||||
}
|
||||
|
||||
if (leftWork.StartWorkDate > lastDayStandingDateGr)
|
||||
{
|
||||
return op.Failed("تاریخ ثبت شده قبل از شروع به کار است");
|
||||
}
|
||||
|
||||
if (leftWork.WorkshopId != workshopId || leftWork.EmployeeId != command.EmployeeId)
|
||||
{
|
||||
return op.Failed("اطلاعات وارد شده نامعتبر است");
|
||||
}
|
||||
|
||||
var leftWorkTemp = LeftWorkTemp.CreateLeftWork(leftWork.id, leftWork.StartWorkDate, leftWorkDateGr,
|
||||
lastDayStandingDateGr,
|
||||
workshopId, command.EmployeeId, leftWork.JobId);
|
||||
|
||||
await _leftWorkTempRepository.CreateAsync(leftWorkTemp);
|
||||
await _leftWorkTempRepository.SaveChangesAsync();
|
||||
return op.Succcedded();
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
public async Task<GetLeftWorkTempDayOfWeekDtoClient> GetLeftWorkTempDayOfWeekDtoClient(string leftWorkTime,
|
||||
string lastDayStanding)
|
||||
{
|
||||
var result = new GetLeftWorkTempDayOfWeekDtoClient();
|
||||
if (!string.IsNullOrWhiteSpace(leftWorkTime) && leftWorkTime.Length == 10)
|
||||
{
|
||||
if (leftWorkTime.TryToGeorgianDateTime(out var left) == false)
|
||||
return result;
|
||||
int year = Convert.ToInt32(leftWorkTime.Substring(0, 4));
|
||||
int month = Convert.ToInt32(leftWorkTime.Substring(5, 2));
|
||||
int day = Convert.ToInt32(leftWorkTime.Substring(8, 2));
|
||||
|
||||
var leftWorkTimePersian = new PersianDateTime(year, month, day);
|
||||
|
||||
result.LeftWorkTime = leftWorkTime;
|
||||
result.LeftWorkTimeDayOfWeek = leftWorkTimePersian.DayOfWeek;
|
||||
|
||||
var lastDayStandingPersian = leftWorkTimePersian.AddDays(-1);
|
||||
result.LastDayStanding = $"{lastDayStandingPersian}";
|
||||
result.LastDayStandingDayOfWeek = lastDayStandingPersian.DayOfWeek;
|
||||
}
|
||||
else if(!string.IsNullOrWhiteSpace(lastDayStanding) && lastDayStanding.Length == 10)
|
||||
{
|
||||
if (lastDayStanding.TryToGeorgianDateTime(out var lastDay) == false)
|
||||
return result;
|
||||
int year = Convert.ToInt32(lastDayStanding.Substring(0, 4));
|
||||
int month = Convert.ToInt32(lastDayStanding.Substring(5, 2));
|
||||
int day = Convert.ToInt32(lastDayStanding.Substring(8, 2));
|
||||
|
||||
var lastDayStandingPersian = new PersianDateTime(year, month, day);
|
||||
|
||||
result.LastDayStanding = lastDayStanding;
|
||||
result.LastDayStandingDayOfWeek = lastDayStandingPersian.DayOfWeek;
|
||||
|
||||
|
||||
var leftWorkTimePersian = lastDayStandingPersian.AddDays(1);
|
||||
result.LeftWorkTime = $"{leftWorkTimePersian}";
|
||||
result.LeftWorkTimeDayOfWeek = leftWorkTimePersian.DayOfWeek;
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
@@ -1287,7 +1287,99 @@ public class EmployeeRepository : RepositoryBase<long, Employee>, IEmployeeRepos
|
||||
&& x.EmployeeStatusInWorkshop != EmployeeStatusInWorkshop.LefWorkTemp)
|
||||
.Select(x => new PrintAllEmployeesInfoDtoClient(x)).ToList();
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient(long workshopId)
|
||||
{
|
||||
var hasNotStoppedWorkingYet = Tools.GetUndefinedDateTime();
|
||||
|
||||
var baseQuery = await
|
||||
(
|
||||
from personnelCode in _context.PersonnelCodeSet
|
||||
join employee in _context.Employees
|
||||
on personnelCode.EmployeeId equals employee.id
|
||||
where personnelCode.WorkshopId == workshopId
|
||||
select new
|
||||
{
|
||||
Employee = employee,
|
||||
PersonnelCode = personnelCode
|
||||
}
|
||||
).ToListAsync();
|
||||
|
||||
|
||||
var employeeIds = baseQuery.Select(x => x.Employee.id).ToList();
|
||||
|
||||
var leftWorks = await _context.LeftWorkList
|
||||
.Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId))
|
||||
.ToListAsync();
|
||||
|
||||
var insuranceLeftWorks = await _context.LeftWorkInsuranceList
|
||||
.Where(x => x.WorkshopId == workshopId && employeeIds.Contains(x.EmployeeId))
|
||||
.ToListAsync();
|
||||
|
||||
var children = await _context.EmployeeChildrenSet.Where(x => employeeIds.Contains(x.EmployeeId)).ToListAsync();
|
||||
|
||||
|
||||
|
||||
|
||||
var result = baseQuery.Select(x =>
|
||||
{
|
||||
var left = leftWorks
|
||||
.Where(l => l.EmployeeId == x.Employee.id)
|
||||
.MaxBy(l => l.StartWorkDate);
|
||||
|
||||
var insuranceLeftWork = insuranceLeftWorks
|
||||
.Where(l => l.EmployeeId == x.Employee.id).MaxBy(l => l.StartWorkDate);
|
||||
|
||||
|
||||
var contractLeft = left != null
|
||||
? left.LeftWorkDate != hasNotStoppedWorkingYet ? left.LeftWorkDate.ToFarsi() : ""
|
||||
: "";
|
||||
|
||||
|
||||
var insuranceLeft = insuranceLeftWork != null
|
||||
? insuranceLeftWork.LeftWorkDate != null ? insuranceLeftWork.LeftWorkDate.ToFarsi() : ""
|
||||
: "";
|
||||
int personnelCode = Convert.ToInt32($"{x.PersonnelCode.PersonnelCode}");
|
||||
|
||||
int numberOfChildren = children.Count(ch => ch.EmployeeId == x.Employee.id);
|
||||
|
||||
bool employeeHasLeft =
|
||||
(!string.IsNullOrWhiteSpace(insuranceLeft) && !string.IsNullOrWhiteSpace(contractLeft))
|
||||
|| (left == null && !string.IsNullOrWhiteSpace(insuranceLeft))
|
||||
|| (insuranceLeftWork == null && !string.IsNullOrWhiteSpace(contractLeft));
|
||||
|
||||
return new
|
||||
{
|
||||
EmployeeFullName = x.Employee.FullName,
|
||||
PersonnelCode = personnelCode,
|
||||
NationalCode = x.Employee.NationalCode,
|
||||
IdNumber = x.Employee.IdNumber,
|
||||
DateOfBirth = x.Employee.DateOfBirth.ToFarsi(),
|
||||
FatherName = x.Employee.FatherName,
|
||||
NumberOfChildren = $"{numberOfChildren}",
|
||||
Black = employeeHasLeft,
|
||||
State = x.Employee.State,
|
||||
City = x.Employee.City,
|
||||
Address = x.Employee.Address
|
||||
};
|
||||
}).OrderBy(x => x.Black ? 1 : 0).ThenBy(x => x.PersonnelCode).ToList();
|
||||
|
||||
return result.Select(x => new PrintAllDetailsPersonnelInfoDtoClient
|
||||
{
|
||||
EmployeeFullName = x.EmployeeFullName,
|
||||
NationalCode = x.NationalCode,
|
||||
IdNumber = x.IdNumber,
|
||||
FatherName = x.FatherName,
|
||||
DateOfBirth = x.DateOfBirth,
|
||||
NumberOfChildren = x.NumberOfChildren,
|
||||
State = x.State,
|
||||
City = x.City,
|
||||
Address = x.Address
|
||||
|
||||
}).ToList();
|
||||
|
||||
}
|
||||
|
||||
public async Task<List<EmployeeSelectListViewModel>> GetWorkingEmployeesSelectList(long workshopId)
|
||||
{
|
||||
var hasNotStoppedWorkingYet = Tools.GetUndefinedDateTime();
|
||||
|
||||
@@ -177,7 +177,7 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
|
||||
{
|
||||
checkout.SetUpdateNeeded();
|
||||
if (!_context.CheckoutWarningMessages.Any(x =>
|
||||
x.CheckoutId == checkout.id && x.TypeOfCheckoutWarning !=
|
||||
x.CheckoutId == checkout.id && x.TypeOfCheckoutWarning ==
|
||||
TypeOfCheckoutWarning.InsuranceEmployeeShare))
|
||||
{
|
||||
var createWarrning =
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using _0_Framework.Application;
|
||||
using CompanyManagment.App.Contracts.Employee;
|
||||
using CompanyManagment.App.Contracts.Employee.DTO;
|
||||
using CompanyManagment.App.Contracts.LeftWorkTemp;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using ServiceHost.BaseControllers;
|
||||
|
||||
@@ -9,11 +10,13 @@ namespace ServiceHost.Areas.Client.Controllers;
|
||||
public class EmployeeController:ClientBaseController
|
||||
{
|
||||
private readonly IEmployeeApplication _employeeApplication;
|
||||
private readonly ILeftWorkTempApplication _leftWorkTempApplication;
|
||||
private readonly long _workshopId;
|
||||
|
||||
public EmployeeController(IEmployeeApplication employeeApplication,IAuthHelper authHelper)
|
||||
public EmployeeController(IEmployeeApplication employeeApplication,IAuthHelper authHelper, ILeftWorkTempApplication leftWorkTempApplication)
|
||||
{
|
||||
_employeeApplication = employeeApplication;
|
||||
_leftWorkTempApplication = leftWorkTempApplication;
|
||||
_workshopId = authHelper.GetWorkshopId();
|
||||
}
|
||||
|
||||
@@ -52,6 +55,41 @@ public class EmployeeController:ClientBaseController
|
||||
var result = await _employeeApplication.PrintAllEmployeesInfoClient(_workshopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// پرینت گروهی تفکیکی پرسنل
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("PrintAllDetailsPersonnelInfo")]
|
||||
public async Task<List<PrintAllDetailsPersonnelInfoDtoClient>> PrintAllDetailsPersonnelInfoClient()
|
||||
{
|
||||
var result = await _employeeApplication.PrintAllDetailsPersonnelInfoClient(_workshopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// اعلام ترک کار
|
||||
/// </summary>
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult<OperationResult>> CreateLeftWorkTempClient([FromBody] CreateLeftWorkTempDtoClient command)
|
||||
{
|
||||
var result = await _leftWorkTempApplication.CreateLeftWorkTempClient(command, _workshopId);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// دریافت روز هفته برای ترک کار و اخرین روز کاری
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet("GetDayOfWeek")]
|
||||
public async Task<GetLeftWorkTempDayOfWeekDtoClient> GetLeftWorkTempDayOfWeekDtoClient(string leftWorkTime,
|
||||
string lastDayStanding)
|
||||
{
|
||||
var result = await _leftWorkTempApplication.GetLeftWorkTempDayOfWeekDtoClient(leftWorkTime,lastDayStanding);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,7 +11,7 @@
|
||||
},
|
||||
"ServiceHost": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": false,
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
|
||||
|
||||
Reference in New Issue
Block a user