frmWcsMotBinStatus.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207
  1. using ComponentFactory.Krypton.Toolkit;
  2. using NXWMS.Client.Model.AppModels.Condition.Monitor;
  3. using NXWMS.Client.Model.AppModels.Result.Monitor;
  4. using NXWMS.Services;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.ComponentModel;
  8. using System.Data;
  9. using System.Drawing;
  10. using System.Linq;
  11. using System.Text;
  12. using System.Threading;
  13. using System.Threading.Tasks;
  14. using System.Windows.Forms;
  15. namespace NXWMS.Forms.Monitor
  16. {
  17. public partial class frmWcsMotBinStatus : KryptonForm
  18. {
  19. public frmWcsMotBinStatus()
  20. {
  21. InitializeComponent();
  22. }
  23. private void frmWcsMotBinStatus_Load(object sender, EventArgs e)
  24. {
  25. try
  26. {
  27. Thread th = new Thread(ShowBinMonitorMsg)
  28. {
  29. IsBackground = true
  30. };
  31. th.Start();
  32. }
  33. catch (Exception ex)
  34. {
  35. KryptonMessageBox.Show(ex.Message);
  36. }
  37. }
  38. private void pictureBox980_Paint(object sender, PaintEventArgs e)
  39. {
  40. Pen pp = new Pen(Color.FromArgb(83, 92, 89), 3);
  41. e.Graphics.DrawRectangle(pp, e.ClipRectangle.X, e.ClipRectangle.Y, e.ClipRectangle.X + e.ClipRectangle.Width - 1, e.ClipRectangle.Y + e.ClipRectangle.Height - 1);
  42. }
  43. private void pictureBox980_MouseHover(object sender, EventArgs e)
  44. {
  45. try
  46. {
  47. ToolTip ttp = new ToolTip
  48. {
  49. InitialDelay = 200,
  50. AutoPopDelay = 3000,
  51. ReshowDelay = 200,
  52. ShowAlways = true,
  53. IsBalloon = true
  54. };
  55. PictureBox pic = sender as PictureBox;
  56. int ptbIndex = Convert.ToInt32(pic.Name.Replace("pictureBox", ""));
  57. int maxColIndex = 49;
  58. int maxLayerIndex = 10;
  59. if (Convert.ToInt32(pic.Tag) == 2)
  60. {
  61. ptbIndex -= maxColIndex * maxLayerIndex;
  62. }
  63. int binLayerIndex = 0;
  64. int binColIndex = 0;
  65. switch (ptbIndex % maxLayerIndex)
  66. {
  67. case 0:
  68. binLayerIndex = maxLayerIndex;
  69. break;
  70. case 1:
  71. case 2:
  72. case 3:
  73. case 4:
  74. case 5:
  75. case 6:
  76. case 7:
  77. case 8:
  78. case 9:
  79. binLayerIndex = ptbIndex % maxLayerIndex;
  80. break;
  81. default:
  82. break;
  83. }
  84. binColIndex = (ptbIndex - binLayerIndex + maxLayerIndex) / maxLayerIndex;
  85. WcsMotBalanceMonitor binMd = binMonitorLst.FirstOrDefault(x => x.BIN_ROW == Convert.ToInt32(pic.Tag) && x.BIN_COLUMN == binColIndex && x.BIN_LAYER == binLayerIndex);
  86. if (binMd != null)
  87. {
  88. string tipShowMsg = $"库位号:【{binMd.BIN_CODE}】\r\n托盘号:【{binMd.PALLET_CODE}】\r\n任务号:【{binMd.TASK_NO}】\r\n指令号:【{binMd.CMD_NO}】\r\n库存状态:【{binMd.BALANCE_STATUS_NAME}】\r\n库位状态:【{binMd.USED_FLAG_NAME}】";
  89. ttp.SetToolTip(pic, tipShowMsg);
  90. }
  91. }
  92. catch (Exception ex)
  93. {
  94. KryptonMessageBox.Show(ex.Message);
  95. }
  96. }
  97. public List<WcsMotBalanceMonitor> binMonitorLst = new List<WcsMotBalanceMonitor>();
  98. private void ShowBinMonitorMsg()
  99. {
  100. while (true)
  101. {
  102. try
  103. {
  104. binMonitorLst = WcsMonitorService.wcsMotManageService.GetBinMonitorData(new WcsMotBalanceSearchMd
  105. {
  106. RegionMsg = "YCLK_Region"
  107. }).Data;
  108. if (binMonitorLst != null && binMonitorLst.Count > 0)
  109. {
  110. int maxLayer = binMonitorLst.Max(x => x.BIN_LAYER);
  111. int maxColumn = binMonitorLst.Max(x => x.BIN_COLUMN);
  112. foreach (WcsMotBalanceMonitor item in binMonitorLst)
  113. {
  114. if (item.BIN_ROW == 1)
  115. {
  116. int picNum = item.BIN_LAYER + (item.BIN_COLUMN - 1) * maxLayer;
  117. Invoke(new Action(() => {
  118. Control picControl = this.Controls.Find("pictureBox" + picNum, true)[0];
  119. if (picControl is PictureBox)
  120. {
  121. PictureBox ptb = picControl as PictureBox;
  122. if (item.USED_FLAG == 1)
  123. {
  124. if (item.BALANCE_STATUS == 0)
  125. {
  126. ptb.BackColor = Color.FromArgb(216, 211, 205);
  127. }
  128. else if (item.BALANCE_STATUS > 0 && item.BALANCE_STATUS < 55)
  129. {
  130. ptb.BackColor = Color.Yellow;
  131. }
  132. else if (item.BALANCE_STATUS == 55)
  133. {
  134. ptb.BackColor = Color.Lime;
  135. }
  136. else if (item.BALANCE_STATUS > 55 && item.BALANCE_STATUS < 99)
  137. {
  138. ptb.BackColor = Color.FromArgb(80, 160, 255);
  139. }
  140. else
  141. {
  142. ptb.BackColor = Color.FromArgb(216, 211, 205);
  143. }
  144. }
  145. else
  146. {
  147. ptb.BackColor = Color.Red;
  148. }
  149. }
  150. }));
  151. }
  152. else
  153. {
  154. int picNum = item.BIN_LAYER + (item.BIN_COLUMN - 1) * maxLayer + maxLayer * maxColumn;
  155. Invoke(new Action(() => {
  156. Control picControl = this.Controls.Find("pictureBox" + picNum, true)[0];
  157. if (picControl is PictureBox)
  158. {
  159. PictureBox ptb = picControl as PictureBox;
  160. if (item.USED_FLAG == 1)
  161. {
  162. if (item.BALANCE_STATUS == 0)
  163. {
  164. ptb.BackColor = Color.FromArgb(216, 211, 205);
  165. }
  166. else if (item.BALANCE_STATUS > 0 && item.BALANCE_STATUS < 55)
  167. {
  168. ptb.BackColor = Color.Yellow;
  169. }
  170. else if (item.BALANCE_STATUS == 55)
  171. {
  172. ptb.BackColor = Color.Lime;
  173. }
  174. else if (item.BALANCE_STATUS > 55 && item.BALANCE_STATUS < 99)
  175. {
  176. ptb.BackColor = Color.FromArgb(80, 160, 255);
  177. }
  178. else
  179. {
  180. ptb.BackColor = Color.FromArgb(216, 211, 205);
  181. }
  182. }
  183. else
  184. {
  185. ptb.BackColor = Color.Red;
  186. }
  187. }
  188. }));
  189. }
  190. }
  191. }
  192. }
  193. catch
  194. {
  195. }
  196. Thread.Sleep(500);
  197. }
  198. }
  199. }
  200. }