From 8b00a760cb23067c3ea46a2fd905ae9ff1a713a2 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期五, 24 十月 2025 01:43:03 +0800
Subject: [PATCH] 优化出入库单逻辑

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs |   55 ++++++++++++++++++++++++++++---------------------------
 1 files changed, 28 insertions(+), 27 deletions(-)

diff --git "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs" "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs"
index aa0ab04..52a8d7e 100644
--- "a/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs"
+++ "b/\346\226\260\345\273\272\346\226\207\344\273\266\345\244\271/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs"
@@ -7,6 +7,7 @@
 using System.Security.Policy;
 using System.Text;
 using System.Threading.Tasks;
+using WIDESEA_Common;
 using WIDESEA_Core;
 using WIDESEA_Core.BaseRepository;
 using WIDESEA_Core.BaseServices;
@@ -37,22 +38,22 @@
             var responseContent = new WebResponseContent();
             try
             {
-                
-              var url = "http://121.37.118.63:80/GYZ2/95fck/goodsInfo";
+
+                var url = "http://121.37.118.63:80/GYZ2/95fck/goodsInfo";
 
 
-                if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
+                //if (string.IsNullOrEmpty(SearchDate)) SearchDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                 //璇锋眰鍙傛暟
                 var requestData = new
                 {
-                    searchDate = "2009-1-10 20:45:16"  // 姝g‘鐨勬牸寮�
+                    searchDate = "2009-01-10 20:45:16"  // 姝g‘鐨勬牸寮�
                 };
                 //if (string.IsNullOrEmpty(SearchDate))
                 //{
                 //    // 榛樿鏌ヨ杩囧幓24灏忔椂鐨勬暟鎹�
                 //    SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
                 //}
-                //// 璇锋眰鍙傛暟
+                // 璇锋眰鍙傛暟
                 //var requestData = new
                 //{
                 //    searchDate = SearchDate
@@ -84,14 +85,14 @@
                 var entityList = response.data.Where(Medicat => !existingGoodsNos.Contains(Medicat.goods_no)).Select(Medicat => new Dt_MaterielInfo
                 {
                     MaterielCode = Medicat.goods_no,
-                    MaterielErpType = Medicat.materialCode,
+                    MaterielErpType = Medicat.goods_type,
                     item = Medicat.goods_tym, //閫氱敤鍚�
                     MaterielName = Medicat.goods_spm,//鐗╂枡鍚嶇О
                     MaterielSpec = Medicat.model,
                     Factory = Medicat.factory,
                     MaterielUnit = Medicat.unit,//鍗曚綅
                     // 浣跨敤 ?? 杩愮畻绗︽彁渚涢粯璁ゅ��
-                    MaterielLength = (float?)Medicat.item_length ,
+                    MaterielLength = (float?)Medicat.item_length,
                     MaterielWide = (float?)Medicat.item_width,
                     MaterielHeight = (float?)Medicat.item_hight,
                     MaterielVolume = (float?)Medicat.item_volumn,
@@ -107,7 +108,7 @@
                 ProductSynchronous();
                 return responseContent.OK("鍚屾鎴愬姛");
             }
-            
+
             catch (Exception ex)
             {
                 SendErrorToUpstream(5, "", ex.Message, "");
@@ -126,7 +127,8 @@
             {
                 //鍏堟壘鍒版墍鏈夋湭涓嬪彂鐨勮嵂鍝�
                 //var list = BaseDal.QueryData(x => x.GoodStatus == "鏈笅鍙�").ToList();
-                var list =BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.GoodStatusState == "鏈笅鍙�").ToList();
+                //鎶婂皬浠舵湭涓嬪彂鐨勭殑淇℃伅
+                var list = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.GoodStatusState == "鏈笅鍙�" && x.MaterielSourceType == MaterielSourceTypeEnum.SelfMadePart).ToList();
                 if (list == null || !list.Any())
                 {
                     return new WebResponseContent().OK("鏃犳湭涓嬪彂鑽搧");
@@ -139,28 +141,28 @@
                         //鐢ㄦ埛code
                         customerCode = "905",
                         //鐗╂枡绫诲瀷
-                        materialCode =item.MaterielErpType,
+                        materialCode = item.MaterielErpType,
                         //浜у搧缂栫爜
-                        productCode= item.MaterielCode,
+                        productCode = item.MaterielCode,
                         //浜у搧鍚�
-                        productName =item.MaterielName,
+                        productName = item.MaterielName,
                         //浜у搧鏉$爜
-                        productBarCode= item.MaterielCode,
+                        productBarCode = item.MaterielCode,
 
                         //瑙勬牸
-                        productSpecifications=item.MaterielSpec,
+                        productSpecifications = item.MaterielSpec,
                         //鍗曚綅
                         unit = item.MaterielUnit,
                         //闀�
-                        singleProductLongNum = item.MaterielLength.ToString(),
+                        singleProductLongNum = (item.MaterielLength ?? 0).ToString(),
                         //瀹�
-                        singleProductWideNum = item.MaterielWide.ToString(),
+                        singleProductWideNum = (item.MaterielWide ?? 0).ToString(),
                         //楂�
-                        singleProductHighNum = item.MaterielHeight.ToString(),
+                        singleProductHighNum = (item.MaterielHeight ?? 0).ToString(),
                         //閲嶉噺
-                        singleProductWeight = item.MaterielWeight.ToString(),
+                        singleProductWeight = (item.MaterielWeight ?? 0).ToString(),
                         //浣撶Н
-                        singleProductVolume = item.MaterielVolume.ToString(),
+                        singleProductVolume = (item.MaterielVolume ?? 0).ToString(),
                         //鏄惁鍙栨秷 0鏄笉鍒犻櫎锛�1鍒犻櫎
                         isDelete = "0"
                     };
@@ -168,18 +170,18 @@
                     var result = HttpHelper.Post(url, medicineDTO.ToJsonString());
                     var resp = JsonConvert.DeserializeObject<TowcsResponse<object>>(result);
 
-                    if (resp!=null&&resp.code=="0")
+                    if (resp != null && resp.code == "0")
                     {
                         //鏇存柊鑽搧鐘舵��-宸插畬鎴�
                         BaseDal.Db.Updateable<Dt_MaterielInfo>()
                             .SetColumns(x => x.GoodStatusState == "涓嬪彂瀹屾垚")
-                            .Where(x => x.GoodStatusState == item.MaterielCode)
-                            .ExecuteCommand();  
+                            .Where(x => x.MaterielCode == item.MaterielCode)
+                            .ExecuteCommand();
                     }
                     else
                     {
                         SendErrorToUpstream(5, medicineDTO.materialCode, resp?.msg ?? "WCS鑽搧淇℃伅鍚屾澶辫触", "");
-                      
+
                         return new WebResponseContent { Status = false, Message = "璁㈠崟鎺ㄩ�佸け璐�" };
                     }
 
@@ -203,7 +205,7 @@
         {
             try
             {
-                var goods = BaseDal.Db.Queryable< Dt_MaterielInfo >().Where(x => x.MaterielCode == goodsno).First();
+                var goods = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno).First();
                 if (goods == null)
                 {
                     return new WebResponseContent
@@ -257,8 +259,7 @@
             }
             catch (Exception ex)
             {
-
-              return new WebResponseContent { Status=false,Message = ex.Message };
+                return WebResponseContent.Instance.Error(ex.Message);
             }
         }
 
@@ -290,6 +291,6 @@
             }
         }
 
-       
+
     }
 }

--
Gitblit v1.9.3