|
@ -7,6 +7,8 @@ using Microsoft.AspNetCore.Mvc; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp; |
|
|
using Volo.Abp.Domain.Repositories; |
|
|
using Volo.Abp.Domain.Repositories; |
|
|
|
|
|
using Win_in.Sfs.Basedata.Application.Contracts; |
|
|
|
|
|
using Win_in.Sfs.Shared.Application.Contracts; |
|
|
using Win_in.Sfs.Shared.Domain; |
|
|
using Win_in.Sfs.Shared.Domain; |
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
using Win_in.Sfs.Shared.Domain.Shared; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
|
using Win_in.Sfs.Wms.Store.Application.Contracts; |
|
@ -27,14 +29,18 @@ public class CountNoteAppService : |
|
|
{ |
|
|
{ |
|
|
private readonly ICountNoteManager _countNoteManager; |
|
|
private readonly ICountNoteManager _countNoteManager; |
|
|
private readonly ICountPlanAppService _countPlanAppService; |
|
|
private readonly ICountPlanAppService _countPlanAppService; |
|
|
|
|
|
private readonly ILocationAppService _locationAppService; |
|
|
|
|
|
private readonly IItemBasicAppService _itemBasicAppService; |
|
|
|
|
|
|
|
|
public CountNoteAppService( |
|
|
public CountNoteAppService( |
|
|
ICountNoteRepository repository, |
|
|
ICountNoteRepository repository, |
|
|
|
|
|
|
|
|
ICountNoteManager countNoteManager, ICountPlanAppService countPlanAppService) : base(repository) |
|
|
ICountNoteManager countNoteManager, ICountPlanAppService countPlanAppService, ILocationAppService locationAppService, IItemBasicAppService itemBasicAppService) : base(repository) |
|
|
{ |
|
|
{ |
|
|
_countNoteManager = countNoteManager; |
|
|
_countNoteManager = countNoteManager; |
|
|
_countPlanAppService = countPlanAppService; |
|
|
_countPlanAppService = countPlanAppService; |
|
|
|
|
|
_locationAppService = locationAppService; |
|
|
|
|
|
_itemBasicAppService = itemBasicAppService; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#region 东阳
|
|
|
#region 东阳
|
|
@ -44,20 +50,25 @@ public class CountNoteAppService : |
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <param name="dictionary"></param>
|
|
|
/// <param name="dictionary"></param>
|
|
|
/// <returns></returns>
|
|
|
/// <returns></returns>
|
|
|
protected async override Task<Dictionary<CountNote, EntityState>> ImportProcessingEntityAsync(Dictionary<CountNote, EntityState> dictionary) |
|
|
protected override async Task<Dictionary<CountNote, EntityState>> ImportProcessingEntityAsync(Dictionary<CountNote, EntityState> dictionary) |
|
|
{ |
|
|
{ |
|
|
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key); |
|
|
var dataList = dictionary.Select(p => p.Key);//查询所有的导入盘点数据
|
|
|
|
|
|
var resultDictionary = new Dictionary<CountNote, EntityState>(); |
|
|
|
|
|
|
|
|
foreach (var countNote in addList) |
|
|
var allCountPlanNumbersList= dataList.GroupBy(p => p.CountPlanNumber).Select(p => p.Key).ToList(); |
|
|
|
|
|
//特殊处理 因为盘点记录可以重复导入 所以每次导入前删除调原有记录
|
|
|
|
|
|
foreach (var countPlanNumber in allCountPlanNumbersList) |
|
|
{ |
|
|
{ |
|
|
var countPlanDto=await _countPlanAppService.GetByNumberAsync(countNote.CountPlanNumber).ConfigureAwait(false); |
|
|
var countPlanDto = await _countPlanAppService.GetByNumberAsync(countPlanNumber).ConfigureAwait(false); |
|
|
if (countPlanDto.RequestType != CountPlanRequestType.Import) |
|
|
if (countPlanDto.RequestType != CountPlanRequestType.Import) |
|
|
{ |
|
|
{ |
|
|
throw new UserFriendlyException("非Excel盘点执行方式不能使用导入"); |
|
|
throw new UserFriendlyException("非Excel盘点执行方式不能使用导入"); |
|
|
} |
|
|
} |
|
|
//特殊处理 因为盘点记录可以重复导入 所以每次导入前删除调原有记录
|
|
|
await _repository.DeleteAsync(p => p.CountPlanNumber == countPlanNumber).ConfigureAwait(false); |
|
|
//_repository.DeleteAsync(p=>p.CountPlanNumber==CountPlan)
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
foreach (var countNote in dataList) |
|
|
|
|
|
{ |
|
|
countNote.Worker = CurrentUser.GetUserName(); |
|
|
countNote.Worker = CurrentUser.GetUserName(); |
|
|
countNote.CreatorId = CurrentUser.Id; |
|
|
countNote.CreatorId = CurrentUser.Id; |
|
|
countNote.BeginTime= DateTime.Now; |
|
|
countNote.BeginTime= DateTime.Now; |
|
@ -65,13 +76,29 @@ public class CountNoteAppService : |
|
|
countNote.EndTime=DateTime.Now; |
|
|
countNote.EndTime=DateTime.Now; |
|
|
countNote.Stage = EnumCountStage.Audit; |
|
|
countNote.Stage = EnumCountStage.Audit; |
|
|
|
|
|
|
|
|
//foreach (var detail in purchaseReturnRequest.Details)
|
|
|
foreach (var detail in countNote.Details) |
|
|
//{
|
|
|
{ |
|
|
|
|
|
var locationDto= await _locationAppService.GetByCodeAsync(detail.LocationCode).ConfigureAwait(false); |
|
|
//}
|
|
|
var itemcBasicDto=await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detail.CountLabel =Guid.NewGuid().ToString(); |
|
|
|
|
|
detail.LocationArea = locationDto.AreaCode; |
|
|
|
|
|
detail.LocationGroup= locationDto.LocationGroupCode; |
|
|
|
|
|
detail.LocationErpCode= locationDto.ErpLocationCode; |
|
|
|
|
|
detail.WarehouseCode= locationDto.WarehouseCode; |
|
|
|
|
|
|
|
|
|
|
|
detail.ItemCode = itemcBasicDto.Code; |
|
|
|
|
|
detail.ItemDesc1 = itemcBasicDto.Desc1; |
|
|
|
|
|
detail.ItemDesc2 = itemcBasicDto.Desc2; |
|
|
|
|
|
detail.ItemName= itemcBasicDto.Name; |
|
|
|
|
|
detail.Uom = itemcBasicDto.BasicUom; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
resultDictionary.Add(countNote,EntityState.Added); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return dictionary; |
|
|
return resultDictionary; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
#endregion
|
|
|
#endregion
|
|
|