From 70332ced875cd4afaad7c31dc83f863eb1bd1a9f Mon Sep 17 00:00:00 2001
From: lu <123456>
Date: 星期三, 22 十月 2025 09:58:49 +0800
Subject: [PATCH] 排产工单搜索

---
 DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs |  162 ++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 122 insertions(+), 40 deletions(-)

diff --git a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs
index 696de4b..a0b748a 100644
--- a/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs
+++ b/DevApp/Gs.DevApp/DevFrm/Work/Frm_Work01.cs
@@ -1,10 +1,8 @@
-锘縰sing DevExpress.Office.Utils;
-using DevExpress.XtraEditors;
+锘縰sing DevExpress.XtraEditors;
 using DevExpress.XtraGrid.Columns;
 using DevExpress.XtraLayout.Utils;
 using Gs.DevApp.Entity;
 using Gs.DevApp.ToolBox;
-using Gs.DevApp.UserControl;
 using Newtonsoft.Json;
 using Newtonsoft.Json.Linq;
 using NModbus;
@@ -26,7 +24,7 @@
         string isWater = "0";
         string hostName = "192.168.60.51";
         int hostNamePoint = 502;
-        string strConn = "Data Source=192.168.1.146;Initial Catalog=GS_MES;User ID=mesUser;Password =qixi1qaz@WSXmes";
+        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 = "";//鐢垫鍙栧�艰矾寰�
@@ -43,12 +41,61 @@
         /// <param name="_fGx">宸ュ簭</param>
         /// <param name="_fBc">鐝</param>
         /// <param name="_strinOther">鐩墠涓虹數妫�璺緞</param>
-        public Frm_Work01(string _fGx, string _fBc, string _strinOther)
+        /// <param name="chkWater">鏄惁姘存</param>
+        public Frm_Work01(string _fGx, string _fBc, string _strinOther, int chkWater = 0)
         {
             InitializeComponent();
+            System.Drawing.Font ft1 = new System.Drawing.Font("瀹嬩綋", 35F);//澶ф寜閽�
+            System.Drawing.Font ft2 = new System.Drawing.Font("瀹嬩綋", 25F);//涓寜閽�
+            System.Drawing.Font ft3 = new System.Drawing.Font("瀹嬩綋", 15F);//grid
+            System.Drawing.Font ft4 = new System.Drawing.Font("瀹嬩綋", 12F);//head
+            System.Drawing.Font ft5 = new System.Drawing.Font("瀹嬩綋", 12F);//琛ㄥご
+            //璁剧疆瀛椾綋澶у皬 
+            this.btnGood.Appearance.Font = ft1;
+            this.btnBad.Appearance.Font = ft1;
+            this.simpleButton3.Appearance.Font = ft2;
+            this.simpleButton7.Appearance.Font = ft2;
+            this.simpleButton5.Appearance.Font = ft2;
+            this.simpleButton4.Appearance.Font = ft2;
+            this.simpleButton6.Appearance.Font = ft2;
+            this.lbSum1.Appearance.Font = ft2;
+            this.lbSum2.Appearance.Font = ft2;
+            this.lbSum3.Appearance.Font = ft2;
+            this.lbSum4.Appearance.Font = ft2;
+            this.gvMx1.Appearance.Row.Font = ft3;
+            this.gvMx2.Appearance.Row.Font = ft3;
+            this.layoutControlItem1.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem2.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem3.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem4.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem5.AppearanceItemCaption.Font = ft4;
+            this.layShuiJian.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem7.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem8.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem10.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem11.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem12.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem13.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem14.AppearanceItemCaption.Font = ft4;
+            this.layoutControlItem15.AppearanceItemCaption.Font = ft4;
+            this.txt_gdbh.Properties.Appearance.Font = ft5;
+            this.txt_itemNo.Properties.Appearance.Font = ft5;
+            this.txt_itemModel.Properties.Appearance.Font = ft5;
+            this.txt_gx.Properties.Appearance.Font = ft5;
+            this.txt_bc.Properties.Appearance.Font = ft5;
+            this.txt_itemName.Properties.Appearance.Font = ft5;
+            this.txt_yjDate.Properties.Appearance.Font = ft5;
+            this.txt_collectBy.Properties.Appearance.Font = ft5;
+            this.txt_sbNo.Properties.Appearance.Font = ft5;
+            this.txt_sjXt.Properties.Appearance.Font = ft5;
+            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 = ConfigurationManager.AppSettings["IsWater"];
+                string _vanishingSeconds = chkWater.ToString();
                 if (!string.IsNullOrEmpty(_vanishingSeconds))
                     isWater = _vanishingSeconds;
             }
@@ -69,6 +116,7 @@
             this.Text = "宸ュ簭閲囬泦銆�" + _fGx + " - " + _fBc + "銆�";
             label8.Text = _fGx + "鏁伴噺";
             addColumn();
+            //杩芥函鐮佹鍥炶溅浜嬩欢
             txt_barCode.KeyDown += (s, e) =>
             {
                 if (e.KeyCode == Keys.Enter)
@@ -82,6 +130,7 @@
                         addModel(goodTag);
                 }
             };
+            //宸ヤ綅鍥炶溅妗嗕簨浠�
             txt_gongWei.KeyDown += (s, e) =>
             {
                 if (e.KeyCode == Keys.Enter)
@@ -101,21 +150,51 @@
                     }
                 }
             };
+            //鑹搧鎸夐挳浜嬩欢
             btnGood.Click += (s, e) =>
             {
                 addModel(goodTag);
             };
+            //涓嶈壇鍝佹寜閽簨浠�
             btnBad.Click += (s, e) =>
             {
-                string _collectGuid = lbCollectGuid.Text.Trim();
+                int idx = tabMx.SelectedTabPageIndex;
+                if (idx > 0)
+                {
+                    Toast vm = new Toast(-1, "~宸插府浣犲垏鎹㈠埌銆愯壇鍝佹槑缁嗐��,璇烽噸鏂版搷浣渵");
+                    vm.Show();
+                    tabMx.SelectedTabPageIndex = 0;
+                    return;
+                }
+                string _collectGuid = "";
+                string _collCode = "";
+                var dr = gvMx1.GetFocusedDataRow();
+                if (dr == null || string.IsNullOrEmpty(dr["guid"].ToString()))
+                {
+
+                }
+                else
+                {
+                    _collectGuid = dr["guid"].ToString();
+                    _collCode = dr["barCode"].ToString();
+                }
                 if (_collectGuid.Length < 30)
                 {
                     Toast vm = new Toast(-1, "~璇峰厛閫夋嫨杩芥函鐮亊");
                     vm.Show();
                     return;
                 }
-                string _msg = "浣犲噯澶囧皢銆�" + txt_gdbh.Text + "銆戙��" + txt_currentBarCode.Text.Trim() + "銆戝彉鏇翠负涓嶈壇";
-                UcDictionarySelect frm = new UcDictionarySelect("宸ュ簭涓嶈壇鎻忚堪", " a.s_type='宸ュ簭涓嶈壇鎻忚堪' and pid<>'00000000-0000-0000-0000-000000000000'", _msg);
+                string _msg = "浣犲噯澶囧皢銆�" + _collCode + "銆戝彉鏇翠负涓嶈壇";
+                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:缁堟涓嶈壇鎻忚堪";
+                UcDictionarySelect frm = new UcDictionarySelect(_type, " a.s_type='" + _type + "' and pid<>'00000000-0000-0000-0000-000000000000'", _msg);
                 frm.UpdateParent += (ss, ee) =>
                 {
                     System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
@@ -133,22 +212,14 @@
                         vm.Show();
                     }
                     else
-                        addModel(badTag, _txt, lbCollectGuid.Text.Trim());
+                        addModel(badTag, _txt, _collectGuid);
                 };
                 frm.ShowDialog();
+                this.ActiveControl = this.txt_barCode;
+                txt_barCode.Focus();
             };
             this.ActiveControl = this.txt_barCode;
             txt_barCode.Focus();
-            gvMx1.FocusedRowChanged += (s, e) =>
-            {
-                if (e.FocusedRowHandle >= 0)
-                {
-                    DataRow row = gvMx1.GetDataRow(e.FocusedRowHandle);
-                    txt_gdbh.Text = row["gdbh"].ToString();
-                    txt_currentBarCode.Text = row["barCode"].ToString();
-                    lbCollectGuid.Text = row["guid"].ToString();
-                }
-            };
         }
 
         /// <summary>
@@ -157,6 +228,7 @@
         /// <param name="_barCode">鏉$爜</param>
         /// <param name="_checkResult">缁撴灉</param>
         /// <param name="_badDescription">涓嶈壇鎻忚堪</param>
+        /// <param name="_collectGuid">閲囬泦guid,濡傛灉鏄笉鑹紝闇�瑕乧ollectGuid</param>
         /// <returns></returns>
         private dynamic getObj(string _barCode, string _checkResult, string _badDescription = "", string _collectGuid = "")
         {
@@ -168,23 +240,25 @@
             _obj.gongWei = txt_gongWei.Text.Trim();//宸ヤ綅
             _obj.badDescription = _badDescription.Trim();//涓嶈壇鎻忚堪
             _obj.collectGuid = _collectGuid;
+            //涓嶈壇锛岀洿鎺ユ彁浜�
             if (!string.IsNullOrEmpty(_collectGuid))
             {
                 return _obj;
             }
+            //鎶曞叆锛岀洿鎺ユ彁浜�
             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 = "";
+                string JD = "";//鎺ュ湴
+                string JY = "";//缁濈紭
+                string JN = "";//浜よ��
+                string XL = "";//娉勬紡
+                string GV = ""; //GV鍔熺巼
                 string JDV = "";
                 string JYV = "";
                 string JNV = "";
@@ -195,15 +269,19 @@
                 {
                     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)  //鏌ユ壘鏌愪釜瀛楁涓庡��
+                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(" ", ", ");
@@ -246,18 +324,18 @@
                 string GWZT = "";//宸ヤ綅鐘舵��
                 string SJJGZ = "";//姘存鏌ョ粨鏋�1
                 (strCsl1, strSw1, SJJG, GWZT, SJJGZ) = getShuiJian();
-                _obj.t002 = strCsl1;
-                _obj.t003 = strSw1;
-                _obj.t004 = strCsl2;
-                _obj.t005 = strSw2;
-                _obj.t006 = strCsl3;
-                _obj.t007 = strSw3;
+                _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;
+                _obj.t012 = SJJGZ;//姘存缁撴灉浼间箮涓嶇敤
+                _obj.t013 = GWZT;//宸ヤ綅鐘舵�佷技涔庝笉鐢�
                 return _obj;
             }
             //缁堟
@@ -348,7 +426,11 @@
                     if (!string.IsNullOrEmpty(_msg))
                     {
                         // Toast vm = new Toast((goodTag == "鈭�" ? 1 : -1), _msg); 2025-08-20 淇敼鎻愮ず澶栬
-                        Toast vm = new Toast(1, _rtn.rtnMsg);
+                        Toast vm;
+                        if (_msg.EndsWith("."))
+                            vm = new Toast(-1, _rtn.rtnMsg);
+                        else
+                            vm = new Toast(1, _rtn.rtnMsg);
                         vm.Show();
                     }
                 }
@@ -419,25 +501,25 @@
                 {
                     ziduan = "t007",
                     wenben = "鎺ュ湴缁撴灉",
-                    visibleIndex = -1,
+                    visibleIndex = 1,
                 });
                 _lst.Add(new
                 {
                     ziduan = "t009",
                     wenben = "浜よ�愮粨鏋�",
-                    visibleIndex = -1,
+                    visibleIndex = 1,
                 });
                 _lst.Add(new
                 {
                     ziduan = "t010",
                     wenben = "娉勬紡缁撴灉",
-                    visibleIndex = -1,
+                    visibleIndex = 1,
                 });
                 _lst.Add(new
                 {
                     ziduan = "t011",
                     wenben = "鍔熺巼缁撴灉",
-                    visibleIndex = -1,
+                    visibleIndex = 1,
                 });
             }
             if (txt_gx.Text.Trim() == fGxShouJian)

--
Gitblit v1.9.3