From 2ea047bd801dd9c0f5ed693be452ee67aa8b5ff3 Mon Sep 17 00:00:00 2001 From: 啊鑫 <t2856754968@163.com> Date: 星期一, 11 十一月 2024 19:35:17 +0800 Subject: [PATCH] 质量审核上的五个按钮 --- DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs | 424 +++++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 361 insertions(+), 63 deletions(-) diff --git a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs index f3ede46..bc7044e 100644 --- a/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs +++ b/DevApp/Gs.DevApp/DevFrm/QC/Frm_MesQaItemsDetect01.cs @@ -1,8 +1,7 @@ -using DevExpress.XtraGrid.Views.Grid; -using DevExpress.XtraGrid.Views.Grid.ViewInfo; using Gs.DevApp.Entity; using Gs.DevApp.ToolBox; using Gs.DevApp.UserControl; +using MES.Service.Modes; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using System; @@ -10,9 +9,7 @@ using System.Configuration; using System.Data; using System.Drawing; -using System.IO; -using System.Net.Http; -using System.Threading.Tasks; +using System.Net; using System.Windows.Forms; namespace Gs.DevApp.DevFrm @@ -31,7 +28,10 @@ this.toolBarMenu1.btnDelClick += ToolBarMenu1_btnDelClick1; this.toolBarMenu1.btnEscClick += ToolBarMenu1_btnEscClick; this.toolBarMenu1.btnQueryClick += ToolBarMenu1_btnQueryClick; + toolBarMenu1.btnLogClick += ToolBarMenu1_btnLogClick; + toolBarMenu1.btnJianYanClick += ToolBarMenu1_btnJianYanClick; gcMain.MouseDoubleClick += GcMain_MouseDoubleClick; + gcMx1.MouseClick += GcMx1_MouseClick; getPageList(1, UtilityHelper.GetPageSize()); pageBar1.PagerEvent += PageBar1_PagerEvent; gridView1.CustomDrawRowIndicator += (s, e) => @@ -48,11 +48,171 @@ Rectangle r = new Rectangle(gridView1.GridControl.Width / 2 - 100, e.Bounds.Top + 45, e.Bounds.Right - 5, e.Bounds.Height - 5); e.Graphics.DrawString(str, f, Brushes.Gray, r); }; - - btnUpSelect.Click += BtnUpSelect_Click; - btnUp.Click += BtnUp_Click; + gvMx2.OptionsFind.ShowSearchNavButtons = false; + gvMx2.OptionsView.ShowGroupPanel = false; + gvMx3.OptionsFind.ShowSearchNavButtons = false; + gvMx3.OptionsView.ShowGroupPanel = false; + txt_itemId.KeyFile = "id"; + txt_suppId.KeyFile = "id"; + txt_itemId.EditChanged += (s, e) => + { + txt_itemModel.Text = this.txt_itemId.GetModel(); + txt_itemNo.Text = this.txt_itemId.GetCode(); + }; + txtJianYan.KeyDown += TxtJianYan_KeyDown; + this.btnLoad.Click += BtnLoad_Click; + ucUpFile1.UpChanged += UcUpFile1_UpChanged; + xtraTabControl2.SelectedPageChanged += XtraTabControl2_SelectedPageChanged; } - + + private void GcMx1_MouseClick(object sender, MouseEventArgs e) + { + string rowGuid = Gs.DevApp.ToolBox.UtilityHelper.GetCurrentDoubleRow(gvMx1, e, "guid"); + if (string.IsNullOrEmpty(rowGuid)) + return; + getList12(rowGuid); + } + + /// <summary> + /// 閲嶆柊鍔犺浇妫�楠� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void BtnLoad_Click(object sender, EventArgs e) + { + if (!MsgHelper.AskQuestion("纭畾閲嶆柊鍔犺浇妫�楠岄」鐩悧锛岃鎿嶄綔灏嗕細娓呯┖涔嬪墠鐨勬楠岃褰曪紵")) + return; + string strGuid = lbGuid.Text.Trim(); + if (string.IsNullOrEmpty(strGuid)) + { + ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); + return; + } + var _obj = new + { + guid = strGuid, + }; + try + { + string strJson = UtilityHelper.HttpPost("", _webServiceName + "ReloadModel5", JsonConvert.SerializeObject(_obj)); + ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); + Gs.DevApp.ToolBox.MsgHelper.ShowInformation(_rtn.rtnMsg); + if (_rtn.rtnCode > 0) + { + dynamic dy = _rtn.rtnData; + lbGuid.Text = strGuid; + JObject _job = JObject.Parse(strJson); + JArray array = new JArray(); + foreach (var a in _job["rtnData"]["list5"]) + { + array.Add(a); + } + DataTable dt = JsonConvert.DeserializeObject<DataTable>(array.ToString()); + if (dt.Rows.Count > 0) + { + gcMx1.BindingContext = new BindingContext(); + gcMx1.DataSource = dt; + gcMx1.ForceInitialize(); + getList12(dt.Rows[0]["guid"].ToString()); + } + else + { + Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); + } + } + } + catch (Exception ex) + { + ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + /// <summary> + /// 杈撳叆妫�楠屼簨浠� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void TxtJianYan_KeyDown(object sender, KeyEventArgs e) + { + int intHandle = this.gvMx1.FocusedRowHandle; + if (intHandle < 0) + { + ToolBox.MsgHelper.Warning("鎻愮ず锛氳閫夋嫨妫�楠岄」鐩紒"); + return; + } + if (e.KeyCode == Keys.Enter) + { + string guid5 = this.gvMx1.GetDataRow(intHandle)["guid"].ToString(); + string _strCmd = txtJianYan.Text.Trim().ToUpper(); + string _strOK = "OK"; + string _strNG = "NG"; + if (!(_strCmd.StartsWith(_strOK) || _strCmd.StartsWith(_strNG))) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氳姝g‘浣跨敤OK 鎴� NG 鍛戒护!"); + return; + } + if (!_strCmd.Contains("-")) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氱己灏� 涓敾绾�!"); + return; + } + string[] _ary = _strCmd.Split('-'); + if (_ary.Length != 2) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氾細璇锋纭娇鐢∣K 鎴� NG 鍛戒护!"); + return; + } + string _str1 = _ary[0]; + if (!(_str1 == _strOK || _str1 == _strNG)) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氳姝g‘浣跨敤OK 鎴� NG 鍛戒护!"); + return; + } + string _str2 = _ary[1]; + int n; + if (int.TryParse(_str2, out n)) + { + } + else + { + Gs.DevApp.ToolBox.MsgHelper.ShowError("鍛戒护杈撳叆閿欒锛氳姝g‘浣跨敤OK 鎴� NG 鍛戒护!"); + return; + } + for (int i = 0; i < gvMx2.DataRowCount; i++) + { + gvMx2.SetRowCellValue(i, "fcheckResu", _str1); + gvMx2.SetRowCellValue(i, "fstand", _str1); + } + List<MesQaItemsDetectDetail12> lst = new List<MesQaItemsDetectDetail12>(); + for (var i = 0; i < gvMx2.DataRowCount; i++) + { + var row = gvMx2.GetDataRow(i); + if (row != null) + lst.Add(new MesQaItemsDetectDetail12() + { + ParentGuid = UtilityHelper.ToGuid(guid5), + Guid = UtilityHelper.ToGuid(row["guid"].ToString()), + FcheckResu = row["fcheckResu"].ToString(), + GrandpaGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), + }); + } + var _obj = lst; + try + { + var strJson = UtilityHelper.HttpPost("", + _webServiceName + "EdtModel12", + JsonConvert.SerializeObject(_obj)); + var _rtn = UtilityHelper.ReturnToDynamic(strJson); + MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + if (_rtn.rtnCode > 0) + { + } + } + catch (Exception ex) + { + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + } /// <summary> /// 鍙屽嚮浜嬩欢 @@ -95,6 +255,33 @@ _filterList = e.FilterList; getPageList(1, pageBar1.RowsCount); } + /// <summary> + /// 鏃ュ織浜嬩欢 + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + private void ToolBarMenu1_btnLogClick(object sender, EventArgs e) + { + toolBarMenu1.guidKey = ""; + string rowGuid, rowName; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, + lbGuid, txt_releaseNo, gridView1); + toolBarMenu1.guidKey = rowGuid; + } + /// <summary> + ///妫�楠屼簨浠� + /// </summary> + /// <param name="sender"></param> + /// <param name="e"></param> + /// <exception cref="NotImplementedException"></exception> + private void ToolBarMenu1_btnJianYanClick(object sender, EventArgs e) + { + toolBarMenu1.guidKey = ""; + string rowGuid, rowName; + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, + lbGuid, txt_releaseNo, gridView1); + toolBarMenu1.guidKey = rowGuid; + } /// <summary> /// 鍙栨秷浜嬩欢 @@ -114,7 +301,7 @@ private void ToolBarMenu1_btnDelClick1(object sender, EventArgs e) { string rowGuid = "", rowName = ""; - // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1); + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1); if (string.IsNullOrEmpty(rowGuid)) { ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); @@ -149,8 +336,10 @@ /// <param name="e"></param> private void ToolBarMenu1_btnLoadClick(object sender, EventArgs e) { - UtilityHelper.JumpToTab(xtraTabControl1, 0); - getPageList(1, UtilityHelper.GetPageSize()); + if (xtraTabControl1.SelectedTabPageIndex == 1) + getModel(lbGuid.Text.Trim(), false, 999); + else + getPageList(1, UtilityHelper.GetPageSize()); } /// <summary> /// 淇敼浜嬩欢 @@ -160,7 +349,7 @@ private void ToolBarMenu1_btnEdtClick(object sender, EventArgs e) { string rowGuid = "", rowName = ""; - // (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_billNo, gridView1); + (rowGuid, rowName) = UtilityHelper.GetCurrentRow(xtraTabControl1, lbGuid, txt_releaseNo, gridView1); if (string.IsNullOrEmpty(rowGuid)) { ToolBox.MsgHelper.Warning("璇峰厛閫夋嫨浣犺鎿嶄綔鐨勮锛�"); @@ -179,6 +368,7 @@ lbGuid.Text = ""; List<DevExpress.XtraGrid.Views.Grid.GridView> gridViews = new List<DevExpress.XtraGrid.Views.Grid.GridView>(); gridViews.Add(gvMx1); + gridViews.Add(gvMx2); UtilityHelper.CleanValueByControl(this.panel1.Controls, true, gridViews); Gs.DevApp.ToolBox.UtilityHelper.SetDefaultTable(gcMx1, gvMx1); } @@ -190,15 +380,23 @@ private void ToolBarMenu1_btnSaveClick(object sender, EventArgs e) { toolBarMenu1.isSetBtn = false; - //if (string.IsNullOrEmpty(txt_account.Text.Trim())) + if (string.IsNullOrEmpty(txt_fngDesc.Text.Trim())) { - Gs.DevApp.ToolBox.MsgHelper.Warning("鐧诲綍璐﹀彿涓嶈兘涓虹┖锛�"); - // txt_account.Focus(); + Gs.DevApp.ToolBox.MsgHelper.Warning("涓嶈壇鎻忚堪涓嶈兘涓虹┖锛�"); + txt_fngDesc.Focus(); + return; + } + if (string.IsNullOrEmpty(txt_lotNo1.Text.Trim())) + { + Gs.DevApp.ToolBox.MsgHelper.Warning("澶囨敞鑳戒负绌猴紒"); + txt_fngDesc.Focus(); return; } var _obj = new { guid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //涓诲缓 + fngDesc = txt_fngDesc.Text.Trim(), + lotNo1 = txt_lotNo1.Text.Trim(), }; try { @@ -261,7 +459,7 @@ } _loading.Stop(); } - private void getModel(string strGuid, bool isEdit, int tabIdx) + private async void getModel(string strGuid, bool isEdit, int tabIdx) { if (string.IsNullOrEmpty(strGuid)) { @@ -269,13 +467,14 @@ return; } UtilityHelper.JumpToTab(xtraTabControl1, tabIdx); + UcLoading _loading = new UcLoading(); var _obj = new { guid = strGuid,//涓诲缓 }; try { - string strJson = UtilityHelper.HttpPost("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); + string strJson = await UtilityHelper.HttpPostAsync("", _webServiceName + "GetModel", JsonConvert.SerializeObject(_obj)); ReturnModel<dynamic> _rtn = ToolBox.UtilityHelper.ReturnToDynamic(strJson); if (_rtn.rtnCode > 0) { @@ -286,7 +485,7 @@ UtilityHelper.SetValueByObj(this.panel1.Controls, dy, isEdit, gvList); JObject _job = JObject.Parse(strJson); JArray array = new JArray(); - foreach (var a in _job["rtnData"]["list"]) + foreach (var a in _job["rtnData"]["list5"]) { array.Add(a); } @@ -296,6 +495,8 @@ gcMx1.BindingContext = new BindingContext(); gcMx1.DataSource = dt; gcMx1.ForceInitialize(); + ucUpFile1.parentGuid = lbGuid.Text.Trim(); + getList12(dt.Rows[0]["guid"].ToString()); } else { @@ -309,74 +510,171 @@ { ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); } + + _loading.Stop(); } - - #region 鏂囦欢涓婁紶 - /// <summary> - /// 閫夋嫨涓婁紶鏂囦欢 + /// 閫夐」鍗″垏鎹� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> - private void BtnUpSelect_Click(object sender, EventArgs e) + private void XtraTabControl2_SelectedPageChanged(object sender, DevExpress.XtraTab.TabPageChangedEventArgs e) { - var openFileDialog = new OpenFileDialog(); - // 璁剧疆鍒濆鐩綍 - openFileDialog.InitialDirectory = "c:\\"; - // 璁剧疆鏂囦欢杩囨护閫夐」锛屽锛�"鏂囨湰鏂囦欢 (*.txt)|*.txt|鎵�鏈夋枃浠� (*.*)|*.*" - openFileDialog.Filter = "鏂囨湰鏂囦欢 (*.txt)|*.txt|鎵�鏈夋枃浠� (*.*)|*.*"; - // 璁剧疆鏍囬 - openFileDialog.Title = "閫夋嫨鏂囦欢"; - // 鏄剧ず瀵硅瘽妗� - var result = openFileDialog.ShowDialog(); - // 纭鐢ㄦ埛娌℃湁鍙栨秷鎿嶄綔 - if (result == DialogResult.OK) + if (e.Page.Name == "xtraTabPage3") { - // 鑾峰彇閫変腑鐨勬枃浠惰矾寰� - var filePath = openFileDialog.FileName; - Console.WriteLine($"閫変腑鐨勬枃浠�: {filePath}"); - txtUpUrl.Text = filePath; + getFileList(); } } - /// <summary> - /// 纭畾涓婁紶 + /// 涓婁紶鍚庡埛鏂版枃浠跺垪琛� /// </summary> /// <param name="sender"></param> /// <param name="e"></param> - private async void BtnUp_Click(object sender, EventArgs e) + private void UcUpFile1_UpChanged(object sender, EventArgs e) { - var WebApiUrl = ConfigurationSettings.AppSettings.Get("WebApiUrl"); - var address = WebApiUrl + "Upload/UploadFile"; - var filePath = txtUpUrl.Text.Trim(); - var apiUrl = address; // 鏇挎崲涓轰綘鐨凙PI鍦板潃 - await UploadFileAsync(apiUrl, filePath); + getFileList(); } - - private async Task UploadFileAsync(string url, string filePath) + private void getFileList() { - UcLoading _loading = new UcLoading(); - using (var httpClient = new HttpClient()) - using (var form = new MultipartFormDataContent()) + System.Text.StringBuilder _sbSqlWhere = new System.Text.StringBuilder(); + _sbSqlWhere.Append(" and parent_Guid='" + lbGuid.Text.Trim() + "'"); + PageQueryModel pgq = new PageQueryModel(1, 100, "create_date", "asc", "", _sbSqlWhere.ToString()); + string json = JsonConvert.SerializeObject(pgq); + try { - httpClient.DefaultRequestHeaders.Add("token", - UtilityHelper.GetBasicAuthTicket()); - using (var fs = File.OpenRead(filePath)) - using (var streamContent = new StreamContent(fs)) + string strReturn = UtilityHelper.HttpPost("", "MesFile/GetListPage", json); + ReturnModel<PageListModel> dd = UtilityHelper.ReturnToTablePage(strReturn); + if (dd.rtnCode > 0) { - form.Add(streamContent, "file", Path.GetFileName(filePath)); - var response = await httpClient.PostAsync(url, form); - var responseString = - await response.Content.ReadAsStringAsync(); - MessageBox.Show(responseString); + DataTable dt = dd.rtnData.list; + gcMx3.BindingContext = new BindingContext(); + gcMx3.DataSource = dt; + gcMx3.ForceInitialize(); + } + else + { + ToolBox.MsgHelper.ShowError("鎻愮ず锛�" + dd.rtnMsg); } } - _loading.Close(); + catch (Exception ex) + { + ToolBox.MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + /// <summary> + /// 鏍规嵁妫�楠岄」鐩鍙栨娊鏍风粨鏋� + /// </summary> + /// <param name="guid5"></param> + private async void getList12(string guid5) + { + UcLoading _loading = new UcLoading(); + var _obj = new + { + parentGuid = UtilityHelper.ToGuid(lbGuid.Text.Trim()), //涓诲缓 + guid = UtilityHelper.ToGuid(guid5), //涓诲缓 + }; + try + { + var strReturn = await UtilityHelper.HttpPostAsync("", _webServiceName + "GetModel12", JsonConvert.SerializeObject(_obj)); + var dd = UtilityHelper.ReturnToList(strReturn); + var dt = dd.rtnData; + gcMx2.BindingContext = new BindingContext(); + gcMx2.DataSource = dt; + gcMx2.ForceInitialize(); + } + catch (Exception ex) + { + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + _loading.Stop(); } - #endregion + private void repositoryItemButtonEdit1_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) + { + var rowhandle = gvMx3.FocusedRowHandle; + if (rowhandle < 0) + return; + if (e.Button.Index == 0) + { + var dr = gvMx3.GetDataRow(rowhandle); + var mxGuid = dr["guid"].ToString(); + if (!MsgHelper.AskQuestion("浣犻�夋嫨浜�1鏉℃暟鎹紝纭畾鍒犻櫎鍚楋紵")) + return; + var strJson = ""; + var lst = new List<string>(); + lst.Add(mxGuid); + try + { + strJson = UtilityHelper.HttpPost("", "MesFile/DeleteModel", + JsonConvert.SerializeObject(lst)); + var _rtn = UtilityHelper.ReturnToDynamic(strJson); + if (_rtn.rtnCode > 0) gvMx3.DeleteRow(rowhandle); + MsgHelper.Warning("鎻愮ず锛�" + _rtn.rtnMsg); + } + catch (Exception ex) + { + MsgHelper.Warning("鎻愮ず锛�" + ex.Message); + } + } + } + private void repositoryItemButtonEdit2_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) + { + var rowhandle = gvMx3.FocusedRowHandle; + if (rowhandle < 0) + return; + if (e.Button.Index == 0) + { + try + { + var dr = gvMx3.GetDataRow(rowhandle); + var urlPath = dr["urlPath"].ToString(); + Gs.DevApp.UserControl.ShowFile frm = new ShowFile(urlPath); + frm.ShowDialog(); + } + catch (Exception ex) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message); + } + + } + } + + private void repositoryItemButtonEdit3_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e) + { + var rowhandle = gvMx3.FocusedRowHandle; + if (rowhandle < 0) + return; + if (e.Button.Index == 0) + { + try + { + var dr = gvMx3.GetDataRow(rowhandle); + var urlPath = dr["urlPath"].ToString(); + using (FolderBrowserDialog folderBrowserDialog = new FolderBrowserDialog()) + { + folderBrowserDialog.Description = "閫夋嫨瀵煎嚭鏂囦欢鐨勪繚瀛樿矾寰�"; + DialogResult dialogResult = folderBrowserDialog.ShowDialog(); + if (dialogResult == DialogResult.OK) + { + string _folder = folderBrowserDialog.SelectedPath; + string _folderName = _folder + "\\" + urlPath; + string _url = ConfigurationManager.AppSettings["WebApiUrl"].ToString() + "upload/" + urlPath; + using (WebClient client = new WebClient()) + { + client.DownloadFile(_url, _folderName); + } + ToolBox.MsgHelper.ShowInformation("涓嬭浇鎴愬姛锛�"); + } + } + } + catch (Exception ex) + { + Gs.DevApp.ToolBox.MsgHelper.ShowError(ex.Message); + } + } + } } } \ No newline at end of file -- Gitblit v1.9.3