From 202f048d2c23d581f304d2332a35a0b0184ec0a8 Mon Sep 17 00:00:00 2001
From: yxj <1qaz@123>
Date: 星期四, 28 七月 2022 10:40:37 +0800
Subject: [PATCH] 直接调拨单校验扫码模块,新增扫描物料条码功能:源单中存在多行相同物料时自动拆分换行匹配源单数据

---
 CLOUDWEB/WebService1.asmx.cs |  128 ++++++++++++++++++++++++++++--------------
 1 files changed, 85 insertions(+), 43 deletions(-)

diff --git a/CLOUDWEB/WebService1.asmx.cs b/CLOUDWEB/WebService1.asmx.cs
index 094aea4..a990ea6 100644
--- a/CLOUDWEB/WebService1.asmx.cs
+++ b/CLOUDWEB/WebService1.asmx.cs
@@ -40320,8 +40320,15 @@
                 sWHSPCtl = "N";
             }
 
+            string sMultilineCtl = "N";   //鏍¢獙-澶氳鐩稿悓鐗╂枡鑷姩鎷嗗垎鎹㈣鍖归厤锛�'Y'涓鸿嚜鍔ㄦ媶鍒嗭級
+            if (HBillType == "1207" && oSystemParameterMain.Kf_MoveStockBillCheck_MultilineCtl == "Y")
+            {
+                //鐩存帴璋冩嫧鍗�
+                sMultilineCtl = "Y";
+            }
+
             //鍒ゆ柇鏄惁瀛樺湪鐩稿悓鏉$爜锛屽垽鏂墍鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓�
-            DataSet ds1 = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_MoveStockBillCheck '" + omodel_View.HBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + "," + HSCWHID + "," + HSCSPID + ",'" + sWHSPCtl + "'", "h_p_WMS_AddBarCode_MoveStockBillCheck");
+            DataSet ds1 = oCn.RunProcReturn("exec h_p_WMS_AddBarCode_MoveStockBillCheck_New '" + omodel_View.HBarCode + "'," + HBillID.ToString() + ",'" + HBillNo + "','" + HBillType + "'," + HWhID + "," + HSPID + "," + HSCWHID + "," + HSCSPID + ",'" + sWHSPCtl + "','" + sMultilineCtl + "'", "h_p_WMS_AddBarCode_MoveStockBillCheck_New");
             if (ds1 == null || ds1.Tables[0].Rows.Count == 0)
             {
                 sErrMsg = "鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀湪鍗曟嵁涓彂鐢熼敊璇紒";
@@ -40332,10 +40339,7 @@
                 if (DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0][0]) == 0)
                 {
                     omodel_View.HMaterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HMaterID"]);
-                    omodel_View.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[0]["HSourceBillNo"]);
-                    omodel_View.HSourceEntryID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSourceEntryID"]);
-                    omodel_View.HSourceInterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSourceInterID"]);
-                    omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[0]["HQtyMust"]);     //婧愬崟鍙壂鏁伴噺
+                    omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[0]["HSumQtyMust"]);     //HSumQtyMust涓烘簮鍗曠浉鍚岀墿鏂欏墿浣欏彲鎵暟閲�
                     HWhID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HWhID"]);
                     HSPID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSPID"]);
                     HSCWHID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[0]["HSCWHID"]);
@@ -40478,45 +40482,83 @@
                 }
             }
 
-            oMain.HInterID = HBillID;
-            oMain.HBillNo = HBillNo;
-            oMain.HBillType = HBillType;
-            oMain.HMaker = HMaker;
-            oMain.HMaterID = omodel_View.HMaterID;
-            oMain.HAuxPropID = omodel_View.HAuxPropID;
-            oMain.HQty = sRelQty;
-            oMain.HQtyMust = 0;
-            oMain.HBarCode = omodel_View.HBarCode;
-            oMain.HBatchNo = omodel_View.HBatchNo;
-            oMain.HMTONo = omodel_View.HMTONo;
-            oMain.HWhID = HWhID;
-            oMain.HStockPlaceID = HSPID;
-            oMain.HSCWHID = HSCWHID;
-            oMain.HOutStockPlaceID = HSCSPID;
-            oMain.HSourceInterID = omodel_View.HSourceInterID;
-            oMain.HSourceEntryID = omodel_View.HSourceEntryID;
-            oMain.HSourceBillNo = omodel_View.HSourceBillNo;
-            oMain.HSourceBillType = HBillType;
-            oMain.HRedBlueFlag = false;
-            oMain.HPieceQty = 1;
-            oMain.HSTOCKORGID = HOWNERID;
-            oMain.HOWNERID = HOWNERID;
+            double sSumQty = 0;
+            double sRemQty = 0;
+            for (int i = 0; i < ds1.Tables[0].Rows.Count; i++)
+            {
+                omodel_View.HSourceQty = DBUtility.ClsPub.isDoule(ds1.Tables[0].Rows[i]["HQtyMust"]);   //瀛樺湪鐩稿悓鐗╂枡鏃讹紝鍏朵腑涓�琛屾簮鍗曞墿浣欏彲鎵暟閲�
+                sSumQty = sSumQty + omodel_View.HSourceQty;
+                sRemQty = sRelQty - sSumQty;
 
-            oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
-                "(HInterID,HBillNo,HBillType,HMaterID,HAuxPropID,HProcID" +
-                ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID,HAddr" +
-                ",HQtyMust,HQty,HPieceQty,HBatchNo,HBarCode,HBarCode_Pack" +
-                ",HMaker,HMakeDate,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
-                ",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag,HMTONo,HPlanMode" +
-                ",HSTOCKORGID,HOtherOrgID,HOWNERID,HOWNERTYPEID,HExpressNumber,HSubBillType" +
-                ",HCusID,HDeptID,HCusBarCode,HMulSourceBill) " +
-                " Values(" + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'," + oMain.HMaterID.ToString() + "," + oMain.HAuxPropID.ToString() + "," + oMain.HProcID.ToString() +
-                "," + oMain.HWhID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HStockPlaceID.ToString() + "," + oMain.HOutStockPlaceID.ToString() + "," + oMain.HGroupID.ToString() + ",'" + oMain.HAddr + "'" +
-                "," + oMain.HQtyMust.ToString() + "," + oMain.HQty.ToString() + "," + oMain.HPieceQty.ToString() + ",'" + oMain.HBatchNo + "','" + oMain.HBarCode + "',''" +
-                ",'" + oMain.HMaker + "',getdate()," + oMain.HSourceInterID.ToString() + "," + oMain.HSourceEntryID.ToString() + ",'" + oMain.HSourceBillType + "','" + oMain.HSourceBillNo + "'" +
-                "," + oMain.HRelationInterID.ToString() + "," + oMain.HRelationEntryID.ToString() + ",'" + oMain.HRelationBillNo + "'," + Convert.ToString(oMain.HRedBlueFlag ? 1 : 0) + ",'" + oMain.HMTONo + "',0" +
-                "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() + ",'','鏍¢獙妯″紡',1" +
-                ",0,0,'" + oMain.HCusBarCode + "',0)");
+                //鏁伴噺
+                //鍙瓨鍦ㄤ竴琛屾暟鎹椂锛屾暟閲�=鏉$爜鍙壂鏁伴噺
+                if (ds1.Tables[0].Rows.Count==1)
+                {
+                    oMain.HQty = sRelQty;
+                }
+                //瀛樺湪澶氳鐩稿悓鐗╂枡锛屾潯鐮佸墿浣欐暟閲�<鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺 鎴� 鎵�閫夎婧愬崟涓烘渶鍚庝竴鏉℃暟鎹椂 锛屾暟閲�=鏉$爜鍓╀綑鏁伴噺
+                else if (sRemQty <= 0 || (i == ds1.Tables[0].Rows.Count-1 && sRemQty > 0))
+                {
+                    oMain.HQty = sRemQty + omodel_View.HSourceQty;
+                }
+                //瀛樺湪澶氳鐩稿悓鐗╂枡锛屾潯鐮佸墿浣欐暟閲�>鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺 锛屾暟閲�=鎵�閫夎婧愬崟鍓╀綑鍙壂鏁伴噺
+                else
+                {
+                    oMain.HQty = omodel_View.HSourceQty;
+                }
+                //鏉$爜鏉℃暟
+                if (i == 0)
+                {
+                    oMain.HPieceQty = 1;
+                }
+                else
+                {
+                    oMain.HPieceQty = 0;
+                }
+
+                oMain.HInterID = HBillID;
+                oMain.HBillNo = HBillNo;
+                oMain.HBillType = HBillType;
+                oMain.HMaker = HMaker;
+                oMain.HMaterID = omodel_View.HMaterID;
+                oMain.HAuxPropID = omodel_View.HAuxPropID;
+                oMain.HQtyMust = 0;
+                oMain.HBarCode = omodel_View.HBarCode;
+                oMain.HBatchNo = omodel_View.HBatchNo;
+                oMain.HMTONo = omodel_View.HMTONo;
+                oMain.HWhID = HWhID;
+                oMain.HStockPlaceID = HSPID;
+                oMain.HSCWHID = HSCWHID;
+                oMain.HOutStockPlaceID = HSCSPID;
+                oMain.HSourceInterID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[i]["HSourceInterID"]);
+                oMain.HSourceEntryID = DBUtility.ClsPub.isLong(ds1.Tables[0].Rows[i]["HSourceEntryID"]);
+                oMain.HSourceBillNo = DBUtility.ClsPub.isStrNull(ds1.Tables[0].Rows[i]["HSourceBillNo"]);
+                oMain.HSourceBillType = HBillType;
+                oMain.HRedBlueFlag = false;
+                oMain.HSTOCKORGID = HOWNERID;
+                oMain.HOWNERID = HOWNERID;
+
+                oCn.RunProc("Insert into KF_PonderationBillMain_Temp " +
+                    "(HInterID,HBillNo,HBillType,HMaterID,HAuxPropID,HProcID" +
+                    ",HWhID,HSCWHID,HStockPlaceID,HOutStockPlaceID,HGroupID,HAddr" +
+                    ",HQtyMust,HQty,HPieceQty,HBatchNo,HBarCode,HBarCode_Pack" +
+                    ",HMaker,HMakeDate,HSourceInterID,HSourceEntryID,HSourceBillType,HSourceBillNo" +
+                    ",HRelationInterID,HRelationEntryID,HRelationBillNo,HRedBlueFlag,HMTONo,HPlanMode" +
+                    ",HSTOCKORGID,HOtherOrgID,HOWNERID,HOWNERTYPEID,HExpressNumber,HSubBillType" +
+                    ",HCusID,HDeptID,HCusBarCode,HMulSourceBill) " +
+                    " Values(" + oMain.HInterID.ToString() + ",'" + oMain.HBillNo + "','" + oMain.HBillType + "'," + oMain.HMaterID.ToString() + "," + oMain.HAuxPropID.ToString() + "," + oMain.HProcID.ToString() +
+                    "," + oMain.HWhID.ToString() + "," + oMain.HSCWHID.ToString() + "," + oMain.HStockPlaceID.ToString() + "," + oMain.HOutStockPlaceID.ToString() + "," + oMain.HGroupID.ToString() + ",'" + oMain.HAddr + "'" +
+                    "," + oMain.HQtyMust.ToString() + "," + oMain.HQty.ToString() + "," + oMain.HPieceQty.ToString() + ",'" + oMain.HBatchNo + "','" + oMain.HBarCode + "',''" +
+                    ",'" + oMain.HMaker + "',getdate()," + oMain.HSourceInterID.ToString() + "," + oMain.HSourceEntryID.ToString() + ",'" + oMain.HSourceBillType + "','" + oMain.HSourceBillNo + "'" +
+                    "," + oMain.HRelationInterID.ToString() + "," + oMain.HRelationEntryID.ToString() + ",'" + oMain.HRelationBillNo + "'," + Convert.ToString(oMain.HRedBlueFlag ? 1 : 0) + ",'" + oMain.HMTONo + "',0" +
+                    "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HSTOCKORGID.ToString() + "," + oMain.HOWNERID.ToString() + ",'','鏍¢獙妯″紡',1" +
+                    ",0,0,'" + oMain.HCusBarCode + "',0)");
+
+                if (sRemQty <= 0)
+                {
+                    break;
+                }
+            }
             return true;
         }
 

--
Gitblit v1.9.1