Compare commits
7 Commits
Feature/In
...
Feature/ro
| Author | SHA1 | Date | |
|---|---|---|---|
| 5d55118c3c | |||
| c5a1e5c274 | |||
| 4c6de6a76f | |||
| 25c7b67eb5 | |||
| 19b390b17d | |||
| 3d86ba401f | |||
| ca6638d6a3 |
@@ -27,9 +27,10 @@ public interface ISmsService
|
|||||||
|
|
||||||
Task<double> GetCreditAmount();
|
Task<double> GetCreditAmount();
|
||||||
|
|
||||||
public Task<bool> SendInstitutionVerificationLink(string number,string fullName, Guid institutionId);
|
public Task<bool> SendInstitutionVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId);
|
||||||
|
|
||||||
public Task<bool> SendInstitutionVerificationCode(string number, string code);
|
public Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
|
||||||
|
long contractingPartyId, long institutionContractId);
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ namespace Company.Domain.SmsResultAgg;
|
|||||||
|
|
||||||
public class SmsResult: EntityBase
|
public class SmsResult: EntityBase
|
||||||
{
|
{
|
||||||
public SmsResult(int messageId, string status,string typeOfSms, string contractingPartyName,string mobile, long contractingPatyId, long institutionContractId)
|
public SmsResult(int messageId, string status,string typeOfSms,
|
||||||
|
string contractingPartyName,string mobile, long contractingPatyId, long institutionContractId)
|
||||||
{
|
{
|
||||||
MessageId = messageId;
|
MessageId = messageId;
|
||||||
Status = status;
|
Status = status;
|
||||||
|
|||||||
@@ -373,7 +373,9 @@ namespace CompanyManagment.Application
|
|||||||
Color = color,
|
Color = color,
|
||||||
PersonnelCode = personnelCodes.FirstOrDefault(y => x.Id == y.EmployeeId)?.PersonnelCode.ToString() ?? "-"
|
PersonnelCode = personnelCodes.FirstOrDefault(y => x.Id == y.EmployeeId)?.PersonnelCode.ToString() ?? "-"
|
||||||
};
|
};
|
||||||
}).OrderByDescending(x => x.IsEligible).ThenByDescending(x => x.Reason).ToList();
|
}).OrderBy(x => x.Color switch { "orange" => 0, "white" => 1, "red" => 2, "green" => 3, "black" => 4, _ => 5 })
|
||||||
|
.ToList();
|
||||||
|
|
||||||
return op.Succcedded(employees);
|
return op.Succcedded(employees);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1141,7 +1141,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
|
|
||||||
|
|
||||||
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
||||||
entity.PublicId);
|
entity.PublicId, contractingParty.id,entity.id );
|
||||||
|
|
||||||
await _institutionContractRepository.SaveChangesAsync();
|
await _institutionContractRepository.SaveChangesAsync();
|
||||||
|
|
||||||
@@ -1373,7 +1373,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
|
|||||||
throw new NotFoundException("طرف قرارداد یافت نشد");
|
throw new NotFoundException("طرف قرارداد یافت نشد");
|
||||||
var contractingPartyFullName = contractingParty.FName + " " + contractingParty.LName;
|
var contractingPartyFullName = contractingParty.FName + " " + contractingParty.LName;
|
||||||
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
||||||
institutionContract.PublicId);
|
institutionContract.PublicId, contractingParty.id, institutionContract.id);
|
||||||
return new OperationResult().Succcedded();
|
return new OperationResult().Succcedded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ public class FineRepository : RepositoryBase<long, Fine>, IFineRepository
|
|||||||
}
|
}
|
||||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||||
|
|
||||||
var list = query.ToList().Select(x => new FineViewModel()
|
var list = query.OrderByDescending(x=>x.FineDate).ToList().Select(x => new FineViewModel()
|
||||||
{
|
{
|
||||||
Amount = x.Amount.ToMoney(),
|
Amount = x.Amount.ToMoney(),
|
||||||
AmountDouble = x.Amount,
|
AmountDouble = x.Amount,
|
||||||
|
|||||||
@@ -1318,8 +1318,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
Workshops = workshopDetails,
|
Workshops = workshopDetails,
|
||||||
IsInPersonContract = x.contract.WorkshopGroup?.CurrentWorkshops
|
IsInPersonContract = x.contract.WorkshopGroup?.CurrentWorkshops
|
||||||
.Any(y=>y.Services.ContractInPerson)??true,
|
.Any(y=>y.Services.ContractInPerson)??true,
|
||||||
IsOldContract = x.contract.WorkshopGroup?.CurrentWorkshops
|
IsOldContract = x.contract.WorkshopGroup?.CurrentWorkshops == null
|
||||||
.Any(y=>y.Price == 0)??true
|
|| x.contract.WorkshopGroup.CurrentWorkshops.Count == 0
|
||||||
|
|| x.contract.WorkshopGroup.CurrentWorkshops.Any(y => y.Price == 0)
|
||||||
};
|
};
|
||||||
}).ToList()
|
}).ToList()
|
||||||
};
|
};
|
||||||
@@ -2338,7 +2339,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
|
|||||||
await SaveChangesAsync();
|
await SaveChangesAsync();
|
||||||
|
|
||||||
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
await _smsService.SendInstitutionVerificationLink(contractingParty.Phone, contractingPartyFullName,
|
||||||
entity.PublicId);
|
entity.PublicId, contractingParty.id, entity.id);
|
||||||
|
|
||||||
|
|
||||||
await SaveChangesAsync();
|
await SaveChangesAsync();
|
||||||
|
|||||||
@@ -1724,9 +1724,86 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
|
|||||||
.Include(x => x.LeftWorkInsurances)
|
.Include(x => x.LeftWorkInsurances)
|
||||||
.Where(x => x.LeftWorkInsurances.Any(l => l.StartWorkDate <= firstDayOfMonth &&
|
.Where(x => x.LeftWorkInsurances.Any(l => l.StartWorkDate <= firstDayOfMonth &&
|
||||||
(l.LeftWorkDate == null || l.LeftWorkDate >= firstDayOfMonth)));
|
(l.LeftWorkDate == null || l.LeftWorkDate >= firstDayOfMonth)));
|
||||||
|
|
||||||
|
|
||||||
|
var query = notCreatedWorkshop.Select(result=>new InsuranceListViewModel
|
||||||
|
{
|
||||||
|
Year = searchModel.Year,
|
||||||
|
Month = searchModel.Month,
|
||||||
|
WorkShopId = result.id,
|
||||||
|
WorkShopCode = result.InsuranceWorkshopInfo != null
|
||||||
|
? result.InsuranceWorkshopInfo.InsuranceCode
|
||||||
|
: result.InsuranceCode,
|
||||||
|
WorkShopName = result.InsuranceWorkshopInfo != null
|
||||||
|
? result.InsuranceWorkshopInfo.WorkshopName
|
||||||
|
: result.WorkshopFullName,
|
||||||
|
TypeOfInsuranceSend = result.TypeOfInsuranceSend == "NormalList" ? "عادی" :
|
||||||
|
result.TypeOfInsuranceSend == "Govermentlist" ? "کمک دولت" :
|
||||||
|
result.TypeOfInsuranceSend == "Familylist" ? "خانوادگی" : "",
|
||||||
|
FixedSalary = result.FixedSalary,
|
||||||
|
StrFixedSalary = result.FixedSalary ? "دارد" : "ندارد",
|
||||||
|
EmployerName = result.InsuranceWorkshopInfo != null
|
||||||
|
? result.InsuranceWorkshopInfo.EmployerName
|
||||||
|
: result.WorkshopFullName,
|
||||||
|
Branch = "",
|
||||||
|
City = "",
|
||||||
|
ArchiveCode = result.ArchiveCode,
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(searchModel.Month) && searchModel.Month != "0")
|
||||||
|
query = query.Where(x => x.Month == searchModel.Month).OrderByDescending(x => x.WorkShopName)
|
||||||
|
.ThenByDescending(x => x.EmployerName).ThenByDescending(x => x.Year);
|
||||||
|
|
||||||
var workshopList = await notCreatedWorkshop.Skip(searchModel.PageIndex).Take(30).ToListAsync();
|
if (!string.IsNullOrEmpty(searchModel.Year) && searchModel.Year != "0")
|
||||||
var workshopIds = workshopList.Select(x=>x.id);
|
query = query.Where(x => x.Year == searchModel.Year).OrderByDescending(x => x.EmployerName)
|
||||||
|
.ThenByDescending(x => x.WorkShopName).ThenByDescending(x => x.Month);
|
||||||
|
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(searchModel.WorkShopCode))
|
||||||
|
query = query.Where(x => x.WorkShopCode == searchModel.WorkShopCode).OrderByDescending(x => x.Year)
|
||||||
|
.ThenByDescending(x => x.Month).ThenByDescending(x => x.EmployerName);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(searchModel.WorkShopName))
|
||||||
|
query = query.Where(x => x.WorkShopName.Contains(searchModel.WorkShopName))
|
||||||
|
.OrderByDescending(x => x.EmployerName).ThenByDescending(x => x.Year).OrderByDescending(x => x.Month);
|
||||||
|
|
||||||
|
|
||||||
|
if (searchModel.WorkshopId > 0)
|
||||||
|
{
|
||||||
|
var workshopName = query.FirstOrDefault(u => u.WorkShopId == searchModel.WorkshopId)?.WorkShopName;
|
||||||
|
|
||||||
|
query = query.Where(x => x.WorkShopName.Contains(workshopName)).OrderByDescending(x => x.EmployerName)
|
||||||
|
.ThenByDescending(x => x.Year).ThenByDescending(x => x.Month);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (searchModel.EmployerId > 0)
|
||||||
|
{
|
||||||
|
var employerName = query.FirstOrDefault(u => u.EmployerId == searchModel.EmployerId)?.EmployerName;
|
||||||
|
query = query.Where(x => x.EmployerName.Contains(employerName)).OrderByDescending(x => x.EmployerName)
|
||||||
|
.ThenByDescending(x => x.Year).ThenByDescending(x => x.Month);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(searchModel.EmployerName))
|
||||||
|
query = query.Where(x => x.EmployerName.Contains(searchModel.EmployerName))
|
||||||
|
.OrderByDescending(x => x.EmployerName).ThenByDescending(x => x.Year).OrderByDescending(x => x.Month);
|
||||||
|
|
||||||
|
|
||||||
|
if (searchModel.FixedSalary != null)
|
||||||
|
query = query.Where(x => x.FixedSalary == searchModel.FixedSalary);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(searchModel.TypeOfInsuranceSend) && searchModel.TypeOfInsuranceSend != "0")
|
||||||
|
query = query.Where(x => x.TypeOfInsuranceSend == searchModel.TypeOfInsuranceSend);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(searchModel.City) && searchModel.City != "0")
|
||||||
|
query = query.Where(x => x.City == searchModel.City);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(searchModel.Branch))
|
||||||
|
query = query.Where(x => x.Branch.Contains(searchModel.Branch));
|
||||||
|
|
||||||
|
|
||||||
|
var workshopList = await query.Skip(searchModel.PageIndex).Take(30).ToListAsync();
|
||||||
|
var workshopIds = workshopList.Select(x=>x.WorkShopId);
|
||||||
|
|
||||||
var employers =await _context.WorkshopEmployers
|
var employers =await _context.WorkshopEmployers
|
||||||
.Where(x=>workshopIds.Contains(x.WorkshopId))
|
.Where(x=>workshopIds.Contains(x.WorkshopId))
|
||||||
@@ -1735,20 +1812,16 @@ public class InsuranceListRepository : RepositoryBase<long, InsuranceList>, IIns
|
|||||||
|
|
||||||
var res = workshopList.Select(x =>
|
var res = workshopList.Select(x =>
|
||||||
{
|
{
|
||||||
var employer = employers.FirstOrDefault(e => e.WorkshopId ==x.id)?.Employer;
|
var employer = employers.FirstOrDefault(e => e.WorkshopId ==x.WorkShopId)?.Employer;
|
||||||
|
|
||||||
return new InsuranceListViewModel
|
return new InsuranceListViewModel
|
||||||
{
|
{
|
||||||
WorkShopId = x.id,
|
WorkShopId = x.WorkShopId,
|
||||||
WorkShopCode = x.InsuranceCode,
|
WorkShopCode = x.WorkShopCode,
|
||||||
WorkShopName = x.InsuranceWorkshopInfo != null
|
WorkShopName = x.WorkShopName,
|
||||||
? x.InsuranceWorkshopInfo.WorkshopName
|
|
||||||
: x.WorkshopFullName,
|
|
||||||
EmployerName = employer != null
|
EmployerName = employer != null
|
||||||
? employer.FullName
|
? employer.FullName
|
||||||
: (x.InsuranceWorkshopInfo != null
|
: (x.EmployerName),
|
||||||
? x.InsuranceWorkshopInfo.EmployerName
|
|
||||||
: x.WorkshopFullName),
|
|
||||||
Year = searchModel.Year,
|
Year = searchModel.Year,
|
||||||
Month = searchModel.Month,
|
Month = searchModel.Month,
|
||||||
TypeOfInsuranceSend = x.TypeOfInsuranceSend == "NormalList" ? "عادی" :
|
TypeOfInsuranceSend = x.TypeOfInsuranceSend == "NormalList" ? "عادی" :
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ public class LoanRepository : RepositoryBase<long, Loan>, ILoanRepository
|
|||||||
query = query.Where(x => x.StartInstallmentPayment >= startDate && x.StartInstallmentPayment <= endDate);
|
query = query.Where(x => x.StartInstallmentPayment >= startDate && x.StartInstallmentPayment <= endDate);
|
||||||
}
|
}
|
||||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||||
var list = query.ToList().Select(x => new LoanViewModel()
|
var list = query.OrderByDescending(x=>x.StartInstallmentPayment).ToList().Select(x => new LoanViewModel()
|
||||||
{
|
{
|
||||||
Amount = x.Amount.ToMoney(),
|
Amount = x.Amount.ToMoney(),
|
||||||
AmountDouble = x.Amount,
|
AmountDouble = x.Amount,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ using _0_Framework.InfraStructure;
|
|||||||
using Company.Domain.RewardAgg;
|
using Company.Domain.RewardAgg;
|
||||||
using CompanyManagment.App.Contracts.Reward;
|
using CompanyManagment.App.Contracts.Reward;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
using SharpCompress.Compressors.Xz;
|
||||||
|
|
||||||
namespace CompanyManagment.EFCore.Repository;
|
namespace CompanyManagment.EFCore.Repository;
|
||||||
|
|
||||||
@@ -119,12 +120,12 @@ public class RewardRepository : RepositoryBase<long, Reward>, IRewardRepository
|
|||||||
|
|
||||||
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
query = query.Where(x => x.EmployeeId == searchModel.EmployeeId);
|
||||||
|
|
||||||
var list = query.ToList().Select(x => new RewardViewModel
|
var list = query.ToList().OrderByDescending(x=>x.GrantDate).Select(x => new RewardViewModel
|
||||||
{
|
{
|
||||||
WorkshopId = x.WorkshopId,
|
WorkshopId = x.WorkshopId,
|
||||||
Amount = x.Amount.ToMoney(),
|
Amount = x.Amount.ToMoney(),
|
||||||
AmountDouble = x.Amount,
|
AmountDouble = x.Amount,
|
||||||
Description = x.Description,
|
Description = x.Description ?? "",
|
||||||
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
EmployeeFullName = employees.FirstOrDefault(e => e.id == x.EmployeeId).FullName,
|
||||||
EmployeeId = x.EmployeeId,
|
EmployeeId = x.EmployeeId,
|
||||||
GrantDateFa = x.GrantDate.ToFarsi(),
|
GrantDateFa = x.GrantDate.ToFarsi(),
|
||||||
|
|||||||
@@ -1,28 +1,30 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
|
||||||
using System.Runtime.InteropServices.ComTypes;
|
|
||||||
using System.Security.AccessControl;
|
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using _0_Framework.Application;
|
||||||
|
using _0_Framework.Application.Sms;
|
||||||
|
using Company.Domain.SmsResultAgg;
|
||||||
|
using CompanyManagment.App.Contracts.SmsResult;
|
||||||
using IPE.SmsIrClient;
|
using IPE.SmsIrClient;
|
||||||
using IPE.SmsIrClient.Models.Requests;
|
using IPE.SmsIrClient.Models.Requests;
|
||||||
using IPE.SmsIrClient.Models.Results;
|
using IPE.SmsIrClient.Models.Results;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
|
||||||
|
|
||||||
|
|
||||||
namespace _0_Framework.Application.Sms;
|
namespace CompanyManagment.EFCore.Services;
|
||||||
|
|
||||||
public class SmsService : ISmsService
|
public class SmsService : ISmsService
|
||||||
{
|
{
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
|
private readonly ISmsResultRepository _smsResultRepository;
|
||||||
public SmsIr SmsIr { get; set; }
|
public SmsIr SmsIr { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public SmsService(IConfiguration configuration)
|
public SmsService(IConfiguration configuration, ISmsResultRepository smsResultRepository)
|
||||||
{
|
{
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
|
_smsResultRepository = smsResultRepository;
|
||||||
SmsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
SmsIr = new SmsIr("Og5M562igmzJRhQPnq0GdtieYdLgtfikjzxOmeQBPxJjZtyge5Klc046Lfw1mxSa");
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -330,7 +332,7 @@ public class SmsService : ISmsService
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
public async Task<bool> SendInstitutionVerificationLink(string number,string fullName, Guid institutionId)
|
public async Task<bool> SendInstitutionVerificationLink(string number, string fullName, Guid institutionId, long contractingPartyId, long institutionContractId)
|
||||||
{
|
{
|
||||||
var guidStr=institutionId.ToString();
|
var guidStr=institutionId.ToString();
|
||||||
var firstPart = guidStr.Substring(0, 15);
|
var firstPart = guidStr.Substring(0, 15);
|
||||||
@@ -341,15 +343,25 @@ public class SmsService : ISmsService
|
|||||||
new("CODE1",firstPart),
|
new("CODE1",firstPart),
|
||||||
new("CODE2",secondPart)
|
new("CODE2",secondPart)
|
||||||
});
|
});
|
||||||
|
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "لینک تاییدیه قرارداد مالی",
|
||||||
|
fullName, number, contractingPartyId, institutionContractId);
|
||||||
|
await _smsResultRepository.CreateAsync(smsResult);
|
||||||
|
await _smsResultRepository.SaveChangesAsync();
|
||||||
return verificationSendResult.Status == 0;
|
return verificationSendResult.Status == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> SendInstitutionVerificationCode(string number, string code)
|
public async Task<bool> SendInstitutionVerificationCode(string number, string code, string contractingPartyFullName,
|
||||||
|
long contractingPartyId, long institutionContractId)
|
||||||
{
|
{
|
||||||
var verificationSendResult =await SmsIr.VerifySendAsync(number, 965348, new VerifySendParameter[]
|
var verificationSendResult =await SmsIr.VerifySendAsync(number, 965348, new VerifySendParameter[]
|
||||||
{
|
{
|
||||||
new("VERIFYCODE", code)
|
new("VERIFYCODE", code)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var smsResult = new SmsResult(verificationSendResult.Data.MessageId, verificationSendResult.Message, "کد تاییدیه قرارداد مالی",
|
||||||
|
contractingPartyFullName, number, contractingPartyId, institutionContractId);
|
||||||
|
await _smsResultRepository.CreateAsync(smsResult);
|
||||||
|
await _smsResultRepository.SaveChangesAsync();
|
||||||
return verificationSendResult.Status == 0;
|
return verificationSendResult.Status == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -9,20 +9,20 @@ using WorkFlow.Application.Contracts.WorkFlow;
|
|||||||
|
|
||||||
namespace Query.AdminReports.Handlers
|
namespace Query.AdminReports.Handlers
|
||||||
{
|
{
|
||||||
public interface IGetWorkshopWithRollCallHandler
|
public interface IGetWorkshopWithRollCallHandler
|
||||||
{
|
{
|
||||||
List<WorkshopWithRollCallServiceQueryModel> Handle(WorkshopWithRollCallServiceQueryParameters parameters);
|
List<WorkshopWithRollCallServiceQueryModel> Handle(WorkshopWithRollCallServiceQueryParameters parameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GetWorkshopWithRollCallHandler: IGetWorkshopWithRollCallHandler
|
public class GetWorkshopWithRollCallHandler : IGetWorkshopWithRollCallHandler
|
||||||
{
|
{
|
||||||
private readonly CompanyContext _companyContext;
|
private readonly CompanyContext _companyContext;
|
||||||
private readonly IWorkFlowApplication workFlowApplication;
|
private readonly IWorkFlowApplication workFlowApplication;
|
||||||
|
|
||||||
public GetWorkshopWithRollCallHandler(CompanyContext companyContext, IWorkFlowApplication workFlowApplication)
|
public GetWorkshopWithRollCallHandler(CompanyContext companyContext, IWorkFlowApplication workFlowApplication)
|
||||||
{
|
{
|
||||||
_companyContext = companyContext;
|
_companyContext = companyContext;
|
||||||
this.workFlowApplication = workFlowApplication;
|
this.workFlowApplication = workFlowApplication;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WorkshopWithRollCallServiceQueryModel> Handle(WorkshopWithRollCallServiceQueryParameters parameters)
|
public List<WorkshopWithRollCallServiceQueryModel> Handle(WorkshopWithRollCallServiceQueryParameters parameters)
|
||||||
@@ -30,7 +30,6 @@ namespace Query.AdminReports.Handlers
|
|||||||
var now = DateTime.Now.Date;
|
var now = DateTime.Now.Date;
|
||||||
var lastWeek = now.AddDays(-7);
|
var lastWeek = now.AddDays(-7);
|
||||||
|
|
||||||
|
|
||||||
//workshop filter by parameters
|
//workshop filter by parameters
|
||||||
var rollCallServiceQuery = _companyContext.RollCallServices.AsSplitQuery();
|
var rollCallServiceQuery = _companyContext.RollCallServices.AsSplitQuery();
|
||||||
|
|
||||||
@@ -46,35 +45,49 @@ namespace Query.AdminReports.Handlers
|
|||||||
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.ServiceType == parameters.RollCallServiceType);
|
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.ServiceType == parameters.RollCallServiceType);
|
||||||
|
|
||||||
if (parameters.FilterMode == FilterMode.Active)
|
if (parameters.FilterMode == FilterMode.Active)
|
||||||
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.StartService.Date <= now && x.EndService.Date >= now);
|
rollCallServiceQuery =
|
||||||
else if (parameters.FilterMode == FilterMode.DeActive)
|
rollCallServiceQuery.Where(x => x.StartService.Date <= now && x.EndService.Date >= now);
|
||||||
rollCallServiceQuery = rollCallServiceQuery.Where(x => x.EndService.Date < now || x.StartService.Date > now);
|
|
||||||
|
|
||||||
var workshopsWithService = rollCallServiceQuery.Join(allWorkshops, x => x.WorkshopId, y => y.id, (rcs, workshop) =>
|
else if (parameters.FilterMode == FilterMode.DeActive)
|
||||||
new WorkshopWithRollCallServiceQueryModel()
|
rollCallServiceQuery =
|
||||||
{
|
rollCallServiceQuery.Where(x => x.EndService.Date < now || x.StartService.Date > now);
|
||||||
WorkshopId = workshop.id,
|
|
||||||
RollCallServiceType = rcs.ServiceType,
|
var workshopsWithService = rollCallServiceQuery.Join(allWorkshops, x => x.WorkshopId, y => y.id,
|
||||||
WorkshopName = workshop.WorkshopFullName,
|
(rcs, workshop) =>
|
||||||
MaxPersonValid = rcs.MaxPersonValid,
|
new WorkshopWithRollCallServiceQueryModel()
|
||||||
IsActive = rcs.StartService <= DateTime.Now && rcs.EndService >= DateTime.Now,
|
{
|
||||||
ServiceStart = rcs.StartService,
|
WorkshopId = workshop.id,
|
||||||
ServiceEnd = rcs.EndService
|
RollCallServiceType = rcs.ServiceType,
|
||||||
});
|
WorkshopName = workshop.WorkshopFullName,
|
||||||
|
MaxPersonValid = rcs.MaxPersonValid,
|
||||||
|
IsActive = rcs.StartService <= DateTime.Now && rcs.EndService >= DateTime.Now,
|
||||||
|
ServiceStart = rcs.StartService,
|
||||||
|
ServiceEnd = rcs.EndService
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
//workshop population
|
//workshop population
|
||||||
var workshopLeftWorks = _companyContext.Workshops.AsSplitQuery().Where(x => workshopsWithService.Any(y => y.WorkshopId == x.id)).Include(x => x.LeftWorks).Include(x => x.LeftWorkInsurances)
|
var workshopLeftWorks = _companyContext.Workshops.AsSplitQuery()
|
||||||
.Select(x => new
|
.Where(x => workshopsWithService.Any(y => y.WorkshopId == x.id)).Include(x => x.LeftWorks)
|
||||||
{
|
.Include(x => x.LeftWorkInsurances)
|
||||||
WorkshopId = x.id,
|
.Select(x => new
|
||||||
LeftWorks = x.LeftWorks.Where(y => y.StartWorkDate <= lastWeek && y.LeftWorkDate > now).Select(y => y.EmployeeId),
|
{
|
||||||
LeftWorkInsurances = x.LeftWorkInsurances.Where(y => y.StartWorkDate <= lastWeek && (y.LeftWorkDate > now || y.LeftWorkDate == null)).Select(y => y.EmployeeId)
|
WorkshopId = x.id,
|
||||||
}).ToList();
|
LeftWorks = x.LeftWorks.Where(y => y.StartWorkDate <= lastWeek && y.LeftWorkDate > now)
|
||||||
|
.Select(y => y.EmployeeId),
|
||||||
|
LeftWorkInsurances = x.LeftWorkInsurances
|
||||||
|
.Where(y => y.StartWorkDate <= lastWeek && (y.LeftWorkDate > now || y.LeftWorkDate == null))
|
||||||
|
.Select(y => y.EmployeeId)
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
var workshopsWorkingEmployeesList = workshopLeftWorks
|
var workshopsWorkingEmployeesList = workshopLeftWorks
|
||||||
.Select(x => new { x.WorkshopId, TotalWorkingEmployeesCount = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct().Count(), EmployeeIds = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct() }).ToList();
|
.Select(x =>
|
||||||
|
new
|
||||||
|
{
|
||||||
|
x.WorkshopId,
|
||||||
|
TotalWorkingEmployeesCount = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct().Count(),
|
||||||
|
EmployeeIds = x.LeftWorks.Concat(x.LeftWorkInsurances).Distinct()
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
|
|
||||||
var activeEmployees = _companyContext.RollCallEmployees.AsSplitQuery()
|
var activeEmployees = _companyContext.RollCallEmployees.AsSplitQuery()
|
||||||
@@ -83,15 +96,25 @@ namespace Query.AdminReports.Handlers
|
|||||||
workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId))
|
workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId))
|
||||||
.Select(x => new { x.WorkshopId, x.EmployeeId });
|
.Select(x => new { x.WorkshopId, x.EmployeeId });
|
||||||
|
|
||||||
var lastWeekRollCalls = _companyContext.RollCalls.AsSplitQuery().Where(x => x.StartDate.HasValue && x.StartDate.Value >= lastWeek
|
var lastWeekRollCalls = _companyContext.RollCalls.AsSplitQuery()
|
||||||
&& workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).GroupBy(x => x.EmployeeId).Select(x => x.Key);
|
.Where(x => x.StartDate.HasValue &&
|
||||||
|
x.StartDate.Value >= lastWeek
|
||||||
|
&& workshopsWithService
|
||||||
|
.Any(y => y.WorkshopId == x.WorkshopId))
|
||||||
|
.GroupBy(x => x.EmployeeId)
|
||||||
|
.Select(x => x.Key);
|
||||||
|
|
||||||
|
|
||||||
var leaves = _companyContext.LeaveList.AsSplitQuery().Where(x => x.StartLeave <= lastWeek && x.EndLeave >= now && (x.LeaveType == "استعلاجی" || x.PaidLeaveType == "روزانه")
|
var leaves = _companyContext.LeaveList.AsSplitQuery().Where(x =>
|
||||||
&& workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId)).Select(x => x.EmployeeId);
|
x.StartLeave <= lastWeek && x.EndLeave >= now &&
|
||||||
|
(x.LeaveType == "استعلاجی" || x.PaidLeaveType == "روزانه")
|
||||||
|
&& workshopsWithService.Any(y => y.WorkshopId == x.WorkshopId))
|
||||||
|
.Select(x => x.EmployeeId);
|
||||||
|
|
||||||
|
|
||||||
var activeEmployeesList = activeEmployees.ToList().Where(x => workshopsWorkingEmployeesList.Any(w => w.WorkshopId == x.WorkshopId && w.EmployeeIds.Contains(x.EmployeeId)));
|
var activeEmployeesList = activeEmployees.ToList().Where(x =>
|
||||||
|
workshopsWorkingEmployeesList.Any(w =>
|
||||||
|
w.WorkshopId == x.WorkshopId && w.EmployeeIds.Contains(x.EmployeeId)));
|
||||||
var lastWeekRollCallsList = lastWeekRollCalls.ToList();
|
var lastWeekRollCallsList = lastWeekRollCalls.ToList();
|
||||||
var leavesList = leaves.ToList();
|
var leavesList = leaves.ToList();
|
||||||
var workshopsWithServiceList = workshopsWithService.ToList();
|
var workshopsWithServiceList = workshopsWithService.ToList();
|
||||||
@@ -107,12 +130,13 @@ namespace Query.AdminReports.Handlers
|
|||||||
MaxPersonValid = x.MaxPersonValid,
|
MaxPersonValid = x.MaxPersonValid,
|
||||||
WorkshopName = x.WorkshopName,
|
WorkshopName = x.WorkshopName,
|
||||||
ActiveEmployeesCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId),
|
ActiveEmployeesCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId),
|
||||||
ActiveEmployeesWithRollCallInLastWeekCount = activeEmployeesList.Count(y => y.WorkshopId == x.WorkshopId &&
|
ActiveEmployeesWithRollCallInLastWeekCount = activeEmployeesList.Count(y =>
|
||||||
|
y.WorkshopId == x.WorkshopId &&
|
||||||
lastWeekRollCallsList.Contains(y.EmployeeId) && !leavesList.Contains(y.EmployeeId)),
|
lastWeekRollCallsList.Contains(y.EmployeeId) && !leavesList.Contains(y.EmployeeId)),
|
||||||
TotalEmployeesCount = workshopsWorkingEmployeesList.FirstOrDefault(y => y.WorkshopId == x.WorkshopId)?.TotalWorkingEmployeesCount ?? 0,
|
TotalEmployeesCount = workshopsWorkingEmployeesList
|
||||||
|
.FirstOrDefault(y => y.WorkshopId == x.WorkshopId)?.TotalWorkingEmployeesCount ?? 0,
|
||||||
//UndoneWorkFlowsCount = workFlowApplication.GetAllWorkFlowCount(x.WorkshopId).Result
|
//UndoneWorkFlowsCount = workFlowApplication.GetAllWorkFlowCount(x.WorkshopId).Result
|
||||||
}).OrderByDescending(x => x.IsActive).ToList();
|
}).OrderByDescending(x => x.IsActive).ToList();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -13,15 +13,8 @@
|
|||||||
public int ActiveEmployeesWithRollCallInLastWeekCount { get; set; }
|
public int ActiveEmployeesWithRollCallInLastWeekCount { get; set; }
|
||||||
|
|
||||||
public int UndoneWorkFlowsCount { get; set; }
|
public int UndoneWorkFlowsCount { get; set; }
|
||||||
|
|
||||||
|
public float ActiveEmployeesWithRollCallPercentage => ActiveEmployeesCount == 0 ? 0f : ((float)ActiveEmployeesWithRollCallInLastWeekCount / ActiveEmployeesCount) * 100f;
|
||||||
public float ActiveEmployeesWithRollCallPercentage
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return ((float)ActiveEmployeesWithRollCallInLastWeekCount / ActiveEmployeesCount) * 100;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public int MaxPersonValid { get; set; }
|
public int MaxPersonValid { get; set; }
|
||||||
public bool IsActive { get; set; }
|
public bool IsActive { get; set; }
|
||||||
|
|||||||
49
ServiceHost/Areas/Admin/Controllers/RollCallController.cs
Normal file
49
ServiceHost/Areas/Admin/Controllers/RollCallController.cs
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
using _0_Framework.Application;
|
||||||
|
using AccountManagement.Application.Contracts.Account;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Query.AdminReports.Handlers;
|
||||||
|
using Query.AdminReports.Models;
|
||||||
|
using ServiceHost.BaseControllers;
|
||||||
|
using WorkFlow.Application.Contracts.WorkFlow;
|
||||||
|
|
||||||
|
namespace ServiceHost.Areas.Admin.Controllers;
|
||||||
|
|
||||||
|
public class RollCallController:AdminBaseController
|
||||||
|
{
|
||||||
|
private readonly IGetWorkshopWithRollCallHandler _workshopWithRollCallHandler;
|
||||||
|
private readonly IWorkFlowApplication _workFlowApplication;
|
||||||
|
private readonly long _currentAccountId;
|
||||||
|
|
||||||
|
public RollCallController(IGetWorkshopWithRollCallHandler workshopWithRollCallHandler,IAuthHelper _authHelper, IWorkFlowApplication workFlowApplication)
|
||||||
|
{
|
||||||
|
_workshopWithRollCallHandler = workshopWithRollCallHandler;
|
||||||
|
_workFlowApplication = workFlowApplication;
|
||||||
|
_currentAccountId = _authHelper.CurrentAccountId();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("report")]
|
||||||
|
public ActionResult<List<WorkshopWithRollCallServiceQueryModel>> GetRollCallReport([FromQuery] WorkshopWithRollCallServiceQueryParameters searchModel)
|
||||||
|
{
|
||||||
|
var result = _workshopWithRollCallHandler.Handle(searchModel);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("report/workshops-select-list")]
|
||||||
|
public ActionResult<List<WorkshopSelectList>> GetWorkshopsSelectList()
|
||||||
|
{
|
||||||
|
var result = _workshopWithRollCallHandler.Handle(new WorkshopWithRollCallServiceQueryParameters())
|
||||||
|
.Select(x => new WorkshopSelectList
|
||||||
|
{
|
||||||
|
Id = x.WorkshopId,
|
||||||
|
WorkshopFullName = x.WorkshopName
|
||||||
|
}).Distinct().ToList();
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet("repoert/workfloecount/{workshopId}")]
|
||||||
|
public async Task<ActionResult<int>> GetWorkFlowCountByWorkshopId(long workshopId)
|
||||||
|
{
|
||||||
|
var result = await _workFlowApplication.GetAllWorkFlowCount(workshopId, _currentAccountId);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user