CreateWorkshopAccount and report Fixed lost codes

This commit is contained in:
SamSys
2024-08-04 18:19:16 +03:30
parent 16427f5435
commit ced5c8c576
25 changed files with 1308 additions and 272 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using Microsoft.AspNetCore.Mvc.Rendering;
namespace AccountManagement.Application.Contracts.Account;
@@ -11,4 +12,7 @@ public class AccountLeftWorkViewModel
public string LeftDateFa { get; set; }
public List<AccountViewModel> AccountList { get; set; }
public List<WorkshopAccountlistViewModel> WorkshopAccountlist { get; set; }
public SelectList WorkshopSelectList { get; set; }
public SelectList AccountSelectList { get; set; }
}

View File

@@ -1,14 +1,13 @@
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public class AccountSearchModel
{
public class AccountSearchModel
{
public string Fullname { get; set; }
public string Username { get; set; }
public string Mobile { get; set; }
public long RoleId { get; set; }
public string RoleName { get; set; }
public string VerifyCode { get; set; }
public string IsActiveString { get; set; }
public string positionId { get; set; }
}
}
public string Fullname { get; set; }
public string Username { get; set; }
public string Mobile { get; set; }
public long RoleId { get; set; }
public string RoleName { get; set; }
public string VerifyCode { get; set; }
public string IsActiveString { get; set; }
public string positionId { get; set; }
}

View File

@@ -1,27 +1,26 @@
using System;
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public class AccountViewModel
{
public class AccountViewModel
{
public long Id { get; set; }
public string Fullname { get; set; }
public string Username { get; set; }
public string Mobile { get; set; }
public long RoleId { get; set; }
public string Role { get; set; }
public string ProfilePhoto { get; set; }
public string CreationDate { get; set; }
public string RoleName { get; set; }
public string VerifyCode { get; set; }
public string IsActiveString { get; set; }
public DateTime CreationDateGr { get; set; }
public long Id { get; set; }
public string Fullname { get; set; }
public string Username { get; set; }
public string Mobile { get; set; }
public long RoleId { get; set; }
public string Role { get; set; }
public string ProfilePhoto { get; set; }
public string CreationDate { get; set; }
public string RoleName { get; set; }
public string VerifyCode { get; set; }
public string IsActiveString { get; set; }
public DateTime CreationDateGr { get; set; }
#region Mahan
#region Mahan
public int PositionValue { get; set; }
public long PositionId { get; set; }
#endregion
public string AdminAreaPermission { get; set; }
}
}
public int PositionValue { get; set; }
public long PositionId { get; set; }
#endregion
public string AdminAreaPermission { get; set; }
}

View File

@@ -1,9 +1,8 @@
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public class ChangePassword
{
public class ChangePassword
{
public long Id { get; set; }
public string Password { get; set; }
public string RePassword { get; set; }
}
}
public long Id { get; set; }
public string Password { get; set; }
public string RePassword { get; set; }
}

View File

@@ -5,35 +5,34 @@ using System.ComponentModel.DataAnnotations;
using AccountManagement.Application.Contracts.Role;
using Microsoft.AspNetCore.Http;
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public class CreateAccount
{
public class CreateAccount
{
[Required(ErrorMessage = ValidationMessages.IsRequired)]
public string Fullname { get; set; }
[Required(ErrorMessage = ValidationMessages.IsRequired)]
public string Fullname { get; set; }
[Required(ErrorMessage = ValidationMessages.IsRequired)]
public string Username { get; set; }
[Required(ErrorMessage = ValidationMessages.IsRequired)]
public string Username { get; set; }
[Required(ErrorMessage = ValidationMessages.IsRequired)]
public string Password { get; set; }
[Required(ErrorMessage = ValidationMessages.IsRequired)]
public string Password { get; set; }
[Required(ErrorMessage = "این مقدار نمی تواند خالی باشد")]
[Required(ErrorMessage = "این مقدار نمی تواند خالی باشد")]
[RegularExpression("^[0-9]*$", ErrorMessage = "لطفا فقط عدد وارد کنید")]
public string Mobile { get; set; }
[RegularExpression("^[0-9]*$", ErrorMessage = "لطفا فقط عدد وارد کنید")]
public string Mobile { get; set; }
public long RoleId { get; set; }
public long RoleId { get; set; }
public IFormFile ProfilePhoto { get; set; }
public string ProfilePhotoStr { get; set; }
public List<RoleViewModel> Roles { get; set; }
public IFormFile ProfilePhoto { get; set; }
public string ProfilePhotoStr { get; set; }
public List<RoleViewModel> Roles { get; set; }
public string AdminAreaPermission { get; set; }
public string ClientAriaPermission { get; set; }
public string NationalCode { get; set; }
public string Email { get; set; }
public string VerifyCode { get; set; }
public string IsActiveString { get; set; }
}
}
public string AdminAreaPermission { get; set; }
public string ClientAriaPermission { get; set; }
public string NationalCode { get; set; }
public string Email { get; set; }
public string VerifyCode { get; set; }
public string IsActiveString { get; set; }
}

View File

@@ -1,7 +1,6 @@
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public class EditAccount : CreateAccount
{
public class EditAccount : CreateAccount
{
public long Id { get; set; }
}
}
public long Id { get; set; }
}

View File

@@ -4,10 +4,9 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public class EditClientAccount : RegisterAccount
{
public class EditClientAccount : RegisterAccount
{
public long Id { get; set; }
}
}
public long Id { get; set; }
}

View File

@@ -3,40 +3,45 @@
using System.Collections.Generic;
using System.Threading.Tasks;
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public interface IAccountApplication
{
public interface IAccountApplication
{
AccountViewModel GetAccountBy(long id);
OperationResult Create(CreateAccount command);
OperationResult RegisterClient(RegisterAccount command);
OperationResult Edit(EditAccount command);
OperationResult EditClient(EditClientAccount command);
OperationResult ChangePassword(ChangePassword command);
OperationResult Login(Login command);
OperationResult LoginWithMobile(long id);
EditAccount GetDetails(long id);
List<AccountViewModel> Search(AccountSearchModel searchModel);
void Logout();
List<AccountViewModel> GetAccounts();
List<AccountViewModel> GetClientsAccount();
Task<OperationResult> SetVerifyCode(string phone, long id);
Task<OperationResult> SendVerifyCodeToChangingPass(string phone, long id);
EditAccount GetByVerifyCode(string code, string phone);
EditAccount GetByUserNameAndId(long id, string username);
OperationResult Active(long id);
OperationResult DeActive(long id);
OperationResult DirectLogin(long id);
AccountViewModel GetAccountBy(long id);
OperationResult Create(CreateAccount command);
OperationResult RegisterClient(RegisterAccount command);
OperationResult Edit(EditAccount command);
OperationResult EditClient(EditClientAccount command);
OperationResult ChangePassword(ChangePassword command);
OperationResult Login(Login command);
OperationResult LoginWithMobile(long id);
EditAccount GetDetails(long id);
List<AccountViewModel> Search(AccountSearchModel searchModel);
void Logout();
List<AccountViewModel> GetAccounts();
List<AccountViewModel> GetClientsAccount();
Task<OperationResult> SetVerifyCode(string phone, long id);
Task<OperationResult> SendVerifyCodeToChangingPass(string phone, long id);
EditAccount GetByVerifyCode(string code, string phone);
EditAccount GetByUserNameAndId(long id, string username);
OperationResult Active(long id);
OperationResult DeActive(long id);
OperationResult DirectLogin(long id);
AccountLeftWorkViewModel WorkshopList(long accountId);
AccountLeftWorkViewModel WorkshopList(long accountId);
OperationResult SaveWorkshopAccount(
List<WorkshopAccountlistViewModel> workshopAccountList,
string startDate,
string leftDate,
long accountId);
#region Mahan
List<AccountViewModel> AccountsForAssign(long accountId);
List<AccountViewModel> GetAccountsByPositionId(long positionId);
OperationResult CreateNewWorkshopAccount(long currentAccountId, long newAccountId);
#region Mahan
List<AccountViewModel> AccountsForAssign(long accountId);
List<AccountViewModel> GetAccountsByPositionId(long positionId);
List<AccountViewModel> GetAccountLowerPositionvalue();
OperationResult ReLogin();
List<AccountViewModel> GetAccountLowerPositionvalue();
OperationResult ReLogin();
#endregion
}
}
#endregion
}

View File

@@ -1,8 +1,7 @@
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public class Login
{
public class Login
{
public string Username { get; set; }
public string Password { get; set; }
}
}
public string Username { get; set; }
public string Password { get; set; }
}

View File

@@ -7,31 +7,30 @@ using System.Threading.Tasks;
using _0_Framework.Application;
using Microsoft.AspNetCore.Http;
namespace AccountManagement.Application.Contracts.Account
namespace AccountManagement.Application.Contracts.Account;
public class RegisterAccount
{
public class RegisterAccount
{
[Required(ErrorMessage = "نام و نام خانوادگی نمی تواند خالی باشد")]
public string Fullname { get; set; }
[Required(ErrorMessage = "نام و نام خانوادگی نمی تواند خالی باشد")]
public string Fullname { get; set; }
[Required(ErrorMessage = "نام کاربری نمی تواند خالی باشد")]
public string Username { get; set; }
[Required(ErrorMessage = "نام کاربری نمی تواند خالی باشد")]
public string Username { get; set; }
[Required(ErrorMessage = "گذرواژه نمیتواند خالی باشد")]
public string Password { get; set; }
[Required(ErrorMessage = "گذرواژه نمیتواند خالی باشد")]
public string Password { get; set; }
[Required(ErrorMessage = "شماره موبایل نمی تواند خالی باشد")]
[Required(ErrorMessage = "شماره موبایل نمی تواند خالی باشد")]
[RegularExpression("^[0-9]*$", ErrorMessage = "شماره موبایل معتبر وارد کنید")]
public string Mobile { get; set; }
[RegularExpression("^[0-9]*$", ErrorMessage = "شماره موبایل معتبر وارد کنید")]
public string Mobile { get; set; }
[Required(ErrorMessage = "کد ملی نمی تواند خالی باشد")]
public string NationalCode { get; set; }
[Required(ErrorMessage = "کد ملی نمی تواند خالی باشد")]
public string NationalCode { get; set; }
public string Email { get; set; }
public string Email { get; set; }
public IFormFile ProfilePhoto { get; set; }
public IFormFile ProfilePhoto { get; set; }
public long ContractingPartyId { get; set; }
}
}
public long ContractingPartyId { get; set; }
}

View File

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AccountManagement.Application.Contracts.Account;
public class WorkshopSelectList
{
public long Id { get; set; }
public string WorkshopFullName { get; set; }
}

View File

@@ -4,6 +4,10 @@
<TargetFramework>net8.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.ViewFeatures" Version="2.2.0" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\0_Framework\0_Framework.csproj" />
</ItemGroup>

View File

@@ -13,6 +13,7 @@ using AccountManagement.Domain.AccountLeftWorkAgg;
using AccountManagement.Domain.CameraAccountAgg;
using AccountManagement.Domain.RoleAgg;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc.Rendering;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory.Database;
using TaskManager.Domain.PositionAgg;
//using AccountManagement.Domain.RoleAgg;
@@ -418,8 +419,8 @@ public class AccountApplication : IAccountApplication
public AccountLeftWorkViewModel WorkshopList(long accountId)
{
string fullname = this._accountRepository.GetById(accountId).Fullname;
List<WorkshopAccountlistViewModel> source = this._accountLeftworkRepository.WorkshopList(accountId);
List<long> userWorkshopIds = source.Select<WorkshopAccountlistViewModel, long>((Func<WorkshopAccountlistViewModel, long>)(x => x.WorkshopId)).ToList<long>();
List<WorkshopAccountlistViewModel> source =_accountLeftworkRepository.WorkshopList(accountId);
List<long> userWorkshopIds = source.Select(x => x.WorkshopId).ToList();
List<WorkshopSelectList> allWorkshops = this._accountLeftworkRepository.GetAllWorkshops();
List<AccountViewModel> accountSelectList = this._accountRepository.GetAdminAccountSelectList();
(string StartWorkFa, string LeftWorkFa) byAccountId = this._accountLeftworkRepository.GetByAccountId(accountId);
@@ -430,8 +431,8 @@ public class AccountApplication : IAccountApplication
StartDateFa = byAccountId.StartWorkFa,
LeftDateFa = byAccountId.LeftWorkFa,
WorkshopAccountlist = source,
WorkshopSelectList = new SelectList((IEnumerable)allWorkshops.Where<WorkshopSelectList>((Func<WorkshopSelectList, bool>)(x => !userWorkshopIds.Contains(x.Id))), "Id", "WorkshopFullName"),
AccountSelectList = new SelectList((IEnumerable)accountSelectList, "Id", "Fullname")
WorkshopSelectList = new SelectList(allWorkshops.Where(x => !userWorkshopIds.Contains(x.Id)), "Id", "WorkshopFullName"),
AccountSelectList = new SelectList(accountSelectList, "Id", "Fullname")
};
}

View File

@@ -13,6 +13,7 @@ namespace AccountManagement.Domain.AccountAgg
EditAccount GetByVerifyCode(string code, string phone);
EditAccount GetByUserNameAndId(long id, string username);
List<AccountViewModel> GetAccounts();
List<AccountViewModel> GetAdminAccountSelectList();
List<AccountViewModel> GetClientsAccount();
List<AccountViewModel> Search(AccountSearchModel searchModel);
Task RemoveCode(long id);

View File

@@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using _0_Framework.Application;
using _0_Framework.Domain;
using AccountManagement.Application.Contracts.Account;
@@ -9,4 +10,13 @@ public interface IAccountLeftworkRepository : IRepository<long, AccountLeftWork>
{
(string StartWorkFa, string LeftWorkFa) GetByAccountId(long accountId);
List<WorkshopAccountlistViewModel> WorkshopList(long accountId);
List<WorkshopSelectList> GetAllWorkshops();
OperationResult CopyWorkshopToNewAccount(long currentAccountId, long newAccountId);
OperationResult SaveWorkshopAccount(
List<WorkshopAccountlistViewModel> workshopAccountList,
string startDate,
string leftDate,
long accountId);
}

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using _0_Framework.Application;
using _0_Framework.InfraStructure;
using AccountManagement.Application.Contracts.Account;
@@ -8,6 +9,7 @@ using AccountManagement.Domain.AccountLeftWorkAgg;
using Company.Domain.LeftWorkAgg;
using Company.Domain.WorkingHoursItemsAgg;
using Company.Domain.WorkshopAccountAgg;
using CompanyManagment.App.Contracts.Workshop;
using Microsoft.EntityFrameworkCore;
namespace AccountMangement.Infrastructure.EFCore.Repository;
@@ -16,12 +18,14 @@ public class AccountLeftworkRepository : RepositoryBase<long, AccountLeftWork>,
{
private readonly AccountContext _accountContext;
private readonly IWorkshopAccountRepository _workshopAccountRepository;
private readonly IWorkshopApplication _workshopApplication;
public AccountLeftworkRepository(AccountContext accountContext, IWorkshopAccountRepository workshopAccountRepository) : base(accountContext)
public AccountLeftworkRepository(AccountContext accountContext, IWorkshopAccountRepository workshopAccountRepository, IWorkshopApplication workshopApplication) : base(accountContext)
{
_accountContext = accountContext;
_workshopAccountRepository = workshopAccountRepository;
}
_workshopApplication = workshopApplication;
}
public (string StartWorkFa, string LeftWorkFa) GetByAccountId(long accountId)
{
@@ -53,4 +57,75 @@ public class AccountLeftworkRepository : RepositoryBase<long, AccountLeftWork>,
IsActiveSting = x.IsActiveSting,
}).ToList();
}
}
public List<WorkshopSelectList> GetAllWorkshops()
{
return this._workshopApplication.GetWorkshopAll().Select(x => new WorkshopSelectList()
{
Id = x.Id,
WorkshopFullName = x.WorkshopFullName
}).ToList();
}
public OperationResult CopyWorkshopToNewAccount(long currentAccountId, long newAccountId)
{
List<WorkshopAccountViewModel> accountViewModelList = new List<WorkshopAccountViewModel>();
OperationResult operationResult = new OperationResult();
List<WorkshopAccountViewModel> list =_workshopAccountRepository.GetList(currentAccountId);
List<long> newPrsonIds =_workshopAccountRepository.GetList(newAccountId).Select(x => x.WorkshopId).ToList();
if (list.Count <= 0)
return operationResult.Failed("پرسنل هیچ کارگاهی برای انتقال ندارد");
List<WorkshopAccountViewModel> source = newPrsonIds.Count <= 0 ? list : list.Where(x => !newPrsonIds.Contains(x.WorkshopId)).ToList();
try
{
var res = source.Select(x => new WorkshopAccountViewModel()
{
AccountId = newAccountId,
WorkshopId = x.WorkshopId,
Insurance = x.Insurance,
Tax = x.Tax,
ContractAndCheckout = x.ContractAndCheckout,
WorkshopName = x.WorkshopName,
IsActiveSting = "true"
}).ToList();
_workshopAccountRepository.CreateNewWorkshopAccountByList(res);
return operationResult.Succcedded();
}
catch (Exception ex)
{
return operationResult.Failed("خطا در انجام عملیات");
}
}
public OperationResult SaveWorkshopAccount(
List<WorkshopAccountlistViewModel> workshopAccountList,
string startDate,
string leftDate,
long accountId)
{
OperationResult operationResult = new OperationResult();
DateTime start = startDate.ToGeorgianDateTime();
DateTime leftWorkGr = new DateTime(2150, 1, 1);
if (!string.IsNullOrWhiteSpace(leftDate) && leftDate.Length == 10)
leftWorkGr = leftDate.ToGeorgianDateTime();
if (start > leftWorkGr)
return operationResult.Failed("تاریخ شروع بکار از تاریخ ترک کار بزرگتر است");
if (start == leftWorkGr)
return operationResult.Failed("تاریخ شروع بکار و ترک کار برابرند");
var oldLefts = _accountContext.AccountLeftWorks.Where(x => x.AccountId == accountId).ToList();
_accountContext.AccountLeftWorks.RemoveRange(oldLefts);
Create(new AccountLeftWork(start, leftWorkGr, accountId));
SaveChanges();
var workshopAccountViewModel = workshopAccountList.Select(x => new WorkshopAccountViewModel()
{
AccountId = x.AccountId,
WorkshopId = x.WorkshopId,
Insurance = x.Insurance,
ContractAndCheckout = x.ContractAndCheckout,
Tax = x.Tax,
IsActiveSting = x.IsActiveSting
}).ToList();
_workshopAccountRepository.SaveWorkshopAccount(workshopAccountViewModel);
return operationResult.Succcedded();
}
}

View File

@@ -7,6 +7,8 @@ using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Threading.Tasks;
using AccountManagement.Domain.RoleAgg;
using Microsoft.AspNetCore.Http;
@@ -93,6 +95,16 @@ public class AccountRepository : RepositoryBase<long, Account>, IAccountReposito
}).ToList();
}
public List<AccountViewModel> GetAdminAccountSelectList()
{
return _context.Accounts.Where(x => x.AdminAreaPermission == "true").Select(x => new AccountViewModel()
{
Id = x.id,
Fullname = x.Fullname,
}).ToList();
}
public List<AccountViewModel> GetClientsAccount()
{
return _context.Accounts.Select(x => new AccountViewModel

View File

@@ -7,4 +7,7 @@ namespace Company.Domain.WorkshopAccountAgg;
public interface IWorkshopAccountRepository: IRepository<long, WorkshopAccount>
{
List<WorkshopAccountViewModel> GetList(long accountId);
void CreateNewWorkshopAccountByList(List<WorkshopAccountViewModel> workshopAccountList);
void SaveWorkshopAccount(List<WorkshopAccountViewModel> workshopAccountList);
}

View File

@@ -18,10 +18,10 @@ namespace CompanyManagment.App.Contracts.Report
public int CheckoutSignaturePercent { get; set; }
public string Year { get; set; }
public string Month { get; set; }
public List<AccountResults> AccountResults { get; set; }
//قراداد
public int AllContract { get; set; }
public List<AccountResults> ContractAccountResults { get; set; }
public List<AccountResults> CheckoutAccountResults { get; set; }
//قراداد
public int AllContract { get; set; }
public int ContractNotDone { get; set; }
public int ContrcatDone { get; set; }
public int ContractSignNotDone { get; set; }

View File

@@ -56,7 +56,7 @@ public class ReportRepository : IReportRepository
ContractLeftWorkCount = 0,
CheckoutLeftWorkCount = 0,
ContractingPartId = x.WorkshopEmployers.Select(e => e.Employer.ContractingPartyId).FirstOrDefault(),
AccountIdList = _context.WorkshopAccounts.Where(m => m.WorkshopId == x.id).Select(a => a.AccountId).ToList(),
AccountIdList = _context.WorkshopAccounts.Where(m => m.WorkshopId == x.id && m.ContractAndCheckout == "true" && m.IsActiveSting == "true").Select(a => a.AccountId).ToList(),
#region Contracts
//contractLeft This Mont
@@ -92,7 +92,7 @@ public class ReportRepository : IReportRepository
#endregion
}).Where(e => blockContractingPartyIds.Contains(e.ContractingPartId));
}).Where(e => blockContractingPartyIds.Contains(e.ContractingPartId) && e.AccountIdList.Count > 0);
var workshopsList = workshops.Select(x => new ActiveWorkshops
{
@@ -165,19 +165,17 @@ public class ReportRepository : IReportRepository
});
Console.WriteLine("Ripo query 2 >>>>>: " + watch.Elapsed);
var accountResult = result.Select(x => new ActiveWorkshops()
var contractAccountResult = result.Select(x => new ActiveWorkshops()
{
Id = x.Id,
AccountId = _accountContext.Accounts.Any(e => x.AccountIdList.Contains(e.id) && e.RoleId == 5)
? _accountContext.Accounts.Where(e => x.AccountIdList.Contains(e.id)).FirstOrDefault(e => e.RoleId == 5)!.id : 0,
AccountFullname = _accountContext.Accounts.Any(e => x.AccountIdList.Contains(e.id) && e.RoleId == 5)
? _accountContext.Accounts.Where(e => x.AccountIdList.Contains(e.id)).FirstOrDefault(e => e.RoleId == 5)!.Fullname : "",
//AccountId = _accountContext.Accounts.Any(e => x.AccountIdList.Contains(e.id) && e.RoleId == 5)
// ? _accountContext.Accounts.Where(e => x.AccountIdList.Contains(e.id)).FirstOrDefault(e => e.RoleId == 5)!.id : 0,
//AccountFullname = _accountContext.Accounts.Any(e => x.AccountIdList.Contains(e.id) && e.RoleId == 5)
// ? _accountContext.Accounts.Where(e => x.AccountIdList.Contains(e.id)).FirstOrDefault(e => e.RoleId == 5)!.Fullname : "",
AccountId = _accountContext.AccountLeftWorks.Any(e=> x.AccountIdList.Contains(e.AccountId) && e.StartWorkGr <= currentMonthStart && e.LeftWorkGr >= currentMonthEnd) ?
_accountContext.AccountLeftWorks.FirstOrDefault(e => x.AccountIdList.Contains(e.AccountId) && e.StartWorkGr <= currentMonthStart && e.LeftWorkGr >= currentMonthEnd)!.AccountId : 0,
ContractLeftWorkCount = x.ContractLeftWorkCount,
CheckoutLeftWorkCount = x.CheckoutLeftWorkCount,
CheckoutDoneCount = x.CheckoutDoneCount,
CheckoutSignDoneCount = x.CheckoutSignDoneCount,
ContractLeftWorkCount = x.ContractLeftWorkCount,
ContrctDoneCount = x.ContrctDoneCount,
ContrctSignDoneCount = x.ContrctSignDoneCount,
@@ -185,46 +183,67 @@ public class ReportRepository : IReportRepository
WorkshopFullName = x.WorkshopFullName,
}).Where(x => x.AccountId != 0).ToList();
watch.Restart();
//قرارداد هایی که باید اسجاد می شد
var contractToBe = accountResult.Sum(x => x.ContractLeftWorkCount);
// تصفیه هایی که باید ایجاد می شد
var checkoutToBe = accountResult.Sum(x => x.CheckoutLeftWorkCount);
var checkoutAccountResult = result.Select(x => new ActiveWorkshops()
{
Id = x.Id,
//AccountId = _accountContext.Accounts.Any(e => x.AccountIdList.Contains(e.id) && e.RoleId == 5)
// ? _accountContext.Accounts.Where(e => x.AccountIdList.Contains(e.id)).FirstOrDefault(e => e.RoleId == 5)!.id : 0,
//AccountFullname = _accountContext.Accounts.Any(e => x.AccountIdList.Contains(e.id) && e.RoleId == 5)
// ? _accountContext.Accounts.Where(e => x.AccountIdList.Contains(e.id)).FirstOrDefault(e => e.RoleId == 5)!.Fullname : "",
AccountId = _accountContext.AccountLeftWorks.Any(e => x.AccountIdList.Contains(e.AccountId) && e.StartWorkGr <= nextMonthStart && e.LeftWorkGr >= nextMonthEnd) ?
_accountContext.AccountLeftWorks.FirstOrDefault(e => x.AccountIdList.Contains(e.AccountId) && e.StartWorkGr <= nextMonthStart && e.LeftWorkGr >= nextMonthEnd)!.AccountId : 0,
CheckoutLeftWorkCount = x.CheckoutLeftWorkCount,
CheckoutDoneCount = x.CheckoutDoneCount,
CheckoutSignDoneCount = x.CheckoutSignDoneCount,
IsActiveString = x.IsActiveString,
WorkshopFullName = x.WorkshopFullName,
}).Where(x => x.AccountId != 0).ToList();
watch.Restart();
//قرارداد هایی که باید اسجاد می شد
var contractToBe = contractAccountResult.Sum(x => x.ContractLeftWorkCount);
//قراردادهای ایجاد شده
var createdContracts = accountResult.Sum(x => x.ContrctDoneCount);
var createdContracts = contractAccountResult.Sum(x => x.ContrctDoneCount);
// قراداد های امضاء شده
var signedContracts = accountResult.Sum(x => x.ContrctSignDoneCount);
var signedContracts = contractAccountResult.Sum(x => x.ContrctSignDoneCount);
// تصفیه هایی که باید ایجاد می شد
var checkoutToBe = checkoutAccountResult.Sum(x => x.CheckoutLeftWorkCount);
// تصفیه های ایجاد شده
var createdCheckouts = accountResult.Sum(x => x.CheckoutDoneCount);
var createdCheckouts = checkoutAccountResult.Sum(x => x.CheckoutDoneCount);
//تصفیه های امضاء شده
var signedChckouts = accountResult.Sum(x => x.CheckoutSignDoneCount);
var signedChckouts = checkoutAccountResult.Sum(x => x.CheckoutSignDoneCount);
var groupResult = accountResult.GroupBy(x => x.AccountId).Select(x => new AccountResults()
var contractGroupResult = contractAccountResult.GroupBy(x => x.AccountId).Select(x => new AccountResults()
{
AccountId = x.Key,
AccountFullName = x.FirstOrDefault()?.AccountFullname,
//ContractToBe = x.Sum(c=>c.ContractLeftWorkCount),
//CheckoutoBe = x.Sum(c => c.CheckoutLeftWorkCount),
//ContractDone = x.Sum(c => c.ContrctDoneCount),
//ContractSignDone = x.Sum(c => c.ContrctSignDoneCount),
//CheckoutDone = x.Sum(c => c.CheckoutDoneCount),
//CheckoutSignDone = x.Sum(c => c.CheckoutSignDoneCount),
AccountFullName = _accountContext.Accounts.FirstOrDefault(a=>a.id == x.Key)!.Fullname,
ContractDonePercent = (x.Sum(c => c.ContrctDoneCount) * 100) / x.Sum(c => c.ContractLeftWorkCount),
CheckoutDonePercent = (x.Sum(c => c.CheckoutDoneCount) * 100) / x.Sum(c => c.CheckoutLeftWorkCount),
ContractSignPercent = x.Sum(c => c.ContrctDoneCount) > 0 ? (x.Sum(c => c.ContrctSignDoneCount) * 100) / (x.Sum(c => c.ContrctDoneCount)) : 0,
CheckoutSignPercent = x.Sum(c => c.CheckoutDoneCount) > 0 ? (x.Sum(c => c.CheckoutSignDoneCount) * 100) / (x.Sum(c => c.CheckoutDoneCount)) : 0,
}).ToList();
var checkoutGroupResult = checkoutAccountResult.GroupBy(x => x.AccountId).Select(x => new AccountResults()
{
AccountId = x.Key,
AccountFullName = _accountContext.Accounts.FirstOrDefault(a => a.id == x.Key)!.Fullname,
CheckoutDonePercent = (x.Sum(c => c.CheckoutDoneCount) * 100) / x.Sum(c => c.CheckoutLeftWorkCount),
CheckoutSignPercent = x.Sum(c => c.CheckoutDoneCount) > 0 ? (x.Sum(c => c.CheckoutSignDoneCount) * 100) / (x.Sum(c => c.CheckoutDoneCount)) : 0,
#region ComputePercentage
}).ToList();
#region ComputePercentage
//قرارداد
var contractPercent = (createdContracts * 100) / contractToBe;
//قرارداد
var contractPercent = (createdContracts * 100) / contractToBe;
//امضاء قراداد
var contractSignaturePercent = createdContracts > 0 ? (signedContracts * 100) / createdContracts : 0;
// تصفیه
@@ -246,8 +265,8 @@ public class ReportRepository : IReportRepository
Year = $"{currentYear}",
Month = nowFa.Substring(5, 2),
AccountResults = groupResult,
ContractAccountResults = contractGroupResult,
CheckoutAccountResults = checkoutGroupResult,
AllContract = contractToBe,
ContractNotDone = contractToBe - createdContracts,

View File

@@ -1,6 +1,7 @@
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Linq.Expressions;
using _0_Framework.InfraStructure;
using Company.Domain.WorkshopAccountAgg;
using CompanyManagment.App.Contracts.Workshop;
@@ -33,4 +34,41 @@ public class WorkshopAccountRepository : RepositoryBase<long, WorkshopAccount>,
}).ToList();
}
}
public void CreateNewWorkshopAccountByList(List<WorkshopAccountViewModel> workshopAccountList)
{
var addNew = workshopAccountList.Select(x => new WorkshopAccount()
{
AccountId = x.AccountId,
WorkshopId = x.WorkshopId,
ContractAndCheckout = x.ContractAndCheckout,
Insurance = x.Insurance,
Tax = x.Tax,
IsActiveSting = "true"
}).ToList();
_Context.WorkshopAccounts.AddRange(addNew);
_Context.SaveChanges();
}
public void SaveWorkshopAccount(List<WorkshopAccountViewModel> workshopAccountList)
{
if (workshopAccountList.Count > 0)
{
long accountId = workshopAccountList.Select(x => x.AccountId).FirstOrDefault();
var removeOld = this._Context.WorkshopAccounts.Where(x => x.AccountId == accountId).ToList();
var addNew = workshopAccountList.Select(x => new WorkshopAccount()
{
AccountId = x.AccountId,
WorkshopId = x.WorkshopId,
ContractAndCheckout = x.ContractAndCheckout,
Insurance = x.Insurance,
Tax = x.Tax,
IsActiveSting = x.IsActiveSting
}).ToList();
_Context.WorkshopAccounts.RemoveRange(removeOld);
_Context.WorkshopAccounts.AddRange(addNew);
_Context.SaveChanges();
}
}
}

View File

@@ -230,7 +230,7 @@ public class IndexModel : PageModel
isSuccess = false,
mess = "تاریخ شروع بکار خالی است"
});
OperationResult operationResult = this._accountApplication.SaveWorkshopAccount(workshopAccountlistViewModel, startDate, leftDate, accountId);
OperationResult operationResult = _accountApplication.SaveWorkshopAccount(workshopAccountlistViewModel, startDate, leftDate, accountId);
return operationResult.IsSuccedded ? (IActionResult)new JsonResult((object)new
{
isSuccess = true,
@@ -255,4 +255,3 @@ public class IndexModel : PageModel
});
}
}
}

View File

@@ -380,7 +380,7 @@
<div class="users-list">
@{
var firstItem1 = true;
foreach (var personnel in Model.Personnel.OrderBy(x => x.ContractDonePercent))
foreach (var personnel in Model.PersonnelContract.OrderBy(x => x.ContractDonePercent))
{
if (firstItem1)
{
@@ -426,7 +426,7 @@
}
var firstItem2 = true;
foreach (var personnel in Model.Personnel.OrderBy(x => x.ContractSignPercent))
foreach (var personnel in Model.PersonnelContract.OrderBy(x => x.ContractSignPercent))
{
<div style="display: none" id="ContractSignPercentDiv" class="d-flex align-items-center m-1 select @(firstItem2 ? "active" : "") ContractSignPercent activeBtn" onclick="ajaxContractSignDone(@personnel.AccountId, '@personnel.AccountFullName')">
<div class="col-xs-4">
@@ -461,7 +461,7 @@
}
var firstItem3 = true;
foreach (var personnel in Model.Personnel.OrderBy(x => x.CheckoutDonePercent))
foreach (var personnel in Model.PersonnelCheckout.OrderBy(x => x.CheckoutDonePercent))
{
<div id="CheckoutDonePercentDiv" style="display: none" class="d-flex align-items-center m-1 select @(firstItem3 ? "active" : "") CheckoutDonePercent activeBtn" onclick="ajaxWorkshopCheckoutDone(@personnel.AccountId, '@personnel.AccountFullName')">
<div class="col-xs-4">
@@ -496,7 +496,7 @@
}
var firstItem4 = true;
foreach (var personnel in Model.Personnel.OrderBy(x => x.CheckoutSignPercent))
foreach (var personnel in Model.PersonnelCheckout.OrderBy(x => x.CheckoutSignPercent))
{
<div id="CheckoutSignPercentDiv" style="display: none" class="d-flex align-items-center m-1 select @(firstItem4 ? "active" : "") CheckoutSignPercent activeBtn" onclick="ajaxWorkshopCheckoutSignDone(@personnel.AccountId, '@personnel.AccountFullName')">
<div class="col-xs-4">
@@ -539,7 +539,7 @@
<div class="col-xs-block mainMobilePersonal1">
@{
var firstItemMobile1 = true;
foreach (var personnel in Model.Personnel.OrderBy(x => x.ContractDonePercent))
foreach (var personnel in Model.PersonnelContract.OrderBy(x => x.ContractDonePercent))
{
<div class="card btn-card @(firstItemMobile1 ? "active" : "") ContractDonePercent activeBtn" onclick="ajaxContractDone(@personnel.AccountId)">
<div class="card-body">
@@ -569,7 +569,7 @@
<div class="col-xs-block mainMobilePersonal2">
@{
var firstItemMobile2 = true;
foreach (var personnel in Model.Personnel.OrderBy(x => x.ContractSignPercent))
foreach (var personnel in Model.PersonnelContract.OrderBy(x => x.ContractSignPercent))
{
<div class="card btn-card @(firstItemMobile2 ? "active" : "") ContractSignPercent activeBtn" onclick="ajaxContractSignDone(@personnel.AccountId)">
<div class="card-body">
@@ -598,7 +598,7 @@
<div class="col-xs-block mainMobilePersonal3">
@{
var firstItemMobile3 = true;
foreach (var personnel in Model.Personnel.OrderBy(x => x.CheckoutDonePercent))
foreach (var personnel in Model.PersonnelCheckout.OrderBy(x => x.CheckoutDonePercent))
{
<div class="card btn-card @(firstItemMobile3 ? "active" : "") CheckoutDonePercent activeBtn" onclick="ajaxWorkshopCheckoutDone(@personnel.AccountId)">
<div class="card-body">
@@ -627,7 +627,7 @@
<div class="col-xs-block mainMobilePersonal4">
@{
var firstItemMobile4 = true;
foreach (var personnel in Model.Personnel.OrderBy(x => x.CheckoutSignPercent))
foreach (var personnel in Model.PersonnelCheckout.OrderBy(x => x.CheckoutSignPercent))
{
<div class="card btn-card @(firstItemMobile4 ? "active" : "") CheckoutSignPercent activeBtn" onclick="ajaxWorkshopCheckoutDone(@personnel.AccountId)">
<div class="card-body">

View File

@@ -33,7 +33,8 @@ public class IndexModel : PageModel
_workshopApplication = workshopApplication;
}
public List<AccountResults> Personnel { get; set; }
public List<AccountResults> PersonnelContract { get; set; }
public List<AccountResults> PersonnelCheckout { get; set; }
//قراداد
public int AllContract { get; set; }
@@ -60,7 +61,8 @@ public class IndexModel : PageModel
CheckoutSignaturePercent = allReports.CheckoutSignaturePercent;
Year = allReports.Year;
Month = allReports.Month;
Personnel = allReports.AccountResults;
PersonnelContract = allReports.ContractAccountResults;
PersonnelCheckout = allReports.CheckoutAccountResults;
CurrentMonth = allReports.Month.ToFarsiMonthByNumber();
var now = new PersianDateTime(Convert.ToInt32(allReports.Year), Convert.ToInt32(allReports.Month), 1);
var before = now.AddMonths(1);