From 4cf8cdb357e04b1004b0fdfe3ed3dc367f0dd0c2 Mon Sep 17 00:00:00 2001
From: yusijie <ysj@hz-kingdee.com>
Date: 星期三, 28 六月 2023 14:18:00 +0800
Subject: [PATCH] 生产退料单

---
 WebAPI/Controllers/条码管理/WEBSController.cs     |   79 +++++++++++++++++++++++++++++----------
 WebAPI/Controllers/POStockInBillController.cs |    2 
 2 files changed, 59 insertions(+), 22 deletions(-)

diff --git a/WebAPI/Controllers/POStockInBillController.cs b/WebAPI/Controllers/POStockInBillController.cs
index 1254a72..c56ce92 100644
--- a/WebAPI/Controllers/POStockInBillController.cs
+++ b/WebAPI/Controllers/POStockInBillController.cs
@@ -969,7 +969,7 @@
                     string text4 = ClsPub.isStrNull(dataSet2.Tables[0].Rows[0]["HModel"]);
                     long num3 = (long)ClsPub.isInt(dataSet2.Tables[0].Rows[0]["HUnitID"]);
                     text = str3 + num2.ToString() + text2  + "#" + num;
-                    text1 = str3 + num2.ToString() + text2;
+                    text1 = str3 + num2.ToString() + text2;//缁勭粐浠g爜+鐗╂枡id+鎵瑰彿
                     //鎵炬簮鍗�
                     DataSet dataSet3 = clsCN.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FSRCBILLNO= '" + str2 + "' and  FLOT_TEXT = '" + text2 + "' and  FMATERIALID = " + num2.ToString(), "h_v_RECEIVEQuery");
                     //DataSet dataSet3 = clsCN.RunProcReturn(" select fid,FMATERIALID,FENTRYID,FBILLNO from h_v_RECEIVEQuery where FLOT_TEXT= '" + text2 + "' and FPRODUCEDATE = '" + dateTime + "' and  FMATERIALID = " + num2.ToString(), "h_v_RECEIVEQuery");
diff --git "a/WebAPI/Controllers/\346\235\241\347\240\201\347\256\241\347\220\206/WEBSController.cs" "b/WebAPI/Controllers/\346\235\241\347\240\201\347\256\241\347\220\206/WEBSController.cs"
index 1ee4400..373ba53 100644
--- "a/WebAPI/Controllers/\346\235\241\347\240\201\347\256\241\347\220\206/WEBSController.cs"
+++ "b/WebAPI/Controllers/\346\235\241\347\240\201\347\256\241\347\220\206/WEBSController.cs"
@@ -940,34 +940,71 @@
                 }
                 try
                 {
-                    oCn.BeginTran();//寮�濮嬩簨鐗�
-
-                    WebSoBar = oWebs.get_BarCode(sJXCode, HInterID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HStockOrgID, HScanStyle, HCustom1, HCustom2, ref DBUtility.ClsPub.sErrInfo);
-
                     if (oSystemParameter.omodel.WMS_CampanyName == "瀹夌憺" && int.Parse(HBillType) == 1244)
                     {
-                        ds = oCn.RunProcReturn("select HMaterID,HQty,HBatchNo from KF_PonderationBillMain_Temp where HInterID = " + HInterID + "and HBillNo = '" + HBillNo + "'", "KF_PonderationBillMain_Temp");
+                        string[] arr = sBarCode.Split('@');
+                        string HMaterNumber = arr[0]; //鐗╂枡浠g爜
+                        string HBatchNo = arr[6]; //鎵规
+                        string HMaterQty = arr[4]; //鏁伴噺
+                        string HMaterID = "";
+
+                        //鐢ㄦ媶鍒嗗嚭鏉ョ殑鐗╂枡浠g爜鏌ヨ鐗╂枡琛ㄩ噷鐨勭墿鏂檌d
+                        DataSet ds_material;
+                        ds_material = oCn.RunProcReturn(" select FMATERIALID from AIS20220914133941..T_BD_MATERIAL where FNumber = '" + HMaterNumber + "' and FUSEORGID = " + HStockOrgID, "T_BD_MATERIAL");
+
+                        if (ds_material != null || ds_material.Tables[0].Rows.Count > 0)
+                        {                         
+                            HMaterID = ds_material.Tables[0].Rows[0]["FMATERIALID"].ToString();
+                        }
+                        else
+                        {
+                            //鏂扮墿缂栫爜閲屾病鏈夎繑鍥炴暟鎹垯鏌ヨ鐗╂枡琛ㄩ噷鐨勬棫鐗╂枡缂栫爜
+                            DataSet ds_material_old;
+                            ds_material_old = oCn.RunProcReturn(" select FMATERIALID from AIS20220914133941..T_BD_MATERIAL where FOldNumber = '" + HMaterNumber + "' and FUSEORGID =" + HStockOrgID, "T_BD_MATERIAL");
+
+                            if (ds_material_old != null || ds_material_old.Tables[0].Rows.Count > 0)
+                            {
+                                HMaterID = ds_material_old.Tables[0].Rows[0]["FMATERIALID"].ToString();
+                            }
+                            else
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "娌℃湁鏌ヨ鍒扮墿鏂欎俊鎭紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }                       
+
+                        ds = oCn.RunProcReturn("select HMaterID,HQty,HBatchNo from KF_PonderationBillMain_Temp where HInterID = " + HInterID + "and HBillNo = '" + HBillNo + "' and HMaterID = " + HMaterID + " and HBatchNo = '" + HBatchNo + "' and HQty = " + HMaterQty, "KF_PonderationBillMain_Temp");
+
                         if (ds.Tables[0].Rows.Count > 0)
                         {
-                            for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
-                            {
-                                for (var j = i + 1; j < ds.Tables[0].Rows.Count; j++)
-                                {
-                                    if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]) == DBUtility.ClsPub.isLong(ds.Tables[0].Rows[j]["HMaterID"]) && DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HQty"]) == DBUtility.ClsPub.isLong(ds.Tables[0].Rows[j]["HQty"]) && DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HBatchNo"]) == DBUtility.ClsPub.isLong(ds.Tables[0].Rows[j]["HBatchNo"]))
-                                    {
-                                        oCn.RollBack();
-                                        objJsonResult.code = "0";
-                                        objJsonResult.count = 0;
-                                        objJsonResult.Message = "鍚屼竴鍗曟嵁鍙蜂腑宸叉壂杩囦俊鎭浉鍚岀殑鏉$爜";
-                                        objJsonResult.data = null;
-                                        return objJsonResult;
-                                    }
-                                }
-                            }
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍚屼竴鍗曟嵁鍙蜂腑宸叉壂杩囦俊鎭浉鍚岀殑鏉$爜";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+
+                            //for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
+                            //{
+                            //    for (var j = i + 1; j < ds.Tables[0].Rows.Count; j++)
+                            //    {
+                            //        if (DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HMaterID"]) == DBUtility.ClsPub.isLong(ds.Tables[0].Rows[j]["HMaterID"]) && DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HQty"]) == DBUtility.ClsPub.isLong(ds.Tables[0].Rows[j]["HQty"]) && DBUtility.ClsPub.isLong(ds.Tables[0].Rows[i]["HBatchNo"]) == DBUtility.ClsPub.isLong(ds.Tables[0].Rows[j]["HBatchNo"]))
+                            //        {
+                            //            objJsonResult.code = "0";
+                            //            objJsonResult.count = 0;
+                            //            objJsonResult.Message = "鍚屼竴鍗曟嵁鍙蜂腑宸叉壂杩囦俊鎭浉鍚岀殑鏉$爜";
+                            //            objJsonResult.data = null;
+                            //            return objJsonResult;
+                            //        }
+                            //    }
+                            //}
                         }
                     }
-                    oCn.Commit();//鎻愪氦浜嬬墿
 
+                    WebSoBar = oWebs.get_BarCode(sJXCode, HInterID, HBillType, HBillNo, HMaker, HWhID, HSPID, HQty, HRedBlueFlag, SourceFlag, HSourceBillNo, HSourceBillType, HStockOrgID, HScanStyle, HCustom1, HCustom2, ref DBUtility.ClsPub.sErrInfo);
+                  
                     if (WebSoBar == null)
                     {
                         objJsonResult.code = "0";

--
Gitblit v1.9.1