From 5057e75e1837bcdf9e7e60de7970bf8a1d3dda92 Mon Sep 17 00:00:00 2001
From: wtt <1985833171@qq.com>
Date: 星期五, 09 一月 2026 12:23:23 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/CJGL/Cj_SingleStationController.cs |  129 +++++++++++++++++++++++++++++++------------
 1 files changed, 93 insertions(+), 36 deletions(-)

diff --git a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
index b173f53..bc1f3fa 100644
--- a/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
+++ b/WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -1728,11 +1728,11 @@
                     ds = oCN.RunProcReturn("select * from Sc_SourceLineRepairBillSub_Mater where HInterID=" + model.HInterID+ " order by HEntryID  desc", "Sc_SourceLineRepairBillSub_Mater");
 
                     oCN.RunProc($@"insert into Sc_SourceLineRepairBillSub_Mater
-(HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID
-,HSourceEntryID,HSourceBillNo,HSourceBillType,HMaterID
-,HUnitID,HBarCode,HBatchNo )values
-({model.HInterID},{(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)},'{model.HBillNo}','',{temp.HProcExchInterID}
-,{temp.HProcExchEntryID},'{temp.HProcExchBillNo}','',{temp.HMaterID},0,'{temp.HBarCode}','{temp.HBatchNo}')");
+                    (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID
+                    ,HSourceEntryID,HSourceBillNo,HSourceBillType,HMaterID
+                    ,HUnitID,HBarCode,HBatchNo )values
+                    ({model.HInterID},{(ds.Tables[0].Rows.Count == 0 ? 1 : int.Parse(ds.Tables[0].Rows[0]["HEntryID"].ToString()) + 1)},'{model.HBillNo}','',{temp.HProcExchInterID}
+                    ,{temp.HProcExchEntryID},'{temp.HProcExchBillNo}','',{temp.HMaterID},0,'{temp.HBarCode}','{temp.HBatchNo}')");
 
                     //淇敼浜х嚎杩芥函鍗曠粦瀹氱殑鏉$爜鎵瑰彿
                     oCN.RunProc("update Sc_AssemblyBillSub set HBarCode='" + temp.HBarCode + "' where HInterID=" + temp.HInterID + " and HEntryID=" + temp.HEntryID);
@@ -1743,21 +1743,21 @@
                     model = JsonConvert.DeserializeObject<Model.ClsSc_SourceLineRepairBillMain>(sMainStr);
 
                     oCN.RunProc($@"insert into Sc_SourceLineRepairBillMain(HYear, HPeriod, HBillType, HBillSubType, HInterID,
-HDate, HBillNo, HBillStatus, HRemark, HEmpID, HDeptID, HSourceID, HProdOrgID, HMaterID, HWorkStationID,
-HProcess, HIPAddr, HMacAddr, HProdMac, HBarCode,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo)
-values('{DateTime.Now.Year}','{DateTime.Now.Month}','3748','3748',{model.HInterID}
-,getdate(),'{model.HBillNo}','1','{HResult}',{model.HEmpID},{model.HDeptID},{model.HSourceID},{model.HProdOrgID},{model.HMaterID},0
-,{model.HProcess},'','','','{model.HBarCode}','{user}',getdate(),{model.HICMOInterID},{model.HICMOEntryID},'{model.HICMOBillNo}')");
+                    HDate, HBillNo, HBillStatus, HRemark, HEmpID, HDeptID, HSourceID, HProdOrgID, HMaterID, HWorkStationID,
+                    HProcess, HIPAddr, HMacAddr, HProdMac, HBarCode,HMaker,HMakeDate,HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo)
+                    values('{DateTime.Now.Year}','{DateTime.Now.Month}','3748','3748',{model.HInterID}
+                    ,getdate(),'{model.HBillNo}','1','{HResult}',{model.HEmpID},{model.HDeptID},{model.HSourceID},{model.HProdOrgID},{model.HMaterID},0
+                    ,{model.HProcess},'','','','{model.HBarCode}','{user}',getdate(),{model.HICMOInterID},{model.HICMOEntryID},'{model.HICMOBillNo}')");
 
                     List<Model.ClsSc_SourceLineRepairBillSub> subLsit = new List<Model.ClsSc_SourceLineRepairBillSub>();
                     sMainStr = "[" + sMainStr + "]";
                     subLsit = JsonConvert.DeserializeObject<List<Model.ClsSc_SourceLineRepairBillSub>>(sMainStr);
 
                     oCN.RunProc($@"insert into Sc_SourceLineRepairBillSub
-(HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType
-,HBadReasonID,HBadTypeID,HBadResultID,HBadProcID,HRepairResult,HCreator,HCreateDate)
-values({model.HInterID},1,'{model.HBillNo}','',{subLsit[0].HProcExchInterID},{subLsit[0].HProcExchEntryID},'{subLsit[0].HProcExchBillNo}',''
-,{subLsit[0].HBadReasonID},{subLsit[0].HBadTypeID},{subLsit[0].HBadResultID},{model.HBadProcID},'{HResult}','{subLsit[0].HCreator}',getdate())");
+                    (HInterID,HEntryID,HBillNo_bak,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType
+                    ,HBadReasonID,HBadTypeID,HBadResultID,HBadProcID,HRepairResult,HCreator,HCreateDate)
+                    values({model.HInterID},1,'{model.HBillNo}','{model.HRemark}',{subLsit[0].HProcExchInterID},{subLsit[0].HProcExchEntryID},'{subLsit[0].HProcExchBillNo}',''
+                    ,{subLsit[0].HBadReasonID},{subLsit[0].HBadTypeID},{subLsit[0].HBadResultID},{model.HBadProcID},'{HResult}','{subLsit[0].HCreator}',getdate())");
 
                     if (HResult == "OK")
                     {
@@ -3005,18 +3005,18 @@
             try
             {
                 //鍒ゆ柇鎵�鎵潯鐮佹槸鍚﹀瓨鍦ㄦ潯鐮佹。妗堝綋涓�
-                ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
-                if (ds.Tables[0].Rows.Count == 0)
-                {
-                    //鏉$爜妗f涓病鏈夋湰娆℃壂鎻忕殑鏉$爜锛屽垯鏍规嵁瑙勫垯瑙f瀽鐢熸垚鏉$爜
+                //ds = oCN.RunProcReturn(@"select 1 from Gy_BarCodeBill WITH(NOLOCK) where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
+                //if (ds.Tables[0].Rows.Count == 0)
+                //{
+                //    //鏉$爜妗f涓病鏈夋湰娆℃壂鎻忕殑鏉$爜锛屽垯鏍规嵁瑙勫垯瑙f瀽鐢熸垚鏉$爜
 
-                    objJsonResult.code = "0";
-                    objJsonResult.count = 0;
-                    objJsonResult.Message = "璇ユ潯鐮佷笉瀛樺湪锛�" + HBarCode;
-                    objJsonResult.data = "";
-                    return objJsonResult;
+                //    objJsonResult.code = "0";
+                //    objJsonResult.count = 0;
+                //    objJsonResult.Message = "璇ユ潯鐮佷笉瀛樺湪锛�" + HBarCode;
+                //    objJsonResult.data = "";
+                //    return objJsonResult;
 
-                }
+                //}
 
                 //鏉$爜妗f涓凡鏈夋湰娆℃壂鎻忕殑鏉$爜锛屾煡璇㈤厤浠朵俊鎭紙鎵弿鏉$爜淇℃伅鍐欏叆涓存椂琛級
                 ds = oCN.RunProcReturn(@"exec h_p_Gy_BarCodeBillBomBindByHProcExch_XW '" + HBillNo + "','" + HBarCode + "','" + HBarCode_P + "','" + HProcID + "','" + HOrgID + "'", "h_p_Gy_BarCodeBillBomBindByHProcExch_XW");
@@ -3446,7 +3446,8 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_Sc_UnbindStation_BarList order by 鏉$爜鏃ユ湡 desc", "h_v_Sc_UnbindStation_BarList");
+                    ds = oCN.RunProcReturn("select * from h_v_Sc_UnbindStation_BarList" +
+                        " order by 鏉$爜鏃ユ湡 desc", "h_v_Sc_UnbindStation_BarList");
                 }
                 else
                 {
@@ -3622,37 +3623,93 @@
         }
         #endregion
 
-        #region 钃濈墮娴嬭瘯鏁版嵁鎺ュ彛
-        [Route("Cj_SingleStation/BluetoothTestDataSave")]
+        #region 钃濈墮鏍囩鐢熸垚
+        [Route("Cj_SingleStation/BlueToothBarCodeSave")]
         [HttpGet]
-        public object BluetoothTestDataSave(string HBarCode_SN, string HBluetooth_Mac, string HResult)
+        public object BlueToothBarCodeSave(string HBarCode, int HMaterID,int HOrgID ,string user)
         {
             try
             {
-                //鍒ゆ柇鏈夋病鏈夎繃鎵撳嵃璁板綍锛堟潯鐮佹。妗堜腑瀛樹笉瀛樺湪钃濈墮mac鍦板潃锛�
-                ds = oCN.RunProcReturn("select 1 from Gy_BarCodeBill with(nolock) where HBarCode = '" + HBluetooth_Mac + "'", "Gy_BarCodeBill");
-                if (ds.Tables[0].Rows.Count < 1)
+                //鐢熸垚鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Gy_BarCodeBill", 1, false, user))
                 {
                     objJsonResult.code = "0";
                     objJsonResult.count = 0;
-                    objJsonResult.Message = "涓婁紶鐨凥BarCode_SN锛�" + HBarCode_SN + "锛屾病鏈夋爣绛炬墦鍗拌褰曪紝璇峰厛鎵撳嵃钃濈墮mac鏍囩锛�" + HBluetooth_Mac;
+                    objJsonResult.Message = "鏃犳潯鐮佺敓鎴愭潈闄愶紒";
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
 
-                string sql = string.Format($@"insert into Gy_BluetoothTestData(HBarCode_SN,HBluetooth_Mac,HResult,HResult) values ('{HBarCode_SN}','{HBluetooth_Mac}','{HResult}',getdate() ");
+                string sql = "exec h_p_Cj_BlueToothBarCodeSave '" + HBarCode + "'," + HMaterID + "," + HOrgID + ",'" + user + "'";
+
+                oCN.BeginTran();
+                ds = oCN.RunProcReturn(sql, "h_p_Cj_BlueToothBarCodeSave");
+                oCN.Commit();
+                if (ClsPub.isInt(ds.Tables[0].Rows.Count) == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触娌℃湁杩斿洖浠讳綍鍐呭!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "[0000-1-051]淇濆瓨澶辫触" + ds.Tables[0].Rows[0]["HBackRemark"].ToString() + "锛�";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "[0000-1-050]淇濆瓨鎴愬姛!";
+                objJsonResult.data = "";//
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 钃濈墮娴嬭瘯鏁版嵁鎺ュ彛
+        [Route("Cj_SingleStation/BluetoothTestDataSave")]
+        [HttpGet]
+        public object BluetoothTestDataSave(string lotSn, string testData)
+        {
+            try
+            {
+                //鍒ゆ柇鏈夋病鏈夎繃鎵撳嵃璁板綍锛堟潯鐮佹。妗堜腑瀛樹笉瀛樺湪钃濈墮mac鍦板潃锛�
+                ds = oCN.RunProcReturn("select 1 from Gy_BarCodeBill with(nolock) where HBarCode = '" + lotSn + "'", "Gy_BarCodeBill");
+                if (ds.Tables[0].Rows.Count < 1)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "涓婁紶鐨刲otSn锛�" + lotSn + "锛屾病鏈夋爣绛炬墦鍗拌褰曪紝璇峰厛鎵撳嵃钃濈墮mac鏍囩" ;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+
+                string sql = string.Format($@"insert into Gy_BluetoothTestData(HBluetooth_Mac,HResult,HMakeDate) values ('{lotSn}','{testData}',getdate() ) ");
 
                 oCN.RunProc(sql);//鎻掑叆钃濈墮娴嬭瘯鏁版嵁
 
-                objJsonResult.code = "1";
+                objJsonResult.code = "success";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "钃濈墮娴嬭瘯鏁版嵁缁撴潫鎴愬姛锛丠BarCode_SN锛�" + HBarCode_SN + " 锛孒Bluetooth_Mac锛�" + HBluetooth_Mac;
+                objJsonResult.Message = "钃濈墮娴嬭瘯鏁版嵁鎺ユ敹鎴愬姛锛乴otSn锛�" + lotSn;
                 objJsonResult.data = null;
                 return objJsonResult;
             }
             catch (Exception e)
             {
-                objJsonResult.code = "0";
+                objJsonResult.code = "error";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "鍙戠敓寮傚父锛�" + e.ToString();
                 objJsonResult.data = null;

--
Gitblit v1.9.1