From a0a0df2e824b6fe7e5a3c0afce78127fecf84fc9 Mon Sep 17 00:00:00 2001
From: wangxinhui <wangxinhui@hnkhzn.com>
Date: 星期一, 03 十一月 2025 08:23:05 +0800
Subject: [PATCH] ERP接口代码更新,WCS代码优化,出入库分配优化

---
 项目代码/WMS/WMSServices/WIDESEA_BasicService/CustomerInfoService.cs |  111 +++++++++++++++++++++++++++++++++----------------------
 1 files changed, 66 insertions(+), 45 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_BasicService/CustomerInfoService.cs" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_BasicService/CustomerInfoService.cs"
index 010ca83..a1ed488 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_BasicService/CustomerInfoService.cs"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WMS/WMSServices/WIDESEA_BasicService/CustomerInfoService.cs"
@@ -1,10 +1,13 @@
-锘縰sing System;
+锘縰sing AutoMapper;
+using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 using WIDESEA_BasicRepository;
+using WIDESEA_Common.MaterielEnum;
 using WIDESEA_Core;
+using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
 using WIDESEA_Core.Helper;
 using WIDESEA_DTO.Basic;
@@ -17,59 +20,77 @@
 {
     public class CustomerInfoService : ServiceBase<Dt_CustomerInfo, ICustomerInfoRepository>, ICustomerInfoService
     {
-        public CustomerInfoService(ICustomerInfoRepository BaseDal) : base(BaseDal)
-        {
-        }
-
         public ICustomerInfoRepository Repository => BaseDal;
-
-        public WebResponseContent ReceiveCustomer(CustomerInfoDTO model)
+        private readonly IMapper _mapper;
+        private readonly IUnitOfWorkManage _unitOfWorkManage;
+        public CustomerInfoService(ICustomerInfoRepository BaseDal,IMapper mapper,IUnitOfWorkManage unitOfWorkManage) : base(BaseDal)
         {
+            _mapper = mapper;
+            _unitOfWorkManage = unitOfWorkManage;
+        }
+        /// <summary>
+        /// 鎺ユ敹浜屾湡瀹㈡埛淇℃伅
+        /// </summary>
+        /// <param name="eRPCustomerDTO"></param>
+        /// <returns></returns>
+        public WebResponseContent ReceiveCustomer(ERPCustomerDTO eRPCustomerDTO)
+        {
+            WebResponseContent content = new WebResponseContent();
             try
             {
-                //if (model.OperateType == "0")
-                //{
-                Dt_CustomerInfo customer = new Dt_CustomerInfo()
+                if (eRPCustomerDTO == null)
                 {
-                    Code = model.Code,
-                    Name = model.ShortName,
-                    NickName = model.Name,
-                    State = model.State.ObjToInt(),
-                };
-                BaseDal.AddData(customer);
-                //}
-                //else if (model.OperateType == "1")
-                //{
-                //    Dt_Customer customer = BaseDal.QueryFirst(x => x.Code == model.Code);
-                //    if (customer == null)
-                //    {
-                //        return WebResponseContent.Instance.Error($"鏈壘鍒拌瀹㈡埛淇℃伅");
-                //    }
-                //    customer.State = model.State;
-                //    customer.Name = model.ShortName;
-                //    customer.NickName = model.Name;
-                //    BaseDal.UpdateData(customer);
-                //}
-                //else if (model.OperateType == "2")
-                //{
-                //    Dt_Customer customer = BaseDal.QueryFirst(x => x.Code == model.Code);
-                //    if (customer == null)
-                //    {
-                //        return WebResponseContent.Instance.Error($"鏈壘鍒拌瀹㈡埛淇℃伅");
-                //    }
-                //    BaseDal.DeleteData(customer);
-                //}
-                return WebResponseContent.Instance.OK();
+                    return content.Error("瀹㈡埛淇℃伅涓嶈兘浼犲叆涓虹┖");
+                }
+                List<Dt_CustomerInfo> OldcustomerInfos = BaseDal.QueryData();
+
+                if (eRPCustomerDTO.OperateType == 1)
+                {
+                    //鍒ゆ柇閲嶅鎻掑叆
+                    Dt_CustomerInfo? customerInfoOld = OldcustomerInfos.FirstOrDefault(x => x.CustomerCode == eRPCustomerDTO.CustomerCode);
+                    if (customerInfoOld != null)
+                    {
+                        return content.Error($"瀹㈡埛{customerInfoOld.CustomerCode}宸插瓨鍦�");
+                    }
+                    Dt_CustomerInfo customerInfo = _mapper.Map<Dt_CustomerInfo>(eRPCustomerDTO);
+                    //鏂板
+                    BaseDal.AddData(customerInfo);
+                }
+                else if (eRPCustomerDTO.OperateType == 2)
+                {
+                    //鍒ゆ柇鏄惁瀛樺湪
+                    Dt_CustomerInfo? customerInfoOld = OldcustomerInfos.FirstOrDefault(x => x.CustomerCode == eRPCustomerDTO.CustomerCode);
+                    if (customerInfoOld == null)
+                    {
+                        return content.Error($"鏇存柊瀹㈡埛{eRPCustomerDTO.CustomerCode}涓嶅瓨鍦�");
+                    }
+                    Dt_CustomerInfo customerInfo = _mapper.Map<Dt_CustomerInfo>(eRPCustomerDTO);
+                    customerInfo.Id = customerInfoOld.Id;
+                    //鏇存柊
+                    BaseDal.UpdateData(customerInfoOld);
+                }
+                else if (eRPCustomerDTO.OperateType == 3)
+                {
+                    // 鍒ゆ柇鏄惁瀛樺湪
+                    Dt_CustomerInfo? customerInfoOld = OldcustomerInfos.FirstOrDefault(x => x.CustomerCode == eRPCustomerDTO.CustomerCode);
+                    if (customerInfoOld == null)
+                    {
+                        return content.Error($"鏇存柊瀹㈡埛{eRPCustomerDTO.CustomerCode}涓嶅瓨鍦�");
+                    }
+                    BaseDal.DeleteData(customerInfoOld);
+                }
+                else
+                {
+                    return content.Error("鏈壘鍒版搷浣滅被鍨�");
+                }
+                //鏇存柊鏁版嵁
+                return content.OK("鎺ユ敹鎴愬姛");
             }
             catch (Exception ex)
             {
-                return WebResponseContent.Instance.Error(ex.Message);
+                content.Error(ex.Message);
             }
-        }
-        public override WebResponseContent UpdateData(SaveModel saveModel)
-        {
-            saveModel.MainData.Add("state",1);
-            return base.UpdateData(saveModel);
+            return content;
         }
     }
 }

--
Gitblit v1.9.3