From e9046aea8de84c7b82167f4c05d82d2702203195 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期三, 17 九月 2025 22:04:28 +0800
Subject: [PATCH] 数据采集优化,三坐标轮廓仪增加日志,过站增加生产质量汇报单日志

---
 WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs b/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
index b36209a..67bd3e3 100644
--- a/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
+++ b/WFormSynchronizeData_SMR/WFormSynchronizeData_SMR/Form1.cs
@@ -31,7 +31,7 @@
             CustomWriteLog("1.璁℃椂鍣ㄥ紑濮�:"+timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
 
             //鏍规嵁鏃堕棿姝e簭鎺掑簭鑾峰彇鍓�150鏉℃暟鎹�
-            DataTable list = oCN.RunProcReturn("select top 150 HResult,HBarCode,HCreateTime from Sb_EquipMentCollection_SN  WITH(NOLOCK) where HFlag=0  order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
+            DataTable list = oCN.RunProcReturn("select top 150 * from Sb_EquipMentCollection_SN  WITH(NOLOCK) where HFlag=0  order by HCreateTime", "Sb_EquipMentCollection_SN").Tables[0];
           
             //寰幆闆嗗悎
             for (int i = 0; i < list.Rows.Count; i++)
@@ -160,13 +160,15 @@
                 if (num == 0 || num == 1)
                 {
                     flag = getOutBillAdd(dic, HBadCodeSN, "NG");
-
+                    CustomWriteLog("鏉$爜涓嶈壇:" + HBadCodeSN, DateTime.Now.ToString("yyyy-MM-dd"));
                     if (flag)
                     {
                         //鏂板涓嶈壇姹囨姤
                         flag = getBadBillAdd(dic);
+                        CustomWriteLog("瀹屾垚涓嶈壇姹囨姤:", DateTime.Now.ToString("yyyy-MM-dd"));
                         //鍙嶅啓鏉$爜鐘舵��
                         oCN.RunProc("update Gy_BarCodeBill set HStatus='涓嶈壇',HRemark='" + dic["HType"].ToString() + "' where HBarCode='" + HBadCodeSN + "'");
+                        CustomWriteLog("鍙嶅啓鏉$爜鐘舵��:", DateTime.Now.ToString("yyyy-MM-dd"));
                     }
                 }
                 else if (num == 2)
@@ -195,7 +197,7 @@
                 string HMakers = ""; //鍒跺崟浜�
                 CustomWriteLog("2.1.1.鍑虹珯鍗曟柊澧炲紑濮�:" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
                 //鑾峰彇缁戝畾娴佽浆鍗�
-                DataSet ds = oCN.RunProcReturn(@"select HSourceBillNo, from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
+                DataSet ds = oCN.RunProcReturn(@"select HSourceBillNo from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBadCodeSN + "'", "Gy_BarCodeBill");
                 string HProcExchBillNo = ds.Tables[0].Rows[0]["HSourceBillNo"].ToString();
                 string HProcNumber = dic["HProcNumber"].ToString();
 
@@ -399,7 +401,7 @@
                     CustomWriteLog("2.1.11 鏉$爜鍙嶅啓 :" + HProcNumber + "----" + timer.Elapsed, DateTime.Now.ToString("yyyy-MM-dd"));
 
                     //鏌ヨ 鍑虹珯鍗曞瓙琛� 鏉$爜琛ㄧ殑鏁版嵁
-                    ds = oCN.RunProcReturn("select  HEntryID, from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
+                    ds = oCN.RunProcReturn("select  HEntryID from Sc_StationOutBillSub_SN WITH(NOLOCK) where HInterID='" + HInterID + "' order by HEntryID desc", "Sc_StationOutBillSub_SN");
 
                     string HMakeTime = dic["HCreateTime"].ToString();
                     oCN.RunProc($@"insert into Sc_StationOutBillSub_SN(HInterID,HBillNo_bak,HEntryID,HBarCode,HBarCodeQty,HMakeTime,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney)
@@ -955,7 +957,7 @@
         //瀹氭椂璇诲彇鏁版嵁
         private void timer1_Tick(object sender, EventArgs e)
         {
-            DataTable list = oCN.RunProcReturn("select top 100 HResult,HBarCode,HCreateTime from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0  order by HCreateTime asc", "Sb_EquipMentCollection_SN").Tables[0];
+            DataTable list = oCN.RunProcReturn("select top 100 * from Sb_EquipMentCollection_SN WITH(NOLOCK) where HFlag=0  order by HCreateTime asc", "Sb_EquipMentCollection_SN").Tables[0];
 
             //寰幆闆嗗悎
             for (int i = 0; i < list.Rows.Count; i++)
@@ -978,14 +980,16 @@
                 {
                     flag = HResultNG(list.Rows[i]);
                 }
-
+                CustomWriteLog("1-1.寰幆缁撴潫:", DateTime.Now.ToString("yyyy-MM-dd"));
                 if (flag)
                 {
+                    CustomWriteLog("1.1.1鏇存柊:",DateTime.Now.ToString("yyyy-MM-dd"));
                     oCN.RunProc("update Sb_EquipMentCollection_SN set HFlag=1 where HBarCode='" + HBadCodeSN + "' and HCreateTime='" + HCreateTime + "'");
                     //缁撴潫浜嬪姟
                     oCN.Commit();
+                    CustomWriteLog("1.1.2鎻愪氦:", DateTime.Now.ToString("yyyy-MM-dd"));
                 }
-
+                CustomWriteLog("1.1.3鎻愪氦:", DateTime.Now.ToString("yyyy-MM-dd"));
             }
         }
 
@@ -993,7 +997,7 @@
         public bool getBadBillAdd(DataRow dic) {
             try
             {
-
+                CustomWriteLog("鏂板涓嶈壇姹囨姤1.1:", DateTime.Now.ToString("yyyy-MM-dd"));
                 //鏌ヨ鑱屽憳
                 DataSet ds = oCN.RunProcReturn("select HItemID,HName from Gy_Employee WITH(NOLOCK) where HNumber='" + dic["HEmpCode"].ToString() + "' ", "Gy_Employee");
                 long HEmpIDs = 0;
@@ -1011,16 +1015,10 @@
                     HDeptID = 389505;
                 }
                 else
-                {
-                    //ds = oCN.RunProcReturn("select * from Gy_Department where HNumber='" + dic["HDeptNumber"].ToString() + "' ", "Gy_Department");
-
-                    //if (ds.Tables[0].Rows.Count != 0)
-                    //{
-                    //    HDeptID = long.Parse(ds.Tables[0].Rows[0]["HItemID"].ToString());//鐢熶骇閮ㄩ棬
-                    //}
+                {                    
                     HDeptID = 0;
                 }
-
+                CustomWriteLog("鏂板涓嶈壇姹囨姤1.2:", DateTime.Now.ToString("yyyy-MM-dd"));
                 string HProcExchInterID = "0";
                 string HProcExchEntryID = "0";
                 string HProcExchBillNo = "";
@@ -1031,6 +1029,7 @@
                 long HICMOEntryID = 0;
                 string HICMOBillNo = "";
 
+                CustomWriteLog("鏂板涓嶈壇姹囨姤1.3:"+ dic["HBarCode"].ToString()+  dic["HProcNumber"].ToString() , DateTime.Now.ToString("yyyy-MM-dd"));
                 //鏍规嵁 鏉$爜+宸ュ簭 鏌ヨ娴佽浆鍗′俊鎭�
                 ds = oCN.RunProcReturn(@"select b.HProcID, HMaterID,HUnitID,a.HICMOInterID,a.HICMOEntryID,a.HICMOBillNo,HBillNo,a.HInterID,b.HEntryID,a.HBillNo from Sc_ProcessExchangeBillMain a WITH(NOLOCK)
 inner join Sc_ProcessExchangeBillSub b  WITH(NOLOCK) on a.HInterID=b.HInterID
@@ -1049,7 +1048,7 @@
                     HProcID = int.Parse(ds.Tables[0].Rows[0]["HProcID"].ToString());
                 }
 
-
+                CustomWriteLog("鏂板涓嶈壇姹囨姤1.4:"+ dic["HSourceCode"].ToString(), DateTime.Now.ToString("yyyy-MM-dd"));
                 ds = oCN.RunProcReturn("select HItemID from Gy_Source WITH(NOLOCK) where HNumber='" + dic["HSourceCode"].ToString() + "' ", "Gy_Source");
                 long HSourceID = 0;
                 if (ds.Tables[0].Rows.Count != 0)
@@ -1068,15 +1067,15 @@
                 long HMainSourceInterID = HICMOInterID;
                 long HMainSourceEntryID = HICMOEntryID;
                 string HMainSourceBillNo = HICMOBillNo;
-
+                CustomWriteLog("鏂板涓嶈壇姹囨姤1.5:", DateTime.Now.ToString("yyyy-MM-dd"));
                 //涓昏〃
                 oCN.RunProc(@"Insert Into Sc_QualityReportBillMain   
 (HBillType,HBillSubType,HBillStatus,HInterID,HBillNo,HDate
 ,HYear,HPeriod,HRemark,HMaker,HMakeDate
-,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo)
+,HEmpID,HGroupID,HDeptID,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HSTOCKORGID)
                         values('3717','3717',1," + HInterID + ",'" + HBillNo + "','" + HDate + "'" +
                 "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",'" + HRemark + "','" + HMaker + "',getdate()" +
-                ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "') ");
+                ",'" + HEmpID + "'," + HGroupID + "," + HDeptID + "," + HMainSourceInterID + "," + HMainSourceEntryID + ",'" + HMainSourceBillNo + "','100199') ");
 
                 string HBarCode = dic["HBarCode"].ToString();
                 string HMakeDate = dic["HCreateTime"].ToString();
@@ -1091,14 +1090,15 @@
 ,0,0,'','',0,0
 ,1,'{HResult}',{ HProcExchInterID},{ HProcExchEntryID},'{ HProcExchBillNo}'," + HProcID + ")");
 
-                return true;
+                CustomWriteLog("鏂板涓嶈壇姹囨姤1.6:", DateTime.Now.ToString("yyyy-MM-dd"));
+                return true;              
             }
             catch (Exception e)
             {
                 oCN.RollBack();
                 CustomWriteLog("鎶ラ敊鍘熷洜:" + e.Message + "!", DateTime.Now.ToString("yyyy-MM-dd"));
                 return false;
-            }
+            }           
         }
 
         #region 鍩虹鏂规硶

--
Gitblit v1.9.1