From 3c6cad1224e7cb985f03d15cc98a4a2074a5af49 Mon Sep 17 00:00:00 2001
From: cdk <2441919651@qq.com>
Date: 星期一, 22 十二月 2025 22:25:33 +0800
Subject: [PATCH] 增加轮播看板

---
 DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01Fg.cs |  442 ++-----------------------------------------------------
 1 files changed, 18 insertions(+), 424 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01Fg.cs b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01Fg.cs
index 8575be0..b0e33e8 100644
--- a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01Fg.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01Fg.cs
@@ -1,40 +1,22 @@
-锘縰sing DevExpress.XtraEditors;
-using DevExpress.XtraGrid.Columns;
-using DevExpress.XtraLayout.Utils;
-using Gs.DevApp.Entity;
+锘縰sing Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
-using NModbus;
 using System;
-using System.Collections.Generic;
-using System.Configuration;
 using System.Data;
-using System.Data.SqlClient;
 using System.Dynamic;
-using System.IO;
-using System.Net.Sockets;
-using System.Text;
 using System.Windows.Forms;
 
 namespace Gs.DevApp.DevFrm.Work
 {
     public partial class Frm_Work01Fg : DevExpress.XtraEditors.XtraForm
     {
-        string isWater = "0";
-        string hostName = "192.168.60.51";
-        int hostNamePoint = 502;
-        string strConn = "Data Source=192.168.1.146,12468;Initial Catalog=GS_MES;User ID=mesUser;Password =qixi1qaz@WSXmes";
-        bool isCleanDianJian = true;
         string _webServiceName = "WorkCollect/";
         string dianJianPath = "";//鐢垫鍙栧�艰矾寰�
         string goodTag = "鈭�";
         string badTag = "脳";
         string fGxTouRu = "G001:鎶曞叆";
-        string fGxDianJian = "G002:鐢垫";
-        string fGxShouJian = "G003:姘存";
-        string fGxZhongJian = "G004:缁堟";
-
+       
         /// <summary>
         /// 
         /// </summary>
@@ -42,7 +24,7 @@
         /// <param name="_fBc">鐝</param>
         /// <param name="_strinOther">鐩墠涓虹數妫�璺緞</param>
         /// <param name="chkWater">鏄惁姘存</param>
-        public Frm_Work01Fg(string _fGx, string _fBc, string _strinOther, int chkWater = 0)
+        public Frm_Work01Fg(string _fGx, string _fBc)
         {
             InitializeComponent();
             System.Drawing.Font ft1 = new System.Drawing.Font("瀹嬩綋", 35F);//澶ф寜閽�
@@ -91,18 +73,7 @@
             this.txt_sjDate.Properties.Appearance.Font = ft5;
             this.txt_barCode.Properties.Appearance.Font = ft5;
             this.txt_currentBarCode.Properties.Appearance.Font = ft5;
-            this.txt_gongWei.Properties.Appearance.Font = ft5;
-            this.txt_dianJianPath.Properties.Appearance.Font = ft5;
-            try
-            {
-                string _vanishingSeconds = chkWater.ToString();
-                if (!string.IsNullOrEmpty(_vanishingSeconds))
-                    isWater = _vanishingSeconds;
-            }
-            catch (Exception)
-            {
-
-            }
+            this.txt_OldLiuShuiMa.Properties.Appearance.Font = ft5;
             gvMx1.IndicatorWidth = 60;
             gvMx1.CustomDrawRowIndicator += (s, e) =>
             {
@@ -111,43 +82,30 @@
             };
             txt_gx.Text = _fGx;
             txt_bc.Text = _fBc;
-            txt_dianJianPath.Text = _strinOther;
-            dianJianPath = _strinOther;
             this.Text = "宸ュ簭閲囬泦銆�" + _fGx + " - " + _fBc + "銆�";
             label8.Text = _fGx + "鏁伴噺";
-            addColumn();
             //杩芥函鐮佹鍥炶溅浜嬩欢
             txt_barCode.KeyDown += (s, e) =>
             {
                 if (e.KeyCode == Keys.Enter)
                 {
-                    //濡傛灉鏄按妫�锛岃繕瑕佹壂宸ヤ綅
-                    if (txt_gx.Text.Trim() == fGxShouJian && isWater == "1")
-                    {
-                        txt_gongWei.Focus();
-                    }
-                    else
-                        addModel(goodTag);
+                    txt_OldLiuShuiMa.Focus();
                 }
             };
-            //宸ヤ綅鍥炶溅妗嗕簨浠�
-            txt_gongWei.KeyDown += (s, e) =>
+            //娴佹按鐮佹鍥炶溅浜嬩欢
+            txt_OldLiuShuiMa.KeyDown += (s, e) =>
             {
                 if (e.KeyCode == Keys.Enter)
                 {
-                    //濡傛灉鏄按妫�锛屽彲浠ユ彁浜や簡
-                    if (txt_gx.Text.Trim() == fGxShouJian)
+                    if (txt_OldLiuShuiMa.Text.Trim().Length <= 0)
                     {
-                        if (txt_gongWei.Text.Trim().Length <= 0)
-                        {
-                            Toast vm = new Toast(-1, "鎿嶄綔澶辫触@n璇峰厛鎵弿宸ヤ綅鐮�");
-                            vm.Show();
-                            this.ActiveControl = this.txt_gongWei;
-                            txt_gongWei.Focus();
-                            return;
-                        }
-                        addModel(goodTag);
+                        Toast vm = new Toast(-1, "鎿嶄綔澶辫触@n璇峰厛鎵拷婧爜");
+                        vm.Show();
+                        this.ActiveControl = this.txt_OldLiuShuiMa;
+                        txt_OldLiuShuiMa.Focus();
+                        return;
                     }
+                    addModel(goodTag);
                 }
             };
             //鑹搧鎸夐挳浜嬩欢
@@ -188,12 +146,6 @@
                 string _type = "";
                 if (txt_gx.Text.Trim() == fGxTouRu)
                     _type = "宸ュ簭G001:鎶曞叆涓嶈壇鎻忚堪";
-                if (txt_gx.Text.Trim() == fGxDianJian)
-                    _type = "宸ュ簭G002:鐢垫涓嶈壇鎻忚堪";
-                if (txt_gx.Text.Trim() == fGxShouJian)
-                    _type = "宸ュ簭G003:姘存涓嶈壇鎻忚堪";
-                if (txt_gx.Text.Trim() == fGxZhongJian)
-                    _type = "宸ュ簭G004:缁堟涓嶈壇鎻忚堪";
                 string condition = $" pid<>'00000000-0000-0000-0000-000000000000' ";
                 if (txt_orgId.Text.Trim() == "104554") // 鐢靛櫒
                 {
@@ -247,9 +199,10 @@
             _obj.checkResult = _checkResult;//妫�娴嬬粨鏋�
             _obj.processNo = txt_gx.Text.Trim();//宸ュ簭
             _obj.banCi = txt_bc.Text.Trim();//鐝
-            _obj.gongWei = txt_gongWei.Text.Trim();//宸ヤ綅
+            _obj.gongWei = "";//宸ヤ綅
             _obj.badDescription = _badDescription.Trim();//涓嶈壇鎻忚堪
             _obj.collectGuid = _collectGuid;
+            _obj.oldLiushuima = txt_OldLiuShuiMa.Text.Trim();
             //涓嶈壇锛岀洿鎺ユ彁浜�
             if (!string.IsNullOrEmpty(_collectGuid))
             {
@@ -257,99 +210,6 @@
             }
             //鎶曞叆锛岀洿鎺ユ彁浜�
             if (txt_gx.Text.Trim() == fGxTouRu)
-            {
-                return _obj;
-            }
-            //鐢垫锛岄渶瑕佽鍙栫浉鍏虫暟鎹�
-            if (txt_gx.Text.Trim() == fGxDianJian)
-            {
-                string TM = "";
-                string JD = "";//鎺ュ湴
-                string JY = "";//缁濈紭
-                string JN = "";//浜よ��
-                string XL = "";//娉勬紡
-                string GV = ""; //GV鍔熺巼
-                string JDV = "";
-                string JYV = "";
-                string JNV = "";
-                string XLV = "";
-                string GVV = "";
-                string myStr = File.ReadAllText(dianJianPath, Encoding.Default);
-                if (myStr == "")
-                {
-                    return _obj;
-                }
-                //鎶婄數妫�鏁版嵁杞负json
-                //[{"TiaoMa":"","JiaoNai":{"state":"ok","value":"1800V 0.192mA"},"XieLou":{"state":"ok","value":"235.0V 0.024mA"},"JieDi":{"state":"ok","value":"25.0A 43m娆�"},"GongLv":{"state":"ok","value":"220.0V 9.96A 2196.0W"}}]
-                JArray dsTemp = JArray.Parse(myStr);
-                foreach (var ss in dsTemp)
-                {
-                    TM = (((JObject)ss)["TiaoMa"] == null) ? "" : ((JObject)ss)["TiaoMa"].ToString();
-                    //鐘舵�侊紝ng鎴杘k
-                    JD = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["state"].ToString();
-                    JY = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["state"].ToString();
-                    JN = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["state"].ToString();
-                    XL = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["state"].ToString();
-                    GV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["state"].ToString();
-                    //鍏蜂綋鐨勫��
-                    JDV = (((JObject)ss)["JieDi"] == null) ? "" : ((JObject)ss)["JieDi"]["value"].ToString().Replace(" ", ",");
-                    JYV = (((JObject)ss)["JueYuan"] == null) ? "" : ((JObject)ss)["JueYuan"]["value"].ToString().Replace(" ", ", ");
-                    JNV = (((JObject)ss)["JiaoNai"] == null) ? "" : ((JObject)ss)["JiaoNai"]["value"].ToString().Replace(" ", ", ");
-                    XLV = (((JObject)ss)["XieLou"] == null) ? "" : ((JObject)ss)["XieLou"]["value"].ToString().Replace(" ", ", ");
-                    GVV = (((JObject)ss)["GongLv"] == null) ? "" : ((JObject)ss)["GongLv"]["value"].ToString().Replace(" ", ", ");
-                }
-                _obj.t001 = TM;
-                _obj.t002 = JD;
-                _obj.t003 = JY;
-                _obj.t004 = JN;
-                _obj.t005 = XL;
-                _obj.t006 = GV;
-                _obj.t007 = JDV;
-                _obj.t008 = JYV;
-                _obj.t009 = JNV;
-                _obj.t010 = XLV;
-                _obj.t011 = GVV;
-                if (isCleanDianJian == true)
-                    File.WriteAllText(dianJianPath, "");
-                return _obj;
-            }
-            //姘存
-            if (txt_gx.Text.Trim() == fGxShouJian)
-            {
-                if (isWater == "0")
-                {
-                    return _obj;
-                }
-                string strCsl1 = "";//妯″紡1鍑烘按閲�
-                string strSw1 = "";//妯″紡1姘存俯
-                string strCsl2 = "";
-                string strSw2 = "";
-                string strCsl3 = "";
-                string strSw3 = "";
-                string strCsl4 = "";
-                string strSw4 = "";
-                string strCsl5 = "";
-                string strSw5 = "";
-                string SJJG = "";//姘存鏌ョ粨鏋渙k銆乶g
-                string GWZT = "";//宸ヤ綅鐘舵��
-                string SJJGZ = "";//姘存鏌ョ粨鏋�1
-                (strCsl1, strSw1, SJJG, GWZT, SJJGZ) = getShuiJian();
-                _obj.t002 = strCsl1;//鍑烘按閲�1
-                _obj.t003 = strSw1;//姘存俯1
-                _obj.t004 = strCsl2;//鍑烘按閲�2
-                _obj.t005 = strSw2;//姘存俯2
-                _obj.t006 = strCsl3;//鍑烘按閲�3
-                _obj.t007 = strSw3;//姘存俯3
-                _obj.t008 = strCsl4;
-                _obj.t009 = strSw4;
-                _obj.t010 = strCsl5;
-                _obj.t011 = strSw5;
-                _obj.t012 = SJJGZ;//姘存缁撴灉浼间箮涓嶇敤
-                _obj.t013 = GWZT;//宸ヤ綅鐘舵�佷技涔庝笉鐢�
-                return _obj;
-            }
-            //缁堟
-            if (txt_gx.Text.Trim() == fGxZhongJian)
             {
                 return _obj;
             }
@@ -391,8 +251,7 @@
                     lbSum4.Text = dy.lbSum4;
                     prog1.Position = dy.jd;
                     txt_barCode.ReadOnly = false;
-                    if (txt_gx.Text.Trim() == fGxShouJian)
-                        txt_gongWei.ReadOnly = false;
+                     txt_OldLiuShuiMa.ReadOnly = false;
                     //鑹搧鍒楄〃
                     JObject _job = JObject.Parse(strJson);
                     JArray array = new JArray();
@@ -456,274 +315,9 @@
                 vm.Show();
             }
             txt_barCode.Text = "";
-            txt_gongWei.Text = "";
+            txt_OldLiuShuiMa.Text = "";
             this.ActiveControl = this.txt_barCode;
             txt_barCode.Focus();
         }
-
-        /// <summary>
-        /// 澧炲姞鐢垫锛屾按妫�鐨勫垪
-        /// </summary>
-        public void addColumn()
-        {
-            //鍙湁鐢垫鎵嶆樉绀�
-            if (txt_gx.Text.Trim() == fGxDianJian)
-                layDianJian.Visibility = LayoutVisibility.Always;
-            else
-                layDianJian.Visibility = LayoutVisibility.Never;
-            //鍙湁姘存鎵嶆樉绀�
-            if (txt_gx.Text.Trim() == fGxShouJian && isWater == "1")
-                layShuiJian.Visibility = LayoutVisibility.Always;
-            else
-                layShuiJian.Visibility = LayoutVisibility.Never;
-            List<dynamic> _lst = new List<dynamic>();
-            if (txt_gx.Text.Trim() == fGxDianJian)
-            {
-                _lst.Add(new
-                {
-                    ziduan = "t002",
-                    wenben = "鎺ュ湴",
-                    kejian = true,
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t004",
-                    wenben = "浜よ��",
-                    kejian = true,
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t005",
-                    wenben = "娉勬紡",
-                    kejian = true,
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t006",
-                    wenben = "鍔熺巼",
-                    kejian = true,
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t007",
-                    wenben = "鎺ュ湴缁撴灉",
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t009",
-                    wenben = "浜よ�愮粨鏋�",
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t010",
-                    wenben = "娉勬紡缁撴灉",
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t011",
-                    wenben = "鍔熺巼缁撴灉",
-                    visibleIndex = 1,
-                });
-            }
-            if (txt_gx.Text.Trim() == fGxShouJian)
-            {
-                _lst.Add(new
-                {
-                    ziduan = "t002",
-                    wenben = "鍑烘按閲�1",
-                    kejian = true,
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t003",
-                    wenben = "姘存俯1",
-                    kejian = true,
-                    visibleIndex = 1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t004",
-                    wenben = "鍑烘按閲�2",
-                    visibleIndex = -1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t005",
-                    wenben = "姘存俯2",
-                    visibleIndex = -1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t006",
-                    wenben = "鍑烘按閲�3",
-                    visibleIndex = -1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t007",
-                    wenben = "姘存俯3",
-                    visibleIndex = -1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t008",
-                    wenben = "鍑烘按閲�4",
-                    visibleIndex = -1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t009",
-                    wenben = "姘存俯4",
-                    visibleIndex = -1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t010",
-                    wenben = "鍑烘按閲�5",
-                    visibleIndex = -1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t011",
-                    wenben = "姘存俯5",
-                    visibleIndex = -1,
-                });
-                _lst.Add(new
-                {
-                    ziduan = "t012",
-                    wenben = "鏁版嵁缁撴灉",
-                    kejian = true,
-                    visibleIndex = 1,
-                });
-            }
-            foreach (var item in _lst)
-            {
-                GridColumn newColumn = new GridColumn();
-                newColumn.FieldName = item.ziduan; // 璁剧疆涓庢暟鎹簮瀵瑰簲鐨勫瓧娈靛悕
-                newColumn.Caption = item.wenben; // 璁剧疆鍒楃殑鏍囬
-                newColumn.VisibleIndex = item.visibleIndex; // 璁剧疆鍒楃殑鏄剧ず椤哄簭
-                gvMx1.Columns.Add(newColumn);
-            }
-        }
-
-
-        #region  璇诲彇姘存鏁版嵁
-        private (string, string, string, string, string) getShuiJian()
-        {
-            string strCsl1 = ""; //妯″紡1鍑烘按閲�
-            string strSw1 = "";//妯″紡1姘存俯
-            string SJJG = "";//姘存鏌ョ粨鏋渙k銆乶g
-            string GWZT = "";//宸ヤ綅鐘舵��
-            string SJJGZ = "";//姘存鏌ョ粨鏋�1
-            bool blIp = true;
-            blIp = CheckPort(hostName, hostNamePoint);
-            if (blIp)
-            {
-                System.Text.StringBuilder sbSql1 = new StringBuilder();
-                sbSql1.Append($"select MIG004,MIG005 from BASMIG(nolock) where MIG001='ShuiJianZhanWei01' and MIG003='{((BaseEdit)this.txt_gongWei).EditValue.ToString()}'");
-                DataTable dataTable1 = this.GetDataTable(sbSql1.ToString(), "tmpBASMIG2");
-                if (dataTable1 == null || dataTable1.Rows.Count <= 0)
-                {
-                    ((BaseEdit)this.txt_gongWei).EditValue = (object)"";
-                    LogHelper.Debug(this.ToString(), txt_gongWei.Text + "璇ユ按妫�绔欎綅鐮佷笉瀛樺湪锛岃纭锛�");
-                    //Toast vm = new Toast(-1, "璇ユ按妫�绔欎綅鐮佷笉瀛樺湪锛岃纭锛�");
-                    //vm.Show();
-                }
-                else
-                {
-                    ModbusFactory modbusFactory = new ModbusFactory();
-                    byte num1 = byte.Parse("1");
-                    ushort num2 = ushort.Parse("1");
-                    System.Text.StringBuilder sbSql2 = new StringBuilder();
-                    sbSql2.Append(string.Format($"select case when MIG006='D' then MIG003+{dataTable1.Rows[0][0]} else MIG003+{dataTable1.Rows[0][1]} end MIG003,MIG004 from BASMIG(nolock) where MIG001 = 'ShuiJianAddress01' order by MIG005"));
-                    DataTable dataTable2 = GetDataTable(sbSql2.ToString(), "tmpBASMIG3");
-                    if (dataTable2 == null || dataTable2.Rows.Count <= 0)
-                    {
-                        ((BaseEdit)this.txt_gongWei).EditValue = (object)"";
-                        LogHelper.Debug(this.ToString(), txt_gongWei.Text + "姘存鍦板潃涓嶅瓨鍦紝璇风‘璁わ紒");
-                        //Toast vm = new Toast(-1, "姘存鍦板潃涓嶅瓨鍦紝璇风‘璁わ紒");
-                        //vm.Show();
-                    }
-                    else
-                    {
-                        try
-                        {
-                            IModbusMaster master = modbusFactory.CreateMaster(new TcpClient(this.hostName, this.hostNamePoint));
-                            master.Transport.ReadTimeout = 10000;
-                            master.Transport.Retries = 10000;
-                            strCsl1 = master.ReadHoldingRegisters(num1, ushort.Parse(dataTable2.Rows[0]["MIG003"].ToString()), num2)[0].ToString();
-                            strSw1 = (float.Parse(master.ReadHoldingRegisters(num1, ushort.Parse(dataTable2.Rows[1]["MIG003"].ToString()), num2)[0].ToString()) / 10f).ToString();
-                            ushort[] numArray = master.ReadHoldingRegisters(num1, ushort.Parse(dataTable2.Rows[2]["MIG003"].ToString()), num2);
-                            SJJGZ = numArray[0].ToString();
-                            SJJG = numArray[0].ToString();
-                            SJJG = (SJJG == "1" ? "OK" : (SJJG == "2" ? "NG" : SJJG));
-                            GWZT = master.ReadCoils(num1, ushort.Parse(dataTable2.Rows[3]["MIG003"].ToString()), num2)[0].ToString();
-                        }
-                        catch (Exception ex)
-                        {
-                            ((BaseEdit)this.txt_gongWei).EditValue = (object)"";
-                            LogHelper.Debug(this.ToString(), txt_gongWei.Text + ex.Message);
-                            //Toast vm = new Toast(-1, ex.Message);
-                            //vm.Show();
-                        }
-                    }
-                }
-            }
-            return (strCsl1, strSw1, SJJG, GWZT, SJJGZ);
-        }
-        private DataTable GetDataTable(string SQLString, string tmpBASMIG2)
-        {
-            using (var connection = new SqlConnection(strConn))
-            {
-                var ds = new DataSet();
-                try
-                {
-                    connection.Open();
-                    var command = new SqlDataAdapter(SQLString, connection);
-                    command.Fill(ds, tmpBASMIG2);
-                }
-                catch (SqlException ex)
-                {
-                    LogHelper.Debug(this.ToString(), ex.Message);
-                }
-                return ds.Tables[0];
-            }
-        }
-
-        private bool CheckPort(string host, int port)
-        {
-            int vanishingSeconds = 3;
-            string _vanishingSeconds = ConfigurationManager.AppSettings["AsyncSeconds"];
-            if (!string.IsNullOrEmpty(_vanishingSeconds))
-                vanishingSeconds = int.Parse(_vanishingSeconds);
-            bool isOpen = false;
-            try
-            {
-                using (var client = new TcpClient())
-                {
-                    var result = client.BeginConnect(host, port, null, null);
-                    var success = result.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(vanishingSeconds)); // 绛夊緟5绉�
-                    if (success)
-                    {
-                        isOpen = true;
-                    }
-                }
-            }
-            catch (Exception ex)
-            {
-                LogHelper.Debug(this.ToString(), "CheckPort:" + ex.Message);
-            }
-            return isOpen;
-        }
-        #endregion
-
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3