From 02789cadcfafd3cb02f4bee8b2fbec32a7c72310 Mon Sep 17 00:00:00 2001
From: llj <132905093+newwwwwwtree@users.noreply.github.com>
Date: 星期二, 09 九月 2025 19:50:56 +0800
Subject: [PATCH] 条码打印补充

---
 WebAPI/Controllers/MaterialHandingController.cs         |   10 ++-
 WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs |  111 +++++++++++++++++++++++++++---------
 WebAPI/WebAPI.csproj                                    |    3 
 3 files changed, 90 insertions(+), 34 deletions(-)

diff --git a/WebAPI/Controllers/MaterialHandingController.cs b/WebAPI/Controllers/MaterialHandingController.cs
index d287e02..3c4e922 100644
--- a/WebAPI/Controllers/MaterialHandingController.cs
+++ b/WebAPI/Controllers/MaterialHandingController.cs
@@ -263,13 +263,17 @@
             {
                 //ds1鑾峰彇鐨剆ql鍚庢湡璁板緱鏀瑰洖渚涘簲鍟嗭紝淇敼浜�->渚涘簲鍟�
                 var ds1 = oCN.RunProcReturn("select * from h_v_Gy_UserMaterRelationEdit where 鐗╂枡浠g爜='" + HMaterID + "'" + "and 淇敼浜�='" + user + "'", "h_v_Gy_UserMaterRelationEdit");
-                var ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterID+ "'", "Gy_Material");
-
+                var ds = oCN.RunProcReturn("select * from Gy_Material where HNumber='" + HMaterID+ "'"+ " and HUSEORGID="+"'"+ OrganizationID+"'", "Gy_Material");
+                if(ds.Tables[0].Rows.Count == 0)
+                {
+                    return 2;
+                }
                 if (param == 0)
                 {
-                    if (ds1.Tables[0].Rows.Count > 0)
+                    if (ds1.Tables[0].Rows.Count > 0)//鐗╂枡閲嶅锛屽脊鍑鸿闂�
                     {
                         return 1;
+
                     }
                     else
                     {
diff --git a/WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs b/WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs
index debdad8..4eeceed 100644
--- a/WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs
+++ b/WebAPI/Controllers/SRM_MaterialBarCodeBillController.cs
@@ -165,8 +165,14 @@
                 LSH = ClsPub.isInt(Ds.Tables[0].Rows[0][0]);
                 #endregion
 
+                //// 瀛樺偍鐢熸垚鐨勬潯鐮佸垪琛�
+                List<string> generatedBarcodes = new List<string>();
+
+                var biaoqianCount = 0;
                 foreach (Model.ClsGy_MaterialBarCodeBillModel oItemSub in ls)
                 {
+                    biaoqianzhangshu = ls[biaoqianCount].biaoqianzhangshu;
+                    biaoqianCount++;
                     //鏁伴噺涓�0 璺宠繃
                     if (oItemSub.HQty == 0 || oItemSub.HMinQty == 0 )
                         continue;
@@ -187,25 +193,6 @@
                         return objJsonResult;
                     }
                     string sql = "";
-                    //鏍¢獙鎵瑰彿 鍜� 鐢熶骇鏃ユ湡
-                    //string sql = $"select top 1 HKFDate from Gy_BarCodeBill where HSupID = '{oItemSub.HSupID}' and HBatchNo = '{HBatchNo.TrimStart().TrimEnd()}' and HMaterID ={oItemSub.HMaterID} and isnull(HKFDate, '') <> ''";
-                    //LogService.Write($"sql:{sql}");
-                    //DataTable dt = oCn.RunProcReturn(sql, "tables").Tables[0];
-                    //if (dt.Rows.Count > 0)
-                    //{
-                    //    LogService.Write($"HKFDate:{dt.Rows[0][0]}");
-                    //    sql = $"select DATEDIFF(D,{dt.Rows[0][0]},{HKFDate})";
-                    //    DataSet ds = oCn.RunProcReturn(sql, "tables2");
-                    //    LogService.Write($"DATEDIFF:{Convert.ToInt32(ds.Tables[0].Rows[0][0])}");
-                    //    if (ds.Tables[0].Rows.Count > 0 && Convert.ToInt32(ds.Tables[0].Rows[0][0]) != 0)
-                    //    {
-                    //        objJsonResult.code = "0";
-                    //        objJsonResult.count = 0;
-                    //        objJsonResult.Message = $"鐗╂枡缂栫爜{oItemSub.HMaterNumber}锛屾壒鍙穥oItemSub.HBatchNo.TrimStart().TrimEnd()},鐢熶骇鏃ユ湡涓簕dt.Rows[0][0]},璇锋牳瀵�";
-                    //        objJsonResult.data = null;
-                    //        return objJsonResult;
-                    //    }
-                    //}
                     if (ClsPub.isLong(oItemSub.HMaterID) != 0)
                     {
 
@@ -217,9 +204,15 @@
                         // HSumQty = ClsPub.isDoule(oItemSub.HQty);  //浜у搧鏁伴噺
                        for (int i = 0; i < biaoqianzhangshu; i++)
                         {
-                            ///渚涘簲鍟嗗悕绉�+@+鐗╂枡浠g爜+@+鐗╂枡绠�绉�+@+鏁伴噺+@+鏃ユ湡+@+娴佹按鍙�  
+                            double currentQty = (i == biaoqianzhangshu - 1 && (HQty % HMinQty != 0))
+                              ? (HQty % HMinQty)
+                              : HMinQty;
+                            ///渚涘簲鍟嗗悕绉�+@+鐗╂枡浠g爜+@+鐗╂枡绠�绉�+@+鏁伴噺+@鏉$爜鏁�+@+鏃ユ湡+@+娴佹按鍙�  
                             LSH += 1;
-                            TM = $"{oItemSub.HSupName}@{oItemSub.HMaterID}@{oItemSub.HMaterName}@{oItemSub.biaoqianzhangshu}@{HKFDate_1}@{LSH}";
+                            TM = $"{oItemSub.HSupName}@{oItemSub.HMaterID}@{oItemSub.HMaterName}@{currentQty}@{HKFDate_1}@{LSH}";
+                            //TM = $"{oItemSub.HSupName}@{oItemSub.HMaterID}@{oItemSub.HMaterName}@{oItemSub.biaoqianzhangshu}@{HKFDate_1}@{LSH}";
+                            // 娣诲姞鍒扮敓鎴愮殑鏉$爜鍒楄〃
+                            generatedBarcodes.Add(TM);
                             Model.ClsGy_BarCodeBill_WMS_Model bar = new Model.ClsGy_BarCodeBill_WMS_Model();
 
                            // var HBarCode_verify = TM.Split('@'); //鏍¢獙鏉$爜淇℃伅
@@ -261,7 +254,13 @@
                         }
                 }
                 oCn.Commit();
-
+                // 杩斿洖鐢熸垚鐨勬潯鐮佸垪琛�
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鐢熸垚鏉$爜鎴愬姛锛�";
+                objJsonResult.data = generatedBarcodes; // 杩斿洖鐢熸垚鐨勬潯鐮佸垪琛�
+                WebAPIController.Add_Log("鏉$爜涓嬫帹", UserName, "鐢熸垚鏉$爜");
+                return objJsonResult;
             }
             catch (Exception e)
             {
@@ -273,19 +272,14 @@
                 return objJsonResult;
             }
 
-            objJsonResult.code = "0";
-            objJsonResult.count = 1;
-            objJsonResult.Message = "鐢熸垚鏉$爜鎴愬姛锛�";
-            WebAPIController.Add_Log("鏉$爜涓嬫帹", UserName, "鐢熸垚鏉$爜");
-            objJsonResult.data = null;
-            return objJsonResult;
+            
         }
         #endregion
 
         #region 鏉$爜鍒楄〃
         [Route("showHBarCodeBillDetail")]
         [HttpGet]
-        public object showHBarCodeBillDetail(string sMsg,string Organization)
+        public object showHBarCodeBillDetail(string sMsg,string user)
         {
             try
             {
@@ -331,6 +325,65 @@
         }
         #endregion
 
+        #region 鏍规嵁鏉$爜鑾峰彇鏉$爜璇︽儏
+        [Route("GetBarcodeDetails")]
+        [HttpGet]
+        public object GetBarcodeDetails(string barcodes)
+        {
+            try
+            {
+                if (string.IsNullOrEmpty(barcodes))
+                {
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = "鏉$爜鍙傛暟涓嶈兘涓虹┖";
+                    objjson.data = null;
+                    return objjson;
+                }
+
+                // 灏嗛�楀彿鍒嗛殧鐨勬潯鐮佽浆鎹负SQL IN鏌ヨ鏉′欢
+                var barcodeList = barcodes.Split(',');
+
+                // 鏋勫缓IN瀛愬彞锛屼负姣忎釜鏉$爜娣诲姞鍗曞紩鍙�
+                var inValues = new List<string>();
+                foreach (var barcode in barcodeList)
+                {
+                    inValues.Add("'" + barcode.Replace("'", "''") + "'"); // 澶勭悊鍗曞紩鍙疯浆涔�
+                }
+
+                string inClause = string.Join(",", inValues);
+                string sql = $"SELECT * FROM h_v_Gy_UserMaterRelationPrint WHERE HBarCode IN ({inClause})";
+
+                // 鐩存帴鎵цSQL鏌ヨ
+                DataSet ds = oCn.RunProcReturn(sql, "h_v_Gy_UserMaterRelationPrint");
+
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objjson.code = "0";
+                    objjson.count = 0;
+                    objjson.Message = "鏈壘鍒扮浉鍏虫潯鐮佷俊鎭�";
+                    objjson.data = null;
+                    return objjson;
+                }
+
+                objjson.code = "0";
+                objjson.count = ds.Tables[0].Rows.Count;
+                objjson.Message = "鑾峰彇鎴愬姛";
+                objjson.data = ds.Tables[0];
+                return objjson;
+            }
+            catch (Exception e)
+            {
+                objjson.code = "0";
+                objjson.count = 0;
+                objjson.Message = "鑾峰彇鏉$爜璇︽儏澶辫触:" + e.Message;
+                objjson.data = null;
+                return objjson;
+            }
+        }
+        #endregion
+
+
 
     }
 }
\ No newline at end of file
diff --git a/WebAPI/WebAPI.csproj b/WebAPI/WebAPI.csproj
index e86d46d..6f8a00a 100644
--- a/WebAPI/WebAPI.csproj
+++ b/WebAPI/WebAPI.csproj
@@ -263,8 +263,6 @@
     <None Include="Properties\PublishProfiles\SRMAPI.pubxml" />
     <None Include="Properties\PublishProfiles\WEBAPI.pubxml" />
     <None Include="Properties\PublishProfiles\WEBAPIConfig.pubxml" />
-    <Content Include="Views\_ViewStart.cshtml" />
-    <Content Include="Views\Shared\_Layout.cshtml" />
     <Content Include="Views\web.config" />
     <None Include="Web.Debug.config">
       <DependentUpon>Web.config</DependentUpon>
@@ -277,6 +275,7 @@
     <Folder Include="App_Data\" />
     <Folder Include="Data\" />
     <Folder Include="Views\MaterialHanding\" />
+    <Folder Include="Views\Shared\" />
     <Folder Include="Views\SRM_MaterialBarCodeBill\" />
   </ItemGroup>
   <PropertyGroup>

--
Gitblit v1.9.1