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.
166 lines
5.1 KiB
166 lines
5.1 KiB
2 years ago
|
using System;
|
||
|
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/inspect")]
|
||
|
|
||
|
public class InspectJobController : AbpController
|
||
|
{
|
||
|
private readonly IInspectJobAppService _inspectJobAppService;
|
||
|
|
||
|
private readonly IUserWorkGroupAppService _userWorkGroupAppService;
|
||
|
|
||
|
/// <summary>
|
||
|
///
|
||
|
/// </summary>
|
||
|
/// <param name="inspectJobAppService"></param>
|
||
|
/// <param name="userWorkGroupAppService"></param>
|
||
|
public InspectJobController(
|
||
|
IInspectJobAppService inspectJobAppService
|
||
|
, IUserWorkGroupAppService userWorkGroupAppService)
|
||
|
{
|
||
|
_userWorkGroupAppService = userWorkGroupAppService;
|
||
|
_inspectJobAppService = inspectJobAppService;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取检验任务详情
|
||
|
/// </summary>
|
||
|
/// <param name="id"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpGet("{id}")]
|
||
|
|
||
|
public virtual async Task<ActionResult<InspectJobDTO>> GetAsync(Guid id)
|
||
|
{
|
||
|
var result = await _inspectJobAppService.GetAsync(id).ConfigureAwait(false);
|
||
|
return Ok(result);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="pageSize"></param>
|
||
|
/// <param name="pageIndex"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpGet("list")]
|
||
|
public virtual async Task<PagedResultDto<InspectJobDTO>> GetListAsync(int pageSize, int pageIndex)
|
||
|
{
|
||
|
_ = CurrentUser.Id;
|
||
|
var wlgCodes = await _userWorkGroupAppService.GetCodsOfCurrentUserAsync().ConfigureAwait(false);
|
||
|
var jsonCodes = JsonSerializer.Serialize(wlgCodes);
|
||
|
|
||
|
List<int> status = new List<int>() { (int)EnumJobStatus.Open, (int)EnumJobStatus.Doing };
|
||
|
var jsonStatus = JsonSerializer.Serialize(status);
|
||
|
|
||
|
var request = new SfsJobRequestInputBase
|
||
|
{
|
||
|
MaxResultCount = pageSize,
|
||
|
SkipCount = (pageIndex - 1) * pageSize,
|
||
|
Sorting = $"{nameof(InspectJobDTO.Priority)} ASC",
|
||
|
Condition = new Condition
|
||
|
{
|
||
|
Filters = new List<Filter>
|
||
|
{
|
||
|
new(nameof(InspectJobDTO.WorkGroupCode),jsonCodes,"In"),
|
||
|
new(nameof(InspectJobDTO.JobStatus),jsonStatus,"In")
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var list = await _inspectJobAppService.GetPagedListByFilterAsync(request, true).ConfigureAwait(false);
|
||
|
return list;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取列表 筛选
|
||
|
/// </summary>
|
||
|
/// <param name="sfsRequestDTO"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpPost("list")]
|
||
|
public virtual async Task<PagedResultDto<InspectJobDTO>> GetListAsync(SfsJobRequestInputBase sfsRequestDTO)
|
||
|
{
|
||
|
var list = await _inspectJobAppService.GetPagedListByFilterAsync(sfsRequestDTO, true).ConfigureAwait(false);
|
||
|
return list;
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 获取任务数量
|
||
|
/// </summary>
|
||
|
/// <returns></returns>
|
||
|
[HttpGet("count")]
|
||
|
public virtual async Task<ActionResult<long>> CountAsync()
|
||
|
{
|
||
|
var wlgCodes = await _userWorkGroupAppService.GetCodsOfCurrentUserAsync().ConfigureAwait(false);
|
||
|
var jsonCodes = JsonSerializer.Serialize(wlgCodes);
|
||
|
|
||
|
List<int> status = new List<int>() { (int)EnumJobStatus.Open, (int)EnumJobStatus.Doing };
|
||
|
var jsonStatus = JsonSerializer.Serialize(status);
|
||
|
|
||
|
var request = new SfsJobRequestInputBase
|
||
|
{
|
||
|
Sorting = $"{nameof(InspectJobDTO.Priority)} ASC",
|
||
|
Condition = new Condition
|
||
|
{
|
||
|
Filters = new List<Filter>
|
||
|
{
|
||
|
new(nameof(InspectJobDTO.WorkGroupCode),jsonCodes,"In"),
|
||
|
new(nameof(InspectJobDTO.JobStatus),jsonStatus,"In")
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
var count = await _inspectJobAppService.GetCountByFilterAsync(request).ConfigureAwait(false);
|
||
|
|
||
|
return Ok(count);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 承接任务
|
||
|
/// </summary>
|
||
|
/// <param name="id"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpPost("take/{id}")]
|
||
|
public virtual async Task TakeAsync(Guid id)
|
||
|
{
|
||
|
await _inspectJobAppService.AcceptAsync(id).ConfigureAwait(false);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 取消承接任务
|
||
|
/// </summary>
|
||
|
/// <param name="id"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpPost("cancel-take/{id}")]
|
||
|
public virtual async Task CancelTakeAsync(Guid id)
|
||
|
{
|
||
|
await _inspectJobAppService.CancelAcceptAsync(id).ConfigureAwait(false);
|
||
|
}
|
||
|
|
||
|
/// <summary>
|
||
|
/// 执行任务
|
||
|
/// </summary>
|
||
|
/// <param name="id"></param>
|
||
|
/// <param name="dto"></param>
|
||
|
/// <returns></returns>
|
||
|
[HttpPost("finish/{id}")]
|
||
|
public virtual async Task FinishAsync(Guid id, [FromBody] InspectJobDTO dto)
|
||
|
{
|
||
|
await _inspectJobAppService.CompleteAsync(id, dto).ConfigureAwait(false);
|
||
|
}
|
||
|
}
|