647556386
3 天以前 696edbff3c8812e4b820f624d66a02ae6ddb1a06
ÏîÄ¿´úÂë/WMSÎÞ²Ö´¢°æ/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/Allocate/AllocateOrderController.cs
@@ -5,9 +5,11 @@
using System.Diagnostics.Eventing.Reader;
using System.Threading.Tasks;
using WIDESEA_Common.AllocateEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Core;
using WIDESEA_Core.Attributes;
using WIDESEA_Core.BaseController;
using WIDESEA_Core.BaseRepository;
using WIDESEA_DTO.Allocate;
using WIDESEA_IAllocateService;
using WIDESEA_IInboundService;
@@ -26,9 +28,11 @@
    public class AllocateOrderController : ApiBaseController<IAllocateService, Dt_AllocateOrder>
    {
        private readonly ILogger<AllocateOrderController> _logger;
        public AllocateOrderController(IAllocateService service, ILogger<AllocateOrderController> logger) : base(service)
        private readonly IRepository<Dt_MaterielInfo> _materialInfoRepository;
        public AllocateOrderController(IAllocateService service, ILogger<AllocateOrderController> logger,IRepository<Dt_MaterielInfo> materialInfoRepository) : base(service)
        {
            _logger = logger;
            _materialInfoRepository = materialInfoRepository;
        }
        [HttpPost, Route("ReceiveAllocateOrder"), MethodParamsValidate, AllowAnonymous]
@@ -42,7 +46,7 @@
                BusinessType = model.BusinessType,
                FactoryArea = model.FactoryArea,
                IsBatch = model.IsBatch,
                CreateType = model.OperationType,
                CreateType =(int)OrderCreateTypeEnum.UpperSystemPush,
                FromWarehouse = model.fromWarehouse,
                ToWarehouse = model.toWarehouse,
                Details = new List<Dt_AllocateOrderDetail>()
@@ -51,29 +55,35 @@
            //allocateOrder.OrderType = businessType == BusinessTypeEnum.智仓调外部仓库 ? 215 : 115;
            if (businessType == BusinessTypeEnum.智仓调外部仓库)
            {
                allocateOrder.OrderType = 115;
                allocateOrder.OrderType = 215;
            }
            else if (businessType == BusinessTypeEnum.外部仓库调智仓)
            {
                allocateOrder.OrderType = 215;
                allocateOrder.OrderType = 115;
            }
            else if (businessType == BusinessTypeEnum.智仓调智仓)
            {
                allocateOrder.OrderType = 117;
            }
            foreach (var detailDto in model.Details)
            {
                if (businessType == BusinessTypeEnum.智仓调外部仓库 && (detailDto.Barcodes == null || !detailDto.Barcodes.Any()))
                if (businessType == BusinessTypeEnum.外部仓库调智仓 && (detailDto.Barcodes == null || !detailDto.Barcodes.Any()))
                {
                    return WebResponseContent.Instance.Error($"条码不能为空");
                }
                var materialName = _materialInfoRepository.QueryFirst(x => x.MaterielCode == detailDto.MaterialCode).MaterielName;
                if (detailDto.Barcodes != null && detailDto.Barcodes.Any())
                {
                    foreach (var barcodeDto in detailDto.Barcodes)
                    {
                        Dt_AllocateOrderDetail orderDetail = new Dt_AllocateOrderDetail
                        {
                            WarehouseCode = detailDto.WarehouseCode,
                            WarehouseCode = model.toWarehouse,
                            MaterielCode = detailDto.MaterialCode,
                            MaterielName = materialName,
                            LineNo = detailDto.LineNo,
                            OrderQuantity = detailDto.Qty,
                            OrderQuantity = barcodeDto.Qty,
                            SupplyCode = barcodeDto.SupplyCode,
                            Unit = detailDto.Unit,
                            Barcode = barcodeDto.Barcode,
@@ -81,8 +91,12 @@
                            BarcodeQty = barcodeDto.Qty,
                            BarcodeUnit = barcodeDto.Unit,
                            ValidDate = barcodeDto.validDate,
                            BoxSN = barcodeDto.BoxSN
                        };
                        if (businessType == BusinessTypeEnum.智仓调外部仓库 || businessType == BusinessTypeEnum.智仓调智仓)
                        {
                            orderDetail.WarehouseCode = model.fromWarehouse;
                        }
                        allocateOrder.Details.Add(orderDetail);
                    }
                }
@@ -90,15 +104,21 @@
                {
                    Dt_AllocateOrderDetail orderDetail = new Dt_AllocateOrderDetail
                    {
                        WarehouseCode = detailDto.WarehouseCode,
                        WarehouseCode = model.toWarehouse,
                        MaterielCode = detailDto.MaterialCode,
                        LineNo = detailDto.LineNo,
                        OrderQuantity = detailDto.Qty,
                        Unit = detailDto.Unit
                        Unit = detailDto.Unit,
                        BarcodeUnit =detailDto.Unit,
                        BarcodeQty=detailDto.Qty,
                        MaterielName = materialName
                    };
                    if (businessType == BusinessTypeEnum.智仓调外部仓库 || businessType == BusinessTypeEnum.智仓调智仓)
                    {
                        orderDetail.WarehouseCode = model.fromWarehouse;
                    }
                    allocateOrder.Details.Add(orderDetail);
                }
                allocateOrder.Details.AddRange(allocateOrder.Details);
            }
            var content = await Service.ReceiveAllocateOrder(allocateOrder, model.OperationType);