FrmHttRunTimeRpt.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Forms;
  5. using Core.Mes.Client.Comm.Control;
  6. using Core.Mes.Client.Comm.Format;
  7. using Core.Mes.Client.Comm.Tool;
  8. using Core.StlMes.Client.Mcp.Treatment.Entity;
  9. using CoreFS.CA06;
  10. using Infragistics.Win.UltraWinEditors;
  11. namespace Core.StlMes.Client.Mcp.Treatment.Report
  12. {
  13. public partial class FrmHttRunTimeRpt : FrmBase
  14. {
  15. public FrmHttRunTimeRpt()
  16. {
  17. InitializeComponent();
  18. this.IsLoadUserView = true;
  19. }
  20. private string balMonth = "";
  21. private string[] plineCodes = null;
  22. private string[] uceFactorys = null;
  23. private string ProcessCode = "";
  24. private List<YdmHttInitialEntityPlus> CurrentlistEntity;
  25. protected override void OnLoad(EventArgs e)
  26. {
  27. base.OnLoad(e);
  28. ProcessCode = this.CustomInfo.ToString2();
  29. if (ProcessCode == "") ProcessCode = "F";
  30. plineCodes = comm.InitDropPlinePower(ProcessCode, cboPline, this.ValidDataPurviewIds, ob);
  31. uceFactorys = comm.InitDroProStation(ProcessCode, uceFactory , this.ValidDataPurviewIds, ob);
  32. if (plineCodes == null || plineCodes.Length <= 0)
  33. {
  34. MessageBox.Show("无数据权限!");
  35. this.Close();
  36. }
  37. if (uceFactorys == null || uceFactorys.Length <= 0)
  38. {
  39. MessageBox.Show("无数据权限!");
  40. this.Close();
  41. }
  42. if (ProcessCode != "G")
  43. {
  44. ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].Hidden = true;
  45. ultraGrid1.DisplayLayout.Bands[0].Groups["JG"].Hidden = true;
  46. ultraGrid1.DisplayLayout.Bands[0].Groups["S0"].Hidden = true;
  47. ultraGrid1.DisplayLayout.Bands[0].Groups["S1"].Hidden = true;
  48. ultraGrid1.DisplayLayout.Bands[0].Groups["S2"].Hidden = true;
  49. ultraGrid1.DisplayLayout.Bands[0].Groups["XH"].Hidden = true;
  50. chkType.Visible = false;
  51. uceType.Visible = false;
  52. }
  53. EntityHelper.ShowGridCaption<YdmHttInitialEntityPlus>(ultraGrid1.DisplayLayout.Bands[0]);
  54. comm.RefreshAndAutoSizeWithHeader(ultraGrid1);
  55. dtBathYear.Value = DateTime.Now;
  56. }
  57. public override void ToolBar_Click(object sender, string ToolbarKey)
  58. {
  59. switch (ToolbarKey)
  60. {
  61. case "Query":
  62. Query();
  63. break;
  64. case "Export":
  65. Export();
  66. break;
  67. case "insertTal":
  68. insertTal();
  69. break;
  70. case "cancelInsertTal":
  71. cancelinsertTal();
  72. break;
  73. case "Close":
  74. this.Close();
  75. break;
  76. }
  77. }
  78. private void insertTal()
  79. {
  80. var data = ydmHttInitialEntityPlusBindingSource.DataSource as List<YdmHttInitialEntityPlus>;
  81. data = data.Where(p => p.EndNum > 0).ToList();
  82. if (!data.Any())
  83. {
  84. MessageBox.Show("无期末,无需结转");
  85. return;
  86. }
  87. DateTime dt = DateTime.ParseExact( data[0].BalYearMonth, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);
  88. var ccp = new CoreClientParam();
  89. ccp.ServerName = "com.steering.mes.mcp.common.FrmHttRunTimeRpt";
  90. ccp.MethodName = "insertTal";
  91. ccp.ServerParams = new object[]
  92. {
  93. dt.AddMonths(1).ToString("yyyyMM"),
  94. dt.AddMonths(2).ToString("yyyyMM"),
  95. data.Select(JSONFormat.Format).ToList(),
  96. data.Select(p=>p.PlineCode).Distinct().ToArray()
  97. };
  98. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  99. if (ccp.ReturnCode != -1)
  100. {
  101. MessageUtil.ShowTips(ccp.ReturnInfo);
  102. if (ccp.ReturnInfo.Equals("结转成功!"))
  103. {
  104. Query();
  105. }
  106. }
  107. }
  108. private void cancelinsertTal()
  109. {
  110. var data = ydmHttInitialEntityPlusBindingSource.DataSource as List<YdmHttInitialEntityPlus>;
  111. data = data.Where(p => p.EndNum > 0).ToList();
  112. if (!data.Any())
  113. {
  114. MessageBox.Show("无数据,无法撤销结转");
  115. }
  116. DateTime dt = DateTime.ParseExact(data[0].BalYearMonth, "yyyyMM", System.Globalization.CultureInfo.CurrentCulture);
  117. var ccp = new CoreClientParam();
  118. ccp.ServerName = "com.steering.mes.mcp.common.FrmHttRunTimeRpt";
  119. ccp.MethodName = "cancelinsertTal";
  120. ccp.ServerParams = new object[]
  121. {
  122. dt.AddMonths(1).ToString("yyyyMM"),
  123. dt.AddMonths(2).ToString("yyyyMM"),
  124. data.Select(p=>p.PlineCode).Distinct().ToArray()
  125. };
  126. ccp = ExecuteNonQuery(ccp, CoreInvokeType.Internal);
  127. if (ccp.ReturnCode != -1)
  128. {
  129. MessageUtil.ShowTips(ccp.ReturnInfo);
  130. if (ccp.ReturnInfo.Equals("撤销成功!"))
  131. {
  132. Query();
  133. }
  134. }
  135. }
  136. private void Export()
  137. {
  138. string title = "";
  139. if (ucePlineCode.Checked && cboPline.CheckedItems.Count > 0)
  140. {
  141. title += cboPline.Text;
  142. }
  143. else if (chkFactory.Checked && uceFactory.SelectedIndex >= 0)
  144. {
  145. title += uceFactory.Text;
  146. }
  147. else
  148. {
  149. title += (ProcessCode == "F" ? "热处理" : ProcessCode=="E"?"镦拔扩": "加工线");
  150. }
  151. if (chkQc.Checked)
  152. {
  153. title += "期初";
  154. }
  155. else
  156. {
  157. title += "收发存一览表";
  158. }
  159. GridHelper.ulGridToExcel(ultraGrid1, title);
  160. }
  161. private void Query()
  162. {
  163. WaitingForm2 wf = new WaitingForm2("正在查询,请稍候....");
  164. try
  165. {
  166. this.Cursor = Cursors.WaitCursor;
  167. CurrentlistEntity =
  168. EntityHelper.GetData<YdmHttInitialEntityPlus>(
  169. ProcessCode.Equals("F")
  170. ? "com.steering.mes.mcp.common.FrmHttRunTimeRpt.doQueryHtt"
  171. :ProcessCode.Equals("G")?
  172. "com.steering.mes.mcp.common.FrmHttRunTimeRpt.doQueryMch"
  173. : "com.steering.mes.mcp.common.FrmHttRunTimeRpt.doQueryVrp",
  174. new object[]
  175. {
  176. dtBathYear.Value.ToString("yyyyMM"),
  177. dtBathYear.Value.AddMonths(1).ToString("yyyyMM"),
  178. ucePlineCode.Checked && cboPline.CheckedItems.Count > 0
  179. ? cboPline.CheckedItems.Select(p => p.DataValue.ToString()).ToArray()
  180. : plineCodes, //uceFactory
  181. chkFactory.Checked && uceFactory.CheckedItems.Count >= 0
  182. ? uceFactory.CheckedItems.Select(p => p.DataValue.ToString()).ToArray()
  183. : uceFactorys,
  184. chkType.Checked && uceType.SelectedIndex >= 0
  185. ? uceType.SelectedItem.DataValue.ToString()
  186. : "",
  187. uceJudgeStove.Checked?txtJudgeStove.Text:""
  188. }, ob);
  189. ShowData();
  190. }
  191. catch (Exception)
  192. {
  193. }
  194. finally
  195. {
  196. wf.Close();
  197. this.Cursor = Cursors.Default;
  198. }
  199. }
  200. private void ShowData()
  201. {
  202. if (CurrentlistEntity == null) return;
  203. List<YdmHttInitialEntityPlus> NewList;
  204. if (chkQc.Checked)
  205. {
  206. NewList = CurrentlistEntity.Where(p => p.ActCount > 0).ToList();
  207. foreach (var ultraGridGroup in ultraGrid1.DisplayLayout.Bands[0].Groups)
  208. {
  209. if (ProcessCode != "G" && (ultraGridGroup.Key == "JG" || ultraGridGroup.Key == "S0" || ultraGridGroup.Key == "S1" || ultraGridGroup.Key == "S2" || ultraGridGroup.Key == "XH") ) continue;
  210. if (ultraGridGroup.Key != "QC") ultraGridGroup.Hidden = true;
  211. }
  212. }
  213. else
  214. {
  215. NewList = CurrentlistEntity;
  216. foreach (var ultraGridGroup in ultraGrid1.DisplayLayout.Bands[0].Groups)
  217. {
  218. if (ProcessCode != "G" && (ultraGridGroup.Key == "JG" || ultraGridGroup.Key == "S0" || ultraGridGroup.Key == "S1" || ultraGridGroup.Key == "S2" || ultraGridGroup.Key == "XH")) continue;
  219. if (ultraGridGroup.Key != "QC") ultraGridGroup.Hidden = false;
  220. }
  221. }
  222. if (checkShowJudge.Checked)
  223. {
  224. if (ProcessCode == "F")
  225. {
  226. ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].Hidden = true;
  227. }
  228. else
  229. {
  230. ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].Hidden = false;
  231. }
  232. ultraGrid1.DisplayLayout.Bands[0].Columns["WatingDecisionMemo"].Hidden = false;
  233. ultraGrid1.DisplayLayout.Bands[0].Columns["JudgeStoveNo"].Hidden = false;
  234. ultraGrid1.DisplayLayout.Bands[0].Columns["ProOrderNo"].Hidden = false;
  235. //ultraGrid1.DisplayLayout.Bands[0].Groups["zlGroup"].Hidden = false;
  236. }
  237. else if (ProcessCode == "E")
  238. {
  239. ultraGrid1.DisplayLayout.Bands[0].Groups["销售合计"].Hidden = true;
  240. ultraGrid1.DisplayLayout.Bands[0].Groups["差值合计"].Hidden = true;
  241. }
  242. else
  243. {
  244. ultraGrid1.DisplayLayout.Bands[0].Columns["BatchNo"].Hidden = true;
  245. ultraGrid1.DisplayLayout.Bands[0].Columns["WatingDecisionMemo"].Hidden = true;
  246. ultraGrid1.DisplayLayout.Bands[0].Columns["JudgeStoveNo"].Hidden = true;
  247. ultraGrid1.DisplayLayout.Bands[0].Columns["ProOrderNo"].Hidden = true;
  248. // ultraGrid1.DisplayLayout.Bands[0].Groups["zlGroup"].Hidden = true;
  249. NewList = NewList.GroupBy(p => new
  250. {
  251. p.BalYearMonth,
  252. p.Dimater,
  253. p.Height,
  254. p.Gradecode,
  255. p.Gradename,
  256. p.Produccode,
  257. p.Producname,
  258. p.Steelcode,
  259. p.Steelname,
  260. p.ModelCode,
  261. p.ModelDesc,
  262. p.PlineCode,
  263. p.PlineName
  264. }
  265. ).Select(p => new YdmHttInitialEntityPlus()
  266. {
  267. BalYearMonth = p.Key.BalYearMonth,
  268. Dimater = p.Key.Dimater,
  269. Height = p.Key.Height,
  270. Gradecode = p.Key.Gradecode,
  271. Gradename = p.Key.Gradename,
  272. Produccode = p.Key.Produccode,
  273. Producname = p.Key.Producname,
  274. Steelcode = p.Key.Steelcode,
  275. Steelname = p.Key.Steelname,
  276. ModelCode = p.Key.ModelCode,
  277. ModelDesc = p.Key.ModelDesc,
  278. PlineCode = p.Key.PlineCode,
  279. PlineName = p.Key.PlineName,
  280. SourceNum0 = p.Sum(q => q.SourceNum0??0),
  281. SourceNum1 = p.Sum(q => q.SourceNum1 ?? 0),
  282. SourceNum2 = p.Sum(q => q.SourceNum2 ?? 0),
  283. SourceNumTotal = p.Sum(q => q.SourceNumTotal ?? 0),
  284. SourceNumTotal2 = p.Sum(q => q.SourceNumTotal2 ?? 0),
  285. SourceWt0 = p.Sum(q => q.SourceWt0 ?? 0),
  286. SourceWt1 = p.Sum(q => q.SourceWt1 ?? 0),
  287. SourceWt2 = p.Sum(q => q.SourceWt2 ?? 0),
  288. SourceWtTotal = p.Sum(q => q.SourceWtTotal ?? 0),
  289. SourceWtTotal2 = p.Sum(q => q.SourceWtTotal2 ?? 0),
  290. FailNum = p.Sum(q => q.FailNum ?? 0),
  291. FailWt = p.Sum(q => q.FailWt ?? 0),
  292. GroupNum = p.Sum(q => q.GroupNum ?? 0),
  293. GroupWt = p.Sum(q => q.GroupWt ?? 0),
  294. CouplingNum = p.Sum(q => q.CouplingNum ?? 0),
  295. CouplingWt = p.Sum(q => q.CouplingWt ?? 0),
  296. JudgeNum = p.Sum(q => q.JudgeNum ?? 0),
  297. JudgeWt = p.Sum(q => q.JudgeWt ?? 0),
  298. EndNum = p.Sum(q => q.EndNum ?? 0),
  299. EndWt = p.Sum(q => q.EndWt ?? 0),
  300. ActCount = p.Sum(q => q.ActCount ?? 0),
  301. ActWeight = p.Sum(q => q.ActWeight ?? 0),
  302. XsActCount = p.Sum(q => q.XsActCount ?? 0),
  303. XsActWeight = p.Sum(q => q.XsActWeight ?? 0),
  304. CzNum = p.Sum(q => q.CzNum ?? 0),
  305. CzWeight = p.Sum(q => q.CzWeight ?? 0),
  306. }
  307. ).ToList();
  308. }
  309. ydmHttInitialEntityPlusBindingSource.DataSource = NewList;
  310. comm.RefreshAndAutoSizeWithHeader(ultraGrid1, new string[] { "WatingDecisionMemo" });
  311. }
  312. private void checkShowJudge_CheckedChanged(object sender, EventArgs e)
  313. {
  314. ShowData();
  315. }
  316. private void ultraGrid1_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs e)
  317. {
  318. /* YdmHttInitialEntityPlus entity = e.Row.ListObject as YdmHttInitialEntityPlus;
  319. if (entity.SourceNumTotal + entity.ActCount != entity.FailNum + entity.GroupNum + entity.EndNum + entity.JudgeNum)
  320. {
  321. e.Row.Appearance.BackColor = Color.Red;
  322. }*/
  323. }
  324. }
  325. }