From 34ad4c38d536236d83b9eb52f8778375aef1c4b6 Mon Sep 17 00:00:00 2001
From: lvzb <35200379@qq.com>
Date: Tue, 4 Jun 2024 10:53:37 +0800
Subject: [PATCH] =?UTF-8?q?=E6=88=90=E5=93=81=E5=8F=91=E8=BF=90=E6=B7=BB?=
=?UTF-8?q?=E5=8A=A0=E5=AF=BC=E5=85=A5=E5=8A=9F=E8=83=BD?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../Inputs/DeliverRequestImportInput.cs | 45 ++++++--
.../PutawayNotes/PutawayNoteAppService.cs | 49 +++++----
.../DeliverRequestAppService.cs | 103 +++++++++++++++++-
3 files changed, 164 insertions(+), 33 deletions(-)
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs
index 1d48f2443..a27f004e2 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application.Contracts/Requests/DeliverRequests/Inputs/DeliverRequestImportInput.cs
+++ b/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
{
+ ///
+ /// 发货类型
+ ///
+ [Display(Name = "发货类型")]
+ [Required]
+ [Key]
+ public EnumDeliverRequestType DeliverRequestType { get; set; }
///
/// 发货时间
///
[Display(Name = "发货时间")]
[Required]
+ [Key]
public DateTime DeliverTime { get; set; }
///
@@ -18,6 +27,7 @@ public class DeliverRequestImportInput : SfsStoreImportInputBase
///
[Display(Name = "客户")]
[Required]
+ [Key]
public string CustomerCode { get; set; }
///
@@ -62,11 +72,11 @@ public class DeliverRequestImportInput : SfsStoreImportInputBase
public class DeliverRequestFisImportInput : SfsStoreImportInputBase
{
///
- /// 发货时间
+ /// 发货类型
///
- [Display(Name = "发货时间")]
+ [Display(Name = "发货类型")]
[Required]
- public DateTime DeliverTime { get; set; }
+ public EnumDeliverRequestType DeliverRequestType { get; set; }
///
/// 客户
@@ -74,7 +84,12 @@ public class DeliverRequestFisImportInput : SfsStoreImportInputBase
[Display(Name = "客户")]
[Required]
public string CustomerCode { get; set; }
-
+ ///
+ /// 发货时间
+ ///
+ [Display(Name = "发货时间")]
+ [Required]
+ public DateTime DeliverTime { get; set; }
///
/// ERP料号
///
@@ -102,11 +117,19 @@ public class DeliverRequestFisImportInput : SfsStoreImportInputBase
[Display(Name = "订单号")]
[Required]
public string FromVinCode { get; set; }
-
- /////
- ///// 截止底盘号
- /////
- //[Display(Name = "截止底盘号")]
- //[Required]
- //public string ToVinCode { get; set; }
+ ///
+ /// Mes发货单号
+ ///
+ [Display(Name = "Mes发货单号")]
+ public string MesDeliveryNo { get; set; }
+ ///
+ /// Mes发货计划号
+ ///
+ [Display(Name = "Mes发货计划号")]
+ public string MesDeliveryPlan { get; set; }
+ ///
+ /// 底盘号
+ ///
+ [Display(Name = "底盘号")]
+ public string IdentityNo { get; set; }
}
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs
index 51e7f6963..14876bc10 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Notes/PutawayNotes/PutawayNoteAppService.cs
+++ b/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;
}
///
@@ -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(input);
diff --git a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs b/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs
index ee7e8d81f..10ad367a6 100644
--- a/be/Modules/Store/src/Win_in.Sfs.Wms.Store.Application/Requests/DeliverRequests/DeliverRequestAppService.cs
+++ b/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> ImportProcessingEntityAsync(Dictionary 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 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}】不存在");
+ }
+ }
+ ///
+ /// 验证
+ ///
+ ///
+ ///
+ ///
+ protected override async Task ValidateImportModelAsync(DeliverRequestImportInput model, List 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);
}
///
/// 处理请求