From 911a17b31eb1caa56d02a7be547176be6c259127 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 16 十二月 2024 21:30:23 +0800
Subject: [PATCH] 接口优化

---
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/PurchaseOrderService.cs     |   31 +++++
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_SupplierInfo.cs      |   18 +++
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_MaterielInfo.cs      |    6 
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/MaterielInfoDTO.cs               |  122 ++++++++++++++++++++----
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_DTO/ERP/ErpResponseContent.cs              |   73 ++++++++++++++
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/SupplierInfoService.cs        |    6 +
 代码管理/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ERP/ErpController.cs |   25 +++-
 7 files changed, 246 insertions(+), 35 deletions(-)

diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/SupplierInfoService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/SupplierInfoService.cs"
index a99cfdd..8dc8ce7 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/SupplierInfoService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_BasicService/SupplierInfoService.cs"
@@ -31,6 +31,12 @@
                     {
                         Status = 1,
                         SupplierCode = model.Code,
+                        ContactAddress = model.ContactAddress,
+                        ContactNumber = model.ContactNumber,
+                        Contacts = model.Contacts,
+                        Description = model.Description,
+                        Email = model.Email,
+                        InvOrgId = model.InvOrgId,
                         SupplierName = model.Name,
                         SupplierShortName = model.ShortName
                     };
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/MaterielInfoDTO.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/MaterielInfoDTO.cs"
index 3516010..b6c683e 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/MaterielInfoDTO.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/Basic/MaterielInfoDTO.cs"
@@ -4,12 +4,17 @@
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEA_Core.Attributes;
+using static WIDESEA_DTO.ErpResponseContent;
 
 namespace WIDESEA_DTO.Basic
 {
     [ModelValidate]
     public class MaterielInfo
     {
+        /// <summary>
+        /// 
+        /// </summary>
+        public string message { get; set; }
         /// <summary>
         /// 
         /// </summary>
@@ -27,38 +32,113 @@
     [ModelValidate]
     public class MaterielInfoDTO
     {
+        /// <summary>
+        /// 
+        /// </summary>
         public string Code { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
         public string Name { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
         public string StandType { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
         public int ItemType { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Type { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
         public int ItemSourceType { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
         public string Unit { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
         public string MaterialVersion { get; set; }
-
-        public float Size { get; set; }
-
-        public float Length { get; set; }
-
-        public float Thickness { get; set; }
-
-        public float Wide { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
+        public int Size { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public int Length { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public int Thickness { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public int Wide { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
         public string Model { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Color { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string MaterialTG { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Spare1 { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Spare2 { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Spare3 { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Spare4 { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string Spare5 { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
         public int State { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
         public string InvOrgId { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
         public int OperateType { get; set; }
-
+        /// <summary>
+        /// 
+        /// </summary>
+        public string UserDef01 { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string UserDef04 { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
         public int IsCheck { get; set; }
-
-        public int WaId { get; set; }
+        /// <summary>
+        /// 
+        /// </summary>
+        public string WaId { get; set; }
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/ERP/ErpResponseContent.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/ERP/ErpResponseContent.cs"
new file mode 100644
index 0000000..3ae8a32
--- /dev/null
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_DTO/ERP/ErpResponseContent.cs"
@@ -0,0 +1,73 @@
+锘縰sing System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using WIDESEA_Core;
+using WIDESEA_Core.Attributes;
+
+namespace WIDESEA_DTO
+{
+    [ModelValidate]
+    public class ErpResponseContent
+    {
+        public class content
+        {
+            /// <summary>
+            /// 
+            /// </summary>
+            public string Code { get; set; }
+            /// <summary>
+            /// 
+            /// </summary>
+            public string Name { get; set; }
+            /// <summary>
+            /// 
+            /// </summary>
+            public string ShortName { get; set; }
+        }
+
+        //public class Root
+        //{
+        /// <summary>
+        /// 
+        /// </summary>
+        public bool bSucc { get; set; } = true;
+        /// <summary>
+        /// 
+        /// </summary>
+        public string strCode { get; set; } = "0000";
+        /// <summary>
+        /// 鎵ц鎴愬姛
+        /// </summary>
+        public string strMsg { get; set; } = "鎵ц鎴愬姛";
+        /// <summary>
+        /// 
+        /// </summary>
+        public DateTime DataTime { get; set; } = DateTime.Now;
+        /// <summary>
+        /// 
+        /// </summary>
+        public content Content { get; set; }
+        //}
+        public static ErpResponseContent Instance
+        {
+            get { return new ErpResponseContent(); }
+        }
+        public ErpResponseContent OK(string message = null)
+        {
+            bSucc = true;
+            strCode = "0000";
+            strMsg = message == null ? "鎵ц鎴愬姛" : message;
+            return this;
+        }
+
+        public ErpResponseContent Error(string message = null)
+        {
+            bSucc = false;
+            strCode = "404";
+            strMsg = message == null ? "鎵ц澶辫触" : message;
+            return this;
+        }
+    }
+}
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/PurchaseOrderService.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/PurchaseOrderService.cs"
index fd2344f..270c4c6 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/PurchaseOrderService.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_InboundService/PurchaseOrderService.cs"
@@ -11,6 +11,7 @@
 using WIDESEA_Core.Enums;
 using WIDESEA_Core.Helper;
 using WIDESEA_DTO;
+using WIDESEA_DTO.Basic;
 using WIDESEA_IBasicRepository;
 using WIDESEA_IInboundRepository;
 using WIDESEA_IInboundService;
@@ -24,12 +25,16 @@
         private readonly IUnitOfWorkManage _unitOfWorkManage;
         private readonly IPurchaseOrderDetailRepository _purchaseOrderDetailRepository;
         private readonly IBasicRepository _basicRepository;
+        private readonly ISupplierInfoRepository _supplierInfoRepository;
+        private readonly IMaterielInfoRepository _materielInfoRepository;
 
-        public PurchaseOrderService(IPurchaseOrderRepository BaseDal, IPurchaseOrderDetailRepository purchaseOrderDetailRepository, IUnitOfWorkManage unitOfWorkManage,IBasicRepository basicRepository) : base(BaseDal)
+        public PurchaseOrderService(IPurchaseOrderRepository BaseDal, IPurchaseOrderDetailRepository purchaseOrderDetailRepository, IUnitOfWorkManage unitOfWorkManage, IBasicRepository basicRepository, ISupplierInfoRepository supplierInfoRepository, IMaterielInfoRepository materielInfoRepository) : base(BaseDal)
         {
             _purchaseOrderDetailRepository = purchaseOrderDetailRepository;
             _unitOfWorkManage = unitOfWorkManage;
             _basicRepository = basicRepository;
+            _supplierInfoRepository = supplierInfoRepository;
+            _materielInfoRepository = materielInfoRepository;
         }
 
         public WebResponseContent ReceivePurchaseOrder(PurchaseOrderModel model)
@@ -59,14 +64,24 @@
                 {
                     return WebResponseContent.Instance.Error($"閲囪喘鍗曞彿閲嶅");
                 }
+                if (_supplierInfoRepository.QueryFirst(x => x.SupplierCode == model.SCode) == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒颁緵搴斿晢缂栫爜銆恵model.SCode}銆戠殑淇℃伅");
+                }
                 List<Dt_Warehouse> warehouses = _basicRepository.WarehouseRepository.QueryData();
-                 List<Dt_PurchaseOrderDetail> purchaseOrderDetails = new List<Dt_PurchaseOrderDetail>();
+                List<Dt_MaterielInfo> materielInfos = _materielInfoRepository.QueryData();
+                List<Dt_PurchaseOrderDetail> purchaseOrderDetails = new List<Dt_PurchaseOrderDetail>();
                 foreach (var item in model.MList)
                 {
                     Dt_Warehouse? warehouse = warehouses.FirstOrDefault(x => x.WarehouseCode == item.WaId);
-                    if(warehouse == null)
+                    if (warehouse == null)
                     {
                         return WebResponseContent.Instance.Error($"鏈壘鍒颁粨搴撲俊鎭�");
+                    }
+                    Dt_MaterielInfo? materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MCode);
+                    if (materielInfo == null)
+                    {
+                        return WebResponseContent.Instance.Error($"鏈壘鍒扮墿鏂欑紪鐮併�恵item.MCode}銆戠殑淇℃伅");
                     }
                     Dt_PurchaseOrderDetail purchaseOrderDetail = new Dt_PurchaseOrderDetail()
                     {
@@ -114,7 +129,12 @@
                 {
                     return WebResponseContent.Instance.Error($"鏈壘鍒伴噰璐崟鏄庣粏淇℃伅");
                 }
+                if (_supplierInfoRepository.QueryFirst(x => x.SupplierCode == model.SCode) == null)
+                {
+                    return WebResponseContent.Instance.Error($"鏈壘鍒颁緵搴斿晢缂栫爜銆恵model.SCode}銆戠殑淇℃伅");
+                }
                 List<Dt_Warehouse> warehouses = _basicRepository.WarehouseRepository.QueryData();
+                List<Dt_MaterielInfo> materielInfos = _materielInfoRepository.QueryData();
                 List<Dt_PurchaseOrderDetail> purchaseOrderDetails = new List<Dt_PurchaseOrderDetail>();
                 List<Dt_PurchaseOrderDetail> updatePurchaseOrderDetails = new List<Dt_PurchaseOrderDetail>();
                 List<int> detailIds = new List<int>();
@@ -125,6 +145,11 @@
                     {
                         return WebResponseContent.Instance.Error($"鏈壘鍒颁粨搴撲俊鎭�");
                     }
+                    Dt_MaterielInfo? materielInfo = materielInfos.FirstOrDefault(x => x.MaterielCode == item.MCode);
+                    if (materielInfo == null)
+                    {
+                        return WebResponseContent.Instance.Error($"鏈壘鍒扮墿鏂欑紪鐮併�恵item.MCode}銆戠殑淇℃伅");
+                    }
                     Dt_PurchaseOrderDetail? purchaseOrderDetail = purchaseOrder.Details.FirstOrDefault(x => x.RowNo == item.RowId);
                     if (purchaseOrderDetail == null)
                     {
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_MaterielInfo.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_MaterielInfo.cs"
index 0c7d21e..3d1c42b 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_MaterielInfo.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_MaterielInfo.cs"
@@ -12,7 +12,7 @@
 {
     [SugarTable(nameof(Dt_MaterielInfo), "鐗╂枡淇℃伅")]
     [SugarIndex("unique_materielinfo_materielcode", nameof(MaterielCode), OrderByType.Asc, true)]
-    public class Dt_MaterielInfo : BaseEntity, BaseWarehouseEntity
+    public class Dt_MaterielInfo : BaseEntity//, BaseWarehouseEntity
     {
         /// <summary>
         /// 涓婚敭
@@ -116,7 +116,7 @@
         [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "澶囨敞")]
         public string Remark { get; set; }
 
-        [SugarColumn(IsNullable = false, ColumnDescription = "浠撳簱缂栧彿")]
-        public int WarehouseId { get; set; }
+        [SugarColumn(IsNullable = false, Length = 50, ColumnDescription = "浠撳簱缂栧彿")]
+        public string WarehouseId { get; set; }
     }
 }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_SupplierInfo.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_SupplierInfo.cs"
index 91f9182..dbbba7d 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_SupplierInfo.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_Model/Models/Basic/Dt_SupplierInfo.cs"
@@ -23,6 +23,24 @@
         [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "渚涘簲鍟嗙畝绉�")]
         public string SupplierShortName { get; set; }
 
+        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "鑱旂郴浜�")]
+        public string Contacts { get; set; }
+
+        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "鑱旂郴鐢佃瘽")]
+        public string ContactNumber { get; set; }
+
+        [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "鑱旂郴鍦板潃")]
+        public string ContactAddress { get; set; }
+
+        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "鐢靛瓙閭")]
+        public string Email { get; set; }
+
+        [SugarColumn(IsNullable = true, Length = 200, ColumnDescription = "鎻忚堪")]
+        public string Description { get; set; }
+
+        [SugarColumn(IsNullable = true, Length = 50, ColumnDescription = "搴撳瓨缁勭粐")]
+        public string InvOrgId { get; set; }
+
         [SugarColumn(IsNullable = false, ColumnDescription = "鐘舵��")]
         public int Status { get; set; }
     }
diff --git "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ERP/ErpController.cs" "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ERP/ErpController.cs"
index 19dafe1..48ed393 100644
--- "a/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ERP/ErpController.cs"
+++ "b/\344\273\243\347\240\201\347\256\241\347\220\206/WMS/WIDESEA_WMSServer/WIDESEA_WMSServer/Controllers/ERP/ErpController.cs"
@@ -18,6 +18,7 @@
 using WIDESEA_IInboundService;
 using WIDESEA_IOutboundService;
 using WIDESEA_Model.Models;
+using static WIDESEA_DTO.ErpResponseContent;
 
 namespace WIDESEA_WMSServer.Controllers.ERP
 {
@@ -46,9 +47,11 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost, Route("ReceivePurchaseOrderSingle"), AllowAnonymous, MethodParamsValidate]
-        public WebResponseContent ReceivePurchaseOrder([FromBody] Root model)
+        public ErpResponseContent ReceivePurchaseOrder([FromBody] Root model)
         {
-            return _purchaseOrderService.ReceivePurchaseOrder(model.Content);
+            WebResponseContent content = _purchaseOrderService.ReceivePurchaseOrder(model.Content);
+            if (content.Status) return Instance.OK();
+            else return Instance.Error(content.Message);
         }
 
         /// <summary>
@@ -57,9 +60,11 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost, Route("ReceiveSupplier"), AllowAnonymous, MethodParamsValidate]
-        public WebResponseContent ReceiveSupplier([FromBody] Supplier model)
+        public ErpResponseContent ReceiveSupplier([FromBody] Supplier model)
         {
-            return _supplierInfoService.ReceiveSupplier(model.Content);
+            WebResponseContent content = _supplierInfoService.ReceiveSupplier(model.Content);
+            if (content.Status) return Instance.OK();
+            else return Instance.Error(content.Message);
         }
 
         /// <summary>
@@ -68,9 +73,11 @@
         /// <param name="model"></param>
         /// <returns></returns>
         [HttpPost, Route("ReceiveMaterial"), AllowAnonymous, MethodParamsValidate]
-        public WebResponseContent ReceiveMaterial([FromBody] MaterielInfo model)
+        public ErpResponseContent ReceiveMaterial([FromBody] MaterielInfo model)
         {
-            return _materielInfoService.ReceiveMaterial(model.Content);
+             WebResponseContent content = _materielInfoService.ReceiveMaterial(model.Content);
+            if (content.Status) return Instance.OK();
+            else return Instance.Error(content.Message);
         }
 
         /// <summary>
@@ -79,9 +86,11 @@
         /// <param name="erpOutOrder"></param>
         /// <returns></returns>
         [HttpPost, Route("ReceiveOutOrder"), AllowAnonymous, MethodParamsValidate]
-        public WebResponseContent ReceiveOutOrder([FromBody] ErpOutOrder erpOutOrder)
+        public ErpResponseContent ReceiveOutOrder([FromBody] ErpOutOrder erpOutOrder)
         {
-            return _outboundOrderService.ReceiveOutOrder(erpOutOrder.Content);
+             WebResponseContent content = _outboundOrderService.ReceiveOutOrder(erpOutOrder.Content);
+            if (content.Status) return Instance.OK();
+            else return Instance.Error(content.Message);
         }
     }
 }

--
Gitblit v1.9.3