FrmFinalTreatmentG.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Windows.Forms;
  9. using Core.Mes.Client.Comm.Format;
  10. using Core.Mes.Client.Comm.Tool;
  11. using Core.StlMes.Client.Mcp.Control;
  12. using Core.StlMes.Client.Mcp.Control.Common;
  13. using Core.StlMes.Client.Mcp.Control.Entity;
  14. using Core.StlMes.Client.Mcp.Control.Machining;
  15. using CoreFS.CA06;
  16. using Infragistics.Win;
  17. using Infragistics.Win.UltraWinGrid;
  18. namespace Core.StlMes.Client.Mcp.Mch
  19. {
  20. public partial class FrmFinalTreatmentG : FrmBase
  21. {
  22. private string[] plineCodes;
  23. private string _plineCode;
  24. protected List<HttSignatureEntity> Names = new List<HttSignatureEntity>();
  25. public FrmFinalTreatmentG()
  26. {
  27. InitializeComponent();
  28. }
  29. protected override void OnLoad(EventArgs e)
  30. {
  31. base.OnLoad(e);
  32. EntityHelper.ShowGridCaption<MchFinalCheckTreatmentEntity>(ultraGrid1.DisplayLayout.Bands[0]);
  33. EntityHelper.ShowGridCaption<MchFinalCheckGTotal>(ultraGrid2.DisplayLayout.Bands[0]);
  34. commHelper.RefreshAndAutoSize(ultraGrid1);
  35. ultraGrid1.DisplayLayout.Bands[0].Override.HeaderClickAction = HeaderClickAction.Select;
  36. if (ob == null) return;
  37. plineCodes = comm.GetPlineCode(ValidDataPurviewIds, "G", this.CustomInfo, ob);
  38. //comm.InitDroCheckStation("G", uceFactory, ValidDataPurviewIds, ob);
  39. ultraGrid2.DisplayLayout.Override.AllowRowFiltering = DefaultableBoolean.False;
  40. ultraGrid2.DisplayLayout.Override.HeaderClickAction = HeaderClickAction.Default;
  41. if ((plineCodes.Length > 1) &&
  42. ((plineCodes[1] == "C038") || (plineCodes[1] == "C039") || (plineCodes[1] == "C049") ||
  43. (plineCodes[1] == "C050") ||
  44. (plineCodes[1] == "C051") || (plineCodes[1] == "C057")))
  45. {
  46. RegStartTime.Value = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd 20:00"));
  47. RegEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 19:59"));
  48. }
  49. else
  50. {
  51. RegStartTime.Value = DateTime.Parse(DateTime.Now.AddMonths(-1).ToString("yyyy-MM-dd 21:00"));
  52. RegEndTime.Value = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 20:59"));
  53. }
  54. cmbOrder.Text = this.UserInfo.GetUserOrder();
  55. cmbGroup.Text = this.UserInfo.GetUserGroup();
  56. }
  57. public override void ToolBar_Click(object sender, string ToolbarKey)
  58. {
  59. switch (ToolbarKey)
  60. {
  61. case "DoQuery":
  62. Query();
  63. break;
  64. case "DoAdd":
  65. DoAdd();
  66. break;
  67. case "DoDelete":
  68. DoDelete();
  69. break;
  70. case "Print":
  71. Print();
  72. break;
  73. case "DoClose":
  74. Close();
  75. break;
  76. }
  77. }
  78. private void Query()
  79. {
  80. var starts = "";
  81. var No = "";
  82. var judgeStoveNo = "";
  83. string[] plines = plineCodes;
  84. string startTim = "";
  85. string endTim = "";
  86. if (chkTim.Checked)
  87. {
  88. startTim = RegStartTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  89. endTim = RegEndTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
  90. }
  91. mchFinalCheckResultDEntityBindingSource.Clear();
  92. mchFinalCheckTreatmentEntityBindingSource.DataSource = EntityHelper.GetData<MchFinalCheckTreatmentEntity>(
  93. "com.steering.mes.mcp.Mch.FrmFinalCheck.QuerTreatment",
  94. new object[] {startTim,endTim, chbNo.Checked ? txtNo.Text : "",chkJudgeStove.Checked ? txtJudgeStove.Text : "",
  95. plines, ultraOptionSet2.Value.ToString2(), "" },
  96. ob);
  97. commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid1, new string[] { });
  98. }
  99. private void DoDelete()
  100. {
  101. if (ultraGrid1.ActiveRow == null) return;
  102. MchFinalCheckTreatmentEntity Entity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity;
  103. if (Entity == null) return;
  104. /* if (txtInfo.Text.Trim() == "")
  105. {
  106. MessageBox.Show("请输入反馈信息");
  107. return;
  108. }*/
  109. if (MessageUtil.ShowYesNoAndQuestion("是否确认撤销反馈?") == DialogResult.No)
  110. return;
  111. var ccp = new CoreClientParam();
  112. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmFinalCheck";
  113. ccp.MethodName = "DoCancelReply";
  114. ccp.ServerParams = new object[]
  115. {
  116. Entity.TreatmentNo,
  117. this.UserInfo.GetUserName()
  118. };
  119. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  120. if (ccp.ReturnCode != -1)
  121. {
  122. MessageUtil.ShowTips(ccp.ReturnInfo);
  123. if (ccp.ReturnInfo.Equals("撤销反馈成功!"))
  124. {
  125. Query();
  126. }
  127. }
  128. }
  129. private void DoAdd()
  130. {
  131. ultraGrid2.UpdateData();
  132. if (ultraGrid1.ActiveRow == null) return;
  133. MchFinalCheckTreatmentEntity Entity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity;
  134. List<MchFinalCheckGTotal> AllData =
  135. mchFinalCheckResultDEntityBindingSource.DataSource as List<MchFinalCheckGTotal>;
  136. if (Entity == null) return;
  137. if (!AllData.Any())
  138. {
  139. MessageBox.Show("数据异常,无不合管号");
  140. return;
  141. }
  142. var Data = AllData.Where(p => p.Check).ToList();
  143. if (!Data.Any())
  144. {
  145. MessageBox.Show("请勾选需要反馈的管号!");
  146. return;
  147. }
  148. if (txtInfo.Text.Trim() == "")
  149. {
  150. MessageBox.Show("请输入反馈信息");
  151. return;
  152. }
  153. bool NeedSplit = AllData.Count > Data.Count;
  154. if (NeedSplit)
  155. {
  156. if (MessageUtil.ShowYesNoAndQuestion("请确认只反馈" + Data.Count + "支管? 系统将拆分当前处置单,当前反馈的管并入新的处置单中") == DialogResult.No)
  157. return;
  158. }
  159. else
  160. {
  161. if (MessageUtil.ShowYesNoAndQuestion("是否确认反馈?") == DialogResult.No)
  162. return;
  163. }
  164. List<MchBugDEntity> ScrappedList =
  165. Data.Where(p =>p.Station!="2" && p.ReplayStation == "2").SelectMany(p => p.ScrapList).ToList();
  166. string failNum =ScrappedList==null || !ScrappedList.Any()?"0": ScrappedList.Sum(p => p.FailNum).ToString3();
  167. string failWt = ScrappedList == null || !ScrappedList.Any() ? "0" : ScrappedList.Sum(p => p.FailWt).ToString3();
  168. var ccp = new CoreClientParam();
  169. ccp.ServerName = "com.steering.mes.mcp.Mch.FrmFinalCheck";
  170. ccp.MethodName = "DoReply";
  171. ccp.ServerParams = new object[]
  172. {
  173. Entity.TreatmentNo,
  174. name.Text,
  175. txtInfo.Text,
  176. this.UserInfo.GetDeptid(),
  177. this.UserInfo.GetDepartment(),
  178. failNum,
  179. failWt,
  180. Data.Select(JSONFormat.Format).ToList(),
  181. ScrappedList.Select(JSONFormat.Format).ToList(),
  182. NeedSplit,
  183. cmbOrder.Value.ToString2(),
  184. cmbGroup.Value.ToString2()
  185. };
  186. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  187. if (ccp.ReturnCode != -1)
  188. {
  189. MessageUtil.ShowTips(ccp.ReturnInfo);
  190. if (ccp.ReturnInfo.Equals("反馈成功!"))
  191. {
  192. Query();
  193. }
  194. }
  195. }
  196. private void ultraGrid1_AfterRowActivate(object sender, EventArgs e)
  197. {
  198. if(ultraGrid1.ActiveRow==null) return;
  199. MchFinalCheckTreatmentEntity Entity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity;
  200. if(Entity==null) return;
  201. var data = EntityHelper.GetData<MchFinalCheckGTotal>(
  202. "com.steering.mes.mcp.Mch.FrmFinalCheck.getQueryUnPassDetail",
  203. new object[] { Entity.ResultNo, Entity.TreatmentNo },
  204. ob);
  205. data.ForEach(p => p.Check = true);
  206. mchFinalCheckResultDEntityBindingSource.DataSource = data;
  207. commHelper.RefreshAndAutoSizeExceptColumns(ultraGrid2, new string[] { });
  208. ultraGrid2.DisplayLayout.Bands[0].Columns["Check"].SetHeaderCheckedState(ultraGrid2.Rows, true);
  209. if (_plineCode != Entity.PlineCode)
  210. {
  211. Names = EntityHelper.GetData<HttSignatureEntity>(
  212. "com.steering.mes.mcp.heatTreatment.FrmHttCrackDetectResult.getHttSign",
  213. new object[] {Entity.PlineCode, "10"}, ob);
  214. name.DisplayMember = "UserName";
  215. name.ValueMember = "UserName";
  216. YdmBaseClass.SetComboItemHeight(name);
  217. _plineCode = Entity.PlineCode;
  218. name.DataSource = Names;
  219. }
  220. name.Text = this.UserInfo.GetUserName();
  221. txtInfo.Text = "";
  222. }
  223. protected void Print()
  224. {
  225. if (ultraGrid1.ActiveRow == null) return;
  226. MchFinalCheckTreatmentEntity MchFinalCheckTreatmentEntity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity;
  227. string strurl = "";
  228. strurl =
  229. "http://172.54.10.42:8080/webroot/decision/view/report?viewlet=RepMchNoticeOfQualityDisposal.cpt&__embed__=true" +
  230. "&TREATMENT_NO=" + MchFinalCheckTreatmentEntity.TreatmentNo;
  231. FrmRepExcel fBug = new FrmRepExcel(ob, strurl);
  232. fBug.AutoSize = true;
  233. fBug.MaximumSize = new Size(Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height);
  234. fBug.WindowState = FormWindowState.Maximized;
  235. fBug.Text = "处置单";
  236. fBug.Show();
  237. }
  238. private void uteUnpass_EditorButtonClick(object sender, Infragistics.Win.UltraWinEditors.EditorButtonEventArgs e)
  239. {
  240. if (ultraGrid1.ActiveRow == null) return;
  241. MchFinalCheckTreatmentEntity TreatEntity = ultraGrid1.ActiveRow.ListObject as MchFinalCheckTreatmentEntity;
  242. MchFinalCheckGTotal entity = ultraGrid2.ActiveRow.ListObject as MchFinalCheckGTotal;
  243. if (entity.Station == "2")
  244. {
  245. MessageBox.Show("已经被质检站判废,无法再录入原因");
  246. return;
  247. }
  248. var matfrm = new ReasonChooseNew(ob, "7036", true,entity.ScrapList );
  249. matfrm.ShowDialog();
  250. if (matfrm.DialogResult == DialogResult.OK)
  251. {
  252. entity.ScrapList = matfrm.FailData;
  253. entity.ScrapCode = entity.ScrapList == null || !entity.ScrapList.Any()
  254. ? ""
  255. : entity.ScrapList.Select(p => p.FailTypeCode).Aggregate((a, b) => (string.IsNullOrWhiteSpace(a) ? "" : (a + ",")) + b);
  256. entity.ScrapName = entity.ScrapList == null || !entity.ScrapList.Any()
  257. ? ""
  258. : entity.ScrapList.Select(p => p.FailTypeName).Aggregate((a, b) => (string.IsNullOrWhiteSpace(a) ? "" : (a + ",")) + b);
  259. entity.ScrapList.ForEach(p =>
  260. {
  261. p.MatNo = entity.MatNo;
  262. p.FailNum = 1;
  263. p.FailWt = TreatEntity.UnqualifiedWt;
  264. p.BatchNo = TreatEntity.BatchNo;
  265. p.HeatPlanNo = TreatEntity.HeatPlanNo;
  266. });
  267. entity.ReplayStation = entity.ScrapList!=null && entity.ScrapList.Any() ? "2" : "0";
  268. if (entity.ReplayStation == "1" || entity.ReplayStation == "2")
  269. {
  270. ultraGrid2.ActiveCell.Row.Cells["ReplayStation"].Appearance.BackColor = Color.Red;
  271. }
  272. else
  273. {
  274. ultraGrid2.ActiveCell.Row.Cells["ReplayStation"].Appearance.ResetBackColor();
  275. }
  276. ultraGrid2.PerformAction(UltraGridAction.ExitEditMode);
  277. mchFinalCheckResultDEntityBindingSource.ResetBindings(false);
  278. ultraGrid2.UpdateData();
  279. }
  280. }
  281. }
  282. }