1
hutongqing
2024-12-12 2510ff614cd2962d2a91ec1a9eb6668009e9b671
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ERP/ErpController.cs
@@ -1,10 +1,16 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Core;
using WIDESEA_Core.Attributes;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.Basic;
using WIDESEA_External.ERPService;
using WIDESEA_External.Model;
using WIDESEA_IInboundRepository;
using WIDESEA_IInboundService;
using WIDESEA_Model.Models;
namespace WIDESEA_WMSServer.Controllers.ERP
{
@@ -12,23 +18,53 @@
    [ApiController]
    public class ErpController : ControllerBase
    {
        private readonly IERPInvokeService _service;
        public ErpController(IERPInvokeService service)
        private readonly IPurchaseOrderRepository _purchaseOrderRepository;
        private readonly IPurchaseOrderService _purchaseOrderService;
        public ErpController(IPurchaseOrderRepository purchaseOrderRepository, IPurchaseOrderService purchaseOrderService)
        {
            _service = service;
            _purchaseOrderRepository = purchaseOrderRepository;
            _purchaseOrderService = purchaseOrderService;
        }
        [HttpPost, Route("ReceivePurchaseOrder"), AllowAnonymous]
        public WebResponseContent ReceivePurchaseOrder([FromBody] PurchaseOrderModel model)
        [HttpPost, Route("ReceivePurchaseOrder"), AllowAnonymous, MethodParamsValidate]
        public WebResponseContent ReceivePurchaseOrder([FromBody] Dt_PurchaseOrder model)
        {
            try
            {
                return _service.ReceivePurchaseOrder(model);
                _purchaseOrderRepository.AddData(model, x => x.Details);
                foreach (var item in model.Details)
                {
                    Dt_ReceiveOrder receiveOrder = new Dt_ReceiveOrder()
                    {
                        ReceiveOrderStatus = InOrderStatusEnum.未开始.ObjToInt(),
                        WarehouseId = item.WarehouseId,
                        SuppliersId = model.SupplierCode,
                        ReceiveOrderType = InOrderTypeEnum.Purchase.ObjToInt(),
                        ReceiveDate = DateTime.Now,
                    };
                }
                return WebResponseContent.Instance.OK();
            }
            catch (Exception ex)
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
        }
        [HttpPost, Route("ReceivePurchaseOrderSingle"), AllowAnonymous, MethodParamsValidate]
        public WebResponseContent ReceivePurchaseOrderSingle(PurchaseOrderModel model)
        {
            return _purchaseOrderService.ReceivePurchaseOrderSingle(model);
        }
        [HttpPost, Route("Test"), AllowAnonymous]
        public WebResponseContent Test(string str)
        {
            MatSerNumAnalysisModel model = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(WIDESEA_Core.CodeConfigEnum.AnalysisCodeEnum.MatSerNumAnalysis, str);
            return WebResponseContent.Instance.OK(model.Serialize());
        }
    }
}