|  |  | 
 |  |  | 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_IBasicRepository; | 
 |  |  | using WIDESEA_IBasicService; | 
 |  |  | using WIDESEA_IInboundRepository; | 
 |  |  | using WIDESEA_IInboundService; | 
 |  |  | using WIDESEA_InboundService; | 
 |  |  | 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 IPurchaseOrderRepository _purchaseOrderRepository; | 
 |  |  |         private readonly IPurchaseOrderService _purchaseOrderService; | 
 |  |  |         private readonly IBasicService _basicService; | 
 |  |  |         private readonly IOutboundService _outboundService; | 
 |  |  |         private readonly IInboundService _inboundService; | 
 |  |  |  | 
 |  |  |         public ErpController(IPurchaseOrderRepository purchaseOrderRepository, IPurchaseOrderService purchaseOrderService) | 
 |  |  |         public ErpController(IBasicService basicService, IOutboundService outboundService, IInboundService inboundService) | 
 |  |  |         { | 
 |  |  |             _purchaseOrderRepository = purchaseOrderRepository; | 
 |  |  |             _purchaseOrderService = purchaseOrderService; | 
 |  |  |             _basicService = basicService; | 
 |  |  |             _outboundService = outboundService; | 
 |  |  |             _inboundService = inboundService; | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         /// <summary> | 
 |  |  |         /// æ¥æ¶ERPéè´åä¿¡æ¯ | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="model"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [HttpPost, Route("ReceivePurchaseOrder"), AllowAnonymous, MethodParamsValidate] | 
 |  |  |         public WebResponseContent ReceivePurchaseOrder([FromBody] Dt_PurchaseOrder model) | 
 |  |  |         public ErpResponseContent ReceivePurchaseOrder([FromBody] Root<PurchaseOrderModel> model) | 
 |  |  |         { | 
 |  |  |             try | 
 |  |  |             { | 
 |  |  |                 _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) | 
 |  |  |             { | 
 |  |  |                 return WebResponseContent.Instance.Error(ex.Message); | 
 |  |  |             } | 
 |  |  |             WebResponseContent content = _inboundService.PurchaseOrderService.ReceivePurchaseOrder(model.Content); | 
 |  |  |             if (content.Status) return Instance.OK(); | 
 |  |  |             else return Instance.Error(content.Message); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         public WebResponseContent ReceivePurchaseOrderSingle(PurchaseOrderModel model) | 
 |  |  |         /// <summary> | 
 |  |  |         /// æ¥æ¶ERPä»åºåå·¥åè´¨æ£åå·¥æ°æ® | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="model"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [HttpPost, Route("ReceiveUser"), AllowAnonymous, MethodParamsValidate] | 
 |  |  |         public ErpResponseContent ReceiveUser([FromBody] Root<UserInfoDTO> model) | 
 |  |  |         { | 
 |  |  |             return _purchaseOrderService.ReceivePurchaseOrderSingle(model); | 
 |  |  |             WebResponseContent content = _basicService.UserInfoService.ReceiveUser(model.Content); | 
 |  |  |             if (content.Status) return Instance.OK(); | 
 |  |  |             else return Instance.Error(content.Message); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         [HttpPost, Route("Test"), AllowAnonymous] | 
 |  |  |         public WebResponseContent Test(string str) | 
 |  |  |         /// <summary> | 
 |  |  |         /// æ¥æ¶ERPä¾åºåä¿¡æ¯ | 
 |  |  |         /// </summary> | 
 |  |  |         /// <param name="model"></param> | 
 |  |  |         /// <returns></returns> | 
 |  |  |         [HttpPost, Route("ReceiveSupplier"), AllowAnonymous, MethodParamsValidate] | 
 |  |  |         public ErpResponseContent ReceiveSupplier([FromBody] Root<SupplierDTO> model) | 
 |  |  |         { | 
 |  |  |             MatSerNumAnalysisModel model = CodeAnalysisHelper.CodeAnalysis<MatSerNumAnalysisModel>(WIDESEA_Core.CodeConfigEnum.AnalysisCodeEnum.MatSerNumAnalysis, str); | 
 |  |  |             return WebResponseContent.Instance.OK(model.Serialize()); | 
 |  |  |             WebResponseContent content = _basicService.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 = _basicService.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 = _basicService.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 = _outboundService.OutboundOrderService.ReceiveOutOrder(erpOutOrder.Content); | 
 |  |  |             if (content.Status) return Instance.OK(); | 
 |  |  |             else return Instance.Error(content.Message); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | } |