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/EquipmentCollectionForm/EquipmentCollectionForm_JiuLing.cs | 1201 ++++++++++-----------------------------------------------
 1 files changed, 214 insertions(+), 987 deletions(-)

diff --git a/WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm_JiuLing.cs b/WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm_JiuLing.cs
index 3283228..0cb07c1 100644
--- a/WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm_JiuLing.cs
+++ b/WFormSynchronizeData_SMR/EquipmentCollectionForm/EquipmentCollectionForm_JiuLing.cs
@@ -25,820 +25,14 @@
             InitializeComponent();
         }
 
-        private void EquipmentCollectionForm_Load(object sender, EventArgs e)
+        private void btnWB_Click(object sender, EventArgs e)
         {
-            this.txtBegin.ReadOnly = true;
-            this.txtEnd.ReadOnly = true;
-            this.txtLj.ReadOnly = true;
-            this.btnSave.Enabled = false;
-            this.txtHMaterNumber.ReadOnly = true;
-            //this.btnRest.Enabled = false;
-            //鍒跺崟缂栫爜鍙
-            this.txtHMakerNumber.ReadOnly = true;
-            //鍒跺崟浜烘彁绀�
-            this.txtHMaker.ForeColor = Color.LightGray;
-            this.txtHMaker.Text = "璇疯緭鍏ョ敤鎴风紪鐮�!";
-
-            bindCbox();
-
-        }
-
-        private void btnBegin_Click(object sender, EventArgs e)
-        {
-            if (this.txtHBathNo.Text == "" || this.txtHBathNo.ReadOnly == false)
-            //if (false)
-            {
-                MessageBox.Show("璇疯緭鍏ユ壒娆″彿杩涜纭!");
-            }
-            else
-            {
-                this.txtBegin.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-                //this.txtBegin.Text = "2024-11-21 13:40:27";
-                this.btnBegin.Enabled = false;
-                if (cmbEquipFile.SelectedIndex == 1)
-                {
-                    this.txtHBathNo.ReadOnly = true;
-                    this.timer.Enabled = true;
-                }
-            }
-        }
-
-        private void btnEnd_Click(object sender, EventArgs e)
-        {
-            if (this.txtBegin.Text == "")
-            {
-                MessageBox.Show("璇风偣鍑诲紑濮嬫寜閽繘琛屽紑濮嬬‘璁�!");
-            }
-            else
-            {
-                this.txtEnd.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
-                //this.txtEnd.Text = "2024-09-24 09:52:39";
-                this.btnEnd.Enabled = false;
-
-                if (cmbEquipFile.SelectedIndex == 1)
-                {
-                    this.btnSave.Enabled = true;
-                }
-            }
-        }
-
-        private void btnLj_Click(object sender, EventArgs e)
-        {
-            if (this.txtEnd.Text == "")
-            {
-                MessageBox.Show("璇风偣鍑荤粨鏉熸寜閽繘琛岀粨鏉熺‘璁�!");
-            }
-            else
-            {
-                //璺緞璧嬪�肩粰鏂囨湰
-                using (OpenFileDialog openFile = new OpenFileDialog())
-                {
-                    openFile.Multiselect = true; // 鍏佽閫夋嫨澶氫釜鏂囦欢
-                    DialogResult result = openFile.ShowDialog();
-                    if (result == DialogResult.OK)
-                    {
-                        //淇濆瓨鎸夐挳鐏版帀
-                        this.btnSave.Enabled = true;
-
-                        string selectedFolderPath = openFile.FileName;
-                        this.txtLj.Text = selectedFolderPath;
-
-                        objJsonResult = Xt_CSVReadText(openFile.FileNames, 1);
-                        dt = objJsonResult.dataTable;
-
-                        if (objJsonResult.code == "0")
-                        {
-                            MessageBox.Show(objJsonResult.Message);
-                        }
-                        else
-                        {
-                            for (int i = 0; i < dt.Rows.Count; i++)
-                            {
-                                ListData.Items.Add("搴曞瓟鐩村緞:" + dt.Rows[i]["BottomHoleDiameter"].ToString() +
-                                    ",鏈夋棤铻虹墮妫�娴嬫暟鎹�:" + dt.Rows[i]["TestingData"].ToString() +
-                                    ",鏈夋棤铻虹墮妫�娴嬬粨鏋�:" + dt.Rows[i]["DetectionResult"].ToString() +
-                                ",鏃堕棿:" + dt.Rows[i]["HDate"].ToString());
-                            }
-
-                        }
-                    }
-                }
-            }
-        }
-
-        //璇诲彇CSV鏂囦欢鏁版嵁  鏍规嵁鏂囦欢璺緞鎵惧埌瀵瑰簲鏂囦欢 骞惰幏鍙栧搴旂殑鏁版嵁
-        public json Xt_CSVReadText(string[] FilePath, int num)
-        {
-            try
-            {
-                DataTable dt = new DataTable(num.ToString());
-                dt.Columns.Add("BottomHoleDiameter");
-                dt.Columns.Add("TestingData");
-                dt.Columns.Add("DetectionResult");
-                dt.Columns.Add("HDate");
-
-                DataTable dt2 = new DataTable();
-                for (int u = 0; u < FilePath.Length; u++)
-                {
-                    using (StreamReader sr = new StreamReader(FilePath[u], Encoding.GetEncoding("gb2312")))
-                    {
-                        string[] headers = sr.ReadLine()?.Split(',');
-                        if (headers != null && u == 0)
-                        {
-                            foreach (var header in headers)
-                            {
-                                dt2.Columns.Add(header.Trim());
-                            }
-                        }
-
-                        string line;
-                        while ((line = sr.ReadLine()) != null)
-                        {
-                            var values = line.Split(',');
-                            DataRow row = dt2.NewRow();
-
-                            for (int i = 0; i < values.Length; i++)
-                            {
-                                // 杩欓噷鍙兘闇�瑕佹坊鍔犵被鍨嬭浆鎹㈠拰閿欒澶勭悊  
-                                row[i] = values[i].Trim();
-                            }
-
-                            dt2.Rows.Add(row);
-                        }
-                    }
-                }
-                DateTime HBegin = DateTime.Parse(this.txtBegin.Text);
-                DateTime HEnd = DateTime.Parse(this.txtEnd.Text);
-
-                for (int i = 0; i < dt2.Rows.Count; i++)
-                {
-                    for (int j = 0; j < 2; j++)
-                    {
-                        DateTime Now = DateTime.Parse(dt2.Rows[i][dt2.Columns[6]].ToString() + " " + dt2.Rows[i][dt2.Columns[7]].ToString());
-                        if (Now >= HBegin && Now <= HEnd)
-                        {
-                            DataRow dr = dt.NewRow();
-                            dr["BottomHoleDiameter"] = dt2.Rows[i][dt2.Columns[j]].ToString();
-                            dr["TestingData"] = dt2.Rows[i][dt2.Columns[j + 2]].ToString();
-                            dr["DetectionResult"] = dt2.Rows[i][dt2.Columns[j + 4]].ToString();
-                            dr["HDate"] = DateTime.Parse(dt2.Rows[i][dt2.Columns[6]].ToString() + " " + dt2.Rows[i][dt2.Columns[7]].ToString()).ToString("yyyy-MM-dd HH:mm:ss");
-                            dt.Rows.Add(dr);
-                        }
-                    }
-                }
-
-                objJsonResult.code = "1";
-                objJsonResult.count = 1;
-                objJsonResult.Message = "";
-                objJsonResult.dataTable = dt;
-                return objJsonResult;
-            }
-            catch (Exception e)
-            {
-                objJsonResult.code = "0";
-                objJsonResult.count = 0;
-                objJsonResult.Message = e.Message;
-                objJsonResult.dataTable = null;
-                return objJsonResult;
-            }
-        }
-
-
-        private void txtHBathNo_KeyUp(object sender, KeyEventArgs e)
-        {
-            if (e.KeyCode == Keys.Enter)
-            {
-                if (this.txtHMakerNumber.Text == "")
-                {
-                    MessageBox.Show("璇疯緭鍏ュ埗鍗曚汉淇℃伅!");
-                }
-                else
-                {
-                    Get_DisplayBard();
-                }
-                //this.txtHBathNo.ReadOnly = true;
-
-            }
-        }
-
-        //鏌ヨ鏉$爜鏁版嵁
-        public void Get_DisplayBard()
-        {
-            string HBarCode = this.txtHBathNo.Text;
-            DataSet ds = oCN.RunProcReturn("select HBatchNo,m.HNumber,a.HMaterID from Gy_BarCodeBill a left join Gy_Material m on a.HMaterID = m.HItemID where HBarCode='" + HBarCode + "'", "Gy_BarCodeBill");
-
-            if (ds.Tables[0].Rows.Count == 0)
-            {
-                MessageBox.Show("鏉$爜鏌ユ棤鏁版嵁!");
-            }
-            else
-            {
-                this.txtHBathNo.Text = ds.Tables[0].Rows[0]["HBatchNo"].ToString();
-                this.txtHMaterNumber.Text = ds.Tables[0].Rows[0]["HNumber"].ToString();
-                this.HMaterID.Text = ds.Tables[0].Rows[0]["HMaterID"].ToString();
-            }
-
-            this.txtHBathNo.ReadOnly = true;
-        }
-
-        private void btnRest_Click(object sender, EventArgs e)
-        {
-            this.txtHBathNo.Text = "";
-            this.txtHMaterNumber.Text = "";
-            this.HMaterID.Text = "0";
-            this.txtHBathNo.ReadOnly = false;
-
-            this.btnBegin.Enabled = true;
-            this.txtBegin.Text = "";
-
-            this.btnEnd.Enabled = true;
-            this.txtEnd.Text = "";
-
-            this.btnSave.Enabled = false;
-
-            this.txtLj.Text = "";
-
-            this.ListData.Items.Clear();
-            this.timer.Enabled = false;
-        }
-
-        private async void btnSave_Click(object sender, EventArgs e)
-        {
-            DialogResult dr = MessageBox.Show("纭淇濆瓨?", "鎻愮ず", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
-
-            if (dr == DialogResult.Yes)
-            {
-
-                string Url = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sUrl");
-                //閫氳繃鎺ュ彛 鑾峰彇token
-                JsonResult_JL jsonResult = await FindAccessToken(Url);
-
-                string EquipFile = this.cmbEquipFile.Text;
-
-                switch (EquipFile)
-                {
-                    case "铻烘瘝鍏ㄦ":
-                        SaveFullInspectionOfNuts(jsonResult.data.token, Url);
-                        break;
-                    case "铻烘瘝鍘嬭":
-                        SaveNutPressFit(jsonResult.data.token, Url, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
-                        break;
-                    case "娉ㄥ鏈�":
-                        SaveInjectionMoldingMachine(jsonResult.data.token, Url, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
-                        break;
-                }
-                this.btnSave.Enabled = false;
-            }
-        }
-
-        //铻烘瘝鍏ㄦ淇濆瓨
-        public async void SaveFullInspectionOfNuts(string token, string url)
-        {
-            try
-            {
-
-                //鑾峰彇鎵�鏈夎澶囨暟鎹�
-                JsonEquipmentData_JL jsonResult = await FindDeviceList(url, token);
-
-                if (jsonResult.code != "0")
-                {
-                    this.btnSave.Enabled = true;
-                    MessageBox.Show("璁惧鍒楄〃鎶ラ敊:" + jsonResult.message);
-                }
-                else
-                {
-                    string nos = "";
-                    //鑾峰彇璁惧缂栫爜
-                    for (int i = 0; i < jsonResult.data.Count; i++)
-                    {
-                        if (jsonResult.data[i].no == this.cmbEquipFile.SelectedValue.ToString())
-                        {
-                            nos = jsonResult.data[i].no;
-                        }
-                    }
-                    //寮�濮嬫椂闂�
-                    string HBegin = this.txtBegin.Text;
-                    //缁撴潫鏃堕棿
-                    string HEnd = this.txtEnd.Text;
-                    //鑾峰彇涓嶈壇鏁帮紝鍚堟暟鏁帮紝鍙枒鏁� 鎬绘暟
-                    jsonResult = await FindDevicePropCalc(url, token, nos, HBegin, HEnd);
-                    if (jsonResult.code != "0")
-                    {
-                        this.btnSave.Enabled = true;
-                        MessageBox.Show("鏁伴噺鑾峰彇鎶ラ敊:" + jsonResult.message);
-                    }
-                    else
-                    {
-                        double HInSpectQty = 0;//妫�楠屾暟閲�
-                        double HRightQty = 0;//鍚堟牸
-                        double HUnRightQty = 0;//涓嶅悎鏍�
-                        double HUnKnowQty = 0;//鍙枒
-
-                        for (int i = 0; i < jsonResult.data.Count; i++)
-                        {
-                            if (jsonResult.data[i].propId == 173)
-                            {
-                                //HInSpectQty = jsonResult.data[i].sum;
-                            }
-                            else if (jsonResult.data[i].propId == 469)
-                            {
-                                HRightQty = jsonResult.data[i].sum;
-                            }
-                            else if (jsonResult.data[i].propId == 606)
-                            {
-                                HUnKnowQty = jsonResult.data[i].sum;
-                            }
-                            else if (jsonResult.data[i].propId == 470)
-                            {
-                                HUnRightQty = jsonResult.data[i].sum;
-                            }
-                        }
-                        //閫氳繃鍙屾柟璁ㄨ 鏈�缁堥噰绾� 妫�楠屾暟閲�=鍚堟牸+涓嶅悎鏍�+鍙枒
-                        HInSpectQty = HRightQty + HUnKnowQty + HUnRightQty;
-
-
-                        string HNumber = "";
-                        int HSourceID = 0;
-                        string HSourceNumber = "";
-
-                        switch (this.cmbEquipFile.Text)
-                        {
-                            case "铻烘瘝鍏ㄦ":
-                                HNumber = "LMJC";
-                                HSourceNumber = "1030";
-                                break;
-                            case "铻烘瘝鍘嬭":
-                                HNumber = "LMYZ";
-                                HSourceNumber = "1029";
-                                break;
-                        }
-
-                        //鏌ヨ鐢熶骇璧勬簮
-                        DataSet dsSouce = oCN.RunProcReturn("select * from Gy_Source with(nolock) where HNumber='" + HSourceNumber + "'", "Gy_Source");
-                        if (dsSouce.Tables[0].Rows.Count == 0)
-                        {
-                            this.btnSave.Enabled = true;
-                            MessageBox.Show("鐢熶骇璧勬簮鏌ユ棤鏁版嵁!");
-                        }
-                        else
-                        {
-
-                            HSourceID = int.Parse(dsSouce.Tables[0].Rows[0]["HItemID"].ToString());
-
-                            //鏌ヨ妫�楠屾柟妗�
-                            DataSet dataSet = oCN.RunProcReturn(@"select a.HInterID HQCSchemeID,b.HQCCheckItemID, ch.HNumber HQCCheckItemNumber,m.HNumber,HUpLimit,HDownLimit,HTargetVal,a.HProcID,b.HInspectInstruMentID
-,b.HAnalysisMethod 
-from  Gy_QCCheckProjectMain a with(nolock)  
-inner join Gy_QCCheckProjectSub b with(nolock) on a.HInterID=b.HInterID 
-left join Gy_Material m with(nolock) on a.HMaterID=m.HItemID
-left join Gy_QCCheckItem ch with(nolock) on b.HQCCheckItemID=ch.HItemID 
-left join Gy_InspectInstruMent ment on b.HInspectInstruMentID=ment.HItemID
-where m.HNumber='" + this.txtHMaterNumber.Text + "' and ment.HNumber='" + HNumber + "'", "Gy_QCCheckProjectMain");
-
-                            //淇濆瓨鏁版嵁
-                            if (dataSet.Tables[0].Rows.Count > 0)
-                            {
-                                string sExeReturnInfo = "";
-                                string BillType = "7519";
-                                long HInterID = oCN.CreateBillID_Prod(BillType, ref sExeReturnInfo);
-                                string HBillNo = oCN.CreateBillCode(BillType, ref sExeReturnInfo, true);
-                                if (dataSet.Tables[0].Rows.Count <= dt.Columns.Count - 1)
-                                {
-                                    oCN.BeginTran();
-
-                                    string HProcID = dataSet.Tables[0].Rows[0]["HProcID"].ToString();
-                                    string HMaterID = this.HMaterID.Text;
-                                    string HQCSchemeID = dataSet.Tables[0].Rows[0]["HQCSchemeID"].ToString();
-                                    string HBatchNo = this.txtHBathNo.Text;
-                                    int HLastResults = 1;
-                                    for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++)
-                                    {
-                                        int HLastResult = 1;
-                                        string HAnalysisMethod = dataSet.Tables[0].Rows[i]["HAnalysisMethod"].ToString();
-                                        decimal HUpLimit = 0;
-                                        decimal HDownLimit = 0;
-
-                                        //鍒嗘瀽鏂规硶 涓哄畾閲忓垎鏋�
-                                        if (HAnalysisMethod == "2")
-                                        {
-                                            //鑾峰彇涓婇檺
-                                            HUpLimit = decimal.Parse(dataSet.Tables[0].Rows[i]["HTargetVal"].ToString()) + decimal.Parse(dataSet.Tables[0].Rows[i]["HUpLimit"].ToString());
-                                            //鑾峰彇涓嬮檺
-                                            HDownLimit = decimal.Parse(dataSet.Tables[0].Rows[i]["HTargetVal"].ToString()) + decimal.Parse(dataSet.Tables[0].Rows[i]["HDownLimit"].ToString());
-                                        }
-
-
-                                        for (int j = 0; j < dt.Columns.Count - 1; j++)
-                                        {
-
-                                            string HQCCheckItemName = "";
-                                            switch (dt.Columns[j].ColumnName)
-                                            {
-                                                case "BottomHoleDiameter":
-                                                    HQCCheckItemName = "DKZJ";
-                                                    break;
-                                                case "TestingData":
-                                                    HQCCheckItemName = "LYJCSJ";
-                                                    break;
-                                                case "DetectionResult":
-                                                    HQCCheckItemName = "LYJCJG";
-                                                    break;
-                                            }
-                                            //SRM@101.2@VEN00005@CGDD000167@1.02.002.002@20231129@1000
-                                            //鍒ゆ柇妫�楠岄」鐩殑浠g爜 璺熷垪鍚嶆槸鍚︿竴鑷�
-                                            if (dataSet.Tables[0].Rows[i]["HQCCheckItemNumber"].ToString().Contains(HQCCheckItemName))
-                                            {
-                                                for (int k = 0; k < dt.Rows.Count; k++)
-                                                {
-                                                    //鍙彇鏃堕棿鑼冨洿鍐呯殑鏁版嵁
-                                                    if (DateTime.Parse(dt.Rows[k]["HDate"].ToString()) >= DateTime.Parse(HBegin) && DateTime.Parse(dt.Rows[k]["HDate"].ToString()) <= DateTime.Parse(HEnd))
-                                                    {
-                                                        //鑾峰彇妫�楠屽��
-                                                        decimal HInSpectValue = decimal.Parse(dt.Rows[k][dt.Columns[j].ColumnName].ToString());
-                                                        //榛樿鍊肩粨璁轰负鍚堟牸
-                                                        int HInSpectResult = 1;
-                                                        //瀹氶噺鍒嗘瀽 杩涜鍒ゆ柇鏄惁婊¤冻涓婁笅闄�
-                                                        if (HAnalysisMethod == "2")
-                                                        {
-                                                            HInSpectResult = (HInSpectValue > HUpLimit || HDownLimit > HInSpectValue) ? 0 : 1;
-                                                        }
-                                                        else
-                                                        {
-                                                            HInSpectResult = int.Parse(HInSpectValue.ToString());
-                                                        }
-
-                                                        //濡傛灉褰撳墠缁撹涓哄悎鏍� 骞朵笖鍘嗗彶缁撹涔熸槸鍚堟牸 鍒欑户缁繚鎸佸悎鏍�
-                                                        if (HInSpectResult == 1 && HLastResult != 0)
-                                                        {
-                                                            HLastResult = 1;
-                                                        }
-                                                        else
-                                                        {
-                                                            HLastResult = 0;
-                                                        }
-
-                                                        oCN.RunProc("Insert into QC_StockCheckBillSub_ValueGrid " +
-                          " (HInterID,HEntryID,HSEQ" +
-                          ",HInSpectResult,HInSpectValue,HInSpectValueB,HInSpectValueT)" +
-                          "values(" + HInterID + "," + ((i + 1)) + "," + (k + 1) + "" +
-                          "," + HInSpectResult + "," + dt.Rows[k][dt.Columns[j].ColumnName].ToString() + "," + dt.Rows[k][dt.Columns[j].ColumnName].ToString() + "," + dt.Rows[k][dt.Columns[j].ColumnName].ToString() + ") ");
-                                                    }
-                                                }
-                                                break;
-                                            }
-                                        }
-
-                                        oCN.RunProc("Insert into QC_StockCheckBillSub " +
-                        " (HInterID,HBillNo_bak,HEntryID,HCloseMan" +
-                        ",HEntryCloseDate,HCloseType,HRemark,HSourceInterID" +
-                        ",HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney" +
-                        ",HQCCheckItemID,HQCStd,HUnit,HQCNote,HResult" +
-                        ",HMax,HMin,HAvg,HSampleSchemeID,HSampleQty,HSampleDamageQty,HAcceptQty" +
-                        ",HRejectQty,HSampleUnRightQty,HStatus,HUnitID,HInspectVal,HTargetVal" +
-                        ",HUpLimit,HDownLimit,HUpOffSet,HDownOffSet,HKeyInspect,HAnalysisMethod,HInspectInstruMentID,HInspectResult" +
-                        ") values("
-                        + HInterID + ",'" + HBillNo + "'," + (i + 1) + ",''" +
-                        ",getdate(),0,'',0" +
-                        ",0,'','',0,0" +
-                        "," + dataSet.Tables[0].Rows[i]["HQCCheckItemID"].ToString() + ",'" + dataSet.Tables[0].Rows[i]["HTargetVal"].ToString() + "','','','" + HLastResult + "'" +
-                        ",'" + dataSet.Tables[0].Rows[i]["HUpLimit"].ToString() + "','" + dataSet.Tables[0].Rows[i]["HDownLimit"].ToString() + "','',0,0,0,0" +
-                        ",0,0,'',0,'','" + dataSet.Tables[0].Rows[i]["HTargetVal"].ToString() + "'" +
-                        ",'" + dataSet.Tables[0].Rows[i]["HUpLimit"].ToString() + "','" + dataSet.Tables[0].Rows[i]["HDownLimit"].ToString() + "','','',0,'" + HAnalysisMethod + "'," + dataSet.Tables[0].Rows[i]["HInspectInstruMentID"].ToString() + ",'" + HLastResult + "'" +
-                        ") ");
-                                        //濡傛灉褰撳墠缁撹涓哄悎鏍� 骞朵笖鍘嗗彶缁撹涔熸槸鍚堟牸 鍒欑户缁繚鎸佸悎鏍�
-                                        if (HLastResult == 1 && HLastResults != 0)
-                                        {
-                                            HLastResults = 1;
-                                        }
-                                        else
-                                        {
-                                            HLastResults = 0;
-                                        }
-                                    }
-
-                                    //涓昏〃
-                                    oCN.RunProc("Insert Into QC_StockCheckBillMain " +
-                                        "(HBillType,HBillSubType,HInterID,HBillNo,HBillStatus,HDate,HMaker,HMakeDate" +
-                                        ",HYear,HPeriod,HRemark" +
-                                        ",HSourceID,HICMOInterID,HICMOBillNo,HICMOQty,HProcExchInterID,HProcExchEntryID" +
-                                        ",HProcExchBillNo,HProcExchQty,HMaterID,HFirstCheckEmp,HLastResult" +
-                                        ",HMainSourceInterID,HMainSourceEntryID,HMainSourceBillNo,HMainSourceBillType,HICMOEntryID,HQCSchemeID,HShiftsID,HErrTreatment" +
-                                        ",HProcID,HBatchNo,HInSpectQty ,HRightQty ,HUnRightQty ,HUnKnowQty " +
-                                        ") " +
-                                        " values('" + BillType + "','" + BillType + "'," + HInterID + ",'" + HBillNo + "',1,getdate(),'" + this.txtHMaker.Text + "',getdate()" +
-                                        "," + DateTime.Now.Year + "," + DateTime.Now.Month + ",''" +
-                                        "," + HSourceID + ",0,'',0,0,0" +
-                                        ",'',0," + HMaterID + ",'" + this.labHMakerID.Text + "', " + HLastResults +
-                                        ",0,0,'','',0," + HQCSchemeID + ",0,''" +
-                                        "," + HProcID + ",'" + HBatchNo + "'," + HInSpectQty + "," + HRightQty + ", " + HUnRightQty + ", " + HUnKnowQty + ") ");
-
-
-                                    oCN.Commit();
-                                    MessageBox.Show("淇濆瓨鎴愬姛!");
-                                    //this.btnRest.Enabled = true;
-
-                                }
-                                else
-                                {
-                                    this.btnSave.Enabled = true;
-                                    MessageBox.Show("褰撳墠鐗╂枡鐨勬楠屾柟妗堜笌Excel鐨勫垪涓嶅尮閰�!");
-                                }
-                            }
-                            else
-                            {
-                                this.btnSave.Enabled = true;
-                                MessageBox.Show("褰撳墠鐗╂枡娌℃湁瀵瑰簲鐨勬楠屾柟妗�!");
-                            }
-                        }
-                    }
-                }
-            }
-            catch (Exception e)
-            {
-                this.btnSave.Enabled = true;
-                MessageBox.Show("淇濆瓨澶辫触!" + e.Message);
-            }
-        }
-
-
-        //鑾峰彇鐧诲綍鐨則oken
-        public async Task<JsonResult_JL> getUrl(string url, FormUrlEncodedContent formData)
-        {
-
-            // 鍒涘缓 HttpClient 瀹炰緥
-            using (var client = new HttpClient())
-            {
-                // 鍙戦�� POST 璇锋眰锛屽苟绛夊緟鍝嶅簲
-                HttpResponseMessage response = await client.PostAsync(url, formData);
-
-                Dictionary<object, object> dic = new Dictionary<object, object>();
-                JsonResult_JL jsonResult = new JsonResult_JL();
-                // 妫�鏌ュ搷搴旀槸鍚︽垚鍔�
-                if (response.IsSuccessStatusCode)
-                {
-                    // 澶勭悊鎴愬姛鍝嶅簲鐨勯�昏緫
-                    string responseBody = await response.Content.ReadAsStringAsync();
-                    jsonResult = JsonConvert.DeserializeObject<JsonResult_JL>(responseBody);
-                }
-                else
-                {
-                    // 澶勭悊澶辫触鍝嶅簲鐨勯�昏緫
-                    MessageBox.Show("璇锋眰澶辫触锛岀姸鎬佺爜锛�" + response.StatusCode);
-                }
-                return jsonResult;
-            }
-        }
-
-        /// <summary>
-        /// 鑾峰彇璁惧鍒楄〃
-        /// </summary>
-        /// <param name="url"></param>
-        /// <param name="postData"></param>
-        /// <returns></returns>
-        public async Task<JsonEquipmentData_JL> EquipmentList(string url, StringContent postData, string Type)
-        {
-
-            // 鍒涘缓 HttpClient 瀹炰緥
-            using (HttpClient client = new HttpClient())
-            {
-                JsonEquipmentData_JL jsonResult = new JsonEquipmentData_JL();
-                try
-                {
-                    HttpResponseMessage response;
-                    if (Type == "POST")
-                    {  // 鍙戣捣 POST 璇锋眰
-                        response = await client.PostAsync(url, postData);
-                    }
-                    else
-                    {
-                        // 鍙戣捣 get 璇锋眰
-                        response = await client.GetAsync(url);
-                    }
-
-
-                    // 纭繚璇锋眰鎴愬姛
-                    if (response.IsSuccessStatusCode)
-                    {
-                        // 璇诲彇鍝嶅簲鍐呭
-                        string responseBody = await response.Content.ReadAsStringAsync();
-                        jsonResult = JsonConvert.DeserializeObject<JsonEquipmentData_JL>(responseBody);
-                    }
-                    else
-                    {
-                        MessageBox.Show($"璇锋眰澶辫触锛歿response.StatusCode} - {url} - 褰撳墠鏃堕棿锛歿DateTime.Now:yyyy-MM-dd HH:mm:ss}");
-                    }
-
-                }
-                catch (Exception ex)
-                {
-                    MessageBox.Show("璇锋眰鎶ラ敊:" + ex.Message);
-                }
-                return jsonResult;
-            }
-        }
-
-        public async Task<JsonResult_JL> EquipResultList(string url, StringContent postData, string Type)
-        {
-
-            // 鍒涘缓 HttpClient 瀹炰緥
-            using (HttpClient client = new HttpClient())
-            {
-                JsonResult_JL jsonResult = new JsonResult_JL();
-                try
-                {
-                    HttpResponseMessage response;
-                    if (Type == "POST")
-                    {  // 鍙戣捣 POST 璇锋眰
-                        response = await client.PostAsync(url, postData);
-                    }
-                    else
-                    {
-                        // 鍙戣捣 get 璇锋眰
-                        response = await client.GetAsync(url);
-                    }
-
-
-                    // 纭繚璇锋眰鎴愬姛
-                    if (response.IsSuccessStatusCode)
-                    {
-                        // 璇诲彇鍝嶅簲鍐呭
-                        string responseBody = await response.Content.ReadAsStringAsync();
-                        jsonResult = JsonConvert.DeserializeObject<JsonResult_JL>(responseBody);
-                    }
-                    else
-                    {
-                        MessageBox.Show($"璇锋眰澶辫触锛歿response.StatusCode} - {url} - 褰撳墠鏃堕棿锛歿DateTime.Now:yyyy-MM-dd HH:mm:ss}");
-                    }
-
-                }
-                catch (Exception ex)
-                {
-                    MessageBox.Show("璇锋眰鎶ラ敊:" + ex.Message);
-                }
-                return jsonResult;
-            }
-        }
-
-
-        //鑾峰彇tockID
-        public async Task<JsonResult_JL> FindAccessToken(string url)
-        {
-            string urls = url + EquipmentType_JL.One;
-            // 鍑嗗瑕佸彂閫佺殑琛ㄥ崟鏁版嵁
-            var formData = new FormUrlEncodedContent(new[]
-            {
-                    new KeyValuePair<string, string>("userName", "admin"),
-                    new KeyValuePair<string, string>("password", "admin")
-                    // 娣诲姞鏇村閿�煎锛屾牴鎹偍鐨勯渶瑕�
-                });
-            JsonResult_JL jsonResult = await getUrl(urls, formData);
-            return jsonResult;
-        }
-
-        //鑾峰彇璁惧鍒楄〃
-        public async Task<JsonEquipmentData_JL> FindDeviceList(string url, string token)
-        {
-            //璁惧鍒楄〃鎺ュ彛
-            string urls = url + EquipmentType_JL.Two;
-            CustomWriteLog("璁惧鍒楄〃鎺ュ彛锛�'" + urls + "'", DateTime.Now.ToString("yyyy-MM-dd"));
-            // 鍑嗗瑕佸彂閫佺殑琛ㄥ崟鏁版嵁
-            var postData = new StringContent("{\"token\":\"" + token + "\"}", System.Text.Encoding.UTF8, "application/json");
-            JsonEquipmentData_JL jsonResult = await EquipmentList(urls, postData, "POST");
-            return jsonResult;
-        }
-
-        //鑾峰彇鑹搧銆佷笉鑹搧鏄庣粏銆佸伐鑹哄弬鏁�
-        public async Task<JsonEquipmentData_JL> FindAllDevicePropsDetailByTimeRange(string url, string token, string nos, string HBegin, string HEnd)
-        {
-            string basePropIds = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "basePropIds");
-            basePropIds = "[" + basePropIds + "]";
-            nos = nos.Replace(",", "\",\"");
-            //20250723  鍙戠幇鏈夌殑瀹㈡埛鏁伴噰娌℃湁閲囬泦宸ヨ壓鍙傛暟 濡傛灉浼犲叆瀵瑰簲鐨� 璁惧缂栧彿 浼氬鑷� 璇锋眰澶辫触  浼犲叆鍙傛暟ID 涔熷彲浠ヨ幏鍙栧埌瀵瑰簲鐨勮澶�  杩欐牱涓嶄細 璇锋眰澶辫触
-            //string stringJson = "{\"token\":\"" + token + "\",\"deviceNos\":[\"" + nos + "\"],\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\",\"basePropIds\":" + basePropIds + "}";
-            string stringJson = "{\"token\":\"" + token + "\",\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\",\"basePropIds\":" + basePropIds + "}";
-            //璁惧鍒楄〃鎺ュ彛
-            string urls = url + EquipmentType_JL.Nine;
-            CustomWriteLog("宸ヨ壓鍙傛暟鎺ュ彛锛�'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
-            // 鍑嗗瑕佸彂閫佺殑琛ㄥ崟鏁版嵁
-            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
-            JsonEquipmentData_JL jsonEquipment = await EquipmentList(urls, postData, "POST");
-            return jsonEquipment;
-        }
-
-        //鑾峰彇涓嶈壇鏁帮紝鍚堟暟鏁帮紝鍙枒鏁� 鎬绘暟
-        public async Task<JsonEquipmentData_JL> FindDevicePropCalc(string url, string token, string nos, string HBegin, string HEnd)
-        {
-            string stringJson = "{\"token\":\"" + token + "\",\"deviceNo\":\"" + nos + "\",\"propIds\":[606,173,469,470],\"beginTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}";
-            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
-            string urls = url + EquipmentType_JL.Seven;
-            CustomWriteLog("鑾峰彇涓嶈壇鏁帮紝鍚堟暟鏁帮紝鍙枒鏁� 鎬绘暟锛�'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
-            JsonEquipmentData_JL jsonResult = await EquipmentList(urls, postData, "POST");
-            return jsonResult;
-        }
-
-
-        //鑾峰彇璁惧杩愯鐘舵��
-        public async Task<JsonEquipmentData_JL> FindDeviceStatusByNos(string url, string token, string nos)
-        {
-            nos = nos.Replace(",", "\",\"");
-            nos = "\"" + nos + "\"";
-            string stringJson = "{\"token\":\"" + token + "\",\"nos\":[" + nos + "]}";
-            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
-            string urls = url + EquipmentType_JL.Three;
-            CustomWriteLog("璁惧杩愯鐘舵�侊細'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
-            JsonEquipmentData_JL jsonResult = await EquipmentList(urls, postData, "POST");
-            return jsonResult;
-        }
-
-        //鑾峰彇璁惧鏃堕棿娈典骇閲�
-        public async Task<JsonEquipmentData_JL> FindProdByNosAndTime(string url, string token, string nos, string HBegin, string HEnd)
-        {
-            nos = nos.Replace(",", "\",\"");
-            nos = "\"" + nos + "\"";
-            string stringJson = "{\"token\":\"" + token + "\",\"nos\":[" + nos + "],\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}";
-            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
-            string urls = url + EquipmentType_JL.Four;
-            CustomWriteLog("璁惧鏃堕棿娈典骇閲忥細'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
-            JsonEquipmentData_JL jsonResult = await EquipmentList(urls, postData, "POST");
-            return jsonResult;
-        }
-
-        //鑾峰彇璁惧杩愯鏃堕棿 寮�鏈� 鍋滄満 寰呮満  鍏虫満
-        public async Task<JsonResult_JL> FindDeviceStatusTimeByNo(string url, string token, string nos, string HBegin, string HEnd)
-        {
-            nos = nos.Replace(",", "\",\"");
-            nos = "\"" + nos + "\"";
-            string stringJson = "{\"token\":\"" + token + "\",\"no\":" + nos + ",\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}";
-            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
-            string urls = url + EquipmentType_JL.Five;
-            // 璁板綍寮�鏈烘椂闀�
-            CustomWriteLog("璁惧杩愯鏃堕棿鎺ュ彛锛�'"+ urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
-            JsonResult_JL jsonResult = await EquipResultList(urls, postData, "POST");
-            return jsonResult;
-        }
-
-        //鑾峰彇娉ㄥ鏈虹殑 寮�鏈�
-        public async Task<JsonResult_JL> FindDeviceStatusTimeByNosAndOperationMode(string url, string token, string nos, string HBegin, string HEnd)
-        {
-            nos = nos.Replace(",", "\",\"");
-            nos = "\"" + nos + "\"";
-            string stringJson = "{\"token\":\"" + token + "\",\"no\":" + nos + ",\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}";
-            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
-            string urls = url + EquipmentType_JL.Ten;
-            CustomWriteLog("娉ㄥ鏈虹殑 寮�鏈烘帴鍙o細'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
-            JsonResult_JL jsonResult = await EquipResultList(urls, postData, "POST");
-            return jsonResult;
-        }
-
-
-        //涓嬫媺妗嗙粦瀹氭暟鎹�
-        private void bindCbox()
-        {
-            IList<Info_JL> infoList = new List<Info_JL>();
-            Info_JL info1 = new Info_JL() { Id = "CMR-QC-SE-001", Name = "铻烘瘝鍏ㄦ" };
-            Info_JL info2 = new Info_JL() { Id = "CMR-ZZ-SE-001", Name = "铻烘瘝鍘嬭" };
-            Info_JL info3 = new Info_JL() { Id = "ZSJ07", Name = "娉ㄥ鏈�#07" };
-            //Info_JL info3 = new Info_JL() { Id = "3", Name = "鐜嬩簲" };
-            infoList.Add(info1);
-            infoList.Add(info2);
-            infoList.Add(info3);
-            cmbEquipFile.DataSource = infoList;
-            cmbEquipFile.ValueMember = "Id";
-            cmbEquipFile.DisplayMember = "Name";
-            this.cmbEquipFile.SelectedIndex = 0;
-            this.cmbEquipFile.DropDownStyle = ComboBoxStyle.DropDownList;
-        }
-
-        //閫夋嫨涓嬫媺妗嗗�兼洿鏀逛簨浠�
-        private void cmbEquipFile_SelectedIndexChanged(object sender, EventArgs e)
-        {
-            if (cmbEquipFile.SelectedIndex == 0)
-            {
-                this.btnLj.Enabled = true;
-                this.timer.Enabled = false;
-            }
-            else
-            {
-                this.btnLj.Enabled = false;
-                DialogResult dr = MessageBox.Show("鏄惁纭寮�濮嬮噰闆�?", "鎻愮ず", MessageBoxButtons.YesNo, MessageBoxIcon.Warning);
-
-                if (dr == DialogResult.Yes)
-                {
-                    this.txtHBathNo.ReadOnly = true;
-                    this.txtBegin.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
-                    //this.txtBegin.Text = "2024-11-21 13:40:27";
-                    this.btnBegin.Enabled = false;
-                    this.timer.Enabled = true;
-                    this.Time_CLHB.Enabled = true;
-                }
-            }
+            MessageBox.Show("鏁版嵁璇诲彇涓�...", "鎿嶄綔鎻愮ず");
         }
 
         //瀹氭椂鑾峰彇鏁版嵁
         private async void timer_Tick(object sender, EventArgs e)
         {
-            //娴嬭瘯鍏ㄦ
-            //this.timer.Enabled = false;
 
             string Url = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sUrl");
             string urls = Url + EquipmentType_JL.One;
@@ -852,108 +46,20 @@
             JsonResult_JL jsonResult = await getUrl(urls, formData);
             string time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
 
-            if (cmbEquipFile.SelectedIndex == 1)
-            {
-                SaveNutPressFit(Url, jsonResult.data.token, time);
-            }
-            else if (cmbEquipFile.SelectedIndex == 2)
-            {
-                SaveInjectionMoldingMachine(jsonResult.data.token, Url, time);
-            }
-
+            SaveInjectionMoldingMachine(jsonResult.data.token, Url, time);
 
         }
 
-        //铻烘瘝鍘嬭閲囬泦鏁版嵁 淇濆瓨
-        public async void SaveNutPressFit(string Url, string token, string time)
-        {
-            if (TimeDate == "")
-            {
-                TimeDate = this.txtBegin.Text;
-            }
-            this.timer.Enabled = false;
-
-            JsonEquipmentData_JL jsonResult = await FindDeviceList(Url, token);
-            if (jsonResult.code != "0")
-            {
-                MessageBox.Show("璁惧鍒楄〃鎶ラ敊:" + jsonResult.message);
-            }
-            else
-            {
-                string nos = "";
-                //鑾峰彇鍘昏澶囩紪鐮�
-                for (int i = 0; i < jsonResult.data.Count; i++)
-                {
-                    if (jsonResult.data[i].no.Contains("CMR-ZZ-SE-001"))
-                    {
-                        nos += jsonResult.data[i].no + ",";
-                    }
-                }
-                nos = nos.Substring(0, nos.Length - 1);
-                //TimeDate = "2024-08-14 08:30:39";
-                //time = "2024-08-14 15:05:39";
-
-                JsonEquipmentData_JL jsonEquipment = await FindAllDevicePropsDetailByTimeRange(Url, token, nos, TimeDate, time);
-
-                var JsonData_JL = "{\"data\":[";
-
-                for (int i = 0; i < jsonEquipment.data[0].props.Count; i++)
-                {
-                    for (int j = 0; j < jsonEquipment.data[0].props[i].datas.Count; j++)
-                    {
-                        valueData_JL value = JsonConvert.DeserializeObject<valueData_JL>(jsonEquipment.data[0].props[i].datas[j].value);
-                        if (value.type == "鑹搧")
-                        {
-                            JsonData_JL += "{\"HDate\":\"" + jsonEquipment.data[0].props[i].datas[j].createTime + "\",\"HTechParamName\":\"铻烘瘝鏄惁鍑稿嚭\",\"HResult\":\"OK\",\"HCount\":1,\"HSourceCode\":\"" + nos + "\"},";
-                        }
-                        else
-                        {
-                            JsonData_JL += "{\"HDate\":\"" + jsonEquipment.data[0].props[i].datas[j].createTime + "\",\"HTechParamName\":\"铻烘瘝鏄惁鍑稿嚭\",\"HResult\":\"NG\",\"HCount\":1,\"HSourceCode\":\"" + nos + "\"},";
-                        }
-                        JsonData_JL += "{\"HDate\":\"" + jsonEquipment.data[0].props[i].datas[j].createTime + "\",\"HTechParamName\":\"鐢熶骇鍛ㄦ湡\",\"HResult\":\"" + value.beat + "\",\"HCount\":1,\"HSourceCode\":\"" + nos + "\"},";
-                    }
-                }
-
-
-                jsonEquipment = await FindDevicePropCalc(Url, token, nos, TimeDate, time);
-
-                for (int i = 0; i < jsonEquipment.data.Count; i++)
-                {
-                    //鍚堟牸鏁�
-                    if (jsonEquipment.data[i].propId == 469)
-                    {
-                        JsonData_JL += "{\"HDate\":\"" + time + "\",\"HTechParamName\":\"鑹搧鏁癨",\"HResult\":\"OK\",\"HCount\":" + jsonEquipment.data[i].sum + ",\"HSourceCode\":\"" + nos + "\"},";
-                    }
-                    //涓嶈壇鏁�
-                    else if (jsonEquipment.data[i].propId == 470)
-                    {
-                        JsonData_JL += "{\"HDate\":\"" + time + "\",\"HTechParamName\":\"NG鏁伴噺\",\"HResult\":\"NG\",\"HCount\":" + jsonEquipment.data[i].sum + ",\"HSourceCode\":\"" + nos + "\"},";
-                    }
-                }
-
-                JsonData_JL = JsonData_JL.Substring(0, JsonData_JL.Length - 1);
-                JsonData_JL += "]}";
-                DataSave(JsonData_JL);
-                if (TimeDate != "")
-                {
-                    TimeDate = time;
-                }
-            }
-        }
-
+        
+      
         //娉ㄥ鏈洪噰闆嗘暟鎹� 淇濆瓨
         public async void SaveInjectionMoldingMachine(string token, string Url, string time)
-        {
-            ListData.Items.Clear();
+        {           
             if (TimeDate == "")
             {
-                TimeDate = this.txtBegin.Text;
+                TimeDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:00");
             }
-            //this.timer.Enabled = false;
-
-            //TimeDate = "2025-02-10 13:10:50";
-            //time = "2025-02-10 13:11:50";
-
+           
             //鑾峰彇鎵�鏈夎澶囨暟鎹�
             JsonEquipmentData_JL jsonResult = await FindDeviceList(Url, token);
             if (jsonResult.code != "0")
@@ -967,11 +73,7 @@
                 //鑾峰彇璁惧缂栫爜
                 for (int i = 0; i < jsonResult.data.Count; i++)
                 {
-                    nos += jsonResult.data[i].no + ",";
-                    //if (jsonResult.data[i].no.Contains("JS_ZS"))
-                    //{
-                    //    nos += jsonResult.data[i].no + ",";
-                    //}
+                    nos += jsonResult.data[i].no + ",";                 
                 }
                 nos = nos.Substring(0, nos.Length - 1);
                 //鑾峰彇鍙傛暟 鑾峰彇姣忎釜璁惧瀵瑰簲鐨勬墍鏈夊弬鏁�
@@ -1000,8 +102,7 @@
                             //寰幆 姣忎釜鍙傛暟瀵瑰簲鐨勬墍鏈夋暟鎹�
                             for (int k = 0; k < jsonEquipment.data[i].props[j].datas.Count; k++)
                             {
-                                JsonData_JL += "{\"HDate\":\"" + jsonEquipment.data[i].props[j].datas[k].createTime + "\",\"HTechParamName\":\"" + jsonEquipment.data[i].props[j].propName + "\",\"HResult\":\"" + jsonEquipment.data[i].props[j].datas[k].value + "\",\"HCount\":1,\"HSourceCode\":\"" + jsonEquipment.data[i].deviceNo + "\"},";
-                                //CustomWriteLog("宸ヨ壓鍙傛暟鍏蜂綋鍊硷細{\"HDate\":\"" + jsonEquipment.data[i].props[j].datas[k].createTime + "\",\"HTechParamName\":\"" + jsonEquipment.data[i].props[j].propName + "\",\"HResult\":\"" + jsonEquipment.data[i].props[j].datas[k].value + "\",\"HCount\":1,\"HSourceCode\":\"" + jsonEquipment.data[i].deviceNo + "\"}", DateTime.Now.ToString("yyyy-MM-dd"));
+                                JsonData_JL += "{\"HDate\":\"" + jsonEquipment.data[i].props[j].datas[k].createTime + "\",\"HTechParamName\":\"" + jsonEquipment.data[i].props[j].propName + "\",\"HResult\":\"" + jsonEquipment.data[i].props[j].datas[k].value + "\",\"HCount\":1,\"HSourceCode\":\"" + jsonEquipment.data[i].deviceNo + "\"},";                                
                             }
                         }
 
@@ -1010,8 +111,7 @@
                         for (int j = 0; j < data.data.Count; j++)
                         {
 
-                            JsonData_JL += "{\"HDate\":\"" + time + "\",\"HTechParamName\":\"鐢熶骇鏁伴噺\",\"HResult\":\"OK\",\"HCount\":" + data.data[j].prod + ",\"HSourceCode\":\"" + jsonEquipment.data[i].deviceNo + "\"},";
-                            //CustomWriteLog("{\"HDate\":\"" + time + "\",\"HTechParamName\":\"鐢熶骇鏁伴噺\",\"HResult\":\"OK\",\"HCount\":" + data.data[j].prod + ",\"HSourceCode\":\"" + jsonEquipment.data[i].deviceNo + "\"}", DateTime.Now.ToString("yyyy-MM-dd"));
+                            JsonData_JL += "{\"HDate\":\"" + time + "\",\"HTechParamName\":\"鐢熶骇鏁伴噺\",\"HResult\":\"OK\",\"HCount\":" + data.data[j].prod + ",\"HSourceCode\":\"" + jsonEquipment.data[i].deviceNo + "\"},";                           
                         }
                     }
                 }
@@ -1029,11 +129,12 @@
                     CustomWriteLog("data灞炴�т负绌�", DateTime.Now.ToString("yyyy-MM-dd"));
                 }
                 else
-                {
+                {                  
                     for (int i = 0; i < EquipmentStaus.data.Count; i++)
                     {
-                        //鍗风粫  娉ㄥ  娴告笉  缁勮  鐨勮澶囪繍琛� 寮�鍏冲仠鏈烘椂闂�
-                        if (EquipmentStaus.data[i].no.Contains("JS-MZ-") || EquipmentStaus.data[i].no.Contains("JS_LS_") || EquipmentStaus.data[i].no.Contains("JL_E_")
+                        CustomWriteLog(EquipmentStaus.data[0].no, DateTime.Now.ToString("yyyy-MM-dd"));
+                        //璁惧杩愯 寮�鍏冲仠鏈烘椂闂�
+                        if (EquipmentStaus.data[i].no.Contains("JS_MZ_") || EquipmentStaus.data[i].no.Contains("JS_LS_") || EquipmentStaus.data[i].no.Contains("JL_E_")
                             || EquipmentStaus.data[i].no.Contains("JL_") || EquipmentStaus.data[i].no.Contains("JL_A_") || EquipmentStaus.data[i].no.Contains("JL_B_")
                             || EquipmentStaus.data[i].no.Contains("JL_3_") || EquipmentStaus.data[i].no.Contains("JL_2_") || EquipmentStaus.data[i].no.Contains("JL_1_")
                             || EquipmentStaus.data[i].no.Contains("JS_RX_") || EquipmentStaus.data[i].no.Contains("JS_ZS_") || EquipmentStaus.data[i].no.Contains("JS_YL_")
@@ -1048,22 +149,7 @@
                             }
 
                             JsonResult_JL HEqDate = await FindDeviceStatusTimeByNo(Url, token, EquipmentStaus.data[i].no, HBegDate, HEndDate);
-
-                            // 璁板綍寮�鏈烘椂闀�
-                            CustomWriteLog("璁惧寮�鏈烘椂闀�: 寮�鏈烘椂闀�" + ((float)(HEqDate.data.onlineTime / 60 / 60)).ToString("0.00") + "  " + EquipmentStaus.data[i].no + "",
-                                            DateTime.Now.ToString("yyyy-MM-dd"));
-
-                            // 璁板綍鍏虫満鏃堕暱
-                            CustomWriteLog("璁惧鍏虫満鏃堕暱: 鍏虫満鏃堕暱" + ((float)(HEqDate.data.offlineTime / 60 / 60)).ToString("0.00") + "  " + EquipmentStaus.data[i].no + "",
-                                            DateTime.Now.ToString("yyyy-MM-dd"));
-
-                            // 璁板綍鍋滄満鏃堕暱
-                            CustomWriteLog("璁惧鍋滄満鏃堕暱: 鍋滄満鏃堕暱" + ((float)(HEqDate.data.standbyTime / 60 / 60)).ToString("0.00") + "  " + EquipmentStaus.data[i].no + "",
-                                            DateTime.Now.ToString("yyyy-MM-dd"));
-
-                            // 璁板綍杩愯鏃堕暱
-                            CustomWriteLog("璁惧杩愯鏃堕暱: 杩愯鏃堕暱" + ((float)(HEqDate.data.runTime / 60 / 60)).ToString("0.00") + "  " + EquipmentStaus.data[i].no + "",
-                                            DateTime.Now.ToString("yyyy-MM-dd"));
+                            
 
                             JsonData_JL += "{\"HDate\":\"" + HEndDate + "\",\"HTechParamName\":\"寮�鏈烘椂闀縗",\"HResult\":\"" + ((float)(HEqDate.data.onlineTime / 60 / 60)).ToString("0.00") + "\",\"HCount\":1,\"HSourceCode\":\"" + EquipmentStaus.data[i].no + "\"},";
                             JsonData_JL += "{\"HDate\":\"" + HEndDate + "\",\"HTechParamName\":\"鍏虫満鏃堕暱\",\"HResult\":\"" + ((float)(HEqDate.data.offlineTime / 60 / 60)).ToString("0.00") + "\",\"HCount\":1,\"HSourceCode\":\"" + EquipmentStaus.data[i].no + "\"},";
@@ -1156,14 +242,12 @@
                 values(getdate(),'" + data.data[i].HSourceCode + "',0,'" + data.data[i].HTechParamName + "'," + data.data[i].HCount
                 + ",'" + data.data[i].HDate + "','" + data.data[i].HResult + "','" + data.data[i].HProcNumber + "',0)");
                 
-            }
-            ListData.Items.Add($"鏃堕棿: {DateTime.Now:yyyy-MM-dd HH:mm:ss}锛屽姞杞芥垚鍔�");
+            }          
         }
 
         //瀹氭椂鐢熸垚浜ч噺姹囨姤鍗�
         private async void Time_CLHB_Tick(object sender, EventArgs e)
-        {
-            //this.Time_CLHB.Enabled = false;
+        {           
             string Url = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "sUrl");
             string urls = Url + EquipmentType_JL.One;
             // 鍑嗗瑕佸彂閫佺殑琛ㄥ崟鏁版嵁
@@ -1190,16 +274,10 @@
                 //鑾峰彇鍘昏澶囩紪鐮�
                 for (int i = 0; i < jsonEquipment.data.Count; i++)
                 {
-                    nos += "''" + jsonEquipment.data[i].no + "'',";
-                    //if (jsonEquipment.data[i].no.Contains("JS_ZS"))
-                    //{
-                    //    nos += "''" + jsonEquipment.data[i].no + "'',";
-                    //}                  
+                    nos += "''" + jsonEquipment.data[i].no + "'',";                               
                 }
                 nos = nos.Substring(0, nos.Length - 1);
-
-                //this.Time_CLHB.Enabled = false;
-
+            
                 CustomWriteLog("浜ч噺姹囨姤鍗曪紝璁惧缂栫爜锛�'"+ nos + "'", DateTime.Now.ToString("yyyy-MM-dd"));
 
                 //鏌ヨ寮�宸ョ殑璁惧淇℃伅 浠ュ強 鏌ヨ褰撳ぉ璁惧瀵瑰簲鐨勫紑宸ユ椂闂� 鍜屽畬宸ユ椂闂�
@@ -1255,66 +333,215 @@
             }
         }
 
-        private void txtHMaker_Leave(object sender, EventArgs e)
+        #region 鎺ュ彛
+        //鑾峰彇鐧诲綍鐨則oken
+        public async Task<JsonResult_JL> getUrl(string url, FormUrlEncodedContent formData)
         {
-            if (string.IsNullOrWhiteSpace(txtHMaker.Text))
-            {
-                this.txtHMaker.ForeColor = Color.LightGray;
-                txtHMaker.Text = "璇疯緭鍏ョ敤鎴风紪鐮�!";
-            }
-        }
 
-        private void txtHMaker_Enter(object sender, EventArgs e)
-        {
-            if (txtHMaker.Text.Trim() == "璇疯緭鍏ョ敤鎴风紪鐮�!")
+            // 鍒涘缓 HttpClient 瀹炰緥
+            using (var client = new HttpClient())
             {
-                txtHMaker.Text = "";
-                this.txtHMaker.ForeColor = Color.Black;
-            }
-        }
+                // 鍙戦�� POST 璇锋眰锛屽苟绛夊緟鍝嶅簲
+                HttpResponseMessage response = await client.PostAsync(url, formData);
 
-        private void txtHMaker_KeyDown(object sender, KeyEventArgs e)
-        {
-            if (e.KeyCode == Keys.Enter)
-            {
-                SelectHMaker(this.txtHMaker.Text);
-            }
-        }
-
-
-        //鏌ヨ鑱屽憳淇℃伅
-        public void SelectHMaker(string txtHMaker)
-        {
-            try
-            {
-                DataSet ds = oCN.RunProcReturn("select  HItemID,HName,HNumber from Gy_Employee where HNumber='" + txtHMaker + "' or HName ='" + txtHMaker + "'", "Gy_Employee");
-                if (ds.Tables[0].Rows.Count > 0)
+                Dictionary<object, object> dic = new Dictionary<object, object>();
+                JsonResult_JL jsonResult = new JsonResult_JL();
+                // 妫�鏌ュ搷搴旀槸鍚︽垚鍔�
+                if (response.IsSuccessStatusCode)
                 {
-                    string HName = ds.Tables[0].Rows[0]["HName"].ToString();
-                    string HMakerID = ds.Tables[0].Rows[0]["HItemID"].ToString();
-                    string HNumber = ds.Tables[0].Rows[0]["HNumber"].ToString();
-                    this.txtHMaker.Text = HName;
-                    this.txtHMakerNumber.Text = HNumber;
-                    this.labHMakerID.Text = HMakerID;
-                    this.txtHMaker.ReadOnly = true;
+                    // 澶勭悊鎴愬姛鍝嶅簲鐨勯�昏緫
+                    string responseBody = await response.Content.ReadAsStringAsync();
+                    jsonResult = JsonConvert.DeserializeObject<JsonResult_JL>(responseBody);
                 }
                 else
                 {
-                    MessageBox.Show(this, "缂栫爜:" + txtHMaker + ",鏌ユ棤鏁版嵁,鍙兘鏄緭鍏ョ紪鐮佹湁璇�!", "鎻愮ず");
+                    // 澶勭悊澶辫触鍝嶅簲鐨勯�昏緫
+                    MessageBox.Show("璇锋眰澶辫触锛岀姸鎬佺爜锛�" + response.StatusCode);
                 }
-            }
-            catch (Exception e)
-            {
-                MessageBox.Show(this, e.Message, "鎻愮ず");
+                return jsonResult;
             }
         }
 
-        private void EquipmentCollectionForm_Activated(object sender, EventArgs e)
+        // 鑾峰彇璁惧鍒楄〃
+        public async Task<JsonEquipmentData_JL> EquipmentList(string url, StringContent postData, string Type)
         {
-            //鍏夋爣閫変腑鍒跺崟浜�
-            this.txtHMaker.Focus();
+
+            // 鍒涘缓 HttpClient 瀹炰緥
+            using (HttpClient client = new HttpClient())
+            {
+                JsonEquipmentData_JL jsonResult = new JsonEquipmentData_JL();
+                try
+                {
+                    HttpResponseMessage response;
+                    if (Type == "POST")
+                    {  // 鍙戣捣 POST 璇锋眰
+                        response = await client.PostAsync(url, postData);
+                    }
+                    else
+                    {
+                        // 鍙戣捣 get 璇锋眰
+                        response = await client.GetAsync(url);
+                    }
+
+
+                    // 纭繚璇锋眰鎴愬姛
+                    if (response.IsSuccessStatusCode)
+                    {
+                        // 璇诲彇鍝嶅簲鍐呭
+                        string responseBody = await response.Content.ReadAsStringAsync();
+                        jsonResult = JsonConvert.DeserializeObject<JsonEquipmentData_JL>(responseBody);
+                    }
+                    else
+                    {
+                        MessageBox.Show($"璇锋眰澶辫触锛歿response.StatusCode} - {url} - 褰撳墠鏃堕棿锛歿DateTime.Now:yyyy-MM-dd HH:mm:ss}");
+                    }
+
+                }
+                catch (Exception ex)
+                {
+                    MessageBox.Show("璇锋眰鎶ラ敊:" + ex.Message);
+                }
+                return jsonResult;
+            }
         }
 
+        public async Task<JsonResult_JL> EquipResultList(string url, StringContent postData, string Type)
+        {
+
+            // 鍒涘缓 HttpClient 瀹炰緥
+            using (HttpClient client = new HttpClient())
+            {
+                JsonResult_JL jsonResult = new JsonResult_JL();
+                try
+                {
+                    HttpResponseMessage response;
+                    if (Type == "POST")
+                    {  // 鍙戣捣 POST 璇锋眰
+                        response = await client.PostAsync(url, postData);
+                    }
+                    else
+                    {
+                        // 鍙戣捣 get 璇锋眰
+                        response = await client.GetAsync(url);
+                    }
+
+
+                    // 纭繚璇锋眰鎴愬姛
+                    if (response.IsSuccessStatusCode)
+                    {
+                        // 璇诲彇鍝嶅簲鍐呭
+                        string responseBody = await response.Content.ReadAsStringAsync();
+                        jsonResult = JsonConvert.DeserializeObject<JsonResult_JL>(responseBody);
+                    }
+                    else
+                    {
+                        MessageBox.Show($"璇锋眰澶辫触锛歿response.StatusCode} - {url} - 褰撳墠鏃堕棿锛歿DateTime.Now:yyyy-MM-dd HH:mm:ss}");
+                    }
+
+                }
+                catch (Exception ex)
+                {
+                    MessageBox.Show("璇锋眰鎶ラ敊:" + ex.Message);
+                }
+                return jsonResult;
+            }
+        }
+
+        //鑾峰彇璁惧鍒楄〃
+        public async Task<JsonEquipmentData_JL> FindDeviceList(string url, string token)
+        {
+            //璁惧鍒楄〃鎺ュ彛
+            string urls = url + EquipmentType_JL.Two;
+            CustomWriteLog("璁惧鍒楄〃鎺ュ彛锛�'" + urls + "'", DateTime.Now.ToString("yyyy-MM-dd"));
+            // 鍑嗗瑕佸彂閫佺殑琛ㄥ崟鏁版嵁
+            var postData = new StringContent("{\"token\":\"" + token + "\"}", System.Text.Encoding.UTF8, "application/json");
+            JsonEquipmentData_JL jsonResult = await EquipmentList(urls, postData, "POST");
+            return jsonResult;
+        }
+
+        //鑾峰彇鑹搧銆佷笉鑹搧鏄庣粏銆佸伐鑹哄弬鏁�
+        public async Task<JsonEquipmentData_JL> FindAllDevicePropsDetailByTimeRange(string url, string token, string nos, string HBegin, string HEnd)
+        {
+            string basePropIds = DBHelper.GetConfigKey(AppDomain.CurrentDomain.BaseDirectory + "Config/SQLAPI.config", "basePropIds");
+            basePropIds = "[" + basePropIds + "]";
+            nos = nos.Replace(",", "\",\"");
+            //20250723  鍙戠幇鏈夌殑瀹㈡埛鏁伴噰娌℃湁閲囬泦宸ヨ壓鍙傛暟 濡傛灉浼犲叆瀵瑰簲鐨� 璁惧缂栧彿 浼氬鑷� 璇锋眰澶辫触  浼犲叆鍙傛暟ID 涔熷彲浠ヨ幏鍙栧埌瀵瑰簲鐨勮澶�  杩欐牱涓嶄細 璇锋眰澶辫触
+            //string stringJson = "{\"token\":\"" + token + "\",\"deviceNos\":[\"" + nos + "\"],\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\",\"basePropIds\":" + basePropIds + "}";
+            string stringJson = "{\"token\":\"" + token + "\",\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\",\"basePropIds\":" + basePropIds + "}";
+            //璁惧鍒楄〃鎺ュ彛
+            string urls = url + EquipmentType_JL.Nine;
+            CustomWriteLog("宸ヨ壓鍙傛暟鎺ュ彛锛�'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
+            // 鍑嗗瑕佸彂閫佺殑琛ㄥ崟鏁版嵁
+            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
+            JsonEquipmentData_JL jsonEquipment = await EquipmentList(urls, postData, "POST");
+            return jsonEquipment;
+        }
+
+        //鑾峰彇涓嶈壇鏁帮紝鍚堟暟鏁帮紝鍙枒鏁� 鎬绘暟
+        public async Task<JsonEquipmentData_JL> FindDevicePropCalc(string url, string token, string nos, string HBegin, string HEnd)
+        {
+            string stringJson = "{\"token\":\"" + token + "\",\"deviceNo\":\"" + nos + "\",\"propIds\":[606,173,469,470],\"beginTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}";
+            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
+            string urls = url + EquipmentType_JL.Seven;
+            CustomWriteLog("鑾峰彇涓嶈壇鏁帮紝鍚堟暟鏁帮紝鍙枒鏁� 鎬绘暟锛�'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
+            JsonEquipmentData_JL jsonResult = await EquipmentList(urls, postData, "POST");
+            return jsonResult;
+        }
+
+        //鑾峰彇璁惧杩愯鐘舵��
+        public async Task<JsonEquipmentData_JL> FindDeviceStatusByNos(string url, string token, string nos)
+        {
+            nos = nos.Replace(",", "\",\"");
+            nos = "\"" + nos + "\"";
+            string stringJson = "{\"token\":\"" + token + "\",\"nos\":[" + nos + "]}";
+            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
+            string urls = url + EquipmentType_JL.Three;
+            CustomWriteLog("璁惧杩愯鐘舵�侊細'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
+            JsonEquipmentData_JL jsonResult = await EquipmentList(urls, postData, "POST");
+            return jsonResult;
+        }
+
+        //鑾峰彇璁惧鏃堕棿娈典骇閲�
+        public async Task<JsonEquipmentData_JL> FindProdByNosAndTime(string url, string token, string nos, string HBegin, string HEnd)
+        {
+            nos = nos.Replace(",", "\",\"");
+            nos = "\"" + nos + "\"";
+            string stringJson = "{\"token\":\"" + token + "\",\"nos\":[" + nos + "],\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}";
+            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
+            string urls = url + EquipmentType_JL.Four;
+            CustomWriteLog("璁惧鏃堕棿娈典骇閲忥細'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
+            JsonEquipmentData_JL jsonResult = await EquipmentList(urls, postData, "POST");
+            return jsonResult;
+        }
+
+        //鑾峰彇璁惧杩愯鏃堕棿 寮�鏈� 鍋滄満 寰呮満  鍏虫満
+        public async Task<JsonResult_JL> FindDeviceStatusTimeByNo(string url, string token, string nos, string HBegin, string HEnd)
+        {
+            nos = nos.Replace(",", "\",\"");
+            nos = "\"" + nos + "\"";
+            string stringJson = "{\"token\":\"" + token + "\",\"no\":" + nos + ",\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}";
+            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
+            string urls = url + EquipmentType_JL.Five;
+            // 璁板綍寮�鏈烘椂闀�
+            CustomWriteLog("璁惧杩愯鏃堕棿鎺ュ彛锛�'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
+            JsonResult_JL jsonResult = await EquipResultList(urls, postData, "POST");
+            return jsonResult;
+        }
+
+        //鑾峰彇娉ㄥ鏈虹殑 寮�鏈�
+        public async Task<JsonResult_JL> FindDeviceStatusTimeByNosAndOperationMode(string url, string token, string nos, string HBegin, string HEnd)
+        {
+            nos = nos.Replace(",", "\",\"");
+            nos = "\"" + nos + "\"";
+            string stringJson = "{\"token\":\"" + token + "\",\"no\":" + nos + ",\"startTime\":\"" + HBegin + "\",\"endTime\":\"" + HEnd + "\"}";
+            var postData = new StringContent(stringJson, System.Text.Encoding.UTF8, "application/json");
+            string urls = url + EquipmentType_JL.Ten;
+            CustomWriteLog("娉ㄥ鏈虹殑 寮�鏈烘帴鍙o細'" + urls + "' 鍙傛暟鍊硷細 '" + stringJson + "'", DateTime.Now.ToString("yyyy-MM-dd"));
+            JsonResult_JL jsonResult = await EquipResultList(urls, postData, "POST");
+            return jsonResult;
+        }
+        #endregion
+
         private static readonly object lockObj = new object();
         //鍐欐棩蹇�
         public static void CustomWriteLog(object obj, string FileName, string filePath = "Vlog", bool isAppend = true)

--
Gitblit v1.9.1