1
hutongqing
2024-12-29 89051aef8a2c1a85d457914cf6317fe70e0e321c
´úÂë¹ÜÀí/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ERP/ErpController.cs
@@ -1,34 +1,129 @@
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using WIDESEA_Common.CommonEnum;
using WIDESEA_Common.MaterielEnum;
using WIDESEA_Common.OrderEnum;
using WIDESEA_Core;
using WIDESEA_Core.Attributes;
using WIDESEA_Core.Helper;
using WIDESEA_DTO;
using WIDESEA_DTO.Basic;
using WIDESEA_DTO.ERP;
using WIDESEA_External.ERPService;
using WIDESEA_External.Model;
using WIDESEA_IBasicRepository;
using WIDESEA_IBasicService;
using WIDESEA_IInboundRepository;
using WIDESEA_IInboundService;
using WIDESEA_IOutboundService;
using WIDESEA_Model.Models;
using static WIDESEA_DTO.ErpResponseContent;
namespace WIDESEA_WMSServer.Controllers.ERP
{
    /// <summary>
    /// ERP接口
    /// </summary>
    [Route("api/Erp")]
    [ApiController]
    public class ErpController : ControllerBase
    {
        private readonly IERPInvokeService _service;
        public ErpController(IERPInvokeService service)
        private readonly IPurchaseOrderRepository _purchaseOrderRepository;
        private readonly IPurchaseOrderService _purchaseOrderService;
        private readonly ISupplierInfoService _supplierInfoService;
        private readonly IMaterielInfoService _materielInfoService;
        private readonly IOutboundOrderService _outboundOrderService;
        private readonly ICustomerInfoService _customerInfoService;
        private readonly IUserInfoService _userInfoService;
        public ErpController(IPurchaseOrderRepository purchaseOrderRepository, IPurchaseOrderService purchaseOrderService, ISupplierInfoService supplierInfoService, IMaterielInfoService materielInfoService, IOutboundOrderService outboundOrderService,ICustomerInfoService customerInfoService, IUserInfoService userInfoService)
        {
            _service = service;
            _purchaseOrderRepository = purchaseOrderRepository;
            _purchaseOrderService = purchaseOrderService;
            _supplierInfoService = supplierInfoService;
            _materielInfoService = materielInfoService;
            _outboundOrderService = outboundOrderService;
            _customerInfoService = customerInfoService;
            _userInfoService = userInfoService;
        }
        [HttpPost, Route("ReceivePurchaseOrder"), AllowAnonymous]
        public WebResponseContent ReceivePurchaseOrder([FromBody] PurchaseOrderModel model)
        /// <summary>
        /// æŽ¥æ”¶ERP采购单信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost, Route("ReceivePurchaseOrder"), AllowAnonymous, MethodParamsValidate]
        public ErpResponseContent ReceivePurchaseOrder([FromBody] Root<PurchaseOrderModel> model)
        {
            try
            {
                return _service.ReceivePurchaseOrder(model);
            }
            catch (Exception ex)
            {
                return WebResponseContent.Instance.Error(ex.Message);
            }
            WebResponseContent content = _purchaseOrderService.ReceivePurchaseOrder(model.Content);
            if (content.Status) return Instance.OK();
            else return Instance.Error(content.Message);
        }
        /// <summary>
        /// æŽ¥æ”¶ERP仓库员工和质检员工数据
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost, Route("ReceiveUser"), AllowAnonymous, MethodParamsValidate]
        public ErpResponseContent ReceiveUser([FromBody] Root<UserInfoDTO> model)
        {
            WebResponseContent content = _userInfoService.ReceiveUser(model.Content);
            if (content.Status) return Instance.OK();
            else return Instance.Error(content.Message);
        }
        /// <summary>
        /// æŽ¥æ”¶ERP供应商信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost, Route("ReceiveSupplier"), AllowAnonymous, MethodParamsValidate]
        public ErpResponseContent ReceiveSupplier([FromBody] Root<SupplierDTO> model)
        {
            WebResponseContent content = _supplierInfoService.ReceiveSupplier(model.Content);
            if (content.Status) return Instance.OK();
            else return Instance.Error(content.Message);
        }
        /// <summary>
        /// æŽ¥æ”¶ERP物料信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost, Route("ReceiveMaterial"), AllowAnonymous, MethodParamsValidate]
        public ErpResponseContent ReceiveMaterial([FromBody] Root<MaterielInfoDTO> model)
        {
            WebResponseContent content = _materielInfoService.ReceiveMaterial(model.Content);
            if (content.Status) return Instance.OK();
            else return Instance.Error(content.Message);
        }
        /// <summary>
        /// æŽ¥æ”¶ERP客户信息
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        [HttpPost, Route("ReceiveCustomer"), AllowAnonymous, MethodParamsValidate]
        public ErpResponseContent ReceiveCustomer([FromBody] Root<CustomerInfoDTO> model)
        {
            WebResponseContent content = _customerInfoService.ReceiveCustomer(model.Content);
            if (content.Status) return Instance.OK();
            else return Instance.Error(content.Message);
        }
        /// <summary>
        /// æŽ¥æ”¶ERP出库单信息
        /// </summary>
        /// <param name="erpOutOrder"></param>
        /// <returns></returns>
        [HttpPost, Route("ReceiveOutOrder"), AllowAnonymous, MethodParamsValidate]
        public ErpResponseContent ReceiveOutOrder([FromBody] Root<ErpOutOrderDTO> erpOutOrder)
        {
            WebResponseContent content = _outboundOrderService.ReceiveOutOrder(erpOutOrder.Content);
            if (content.Status) return Instance.OK();
            else return Instance.Error(content.Message);
        }
    }
}