From 23f7d0e0cf31ea6a7cde81bf23ef07091bd4f3a7 Mon Sep 17 00:00:00 2001
From: dengjunjie <dengjunjie@hnkhzn.com>
Date: 星期一, 03 十一月 2025 14:22:35 +0800
Subject: [PATCH] 添加人工触发调拨单

---
 新建文件夹/WIDESEA_WMSServer/WIDESEA_SquareCabinServices/MedicineGoodsServices.cs |  198 ++++---------------------------------------------
 1 files changed, 16 insertions(+), 182 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 2429882..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,171 +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 = "2022-10-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_MedicineGoods>()
-                    .Select(g => g.Goods_no)
-                    .ToList();
-
-                // 鏀堕泦鎵�鏈夎鎻掑叆鐨勫疄浣�
-                var entityList = response.data.Where(Medicat => !existingGoodsNos.Contains(Medicat.goods_no)).Select(Medicat => new Dt_MedicineGoods
-                {
-                    Goods_no = Medicat.goods_no,
-                    MaterialCode=Medicat.materialCode,
-                    Goods_spm = Medicat.goods_spm,
-                    Model = Medicat.model,
-                    Factory = Medicat.factory,
-                    Unit = Medicat.unit,
-                    // 浣跨敤 ?? 杩愮畻绗︽彁渚涢粯璁ゅ��
-                    Item_Iength = Medicat.item_length ,
-                    Item_width = Medicat.item_width,
-                    Item_hight = Medicat.item_hight,
-                    Item_volumn = Medicat.item_volumn,
-                    Item_weight = Medicat.item_weight,
-                    Storage_cond = Medicat.storage_cond,
-                    Remark = Medicat.remark,
-                    GoodStatus = "鏈笅鍙�",
-                    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();
-                if (list == null || !list.Any())
-                {
-                    return new WebResponseContent().OK("鏃犳湭涓嬪彂鑽搧");
-                }
-                //鎵惧埌浜嗗氨灏嗘暣涓猯ist鍙戠粰涓嬫父绯荤粺
-                foreach (var item in list)
-                {
-                    var medicineDTO = new ProductInfo
-                    {
-                        //鐢ㄦ埛code
-                        customerCode = "905",
-                        //鐗╂枡绫诲瀷
-                        materialCode =item.MaterialCode,
-                        //浜у搧缂栫爜
-                        productCode= item.Goods_no,
-                        //浜у搧鍚�
-                        productName =item.Goods_spm ,
-                        //浜у搧鏉$爜
-                        productBarCode= item.Goods_no,
-
-                        //瑙勬牸
-                        productSpecifications=item.Model,
-                        //鍗曚綅
-                        unit = item.Unit,
-                        //闀�
-                        singleProductLongNum = item.Item_Iength.ToString(),
-                        //瀹�
-                        singleProductWideNum = item.Item_weight.ToString(),
-                        //楂�
-                        singleProductHighNum = item.Item_hight.ToString(),
-                        //閲嶉噺
-                        singleProductWeight = item.Item_weight.ToString(),
-                        //浣撶Н
-                        singleProductVolume = item.Item_volumn.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_MedicineGoods>()
-                            .SetColumns(x => x.GoodStatus == "涓嬪彂瀹屾垚")
-                            .Where(x => x.Goods_no == item.Goods_no)
-                            .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>
         /// 鍚屾鍒犻櫎鍒犻櫎鍟嗗搧淇℃伅 
@@ -199,10 +36,9 @@
         /// <returns></returns>
         public WebResponseContent DeleteProduct(string goodsno)
         {
-            
             try
             {
-                var goods = BaseDal.QueryData(x => x.Goods_no == goodsno).FirstOrDefault();
+                var goods = BaseDal.Db.Queryable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno).First();
                 if (goods == null)
                 {
                     return new WebResponseContent
@@ -218,26 +54,26 @@
                     //鐗╂枡绫诲瀷
                     materialCode = "YY",
                     //浜у搧缂栫爜
-                    productCode = goods.Goods_no,
+                    productCode = goods.MaterielCode,
                     //浜у搧鍚�
-                    productName = goods.Goods_spm,
+                    productName = goods.MaterielName,
                     //浜у搧鏉$爜
-                    productBarCode = goods.Goods_no,
+                    productBarCode = goods.MaterielCode,
 
                     //瑙勬牸
-                    productSpecifications = goods.Model,
+                    productSpecifications = goods.MaterielSpec,
                     //鍗曚綅
-                    unit = goods.Unit,
+                    unit = goods.MaterielUnit,
                     //闀�
-                    singleProductLongNum = goods.Item_Iength.ToString(),
+                    singleProductLongNum = goods.MaterielLength.ToString(),
                     //瀹�
-                    singleProductWideNum = goods.Item_weight.ToString(),
+                    singleProductWideNum = goods.MaterielWide.ToString(),
                     //楂�
-                    singleProductHighNum = goods.Item_hight.ToString(),
+                    singleProductHighNum = goods.MaterielHeight.ToString(),
                     //閲嶉噺
-                    singleProductWeight = goods.Item_weight.ToString(),
+                    singleProductWeight = goods.MaterielWeight.ToString(),
                     //浣撶Н
-                    singleProductVolume = goods.Item_volumn.ToString(),
+                    singleProductVolume = goods.MaterielVolume.ToString(),
                     //鏄惁鍙栨秷 0鏄笉鍒犻櫎锛�1鍒犻櫎
                     isDelete = "1"
                 };
@@ -249,17 +85,14 @@
                 if (resp != null && resp.code == "0")
                 {
                     //鎴戣嚜宸变篃鍒犻櫎
-                    BaseDal.DeleteData(goods);
+                    base.Db.Deleteable<Dt_MaterielInfo>().Where(x => x.MaterielCode == goodsno);
                     return new WebResponseContent { Status = true, Message = "鍒犻櫎鎴愬姛" };
                 }
                 return new WebResponseContent { Status = false, Message = "鍒犻櫎澶辫触璇烽噸璇�" };
-              
-               
             }
             catch (Exception ex)
             {
-
-              return new WebResponseContent { Status=false,Message = ex.Message };
+                return WebResponseContent.Instance.Error(ex.Message);
             }
         }
 
@@ -290,7 +123,8 @@
                 Console.WriteLine("寮傚父鎺ュ彛鎺ㄩ�佸け璐ワ細" + e.Message);
             }
         }
+        
 
-       
+
     }
 }

--
Gitblit v1.9.3