change create checkout api
This commit is contained in:
@@ -874,7 +874,7 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
|
||||
int successProcess = 1;
|
||||
int countList = getContractsData.Data.ContractIncludedData.Count;
|
||||
List<string> failedCreateList = [];
|
||||
List<string> createFailedList = [];
|
||||
int createSuccessCount = 0;
|
||||
int createFailedCount = 0;
|
||||
foreach (var item in getContractsData.Data.ContractIncludedData)
|
||||
@@ -938,6 +938,7 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
if (getContractsData.Data.IsStaticCheckout)
|
||||
hasRollCall = false;
|
||||
|
||||
var isStaticCheckout = hasRollCall == false;
|
||||
//محاسبه موظفی
|
||||
#region MandatoryCompute
|
||||
var mandatoryCompute = new ComputingViewModel();
|
||||
@@ -953,7 +954,7 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
|
||||
mandatoryCompute = await _rollCallMandatoryRepository.MandatoryCompute(item.EmployeeId, workshopId,
|
||||
item.Separation.ContractStartGr, item.Separation.ContractEndGr, item.WorkingHours, getContractsData.Data.WorkshopHolidayWorking,
|
||||
hasRollCall, getContractsData.Data.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute);
|
||||
isStaticCheckout, getContractsData.Data.RotatingShiftCompute, dailyWageUnAffected, totalLeaveCompute);
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1481,7 +1482,7 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
if (!saveToDb)
|
||||
{
|
||||
createFailedCount += 1;
|
||||
failedCreateList.Add(item.EmployeeFullName);
|
||||
createFailedList.Add(item.EmployeeFullName);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1492,13 +1493,18 @@ public class CheckoutApplication : ICheckoutApplication
|
||||
catch (Exception)
|
||||
{
|
||||
createFailedCount += 1;
|
||||
failedCreateList.Add(item.EmployeeFullName);
|
||||
createFailedList.Add(item.EmployeeFullName);
|
||||
|
||||
}
|
||||
|
||||
|
||||
var percent = (successProcess / (double)countList) * 100;
|
||||
await signalR.SendAsync("showStatus", countList, createFailedCount, createSuccessCount, (int)percent, failedCreateList);
|
||||
// await signalR.SendAsync("showStatus", countList, createFailedCount, createSuccessCount, (int)percent, createFailedList);
|
||||
await signalR.SendAsync("all", countList);
|
||||
await signalR.SendAsync("failed", createFailedCount);
|
||||
await signalR.SendAsync("Success", createSuccessCount);
|
||||
await signalR.SendAsync("percent", (int)percent);
|
||||
await signalR.SendAsync("failedList", createFailedList);
|
||||
|
||||
successProcess += 1;
|
||||
|
||||
|
||||
@@ -2784,8 +2784,9 @@ public class CheckoutRepository : RepositoryBase<long, Checkout>, ICheckoutRepos
|
||||
var op = new OperationResult<GetContractAndIncludesDataToCreateDto>();
|
||||
var watcher = new Stopwatch();
|
||||
watcher.Start();
|
||||
var test = _context.Contracts.FirstOrDefault(x => x.id == 290499);
|
||||
//دریافت قراداد ها
|
||||
var getContracts =await _context.Contracts.Include(x=>x.Employee).Where(x => ids.Contains(x.id)).AsNoTracking().ToListAsync();
|
||||
var getContracts =await _context.Contracts.Where(x => ids.Contains(x.id)).Include(e=>e.Employee).AsNoTracking().ToListAsync();
|
||||
if (!getContracts.Any())
|
||||
return op.Failed("قرادادی یافت نشد");
|
||||
|
||||
|
||||
@@ -120,14 +120,6 @@ public class CheckoutController : AdminBaseController
|
||||
// return new OperationResult<List<ContractsListToCreateCheckoutDto>>().Failed(
|
||||
// "این کارگاه به دلیل داشتن کارپوشه مجاز به ایجاد تصفیه حساب نمی باشد");
|
||||
|
||||
#region testCreate
|
||||
|
||||
var ids = result.Data.Where(x => x.CreateCheckoutStatus == CreateCheckoutStatus.ReadyToCreate).Select(x => x.Id).ToList();
|
||||
|
||||
Console.WriteLine(ids.ToJson());
|
||||
var test = await _checkoutApplication.CreateCheckoutApi(ids, year, month,workshopId);
|
||||
|
||||
#endregion
|
||||
|
||||
return result;
|
||||
|
||||
@@ -139,41 +131,41 @@ public class CheckoutController : AdminBaseController
|
||||
/// <param name="command"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<ActionResult> CreateCheckout([FromBody]TestCreateCheckout command)
|
||||
public async Task<ActionResult<OperationResult>> CreateCheckout([FromBody] CreateCheckoutDto command)
|
||||
{
|
||||
var op = new OperationResult<List<Testresponse>>();
|
||||
var ids = new
|
||||
List<long>()
|
||||
{
|
||||
283652, 290314, 290315, 290316, 290317, 290318, 290319, 290320, 290321, 290322, 290323, 290324, 290325,
|
||||
290326, 290327, 290328, 290329, 290330, 290331, 290332, 290333, 290334, 290335, 290336, 290337, 290338,
|
||||
290339, 290340, 290341, 290342, 290343, 290344, 290345, 290346, 290347, 290348, 290349, 290350, 290351,
|
||||
290352, 290353, 290354, 290355, 290356, 290357, 290358, 290359, 290360, 290361, 290362, 290363, 290364,
|
||||
290365, 290366, 290367, 290368, 290369, 290370, 290371, 290372, 290373, 290374, 290375, 290376, 290377,
|
||||
290378, 290379, 290380, 290381, 290382, 290383, 290384, 290385, 290386, 290387, 290388, 290389, 290390,
|
||||
290391, 290392, 290393, 290394, 290395, 290396, 290397, 290398, 290399, 290400, 290401, 290402, 290403,
|
||||
290404, 290405, 290406, 290407, 290408, 290409, 290410, 290411, 290412, 290413, 290414, 290415, 290416,
|
||||
290417, 290418, 290419, 290420, 290421, 290422, 290423, 290424, 290425, 290426, 290427, 290428, 290429,
|
||||
290430, 290431, 290432, 290433, 290434, 290435, 290436, 290437, 290438, 290439, 290440, 290441, 290442,
|
||||
290443, 290444, 290445, 290446, 290447, 290448, 290449, 290450, 290451, 290452, 290453, 290454, 290455,
|
||||
290456, 290457, 290458, 290459, 290460, 290461, 290462, 290463, 290464, 290465, 290466, 290467, 290468,
|
||||
290469, 290470, 290471, 290472, 290473, 290474, 290475, 290476, 290477, 290478, 290479, 290480, 290481,
|
||||
290482, 290483, 290484, 290485, 290486, 290487, 290488, 290489, 290490, 290491, 290492, 290493, 290494,
|
||||
290495, 290496, 290497, 290498, 290499, 290500, 290501, 290502, 290503, 290504, 290505, 290506, 290507,
|
||||
290508, 290509, 290510, 290511, 290512, 290513, 290514, 290515, 290516, 290517, 290518, 290519, 290520,
|
||||
290521, 290522, 290523, 290524, 290525, 290526, 290527, 290528, 290529, 290530, 290531, 290532, 290533,
|
||||
290534, 290535, 290536, 290537, 290538, 290539, 290540, 290541, 290542, 290543, 290544, 290545, 290546,
|
||||
290547, 290548, 290549, 290550, 290551, 290552, 290553, 290554, 290555, 290556, 290557, 290558, 290559,
|
||||
290560, 290561, 290562, 290563, 290564, 290565, 290566, 290567, 290568, 290569, 290570, 290571, 290572,
|
||||
290573, 290574, 290575, 290576, 290577, 290578, 290579, 290580, 290581, 290582, 290583, 290584, 290585,
|
||||
299612, 290587, 290588
|
||||
};
|
||||
// var ids = new List<long>(){ 299612 };
|
||||
var op = new OperationResult();
|
||||
//var ids = new
|
||||
// List<long>()
|
||||
// {
|
||||
// 283652, 290314, 290315, 290316, 290317, 290318, 290319, 290320, 290321, 290322, 290323, 290324, 290325,
|
||||
// 290326, 290327, 290328, 290329, 290330, 290331, 290332, 290333, 290334, 290335, 290336, 290337, 290338,
|
||||
// 290339, 290340, 290341, 290342, 290343, 290344, 290345, 290346, 290347, 290348, 290349, 290350, 290351,
|
||||
// 290352, 290353, 290354, 290355, 290356, 290357, 290358, 290359, 290360, 290361, 290362, 290363, 290364,
|
||||
// 290365, 290366, 290367, 290368, 290369, 290370, 290371, 290372, 290373, 290374, 290375, 290376, 290377,
|
||||
// 290378, 290379, 290380, 290381, 290382, 290383, 290384, 290385, 290386, 290387, 290388, 290389, 290390,
|
||||
// 290391, 290392, 290393, 290394, 290395, 290396, 290397, 290398, 290399, 290400, 290401, 290402, 290403,
|
||||
// 290404, 290405, 290406, 290407, 290408, 290409, 290410, 290411, 290412, 290413, 290414, 290415, 290416,
|
||||
// 290417, 290418, 290419, 290420, 290421, 290422, 290423, 290424, 290425, 290426, 290427, 290428, 290429,
|
||||
// 290430, 290431, 290432, 290433, 290434, 290435, 290436, 290437, 290438, 290439, 290440, 290441, 290442,
|
||||
// 290443, 290444, 290445, 290446, 290447, 290448, 290449, 290450, 290451, 290452, 290453, 290454, 290455,
|
||||
// 290456, 290457, 290458, 290459, 290460, 290461, 290462, 290463, 290464, 290465, 290466, 290467, 290468,
|
||||
// 290469, 290470, 290471, 290472, 290473, 290474, 290475, 290476, 290477, 290478, 290479, 290480, 290481,
|
||||
// 290482, 290483, 290484, 290485, 290486, 290487, 290488, 290489, 290490, 290491, 290492, 290493, 290494,
|
||||
// 290495, 290496, 290497, 290498, 290499, 290500, 290501, 290502, 290503, 290504, 290505, 290506, 290507,
|
||||
// 290508, 290509, 290510, 290511, 290512, 290513, 290514, 290515, 290516, 290517, 290518, 290519, 290520,
|
||||
// 290521, 290522, 290523, 290524, 290525, 290526, 290527, 290528, 290529, 290530, 290531, 290532, 290533,
|
||||
// 290534, 290535, 290536, 290537, 290538, 290539, 290540, 290541, 290542, 290543, 290544, 290545, 290546,
|
||||
// 290547, 290548, 290549, 290550, 290551, 290552, 290553, 290554, 290555, 290556, 290557, 290558, 290559,
|
||||
// 290560, 290561, 290562, 290563, 290564, 290565, 290566, 290567, 290568, 290569, 290570, 290571, 290572,
|
||||
// 290573, 290574, 290575, 290576, 290577, 290578, 290579, 290580, 290581, 290582, 290583, 290584, 290585,
|
||||
// 299612, 290587, 290588
|
||||
// };
|
||||
//command.Ids = new List<long>(){ 290449 };
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(command.year) && string.IsNullOrWhiteSpace(command.Month))
|
||||
return BadRequest();
|
||||
return op.Failed("ماه را انتخاب کنید");
|
||||
if (string.IsNullOrWhiteSpace(command.year) && !string.IsNullOrWhiteSpace(command.Month))
|
||||
return BadRequest();
|
||||
return op.Failed("سال را انتخاب کنید");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(command.year) && string.IsNullOrWhiteSpace(command.Month))
|
||||
{
|
||||
@@ -188,32 +180,26 @@ public class CheckoutController : AdminBaseController
|
||||
command.Month = convertedMonth;
|
||||
}
|
||||
|
||||
if (ids.Count == 0 || command.WorkshopId == 0)
|
||||
return BadRequest();
|
||||
if (command.WorkshopId == 0)
|
||||
return op.Failed("کارگاه انتخاب نشده است");
|
||||
if (command.Ids.Count == 0)
|
||||
return op.Failed("هیچ موردی انتخاب نشده است");
|
||||
|
||||
var test = await _checkoutApplication.CreateCheckoutApi(ids, command.year, command.Month, command.WorkshopId);
|
||||
return Ok();
|
||||
|
||||
var result = await _checkoutApplication.CreateCheckoutApi(command.Ids, command.year, command.Month, command.WorkshopId);
|
||||
return result;
|
||||
|
||||
}
|
||||
#endregion
|
||||
|
||||
}
|
||||
|
||||
public class TestCreateCheckout
|
||||
public class CreateCheckoutDto
|
||||
{
|
||||
public List<long> Ids { get; set; }
|
||||
public string year { get; set; }
|
||||
public string Month { get; set; }
|
||||
public long WorkshopId { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class Testresponse
|
||||
{
|
||||
public string EmployeeName { get; set; }
|
||||
public string ContractNo { get; set; }
|
||||
public string Start { get; set; }
|
||||
public string End { get; set; }
|
||||
public bool HasLeft { get; set; }
|
||||
|
||||
public string LeftDate { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user