pan
2025-11-27 1a1bc81ac1d9ad656e15b409122e23f7f3763293
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs
@@ -2,6 +2,8 @@
using Microsoft.AspNetCore.Mvc;
using System.Data.Common;
using System.Diagnostics.Eventing.Reader;
using System.Threading.Tasks;
using WIDESEA_Common.AllocateEnum;
using WIDESEA_Core;
using WIDESEA_Core.Attributes;
using WIDESEA_Core.BaseController;
@@ -9,6 +11,7 @@
using WIDESEA_IAllocateService;
using WIDESEA_IInboundService;
using WIDESEA_Model.Models;
using WIDESEA_WMSServer.Controllers.Check;
namespace WIDESEA_WMSServer.Controllers.Allocate
@@ -21,26 +24,36 @@
    [ApiController]
    public class AllocateOrderController : ApiBaseController<IAllocateService, Dt_AllocateOrder>
    {
        public AllocateOrderController(IAllocateService service) : base(service)
        private readonly ILogger<AllocateOrderController> _logger;
        public AllocateOrderController(IAllocateService service, ILogger<AllocateOrderController> logger) : base(service)
        {
            _logger = logger;
        }
        [HttpPost, Route("ReceiveAllocateOrder"), MethodParamsValidate, AllowAnonymous]
        public WebResponseContent ReceiveAllocateOrder([FromBody] AllocateDto model)
        public async Task<WebResponseContent> ReceiveAllocateOrder([FromBody] AllocateDto model)
        {
            Dt_AllocateOrder allocateOrder = new Dt_AllocateOrder
            {
                OrderNo = model.OrderNo,
                UpperOrderNo = model.OrderNo,
                BusinessType=model.BusinessType,
                FactoryArea=model.FactoryArea,
                IsBatch=model.IsBatch,
                BusinessType = model.BusinessType,
                FactoryArea = model.FactoryArea,
                IsBatch = model.IsBatch,
                CreateType = model.OperationType,
                Details = new List<Dt_AllocateOrderDetail>()
                FromWarehouse=model.fromWarehouse,
                ToWarehouse=model.toWarehouse,
                Details = new List<Dt_AllocateOrderDetail>()
            };
            Enum.TryParse<BusinessTypeEnum>(allocateOrder.BusinessType, out var businessType);
            foreach (var detailDto in model.Details)
            {
                if (businessType == BusinessTypeEnum.智仓调外部仓库 && (detailDto.Barcodes == null || !detailDto.Barcodes.Any()))
                {
                    return WebResponseContent.Instance.Error($"条码不能为空");
                }
                if (detailDto.Barcodes != null && detailDto.Barcodes.Any())
                {
                    foreach (var barcodeDto in detailDto.Barcodes)
@@ -51,11 +64,14 @@
                            MaterielCode = detailDto.MaterialCode,
                            LineNo = detailDto.LineNo,
                            OrderQuantity = detailDto.Qty,
                            SupplyCode = barcodeDto.SupplyCode,
                            Unit = detailDto.Unit,
                            Barcode = barcodeDto.Barcode,
                            BatchNo = barcodeDto.BatchNo,
                            BarcodeQty = barcodeDto.Qty,
                            BarcodeUnit = barcodeDto.Unit
                            BarcodeUnit = barcodeDto.Unit,
                            ValidDate=barcodeDto.validDate,
                        };
                        allocateOrder.Details.Add(orderDetail);
                    }
@@ -74,7 +90,7 @@
                }
                allocateOrder.Details.AddRange(allocateOrder.Details);
            }
            var content = Service.ReceiveAllocateOrder(allocateOrder, model.OperationType);
            var content = await Service.ReceiveAllocateOrder(allocateOrder, model.OperationType);
            if (content.Status) return WebResponseContent.Instance.OK(200);
            else return WebResponseContent.Instance.Error(content.Message);