Browse Source

成品发运添加导入功能

dev_DY_CC
lvzb 11 months ago
parent
commit
34ad4c38d5
  1. 45
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs
  2. 49
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs
  3. 103
      be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs

45
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs

@ -1,16 +1,25 @@
using System;
using System.ComponentModel.DataAnnotations;
using Win_in.Sfs.Shared.Domain.Shared;
namespace Win_in.Sfs.Wms.Store.Application.Contracts;
[Display(Name = "发货申请")]
public class DeliverRequestImportInput : SfsStoreImportInputBase
{
/// <summary>
/// 发货类型
/// </summary>
[Display(Name = "发货类型")]
[Required]
[Key]
public EnumDeliverRequestType DeliverRequestType { get; set; }
/// <summary>
/// 发货时间
/// </summary>
[Display(Name = "发货时间")]
[Required]
[Key]
public DateTime DeliverTime { get; set; }
/// <summary>
@ -18,6 +27,7 @@ public class DeliverRequestImportInput : SfsStoreImportInputBase
/// </summary>
[Display(Name = "客户")]
[Required]
[Key]
public string CustomerCode { get; set; }
/// <summary>
@ -62,11 +72,11 @@ public class DeliverRequestImportInput : SfsStoreImportInputBase
public class DeliverRequestFisImportInput : SfsStoreImportInputBase
{
/// <summary>
/// 发货时间
/// 发货类型
/// </summary>
[Display(Name = "发货时间")]
[Display(Name = "发货类型")]
[Required]
public DateTime DeliverTime { get; set; }
public EnumDeliverRequestType DeliverRequestType { get; set; }
/// <summary>
/// 客户
@ -74,7 +84,12 @@ public class DeliverRequestFisImportInput : SfsStoreImportInputBase
[Display(Name = "客户")]
[Required]
public string CustomerCode { get; set; }
/// <summary>
/// 发货时间
/// </summary>
[Display(Name = "发货时间")]
[Required]
public DateTime DeliverTime { get; set; }
/// <summary>
/// ERP料号
/// </summary>
@ -102,11 +117,19 @@ public class DeliverRequestFisImportInput : SfsStoreImportInputBase
[Display(Name = "订单号")]
[Required]
public string FromVinCode { get; set; }
///// <summary>
///// 截止底盘号
///// </summary>
//[Display(Name = "截止底盘号")]
//[Required]
//public string ToVinCode { get; set; }
/// <summary>
/// Mes发货单号
/// </summary>
[Display(Name = "Mes发货单号")]
public string MesDeliveryNo { get; set; }
/// <summary>
/// Mes发货计划号
/// </summary>
[Display(Name = "Mes发货计划号")]
public string MesDeliveryPlan { get; set; }
/// <summary>
/// 底盘号
/// </summary>
[Display(Name = "底盘号")]
public string IdentityNo { get; set; }
}

49
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs

@ -32,6 +32,7 @@ public class PutawayNoteAppService :
public readonly IPurchaseOrderManager _purchaseOrderManager;
public readonly IPurchasePriceSheetAppService _purchasePriceSheetAppService;
public readonly IErpLocationItemAppService _erpLocationItemAppService;
public readonly IItemBasicAppService _itemBasicAppService;
public PutawayNoteAppService(
IPutawayNoteRepository repository,
@ -40,14 +41,16 @@ public class PutawayNoteAppService :
IInspectJobAppService inspectJobAppService,
IPurchaseOrderManager purchaseOrderManager,
IPurchasePriceSheetAppService purchasePriceSheetAppService,
IErpLocationItemAppService erpLocationItemAppService) : base(repository)
IErpLocationItemAppService erpLocationItemAppService,
IItemBasicAppService itemBasicAppService) : base(repository)
{
_putawayNoteManager = putawayNoteManager;
_purchaseReceiptNoteAppService = purchaseReceiptNoteAppService;
_inspectJobAppService = inspectJobAppService;
_purchaseOrderManager = purchaseOrderManager;
_purchasePriceSheetAppService = purchasePriceSheetAppService;
_erpLocationItemAppService= erpLocationItemAppService;
_erpLocationItemAppService = erpLocationItemAppService;
_itemBasicAppService = itemBasicAppService;
}
/// <summary>
@ -61,33 +64,37 @@ public class PutawayNoteAppService :
{
foreach (var detail in input.Details)
{
var isClosed = await _purchaseOrderManager.CheckIsCloseAsync(input.Number,input.SupplierCode, detail.ItemCode).ConfigureAwait(false);
if (isClosed)
{
throw new UserFriendlyException($"物品名称【{detail.ItemCode}】的订单明细行以关闭无法执行采购上架!");
}
var isClosed = await _purchaseOrderManager.CheckIsCloseAsync(input.Number, input.SupplierCode, detail.ItemCode).ConfigureAwait(false);
if (isClosed)
{
throw new UserFriendlyException($"物品名称【{detail.ItemCode}】的订单明细行以关闭无法执行采购上架!");
}
var item = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false);
if (!item.CanMake)
{
var isprice = await _purchasePriceSheetAppService.CheckPurPriceAsync(input.SupplierCode, detail.ItemCode).ConfigureAwait(false);
if (isprice)
{
throw new UserFriendlyException($"供应商【{input.SupplierCode}】物品名称【{detail.ItemCode}】无采购价格无法执行采购上架!");
}
var erpLocationItem = await _erpLocationItemAppService.CheckItemErpLocationIsAvailable(detail.ItemCode, detail.ToLocationErpCode).ConfigureAwait(false);
}
var erpLocationItem = await _erpLocationItemAppService.CheckItemErpLocationIsAvailable(detail.ItemCode, detail.ToLocationErpCode).ConfigureAwait(false);
if (erpLocationItem == null)
{
throw new UserFriendlyException($"未找到物品【{detail.ItemCode}】与ERP储位【{detail.ToLocationErpCode}】的开账信息");
}
var purchasereDetail = await _purchaseReceiptNoteAppService
.GetDetailByItemAndPackingAsync(detail.ItemCode, detail.ToPackingCode).ConfigureAwait(false);
if (purchasereDetail != null)
if (erpLocationItem == null)
{
throw new UserFriendlyException($"未找到物品【{detail.ItemCode}】与ERP储位【{detail.ToLocationErpCode}】的开账信息");
}
var purchasereDetail = await _purchaseReceiptNoteAppService
.GetDetailByItemAndPackingAsync(detail.ItemCode, detail.ToPackingCode).ConfigureAwait(false);
if (purchasereDetail != null)
{
var inspectJobDto = await _inspectJobAppService
.GetInspectNoteDetailByPackingCodeAsync(detail.ToPackingCode).ConfigureAwait(false);
if (inspectJobDto.JobStatus != EnumJobStatus.Done)
{
var inspectJobDto = await _inspectJobAppService
.GetInspectNoteDetailByPackingCodeAsync(detail.ToPackingCode).ConfigureAwait(false);
if (inspectJobDto.JobStatus != EnumJobStatus.Done)
{
throw new UserFriendlyException($"包含【{detail.ToPackingCode}】箱码的报检单,尚未完成质检");
}
throw new UserFriendlyException($"包含【{detail.ToPackingCode}】箱码的报检单,尚未完成质检");
}
}
}
var entity = ObjectMapper.Map<PutawayNoteEditInput, PutawayNote>(input);

103
be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs

@ -10,8 +10,10 @@ using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Domain.Entities;
using Volo.Abp.Domain.Entities.Events.Distributed;
using Volo.Abp.ObjectMapping;
using Win_in.Sfs.Basedata.Application;
using Win_in.Sfs.Basedata.Application.Contracts;
using Win_in.Sfs.Shared.Application.Contracts;
using Win_in.Sfs.Shared.Domain;
@ -34,18 +36,117 @@ public class DeliverRequestAppService :
private readonly IAreaAppService _areaApp;
private readonly ICustomerAppService _customerApp;
private readonly ICustomerAddressAppService _customerAddressApp;
private readonly IItemBasicAppService _itemBasicAppService;
public DeliverRequestAppService(
IDeliverRequestRepository repository
, IDeliverRequestManager deliverRequestManager
, IAreaAppService areaApp
, ICustomerAppService customerApp
, ICustomerAddressAppService customerAddressApp)
, ICustomerAddressAppService customerAddressApp,
IItemBasicAppService itemBasicAppService)
: base(repository, deliverRequestManager)
{
_deliverRequestManager = deliverRequestManager;
_areaApp = areaApp;
_customerApp = customerApp;
_customerAddressApp = customerAddressApp;
_itemBasicAppService = itemBasicAppService;
}
protected override async Task<Dictionary<DeliverRequest, EntityState>> ImportProcessingEntityAsync(Dictionary<DeliverRequest, EntityState> dictionary)
{
var addList = dictionary.Where(p => p.Value == EntityState.Added).Select(p => p.Key);
foreach (var request in addList)
{
request.Worker = CurrentUser.GetUserName();
request.CreatorId = CurrentUser.Id;
request.Remark = "成品发运手动导入";
request.ActiveDate = DateTime.Now;
await SetRequestAutoPropertiesAsync(request).ConfigureAwait(false);
var detailGroupCount= request.Details.GroupBy(r => new { r.AreaCode, r.MesDeliveryNo, r.MesDeliveryPlan }).Count();
if (detailGroupCount != 1)
{
throw new UserFriendlyException($"同一发货类型、发货时间、客户的发货区域、Mes发货单号、Mes发货计划号必须相同!");
}
if (request.Details.Count != request.Details.Select(r => r.ItemCode).Distinct().Count())
{
throw new UserFriendlyException($"同一发货类型、发货时间、客户的存在相同零件号!");
}
foreach (var detail in request.Details)
{
var itemBasicDto = await _itemBasicAppService.GetByCodeAsync(detail.ItemCode).ConfigureAwait(false);
CheckItemBasic(itemBasicDto, detail.ItemCode);
detail.ItemDesc1 = itemBasicDto.Desc1;
detail.ItemDesc2 = itemBasicDto.Desc2;
detail.ItemName = itemBasicDto.Name;
detail.Uom = itemBasicDto.BasicUom;
detail.StdPackQty = itemBasicDto.StdPackQty;
}
}
return dictionary;
}
protected override async Task SaveImportAsync(Dictionary<DeliverRequest, EntityState> dict)
{
var addList = dict.Where(p => p.Value == EntityState.Added).Select(p => p.Key).ToList();
await _deliverRequestManager.CreateManyAsync(addList).ConfigureAwait(false);
}
private static void CheckItemBasic(ItemBasicDTO itemcBasicDto, string itemCode)
{
if (itemcBasicDto == null)
{
throw new UserFriendlyException($"ERP料号为【{itemCode}】不存在");
}
}
/// <summary>
/// 验证
/// </summary>
/// <param name="model"></param>
/// <param name="validationRresult"></param>
/// <returns></returns>
protected override async Task ValidateImportModelAsync(DeliverRequestImportInput model, List<ValidationResult> validationRresult)
{
if (model.DeliverRequestType == EnumDeliverRequestType.FIS)
{
if (string.IsNullOrEmpty(model.IdentityNo))
{
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货必须填写底盘号", new string[] { "底盘号" }));
}
if (string.IsNullOrEmpty(model.MesDeliveryNo))
{
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货必须填写MES发货单号", new string[] { "MES发货单号" }));
}
if (!string.IsNullOrEmpty(model.MesDeliveryPlan))
{
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为FIS发货MES发货计划单号应该为空", new string[] { "MES发货计划单号" }));
}
}
if (model.DeliverRequestType == EnumDeliverRequestType.Normal )
{
if (string.IsNullOrEmpty(model.MesDeliveryPlan))
{
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为看板发货必须填写MES发货计划单号", new string[] { "MES发货计划单号" }));
}
if(!string.IsNullOrEmpty(model.IdentityNo)|| !string.IsNullOrEmpty(model.MesDeliveryNo))
{
validationRresult.Add(new ValidationResult($"ERP料号{model.ItemCode}为看板发货底盘号和MES发货单号应该为空", new string[] { "底盘号" , "MES发货单号" }));
}
}
var area = await _areaApp.GetByCodeAsync(model.AreaCode).ConfigureAwait(false);
if (area != null)
{
if (!area.Name.Contains("成品"))//因为区域里没有类型,只能用名称判断
{
validationRresult.Add(new ValidationResult($"发货区域{model.AreaCode}不是成品储位", new string[] { "发货区域" }));
}
}
else
{
validationRresult.Add(new ValidationResult($"发货区域{model.AreaCode}不存在", new string[] { "发货区域" }));
}
await Task.CompletedTask.ConfigureAwait(false);
}
/// <summary>
/// 处理请求

Loading…
Cancel
Save