From bfc11f87e2b64420c9917c0b9881b3e327d6f796 Mon Sep 17 00:00:00 2001
From: yanjinhui <3306209981@qq.com>
Date: 星期二, 04 十一月 2025 22:19:59 +0800
Subject: [PATCH] 优化调拨出入库

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs |  175 +--------------------------------------------------------
 1 files changed, 5 insertions(+), 170 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..9675747 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;
@@ -26,173 +27,7 @@
         }
         public IRepository<Dt_MedicineGoods> Repository => BaseDal;
 
-        static string SearchDate = "";
 
-        /// <summary>
-        /// 鑾峰彇鑽搧鍩虹淇℃伅鍚屾鎺ュ彛
-        /// </summary>
-        /// <returns></returns>
-        public WebResponseContent GetMedicineGoodsInfom()
-        {
-            var responseContent = new WebResponseContent();
-            try
-            {
-                
-              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");
-                //璇锋眰鍙傛暟
-                var requestData = new
-                {
-                    searchDate = "2009-1-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
-                //};
-                //SearchDate = DateTime.Now.AddDays(-1).ToString("yyyy-MM-dd HH:mm:ss");
-                // 鍙戣捣璇锋眰
-                var result = HttpHelper.Post(url, requestData.ToJsonString());
-
-                // 鍙嶅簭鍒楀寲
-                var response = JsonConvert.DeserializeObject<UpstreamResponse<MedicationsInfo>>(result);
-
-                if (response.resultCode != "0")
-                {
-                    // 璋冪敤寮傚父鎺ュ彛
-                    SendErrorToUpstream(5, "", response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触", "");
-                    return responseContent.Error(response.resultMsg ?? "涓婃父鎺ュ彛杩斿洖澶辫触");
-                }
-                if (response.data == null || !response.data.Any())
-                {
-                    return responseContent.OK("鏃犳柊鑽搧鏁版嵁");
-                }
-
-                //鑾峰彇鎵�鏈夊凡瀛樺湪鐨勫晢鍝佺紪鍙�
-                var existingGoodsNos = BaseDal.Db.Queryable<Dt_MaterielInfo>()
-                    .Select(g => g.MaterielCode)
-                    .ToList();
-
-                // 鏀堕泦鎵�鏈夎鎻掑叆鐨勫疄浣�
-                var entityList = response.data.Where(Medicat => !existingGoodsNos.Contains(Medicat.goods_no)).Select(Medicat => new Dt_MaterielInfo
-                {
-                    MaterielCode = Medicat.goods_no,
-                    MaterielErpType = Medicat.materialCode,
-                    item = Medicat.goods_tym, //閫氱敤鍚�
-                    MaterielName = Medicat.goods_spm,//鐗╂枡鍚嶇О
-                    MaterielSpec = Medicat.model,
-                    Factory = Medicat.factory,
-                    MaterielUnit = Medicat.unit,//鍗曚綅
-                    // 浣跨敤 ?? 杩愮畻绗︽彁渚涢粯璁ゅ��
-                    MaterielLength = (float?)Medicat.item_length ,
-                    MaterielWide = (float?)Medicat.item_width,
-                    MaterielHeight = (float?)Medicat.item_hight,
-                    MaterielVolume = (float?)Medicat.item_volumn,
-                    MaterielWeight = (float?)Medicat.item_weight,
-                    MaterielStoragecondition = float.TryParse(Medicat.storage_confition, out var val) ? val : null, //鍌ㄥ瓨鏉′欢
-                    Remark = Medicat.remark,
-                    GoodStatusState = "鏈笅鍙�",
-                    ModifyDate = Medicat.modify_date
-                }).ToList();
-                // 涓�娆℃�ф壒閲忔彃鍏ユ暟鎹簱
-                BaseDal.Db.Insertable(entityList).ExecuteCommand();
-
-                ProductSynchronous();
-                return responseContent.OK("鍚屾鎴愬姛");
-            }
-            
-            catch (Exception ex)
-            {
-                SendErrorToUpstream(5, "", ex.Message, "");
-                return responseContent.Error(ex.Message);
-            }
-        }
-
-
-        /// <summary>
-        /// 鍙戠粰涓嬫父wcs鍚屾鑽搧淇℃伅 
-        /// </summary>
-        /// <returns></returns>
-        public WebResponseContent ProductSynchronous()
-        {
-            try
-            {
-                //鍏堟壘鍒版墍鏈夋湭涓嬪彂鐨勮嵂鍝�
-                //var list = BaseDal.QueryData(x => x.GoodStatus == "鏈笅鍙�").ToList();
-                var list =BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.GoodStatusState == "鏈笅鍙�").ToList();
-                if (list == null || !list.Any())
-                {
-                    return new WebResponseContent().OK("鏃犳湭涓嬪彂鑽搧");
-                }
-                //鎵惧埌浜嗗氨灏嗘暣涓猯ist鍙戠粰涓嬫父绯荤粺
-                foreach (var item in list)
-                {
-                    var medicineDTO = new ProductInfo
-                    {
-                        //鐢ㄦ埛code
-                        customerCode = "905",
-                        //鐗╂枡绫诲瀷
-                        materialCode =item.MaterielErpType,
-                        //浜у搧缂栫爜
-                        productCode= item.MaterielCode,
-                        //浜у搧鍚�
-                        productName =item.MaterielName,
-                        //浜у搧鏉$爜
-                        productBarCode= item.MaterielCode,
-
-                        //瑙勬牸
-                        productSpecifications=item.MaterielSpec,
-                        //鍗曚綅
-                        unit = item.MaterielUnit,
-                        //闀�
-                        singleProductLongNum = item.MaterielLength.ToString(),
-                        //瀹�
-                        singleProductWideNum = item.MaterielWide.ToString(),
-                        //楂�
-                        singleProductHighNum = item.MaterielHeight.ToString(),
-                        //閲嶉噺
-                        singleProductWeight = item.MaterielWeight.ToString(),
-                        //浣撶Н
-                        singleProductVolume = item.MaterielVolume.ToString(),
-                        //鏄惁鍙栨秷 0鏄笉鍒犻櫎锛�1鍒犻櫎
-                        isDelete = "0"
-                    };
-                    var url = "http://172.16.1.2:9357/file-admin/api/product/productSynchronous";
-                    var result = HttpHelper.Post(url, medicineDTO.ToJsonString());
-                    var resp = JsonConvert.DeserializeObject<TowcsResponse<object>>(result);
-
-                    if (resp!=null&&resp.code=="0")
-                    {
-                        //鏇存柊鑽搧鐘舵��-宸插畬鎴�
-                        BaseDal.Db.Updateable<Dt_MaterielInfo>()
-                            .SetColumns(x => x.GoodStatusState == "涓嬪彂瀹屾垚")
-                            .Where(x => x.GoodStatusState == item.MaterielCode)
-                            .ExecuteCommand();  
-                    }
-                    else
-                    {
-                        SendErrorToUpstream(5, medicineDTO.materialCode, resp?.msg ?? "WCS鑽搧淇℃伅鍚屾澶辫触", "");
-                      
-                        return new WebResponseContent { Status = false, Message = "璁㈠崟鎺ㄩ�佸け璐�" };
-                    }
-
-                }
-                return new WebResponseContent { Status = true, Message = "鎴愬姛" };
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine("ProductSynchronous 寮傚父锛�" + ex.Message);
-                return new WebResponseContent { Status = false, Message = ex.Message };
-            }
-
-        }
 
         /// <summary>
         /// 鍚屾鍒犻櫎鍒犻櫎鍟嗗搧淇℃伅 
@@ -203,7 +38,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 +92,7 @@
             }
             catch (Exception ex)
             {
-
-              return new WebResponseContent { Status=false,Message = ex.Message };
+                return WebResponseContent.Instance.Error(ex.Message);
             }
         }
 
@@ -289,7 +123,8 @@
                 Console.WriteLine("寮傚父鎺ュ彛鎺ㄩ�佸け璐ワ細" + e.Message);
             }
         }
+        
 
-       
+
     }
 }

--
Gitblit v1.9.3