yusijie
2025-12-08 71f74aefb19141e39df032a2972ef40d1153274d
WebAPI/Controllers/CJGL/Cj_SingleStationController.cs
@@ -3622,31 +3622,87 @@
        }
        #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 = "上传的HBarCode_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 = "上传的lotSn:" + 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.count = 1;
                objJsonResult.Message = "蓝牙测试数据结束成功!HBarCode_SN:" + HBarCode_SN + " ,HBluetooth_Mac:" + HBluetooth_Mac;
                objJsonResult.Message = "蓝牙测试数据接收成功!lotSn:" + lotSn;
                objJsonResult.data = null;
                return objJsonResult;
            }