From 68c930d60394ec8f741e41d82465a916836d4bdf Mon Sep 17 00:00:00 2001
From: 王 垚 <1402714037@qq.com>
Date: 星期三, 26 十月 2022 08:45:12 +0800
Subject: [PATCH] 优化

---
 WebAPI/Controllers/POStockInBillController.cs |   40 ++++++++++++++++++++++++++++++++++++++--
 1 files changed, 38 insertions(+), 2 deletions(-)

diff --git a/WebAPI/Controllers/POStockInBillController.cs b/WebAPI/Controllers/POStockInBillController.cs
index 1e8517e..2aa0519 100644
--- a/WebAPI/Controllers/POStockInBillController.cs
+++ b/WebAPI/Controllers/POStockInBillController.cs
@@ -1475,6 +1475,19 @@
                 var hinterID = list[0].HInterID;
                 var FID = list[0].FID;
 
+                #region 鏍¢獙鏄惁鎵弿鏉$爜
+                var HInterID = list[0].HInterID;
+                string jysql = string.Format(@"select * from KF_PonderationBillMain_Temp where HSourceInterID = {0}", HInterID);
+                DataTable jyDt =oCn.RunProcReturn(jysql, "jysql").Tables[0];
+                if (jyDt.Rows.Count == 0 || jyDt == null)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "璇锋壂鎻忔潯鐮�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                #endregion
                 #region 閲戣澏瀹℃牳鍚庝細閲嶆柊鍚屾鍗曟嵁鍒癿es 鏁呬笉闇�瑕佹洿鏂癿es鐨勬敹鏂欓�氱煡鍗� 
                 /*
                 oCn.BeginTran();
@@ -1496,7 +1509,7 @@
                 //鏇存柊鎴愬姛鍚� 鍚屾鏇存柊閲戣澏
                 oCn.Commit();
                 **/
-                #endregion 
+                #endregion
 
                 JObject jsonRoot = new JObject();
                 jsonRoot.Add("Creator", "");
@@ -1605,7 +1618,7 @@
             {
                 //var code = HBarcode.Split('#')[0];
                 //鏍¢獙鏉$爜鏄惁瀛樺湪
-                string sql = $"select* from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode.Split('#')[0]}' and HQty = {HBarcode.Split('#')[1]}";
+                string sql = $"select HItemID,HSourceBillNo from  Gy_BarCodeBill where HSourceInterID ={HInterID} and HBarCode = '{HBarcode.Split('#')[0]}' and HQty = {HBarcode.Split('#')[1]}";
                 DataSet ds = oCn.RunProcReturn(sql, "H_v_SRM_POOrderBillList");
                 if (ds.Tables[0].Rows.Count == 0)
                 {
@@ -1615,6 +1628,29 @@
                     objJsonResult.data = ds.Tables[0];
                     return objJsonResult;
                 }
+                else
+                {
+                    //瀛樺叆鏉$爜涓存椂琛�
+                    sql = $"delete from KF_PonderationBillMain_Temp Where HBillNo='{ds.Tables[0].Rows[0]["HSourceBillNo"]}' ";
+                    oCn.RunProc(sql);
+                    sql = string.Format(@"Insert into KF_PonderationBillMain_Temp 
+	(HInterID,HBillNo,HBillType,HMaterID,HProcID,HWhID,HSCWHID
+	,HStockPlaceID,HOutStockPlaceID,HGroupID,HQty,HQtyMust,HPieceQty
+	,HAuxPropID,HBatchNo,HBarCode,HAddr,HMaker,HMakeDate
+	,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo
+	,HSTOCKORGID,HOWNERID,HExpressNumber,HSubBillType
+	,HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag
+	,HCusID)
+	select HInterID,HSourceBillNo,HBillType,HMaterID,0,0,0
+	,0,0,0,HQty,HQty,0
+	,HAuxPropID,HBatchNo,'','','System',getdate()
+	,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo,HMTONo
+	,HSTOCKORGID,HOWNERID,'',HBillType
+	,0,0,'',0
+	,0 from Gy_BarCodeBill  
+	where HItemID = {0}", ds.Tables[0].Rows[0]["HItemID"]);
+                    oCn.RunProc(sql);
+                }
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;

--
Gitblit v1.9.1