|
@ -1,26 +1,13 @@ |
|
|
using System; |
|
|
using System; |
|
|
using System.Collections.Generic; |
|
|
using System.Collections.Generic; |
|
|
using System.ComponentModel.DataAnnotations; |
|
|
|
|
|
using System.Linq; |
|
|
using System.Linq; |
|
|
using System.Linq.Expressions; |
|
|
|
|
|
using System.Threading; |
|
|
|
|
|
using System.Threading.Tasks; |
|
|
using System.Threading.Tasks; |
|
|
using DocumentFormat.OpenXml.Office.PowerPoint.Y2021.M06.Main; |
|
|
|
|
|
using IdentityModel; |
|
|
|
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Authorization; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
|
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp.Application.Dtos; |
|
|
|
|
|
using Volo.Abp.Domain.Entities; |
|
|
|
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
|
|
using Volo.Abp.ObjectMapping; |
|
|
|
|
|
using Win_in.Sfs.Basedata.Application; |
|
|
|
|
|
using Win_in.Sfs.Basedata.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.Shared.Domain.Shared; |
|
|
using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; |
|
|
using Win_in.Sfs.Shared.Domain.Shared.Enums.Store; |
|
|
using Win_in.Sfs.Shared.Event; |
|
|
|
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
using Win_in.Sfs.Wms.Store.Domain; |
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
|
using Win_in.Sfs.Wms.Store.Domain.Shared; |
|
@ -32,48 +19,37 @@ namespace Win_in.Sfs.Wms.Store.Application; |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
[Authorize] |
|
|
[Authorize] |
|
|
[Route($"{StoreConsts.RootPath}injection-issue-request")] |
|
|
[Route($"{StoreConsts.RootPath}injection-issue-request")] |
|
|
public class InjectionIssueRequestAppService : SfsStoreRequestAppServiceBase<InjectionIssueRequest, InjectionIssueRequestDTO, |
|
|
public class InjectionIssueRequestAppService : SfsStoreRequestAppServiceBase<InjectionIssueRequest, |
|
|
SfsStoreRequestInputBase, InjectionIssueRequestEditInput, InjectionIssueRequestDetail, InjectionIssueRequestDetailDTO, |
|
|
InjectionIssueRequestDTO, |
|
|
|
|
|
SfsStoreRequestInputBase, InjectionIssueRequestEditInput, InjectionIssueRequestDetail, |
|
|
|
|
|
InjectionIssueRequestDetailDTO, |
|
|
SfsStoreRequestInputBase, InjectionIssueRequestImportInput>, |
|
|
SfsStoreRequestInputBase, InjectionIssueRequestImportInput>, |
|
|
IInjectionIssueRequestAppService |
|
|
IInjectionIssueRequestAppService |
|
|
{ |
|
|
{ |
|
|
private readonly IInjectionIssueRequestManager _injectionRequestManager; |
|
|
private readonly IInjectionIssueRequestManager _injectionRequestManager; |
|
|
private readonly IItemStoreRelationAppService _itemStoreRelationApp; |
|
|
|
|
|
private readonly IAreaAppService _areaApp; |
|
|
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
private readonly ILocationAppService _locationAppService; |
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
private readonly IItemContainerAppService _itemContainerAppService; |
|
|
private readonly IItemContainerAppService _itemContainerAppService; |
|
|
private readonly IProductionLineAppService _productionLineAppService; |
|
|
|
|
|
|
|
|
|
|
|
private readonly ITransactionTypeAppService _transactionTypeAppService; |
|
|
private readonly ITransactionTypeAppService _transactionTypeAppService; |
|
|
|
|
|
|
|
|
public InjectionIssueRequestAppService( |
|
|
public InjectionIssueRequestAppService( |
|
|
IInjectionIssueRequestRepository repository, |
|
|
IInjectionIssueRequestRepository repository, |
|
|
IInjectionIssueRequestManager injectionRequestManager, |
|
|
IInjectionIssueRequestManager injectionRequestManager, |
|
|
IPreparationPlanManager preparationPlanManager, |
|
|
|
|
|
IItemStoreRelationAppService itemStoreRelationApp, |
|
|
|
|
|
IAreaAppService areaApp, |
|
|
|
|
|
ILocationAppService locationAppService, |
|
|
ILocationAppService locationAppService, |
|
|
IItemBasicAppService itemBasicAppService, |
|
|
IItemBasicAppService itemBasicAppService, |
|
|
IItemContainerAppService itemContainerAppService, |
|
|
IItemContainerAppService itemContainerAppService, |
|
|
IProductionLineAppService productionLineAppService, |
|
|
|
|
|
ITransactionTypeAppService transactionTypeAppService |
|
|
ITransactionTypeAppService transactionTypeAppService |
|
|
) |
|
|
) |
|
|
: base(repository, injectionRequestManager) |
|
|
: base(repository, injectionRequestManager) |
|
|
{ |
|
|
{ |
|
|
_injectionRequestManager = injectionRequestManager; |
|
|
_injectionRequestManager = injectionRequestManager; |
|
|
_itemStoreRelationApp = itemStoreRelationApp; |
|
|
|
|
|
_areaApp = areaApp; |
|
|
|
|
|
_locationAppService = locationAppService; |
|
|
_locationAppService = locationAppService; |
|
|
_itemBasicAppService = itemBasicAppService; |
|
|
_itemBasicAppService = itemBasicAppService; |
|
|
_itemContainerAppService= itemContainerAppService; |
|
|
_itemContainerAppService = itemContainerAppService; |
|
|
_productionLineAppService = productionLineAppService; |
|
|
|
|
|
_transactionTypeAppService = transactionTypeAppService; |
|
|
_transactionTypeAppService = transactionTypeAppService; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#region 东阳V2
|
|
|
|
|
|
|
|
|
|
|
|
public override async Task<InjectionIssueRequestDTO> HandleAsync(Guid id) |
|
|
public override async Task<InjectionIssueRequestDTO> HandleAsync(Guid id) |
|
|
{ |
|
|
{ |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
|
await Task.CompletedTask.ConfigureAwait(false); |
|
@ -101,7 +77,7 @@ public class InjectionIssueRequestAppService : SfsStoreRequestAppServiceBase<Inj |
|
|
|
|
|
|
|
|
detailInput.ToLocationArea = toLocationDto.AreaCode; |
|
|
detailInput.ToLocationArea = toLocationDto.AreaCode; |
|
|
detailInput.ToLocationGroup = toLocationDto.LocationGroupCode; |
|
|
detailInput.ToLocationGroup = toLocationDto.LocationGroupCode; |
|
|
detailInput.ToWarehouseCode= toLocationDto.WarehouseCode; |
|
|
detailInput.ToWarehouseCode = toLocationDto.WarehouseCode; |
|
|
detailInput.ProdLine = detailInput.ToLocationCode; |
|
|
detailInput.ProdLine = detailInput.ToLocationCode; |
|
|
detailInput.ToLocationErpCode = toLocationDto.ErpLocationCode; |
|
|
detailInput.ToLocationErpCode = toLocationDto.ErpLocationCode; |
|
|
|
|
|
|
|
@ -109,8 +85,9 @@ public class InjectionIssueRequestAppService : SfsStoreRequestAppServiceBase<Inj |
|
|
detailInput.ItemDesc2 = itemBasicDto.Desc2; |
|
|
detailInput.ItemDesc2 = itemBasicDto.Desc2; |
|
|
detailInput.ItemName = itemBasicDto.Name; |
|
|
detailInput.ItemName = itemBasicDto.Name; |
|
|
|
|
|
|
|
|
var itemContainerDto = await _itemContainerAppService.GetListByItemCodeAsync(detailInput.ItemCode).ConfigureAwait(false); |
|
|
var itemContainerDto = await _itemContainerAppService.GetListByItemCodeAsync(detailInput.ItemCode) |
|
|
if(itemContainerDto.Count>0) |
|
|
.ConfigureAwait(false); |
|
|
|
|
|
if (itemContainerDto.Count > 0) |
|
|
{ |
|
|
{ |
|
|
detailInput.Uom = itemContainerDto[0].BasicUom; |
|
|
detailInput.Uom = itemContainerDto[0].BasicUom; |
|
|
detailInput.Qty = itemContainerDto[0].Qty; |
|
|
detailInput.Qty = itemContainerDto[0].Qty; |
|
@ -146,7 +123,8 @@ public class InjectionIssueRequestAppService : SfsStoreRequestAppServiceBase<Inj |
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
private async Task SetRequestAutoPropertiesAsync(InjectionIssueRequestEditInput entity) |
|
|
private async Task SetRequestAutoPropertiesAsync(InjectionIssueRequestEditInput entity) |
|
|
{ |
|
|
{ |
|
|
var tranType = await _transactionTypeAppService.GetByTransTypeAsync(EnumTransType.Issue, EnumTransSubType.None).ConfigureAwait(false); |
|
|
var tranType = await _transactionTypeAppService.GetByTransTypeAsync(EnumTransType.Issue, EnumTransSubType.None) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
Check.NotNull(tranType, "事务类型", "事务类型不存在"); |
|
|
Check.NotNull(tranType, "事务类型", "事务类型不存在"); |
|
|
entity.AutoSubmit = tranType.AutoSubmitRequest; |
|
|
entity.AutoSubmit = tranType.AutoSubmitRequest; |
|
|
entity.AutoAgree = tranType.AutoAgreeRequest; |
|
|
entity.AutoAgree = tranType.AutoAgreeRequest; |
|
@ -178,113 +156,39 @@ public class InjectionIssueRequestAppService : SfsStoreRequestAppServiceBase<Inj |
|
|
return entities; |
|
|
return entities; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 导入
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// 用来重写 导入数据时可以加工数据
|
|
|
/// 获取已完成的叫料单数量
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="dictionary"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
protected override async Task<Dictionary<InjectionIssueRequest, EntityState>> ImportProcessingEntityAsync( |
|
|
[HttpPost("get-uncompleted-request")] |
|
|
Dictionary<InjectionIssueRequest, EntityState> dictionary) |
|
|
public async Task<List<UnCompletedRequestDto>> GetUnCompletedRequestAsync(List<UnCompletedRequestDto> p_list) |
|
|
{ |
|
|
{ |
|
|
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); |
|
|
var returnList = new List<UnCompletedRequestDto>(); |
|
|
|
|
|
//枚举类型查不到改成SQL查询
|
|
|
foreach (var injectionRequest in addList) |
|
|
var list = await _repository.GetListAsync(p => |
|
|
|
|
|
p.RequestStatus != EnumRequestStatus.Completed && p.IssueRequestType == EnumIssueRequestType.Vision) |
|
|
|
|
|
.ConfigureAwait(false); |
|
|
|
|
|
foreach (var itm in list) |
|
|
{ |
|
|
{ |
|
|
injectionRequest.Worker = CurrentUser.GetUserName(); |
|
|
var query = from detail in itm.Details |
|
|
injectionRequest.CreatorId = CurrentUser.Id; |
|
|
join citm in p_list on new |
|
|
if (injectionRequest.Type == EnumTransSubType.Issue_Manual.GetDisplayName()) |
|
|
|
|
|
{ |
|
|
{ |
|
|
injectionRequest.Type = EnumTransSubType.Issue_Manual.ToString(); |
|
|
detail.ItemCode, locCode = detail.ToLocationCode, areaCode = detail.PositionCode |
|
|
} |
|
|
} equals |
|
|
|
|
|
new { citm.ItemCode, locCode = citm.LocCode, areaCode = citm.PositionCode } |
|
|
foreach (var detail in injectionRequest.Details) |
|
|
select new UnCompletedRequestDto |
|
|
{ |
|
|
{ |
|
|
var locationDto = await _locationAppService.GetByCodeAsync(detail.ToLocationCode).ConfigureAwait(false); |
|
|
ItemCode = detail.ItemCode, LocCode = detail.ToLocationCode, PositionCode = detail.PositionCode |
|
|
CheckLocation(locationDto, detail.ToLocationCode); |
|
|
}; |
|
|
|
|
|
|
|
|
var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
returnList.AddRange(query.ToList()); |
|
|
CheckItemBasic(itemBasicDto, detail.ItemCode); |
|
|
|
|
|
|
|
|
|
|
|
detail.ToLocationArea = locationDto.AreaCode; |
|
|
|
|
|
detail.ToLocationErpCode = locationDto.ErpLocationCode; |
|
|
|
|
|
detail.ToLocationGroup = locationDto.LocationGroupCode; |
|
|
|
|
|
detail.ToWarehouseCode = locationDto.WarehouseCode; |
|
|
|
|
|
detail.ItemDesc1 = itemBasicDto.Desc1; |
|
|
|
|
|
detail.ItemDesc2 = itemBasicDto.Desc2; |
|
|
|
|
|
detail.ItemName = itemBasicDto.Name; |
|
|
|
|
|
detail.Uom = itemBasicDto.BasicUom; |
|
|
|
|
|
detail.StdPackQty = itemBasicDto.StdPackQty; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return dictionary; |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
return returnList; |
|
|
/// 导入验证
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="model"></param>
|
|
|
|
|
|
/// <param name="validationRresult"></param>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
protected override async Task ValidateImportModelAsync(InjectionIssueRequestImportInput model, |
|
|
|
|
|
List<ValidationResult> validationRresult) |
|
|
|
|
|
{ |
|
|
|
|
|
_ = new Dictionary<string, string>(); |
|
|
|
|
|
_ = await CheckItemBasicAsync(model, validationRresult).ConfigureAwait(false); |
|
|
|
|
|
_ = await CheckLocationAsync(model, validationRresult).ConfigureAwait(false); |
|
|
|
|
|
await CheckAreaAsync(model, validationRresult).ConfigureAwait(false); |
|
|
|
|
|
await CheckStoreRelationAsync(model, validationRresult).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 校验
|
|
|
#region 校验
|
|
|
|
|
|
|
|
|
protected override async Task<bool> ValidateImportEntities(Dictionary<InjectionIssueRequest, EntityState> dict) |
|
|
|
|
|
{ |
|
|
|
|
|
foreach (var entity in dict.Keys) |
|
|
|
|
|
{ |
|
|
|
|
|
var tranType = await TransactionTypeAclService |
|
|
|
|
|
.GetByTransTypeAsync(EnumTransType.Issue, EnumTransSubType.None).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
Check.NotNull(tranType, "事务类型", "事务类型不存在"); |
|
|
|
|
|
|
|
|
|
|
|
entity.AutoCompleteJob = tranType.AutoCompleteJob; |
|
|
|
|
|
entity.AutoSubmit = tranType.AutoSubmitRequest; |
|
|
|
|
|
entity.AutoAgree = tranType.AutoAgreeRequest; |
|
|
|
|
|
entity.AutoHandle = tranType.AutoHandleRequest; |
|
|
|
|
|
entity.DirectCreateNote = tranType.DirectCreateNote; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return await base.ValidateImportEntities(dict).ConfigureAwait(false); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected async Task CheckAreaAsync(InjectionIssueRequestImportInput importInput, |
|
|
|
|
|
List<ValidationResult> validationRresult) |
|
|
|
|
|
{ |
|
|
|
|
|
var area = await _areaApp.GetByCodeAsync(importInput.FromLocationArea).ConfigureAwait(false); |
|
|
|
|
|
if (area == null) |
|
|
|
|
|
{ |
|
|
|
|
|
validationRresult.Add(new ValidationResult($"调出库区{importInput.FromLocationArea}不存在", new[] { "调出库区" })); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected async Task CheckStoreRelationAsync(InjectionIssueRequestImportInput importInput, |
|
|
|
|
|
List<ValidationResult> validationRresult) |
|
|
|
|
|
{ |
|
|
|
|
|
var itemStoreRelation = await _itemStoreRelationApp |
|
|
|
|
|
.GetFirstAsync(importInput.ItemCode, importInput.ToLocationCode).ConfigureAwait(false); |
|
|
|
|
|
if (itemStoreRelation == null) |
|
|
|
|
|
{ |
|
|
|
|
|
validationRresult.Add(new ValidationResult( |
|
|
|
|
|
$"物品代码{importInput.ItemCode}与目标库位{importInput.ToLocationCode}不存在对应关", new[] { "物品库位对应关系" })); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void CheckItemBasic(ItemBasicDTO itemBasicDto, string itemCode) |
|
|
private void CheckItemBasic(ItemBasicDTO itemBasicDto, string itemCode) |
|
|
{ |
|
|
{ |
|
|
if (itemBasicDto == null) |
|
|
if (itemBasicDto == null) |
|
@ -306,78 +210,5 @@ public class InjectionIssueRequestAppService : SfsStoreRequestAppServiceBase<Inj |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
protected async Task<ItemBasicDTO> CheckItemBasicAsync(InjectionIssueRequestImportInput importInput, |
|
|
|
|
|
List<ValidationResult> validationRresult) |
|
|
|
|
|
{ |
|
|
|
|
|
var item = await _itemBasicAppService.GetByCodeAsync(importInput.ItemCode).ConfigureAwait(false); |
|
|
|
|
|
if (item == null) |
|
|
|
|
|
{ |
|
|
|
|
|
validationRresult.Add(new ValidationResult($"物品代码{importInput.ItemCode}不存在", new[] { "物品代码" })); |
|
|
|
|
|
} |
|
|
|
|
|
else if (item.StdPackQty == 0) |
|
|
|
|
|
{ |
|
|
|
|
|
validationRresult.Add( |
|
|
|
|
|
new ValidationResult($"物品代码{importInput.ItemCode}的物品信息中标准包装等于0或不存在", new[] { "标准包装" })); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return item; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
protected async Task<LocationDTO> CheckLocationAsync(InjectionIssueRequestImportInput importInput, |
|
|
|
|
|
List<ValidationResult> validationRresult) |
|
|
|
|
|
{ |
|
|
|
|
|
var location = await _locationAppService.GetByCodeAsync(importInput.ToLocationCode).ConfigureAwait(false); |
|
|
|
|
|
if (location == null) |
|
|
|
|
|
{ |
|
|
|
|
|
validationRresult.Add(new ValidationResult($"目标库位{importInput.ToLocationCode}不存在", new[] { "目标库位" })); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return location; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取已完成的叫料单数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpGet("get-completed-injection-request-count")] |
|
|
|
|
|
public async Task<long> GetCountAsync() |
|
|
|
|
|
{ |
|
|
|
|
|
//枚举类型查不到改成SQL查询
|
|
|
|
|
|
var query =await _repository.GetCountAsync(p => p.RequestStatus != EnumRequestStatus.Completed |
|
|
|
|
|
&&p.Type==nameof(EnumIssueType.Vision)).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
return query; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 获取已完成的叫料单数量
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
[HttpPost("get-uncompleted-request")] |
|
|
|
|
|
public async Task<List<UnCompletedRequestDto>> GetUnCompletedRequestAsync(List<UnCompletedRequestDto> p_list) |
|
|
|
|
|
{ |
|
|
|
|
|
List<UnCompletedRequestDto> returnList = new List<UnCompletedRequestDto>(); |
|
|
|
|
|
//枚举类型查不到改成SQL查询
|
|
|
|
|
|
var list =await _repository.WithDetails().Where(p => p.RequestStatus != EnumRequestStatus.Completed && p.Type == nameof(EnumIssueType.Vision)).ToListAsync().ConfigureAwait(false); |
|
|
|
|
|
foreach (var itm in list) |
|
|
|
|
|
{ |
|
|
|
|
|
var query = from detail in itm.Details join citm in p_list on new { detail.ItemCode, locCode= detail.ToLocationCode,areaCode=detail.PositionCode } equals |
|
|
|
|
|
new { citm.ItemCode, locCode= citm.LocCode,areaCode=citm.PositionCode } |
|
|
|
|
|
select new UnCompletedRequestDto { ItemCode = detail.ItemCode, LocCode = detail.ToLocationCode, PositionCode = detail.PositionCode } ; |
|
|
|
|
|
|
|
|
|
|
|
returnList.AddRange(query.ToList()); |
|
|
|
|
|
} |
|
|
|
|
|
return returnList; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|
} |
|
|
} |
|
|