You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

205 lines
8.5 KiB

2 years ago
using System.Collections.Generic;
using System.Text.Json;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp.Application.Dtos;
using Volo.Abp.AspNetCore.Mvc;
using Win_in.Sfs.Auth.Application.Contracts;
using Win_in.Sfs.Shared.Domain;
using Win_in.Sfs.Shared.Domain.Shared;
using Win_in.Sfs.Wms.Store.Application.Contracts;
namespace Win_in.Sfs.Wms.Pda.Controllers.Jobs;
/// <summary>
///
/// </summary>
[ApiController]
[Route($"{PdaHostConst.ROOT_ROUTE}job/count")]
public class JobController : AbpController
{
private readonly IUserWorkGroupAppService _userWorkGroupAppService;
private readonly ICountJobAppService _countJobAppService;
private readonly IDeliverJobAppService _deliverJobAppService;
private readonly IInspectJobAppService _inspectJobAppService;
private readonly IIssueJobAppService _issueJobAppService;
private readonly IProductReceiveJobAppService _productReceiveJobAppService;
private readonly IPurchaseReceiptJobAppService _purchaseReceiptJobAppService;
private readonly IPurchaseReturnJobAppService _purchaseReturnJobAppService;
private readonly IPutawayJobAppService _putawayJobAppService;
private readonly IProductionReturnJobAppService _productionReturnJobAppService;
/// <summary>
///
/// </summary>
/// <param name="userWorkGroupAppService"></param>
/// <param name="countJobAppService"></param>
/// <param name="deliverJobAppService"></param>
/// <param name="inspectJobAppService"></param>
/// <param name="issueJobAppService"></param>
/// <param name="productReceiveJobAppService"></param>
/// <param name="purchaseReceiptJobAppService"></param>
/// <param name="purchaseReturnJobAppService"></param>
/// <param name="putawayJobAppService"></param>
/// <param name="productionReturnJobAppService"></param>
public JobController(IUserWorkGroupAppService userWorkGroupAppService,
ICountJobAppService countJobAppService,
IDeliverJobAppService deliverJobAppService,
IInspectJobAppService inspectJobAppService,
IIssueJobAppService issueJobAppService,
IProductReceiveJobAppService productReceiveJobAppService,
IPurchaseReceiptJobAppService purchaseReceiptJobAppService,
IPurchaseReturnJobAppService purchaseReturnJobAppService,
IPutawayJobAppService putawayJobAppService,
IProductionReturnJobAppService productionReturnJobAppService)
{
_userWorkGroupAppService = userWorkGroupAppService;
_countJobAppService = countJobAppService;
_deliverJobAppService = deliverJobAppService;
_inspectJobAppService = inspectJobAppService;
_issueJobAppService = issueJobAppService;
_productReceiveJobAppService = productReceiveJobAppService;
_purchaseReceiptJobAppService = purchaseReceiptJobAppService;
_purchaseReturnJobAppService = purchaseReturnJobAppService;
_putawayJobAppService = putawayJobAppService;
_productionReturnJobAppService = productionReturnJobAppService;
}
/// <summary>
/// 获取全部任务数量统计
/// </summary>
/// <returns></returns>
[HttpGet("")]
public virtual async Task<ListResultDto<JobCountDto>> CountAsync()
{
var wlgCodes = await _userWorkGroupAppService.GetCodsOfCurrentUserAsync().ConfigureAwait(false);
var jsonCodes = JsonSerializer.Serialize(wlgCodes);
List<string> status = new List<string>() { EnumJobStatus.Open.ToString(), EnumJobStatus.Doing.ToString() };
2 years ago
var jsonStatus = JsonSerializer.Serialize(status);
var list = new List<JobCountDto>();
var countJobs = await _countJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(CountJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(CountJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.CountJob, Count = countJobs });
var deliverJobs = await _deliverJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(DeliverJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(DeliverJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.DeliverJob, Count = deliverJobs });
var inspectJobs = await _inspectJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(InspectJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(InspectJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.InspectJob, Count = inspectJobs });
var issueJobs = await _issueJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(IssueJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(IssueJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.IssueJob, Count = issueJobs });
var productReceiveJobs = await _productReceiveJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(ProductReceiveJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(ProductReceiveJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.ProductReceiveJob, Count = productReceiveJobs });
var purchaseReceiptJobs = await _purchaseReceiptJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(PurchaseReceiptJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(PurchaseReceiptJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.PurchaseReceiptJob, Count = purchaseReceiptJobs });
var purchaseReturnJobs = await _purchaseReturnJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(PurchaseReturnJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(PurchaseReturnJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.PurchaseReturnJob, Count = purchaseReturnJobs });
var putawayJobs = await _putawayJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(PutawayJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(PutawayJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.PutawayJob, Count = putawayJobs });
var productionReturnJobs = await _productionReturnJobAppService.GetCountByFilterAsync(new SfsJobRequestInputBase
{
Condition = new Condition
{
Filters = new List<Filter>
{
new(nameof(ProductionReturnJobDTO.WorkGroupCode),jsonCodes,"In"),
new(nameof(ProductionReturnJobDTO.JobStatus),jsonStatus,"In")
}
}
}).ConfigureAwait(false);
list.Add(new JobCountDto { JobType = EnumJobType.ProductionReturnJob, Count = productionReturnJobs });
return new ListResultDto<JobCountDto>(list);
}
}