FrmFinalTreatment.cs 13 KB

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