39 changed files with 537 additions and 45 deletions
@ -0,0 +1,204 @@ |
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
using System.Text.Json; |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Polly.Caching; |
|||
using Volo.Abp; |
|||
using Volo.Abp.Application.Dtos; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Win_in.Sfs.Auth.Application.Contracts; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
using Win_in.Sfs.Shared.Domain; |
|||
using Win_in.Sfs.Shared.Domain.Shared; |
|||
using Win_in.Sfs.Wms.Inventory.Application.Contracts; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.Pda.Controllers.Jobs; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
[ApiController] |
|||
[Route($"{PdaHostConst.ROOT_ROUTE}job/third-location")] |
|||
public class ThirdLocationJobController : AbpController |
|||
{ |
|||
private readonly IThirdLocationJobAppService _thirdLocationJobAppService; |
|||
|
|||
private readonly IUserWorkGroupAppService _userWorkGroupAppService; |
|||
|
|||
private readonly IDictAppService _dictApp; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="thirdLocationJobAppService"></param>
|
|||
/// <param name="userWorkGroupAppService"></param>
|
|||
public ThirdLocationJobController( |
|||
IThirdLocationJobAppService thirdLocationJobAppService, |
|||
IDictAppService dictApp |
|||
, IUserWorkGroupAppService userWorkGroupAppService) |
|||
{ |
|||
_userWorkGroupAppService = userWorkGroupAppService; |
|||
_thirdLocationJobAppService = thirdLocationJobAppService; |
|||
_dictApp = dictApp; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取任务详情
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <returns></returns>
|
|||
[HttpGet("{id}")] |
|||
|
|||
public virtual async Task<ActionResult<ThirdLocationJobDTO>> GetAsync(Guid id) |
|||
{ |
|||
var result = await _thirdLocationJobAppService.GetAsync(id).ConfigureAwait(false); |
|||
return Ok(result); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取列表 筛选
|
|||
/// </summary>
|
|||
/// <param name="sfsRequestDTO"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost("list")] |
|||
public virtual async Task<PagedResultDto<ThirdLocationJobDTO>> GetListAsync(SfsJobRequestInputBase sfsRequestDTO) |
|||
{ |
|||
var list = await _thirdLocationJobAppService.GetPagedListByFilterAsync(sfsRequestDTO, true).ConfigureAwait(false); |
|||
return list; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 获取列表
|
|||
/// </summary>
|
|||
/// <param name="pageSize"></param>
|
|||
/// <param name="pageIndex"></param>
|
|||
/// <returns></returns>
|
|||
[HttpGet("list")] |
|||
public virtual async Task<PagedResultDto<ThirdLocationJobDTO>> GetListAsync(int pageSize, int pageIndex, bool isFinished) |
|||
{ |
|||
var dtos = await _dictApp.GetByCodeAsync("ContainerSpecificationsType").ConfigureAwait(false); |
|||
|
|||
var status = new List<int>(); |
|||
if (isFinished == true) |
|||
{ |
|||
status.Add((int)EnumJobStatus.Done); |
|||
} |
|||
else |
|||
{ |
|||
status.Add((int)EnumJobStatus.Open); |
|||
} |
|||
var jsonStatus = JsonSerializer.Serialize(status); |
|||
|
|||
var request = new SfsJobRequestInputBase |
|||
{ |
|||
MaxResultCount = pageSize, |
|||
SkipCount = (pageIndex - 1) * pageSize, |
|||
Sorting = $"{nameof(ThirdLocationJobDTO.CreationTime)} ASC", |
|||
Condition = new Condition |
|||
{ |
|||
Filters = new List<Filter> |
|||
{ |
|||
new(nameof(ThirdLocationJobDTO.JobStatus),jsonStatus,"In") |
|||
} |
|||
} |
|||
}; |
|||
|
|||
var list = await _thirdLocationJobAppService.GetPagedListByFilterAsync(request, true).ConfigureAwait(false); |
|||
|
|||
|
|||
return list; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 根据Job Number 获取任务列表
|
|||
/// </summary>
|
|||
/// <param name="jobNumber"></param>
|
|||
/// <returns></returns>
|
|||
[HttpGet("by-number/{jobNumber}")] |
|||
public virtual async Task<ActionResult<ThirdLocationJobDTO>> GetByNumberAsync(string jobNumber) |
|||
{ |
|||
var jobDto = await _thirdLocationJobAppService.GetByNumberAsync(jobNumber).ConfigureAwait(false); |
|||
if (jobDto == null) |
|||
{ |
|||
throw new UserFriendlyException($"未找到编号为 {jobNumber} 的任务"); |
|||
} |
|||
var wlgCodes = await _userWorkGroupAppService.GetCodsOfCurrentUserAsync().ConfigureAwait(false); |
|||
if (!wlgCodes.Contains(jobDto.WorkGroupCode)) |
|||
{ |
|||
return new NotFoundObjectResult($"任务属于工作组 {jobDto.WorkGroupCode}"); |
|||
} |
|||
if (jobDto.JobStatus == EnumJobStatus.Doing && jobDto.AcceptUserId != CurrentUser.Id) |
|||
{ |
|||
return new NotFoundObjectResult($"任务正在被 {jobDto.AcceptUserName} 处理"); |
|||
} |
|||
return jobDto; |
|||
} |
|||
|
|||
/// <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); |
|||
|
|||
var status = new List<int>() { (int)EnumJobStatus.Open, (int)EnumJobStatus.Doing }; |
|||
var jsonStatus = JsonSerializer.Serialize(status); |
|||
|
|||
var request = new SfsJobRequestInputBase |
|||
{ |
|||
Sorting = $"{nameof(ThirdLocationJobDTO.Priority)} ASC", |
|||
Condition = new Condition |
|||
{ |
|||
Filters = new List<Filter> |
|||
{ |
|||
new(nameof(ThirdLocationJobDTO.WorkGroupCode),jsonCodes,"In"), |
|||
new(nameof(ThirdLocationJobDTO.JobStatus),jsonStatus,"In") |
|||
} |
|||
} |
|||
}; |
|||
|
|||
var count = await _thirdLocationJobAppService.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 _thirdLocationJobAppService.AcceptAsync(id).ConfigureAwait(false); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 取消承接任务
|
|||
/// </summary>
|
|||
/// <param name="id"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost("cancel-take/{id}")] |
|||
public virtual async Task CancelTakeAsync(Guid id) |
|||
{ |
|||
await _thirdLocationJobAppService.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] ThirdLocationJobDTO dto) |
|||
{ |
|||
await _thirdLocationJobAppService.CompleteAsync(id, dto).ConfigureAwait(false); |
|||
} |
|||
} |
@ -0,0 +1,38 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.Pda.Controllers.Stores; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
[ApiController] |
|||
[Route($"{PdaHostConst.ROOT_ROUTE}store/third-location-note")] |
|||
|
|||
public class ThirdLocationNoteController : AbpController |
|||
{ |
|||
private readonly IThirdLocationNoteAppService _thirdLocationNoteAppService; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="thirdLocationNoteAppService"></param>
|
|||
public ThirdLocationNoteController(IThirdLocationNoteAppService thirdLocationNoteAppService) |
|||
{ |
|||
_thirdLocationNoteAppService = thirdLocationNoteAppService; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 创建器具转移记录
|
|||
/// </summary>
|
|||
/// <param name="input">CreateInput</param>
|
|||
/// <returns></returns>
|
|||
[HttpPost("")] |
|||
public virtual async Task CreateAsync(ThirdLocationNoteEditInput input) |
|||
{ |
|||
await _thirdLocationNoteAppService.CreateAsync(input).ConfigureAwait(false); |
|||
} |
|||
|
|||
} |
@ -0,0 +1,51 @@ |
|||
using System.Threading.Tasks; |
|||
using Microsoft.AspNetCore.Mvc; |
|||
using Volo.Abp.AspNetCore.Mvc; |
|||
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.Pda.Controllers.Stores; |
|||
|
|||
/// <summary>
|
|||
///三方库库移请求
|
|||
/// </summary>
|
|||
[ApiController] |
|||
[Route($"{PdaHostConst.ROOT_ROUTE}store/third-location-request")] |
|||
|
|||
public class ThirdLocationRequestController : AbpController |
|||
{ |
|||
private readonly IThirdLocationRequestAppService _thirdLocationRequestAppService; |
|||
|
|||
/// <summary>
|
|||
///
|
|||
/// </summary>
|
|||
/// <param name="ThirdLocationRequestAppService"></param>
|
|||
public ThirdLocationRequestController(IThirdLocationRequestAppService ThirdLocationRequestAppService) |
|||
{ |
|||
_thirdLocationRequestAppService = ThirdLocationRequestAppService; |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 三方库库移申请
|
|||
/// </summary>
|
|||
/// <param name="input"></param>
|
|||
/// <returns></returns>
|
|||
[HttpPost("")] |
|||
public virtual async Task CreateAsync(ThirdLocationRequestEditInput input) |
|||
{ |
|||
_ = await _thirdLocationRequestAppService.CreateAsync(input).ConfigureAwait(false); |
|||
} |
|||
|
|||
/// <summary>
|
|||
/// 根据number获取三方库库移申请详情
|
|||
/// </summary>
|
|||
/// <param name="number"></param>
|
|||
/// <returns></returns>
|
|||
[HttpGet("{number}")] |
|||
|
|||
public virtual async Task<ActionResult<ThirdLocationRequestDTO>> GetAsync(string number) |
|||
{ |
|||
var result = await _thirdLocationRequestAppService.GetByNumberAsync(number).ConfigureAwait(false); |
|||
return Ok(result); |
|||
} |
|||
|
|||
} |
@ -1,9 +1,10 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.Inventory.Domain.Acl.ErpLocationItem; |
|||
public interface IErpLocationItemAclService |
|||
public interface IErpLocationItemAclService : ITransientDependency |
|||
{ |
|||
Task<ErpLocationItemDTO> GetFirstAsync(string itemCode, string locationCode); |
|||
} |
|||
|
@ -0,0 +1,36 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.Caching; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
using Win_in.Sfs.Shared.Application; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Domain.Acl.ErpLocationItem; |
|||
public class ErpLocationItemAclService |
|||
: AclServiceBase, IErpLocationItemAclService |
|||
{ |
|||
private readonly IErpLocationItemAppService _appService; |
|||
private readonly IDistributedCache<ErpLocationItemDTO> _cache; |
|||
|
|||
public ErpLocationItemAclService( |
|||
IErpLocationItemAppService appService |
|||
, IDistributedCache<ErpLocationItemDTO> cache |
|||
) |
|||
{ |
|||
_appService = appService; |
|||
_cache = cache; |
|||
} |
|||
|
|||
public virtual async Task<ErpLocationItemDTO> GetFirstAsync(string itemCode, string locationCode) |
|||
{ |
|||
var dto = await _cache.GetOrAddItemAsync( |
|||
$"{itemCode}:{locationCode}", |
|||
async () => await GetFromAppServiceAsync(itemCode, locationCode).ConfigureAwait(false), |
|||
CacheMinutes).ConfigureAwait(false); |
|||
return dto; |
|||
} |
|||
|
|||
private async Task<ErpLocationItemDTO> GetFromAppServiceAsync(string itemCode, string locationCode) |
|||
{ |
|||
return await _appService.CheckItemErpLocationIsAvailable(itemCode, locationCode).ConfigureAwait(false); |
|||
} |
|||
} |
@ -0,0 +1,10 @@ |
|||
using System.Collections.Generic; |
|||
using System.Threading.Tasks; |
|||
using Volo.Abp.DependencyInjection; |
|||
using Win_in.Sfs.Basedata.Application.Contracts; |
|||
|
|||
namespace Win_in.Sfs.Wms.Store.Domain.Acl.ErpLocationItem; |
|||
public interface IErpLocationItemAclService : ITransientDependency |
|||
{ |
|||
Task<ErpLocationItemDTO> GetFirstAsync(string itemCode, string locationCode); |
|||
} |
Loading…
Reference in new issue