FormCurrentTask.cs 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762
  1. using System;
  2. using System.Collections.Generic;
  3. using ProjectBase.Controls;
  4. using SIMDP.BLL;
  5. using ProjectBase.Data.Pager;
  6. using SIMDP.Model;
  7. using ProjectBase.Util;
  8. using ProjectBase.Data.BaseDAL;
  9. using ProjectBase.Data.Logs;
  10. using ProjectBase.Data.Redis;
  11. using StackExchange.Redis;
  12. using System.Windows.Forms;
  13. using System.Drawing;
  14. using System.Data;
  15. using SIMDP.View;
  16. using DevExpress.XtraGrid.Views.Grid;
  17. namespace SIMDP.Project
  18. {
  19. public partial class FormCurrentTask : BaseDock
  20. {
  21. #region 变量声明
  22. private RedisHelper redis = new RedisHelper(0);
  23. private bool bNeedVerify = true;
  24. public FormCurrentTask()
  25. {
  26. InitializeComponent();
  27. //当前任务功能 初始化
  28. BindData();
  29. SubScribeEnent();
  30. //条码录入功能 初始化
  31. InitLookUpCtrl();
  32. MainForm.eventUserIdle += new MainForm.delegateResetVertify(ResetVervity);//订阅权限超时事件
  33. SetHeadScannerlabel();
  34. SetFEMScannerlabel();
  35. lookUp_TaskState.EditValueChanged += new System.EventHandler(this.lookUp_TaskState_EditValueChanged);
  36. }
  37. private void InitLookUpCtrl()
  38. {
  39. Dictionary<string, string> linkType2 = new Dictionary<string, string>();
  40. linkType2.Add("1", "下载AS400数据");
  41. linkType2.Add("5", "调整扫码工位指针");
  42. linkType2.Add("6", "强制写入安装工位");
  43. lookUp_TaskState.Properties.DataSource = linkType2;
  44. lookUp_TaskState.Properties.ValueMember = "Key";
  45. lookUp_TaskState.Properties.DisplayMember = "Value";
  46. lookUp_TaskState.EditValue = "";
  47. SmProject.InitColorList();
  48. lookUp_Color.Properties.DataSource = SmProject.ColorList;
  49. lookUp_Color.Properties.ValueMember = "Value";
  50. lookUp_Color.Properties.DisplayMember = "Key";
  51. lookUp_Color.EditValue = "";
  52. }
  53. private void lookUp_TaskState_EditValueChanged(object sender, EventArgs e)
  54. {
  55. txt_VINInput.Text = "";
  56. txt_ModelInput.Text = "";
  57. lookUp_Color.Text = "";
  58. txt_VINInput.Enabled = false;
  59. txt_ModelInput.Enabled = false;
  60. lookUp_Color.Enabled = false;
  61. txt_VINInput.EditValueChanged -= txt_VINInput_EditValueChanged;
  62. if (lookUp_TaskState.EditValue.ToString() == "") return;
  63. if (bNeedVerify)
  64. {
  65. FormUserVerification form = new FormUserVerification();
  66. form.ShowDialog();
  67. if (form.DialogResult != DialogResult.OK)
  68. {
  69. lookUp_TaskState.EditValue = "";
  70. return;
  71. }
  72. else
  73. bNeedVerify = false;
  74. }
  75. //判断是什么模式,给什么输入框
  76. if (lookUp_TaskState.EditValue.ToString() == "1")
  77. {
  78. lookUp_Color.EditValue = "";
  79. txt_VINInput.Enabled = true;
  80. txt_VINInput.Focus();
  81. //this.txt_VINInput.EditValueChanged += new System.EventHandler(InputValueChanged);
  82. }
  83. else if (lookUp_TaskState.EditValue.ToString() == "5")
  84. {
  85. lookUp_Color.EditValue = "";
  86. txt_VINInput.Enabled = true;
  87. txt_VINInput.Focus();
  88. }
  89. else if (lookUp_TaskState.EditValue.ToString() == "6")
  90. {
  91. txt_VINInput.Enabled = true;
  92. txt_VINInput.Focus();
  93. // txt_ModelInput.Enabled = true;
  94. lookUp_Color.Enabled = true;
  95. txt_VINInput.EditValueChanged += txt_VINInput_EditValueChanged;
  96. }
  97. else
  98. {
  99. return;
  100. }
  101. }
  102. private void ResetVervity()
  103. {
  104. bNeedVerify = true;
  105. lookUp_TaskState.EditValue = "";
  106. }
  107. #endregion
  108. #region 控件方法
  109. private void BindData()
  110. {
  111. List<MoMtocData> list = BLLFactory<BlMtocData>.Instance.GetAll();
  112. gridControl.DataSource = list;
  113. label_PageInfo.Text = string.Format("共 {0} 条记录", list.Count);
  114. }
  115. private void BindData_SetPointer(string vinInput)
  116. {
  117. List<MoMtocData> list = BLLFactory<BlMtocData>.Instance.GetAll();
  118. gridControl.DataSource = list;
  119. label_PageInfo.Text = string.Format("共 {0} 条记录", list.Count);
  120. MoMtocData moMtocData = BLLFactory<BlMtocData>.Instance.FindPointerModel(txt_VINInput.Text);
  121. if (moMtocData == null)
  122. {
  123. DevExpress.XtraEditors.XtraMessageBox.Show($"当前输入车号 {txt_VINInput.Text} 未下载AS400数据,请先下载数据!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  124. return;
  125. }
  126. SysEnvironment.Global_Scanning_Pointer = vinInput;
  127. redis.Publish(SysEnvironment.redis_Scanning_Pointer, SysEnvironment.Global_Scanning_Pointer);
  128. }
  129. private void timerRefresh_Tick(object sender, EventArgs e)
  130. {
  131. // if (!IsActive) return;
  132. BindData();
  133. }
  134. private void SubScribeEnent()
  135. {
  136. //扫码工位标签值
  137. redis.Subscribe(SysEnvironment.redis_Scanning_Pointer, new Action<RedisChannel, RedisValue>(ScanningPointerChange));
  138. redis.Subscribe(SysEnvironment.redis_Scanning_HeadCode, new Action<RedisChannel, RedisValue>(ScanningHeadcodeChange));
  139. redis.Subscribe(SysEnvironment.redis_Scanning_FEMCode, new Action<RedisChannel, RedisValue>(ScanningFEMCodeChange));
  140. redis.Subscribe(SysEnvironment.redis_ScanningMatchRes, new Action<RedisChannel, RedisValue>(ShowMatchResult));
  141. //拧紧工位标签值
  142. redis.Subscribe(SysEnvironment.redis_Tighting_Pointer, new Action<RedisChannel, RedisValue>(TightingPointerChange));
  143. redis.Subscribe(SysEnvironment.redis_Tighting_Model, new Action<RedisChannel, RedisValue>(TightingModelChange));
  144. redis.Subscribe(SysEnvironment.redis_Tighting_Color, new Action<RedisChannel, RedisValue>(TightingColorChange));
  145. redis.Subscribe(SysEnvironment.redis_ScannerBlock, new Action<RedisChannel, RedisValue>(ScannerBlockChange));
  146. // redis.Subscribe(SysEnvironment.redis_Tighting_HeadCode, new Action<RedisChannel, RedisValue>(TightingHeadCodeChange));
  147. // redis.Subscribe(SysEnvironment.redis_Tighting_FEMCode, new Action<RedisChannel, RedisValue>(TightingFEMCodeChange));
  148. }
  149. private void ScanningPointerChange(RedisChannel channel, RedisValue message)
  150. {
  151. try
  152. {
  153. if (InvokeRequired)
  154. {
  155. BeginInvoke(new Action(() =>
  156. {
  157. ScanningPointerChange(channel, message);
  158. }));
  159. return;
  160. }
  161. lbl_Scanning_Pointer.Text = message.ToString();
  162. }
  163. catch (Exception ex)
  164. {
  165. LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
  166. }
  167. }
  168. private void ShowMatchResult(RedisChannel channel, RedisValue message)
  169. {
  170. try
  171. {
  172. if (InvokeRequired)
  173. {
  174. BeginInvoke(new Action(() =>
  175. {
  176. ShowMatchResult(channel, message);
  177. }));
  178. return;
  179. }
  180. if (message.ToString() == "1")
  181. {
  182. lbl_Scanning_MatchRes.Text = "匹配成功";
  183. lbl_Scanning_MatchRes.ForeColor = Color.Green;
  184. }
  185. else if (message.ToString() == "0")
  186. {
  187. lbl_Scanning_MatchRes.Text = "匹配失败";
  188. lbl_Scanning_MatchRes.ForeColor = Color.Red;
  189. }
  190. else if (message.ToString() == "-1")
  191. {
  192. lbl_Scanning_MatchRes.Text = "空车架/插车";
  193. lbl_Scanning_MatchRes.ForeColor = Color.Orange;
  194. }
  195. else if (message.ToString() == "-2")
  196. {
  197. lbl_Scanning_MatchRes.Text = "匹配中···";//扫码未完成状态
  198. lbl_Scanning_MatchRes.ForeColor = Color.Black;
  199. }
  200. else if (message.ToString() == "-3")
  201. {
  202. lbl_Scanning_MatchRes.Text = "";//未连锁状态
  203. lbl_Scanning_MatchRes.ForeColor = Color.Black;
  204. }
  205. else
  206. {
  207. lbl_Scanning_MatchRes.Text = "??";
  208. lbl_Scanning_MatchRes.ForeColor = Color.Red;
  209. }
  210. }
  211. catch (Exception ex)
  212. {
  213. LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
  214. }
  215. }
  216. private void TightingPointerChange(RedisChannel channel, RedisValue message)
  217. {
  218. try
  219. {
  220. if (InvokeRequired)
  221. {
  222. BeginInvoke(new Action(() =>
  223. {
  224. TightingPointerChange(channel, message);
  225. }));
  226. return;
  227. }
  228. lbl_Tighting_Pointer.Text = message;
  229. }
  230. catch (Exception ex)
  231. {
  232. LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
  233. }
  234. }
  235. private void TightingModelChange(RedisChannel channel, RedisValue message)
  236. {
  237. try
  238. {
  239. if (InvokeRequired)
  240. {
  241. BeginInvoke(new Action(() =>
  242. {
  243. TightingModelChange(channel, message);
  244. }));
  245. return;
  246. }
  247. lbl_TightingModel.Text = SmProject.TaskModelDisplay(message);
  248. }
  249. catch (Exception ex)
  250. {
  251. LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
  252. }
  253. }
  254. private void TightingColorChange(RedisChannel channel, RedisValue message)
  255. {
  256. try
  257. {
  258. if (InvokeRequired)
  259. {
  260. BeginInvoke(new Action(() =>
  261. {
  262. TightingColorChange(channel, message);
  263. }));
  264. return;
  265. }
  266. lbl_TightingColor.Text = SmProject.TaskColorDisplay(message);
  267. }
  268. catch (Exception ex)
  269. {
  270. LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
  271. }
  272. }
  273. private void ScanningHeadcodeChange(RedisChannel channel, RedisValue message)
  274. {
  275. try
  276. {
  277. if (InvokeRequired)
  278. {
  279. BeginInvoke(new Action(() =>
  280. {
  281. ScanningHeadcodeChange(channel, message);
  282. }));
  283. return;
  284. }
  285. lbl_Scanning_HeadCode.Text = message;//缓存获取
  286. }
  287. catch (Exception ex)
  288. {
  289. LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
  290. }
  291. }
  292. private void ScanningFEMCodeChange(RedisChannel channel, RedisValue message)
  293. {
  294. try
  295. {
  296. if (InvokeRequired)
  297. {
  298. BeginInvoke(new Action(() =>
  299. {
  300. ScanningFEMCodeChange(channel, message);
  301. }));
  302. return;
  303. }
  304. lbl_ScanningFEMCode.Text = message;//缓存获取
  305. }
  306. catch (Exception ex)
  307. {
  308. LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
  309. }
  310. }
  311. private void ScannerBlockChange(RedisChannel channel, RedisValue message)
  312. {
  313. try
  314. {
  315. if (InvokeRequired)
  316. {
  317. BeginInvoke(new Action(() =>
  318. {
  319. ScannerBlockChange(channel, message);
  320. }));
  321. return;
  322. }
  323. if (bool.Parse(message.ToString()))
  324. lbl_ScannerBlock.Text = "扫码阻塞";
  325. else
  326. lbl_ScannerBlock.Text = "";
  327. }
  328. catch (Exception ex)
  329. {
  330. LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
  331. }
  332. }
  333. private void GridView_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
  334. {
  335. if (gridView.DataSource == null) return;
  336. Color foreColor = Color.Brown;
  337. Color backColor = Color.LightGreen;
  338. //Change the foreground and background colors of selected rows.
  339. if (e.RowHandle == ((List<MoMtocData>)gridView.DataSource).FindIndex(c => c.Vin == SysEnvironment.Global_Scanning_Pointer))
  340. {
  341. e.Appearance.ForeColor = foreColor;
  342. e.Appearance.BackColor = backColor;
  343. /* This property controls whether settings of the RowStyle event have a higher priority
  344. than the appearances specified by the GridViewAppearances.EvenRow
  345. and GridViewAppearances.OddRow properties. */
  346. e.HighPriority = true;
  347. // gridView.FocusedRowHandle = e.RowHandle;
  348. if (e.RowHandle > 23)
  349. BLLFactory<BlMtocData>.Instance.AutoDelete(SysEnvironment.Global_Scanning_Pointer);
  350. // gridView.TopRowIndex = index;//不要这行
  351. }
  352. }
  353. private void gridView_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
  354. {
  355. if (e.Info.IsRowIndicator && e.RowHandle >= 0)
  356. {
  357. e.Info.DisplayText = (e.RowHandle + 1).ToString();
  358. }
  359. }
  360. private void gridView_MouseDown(object sender, MouseEventArgs e)
  361. {
  362. if (e.Button == MouseButtons.Right)
  363. {
  364. DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo gridHitInfo = new DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo();
  365. Point point = new Point(e.X, e.Y);
  366. gridHitInfo = (sender as GridView).CalcHitInfo(point);
  367. if (gridHitInfo.Column == null) return;
  368. //--获取单元格内容
  369. string copiedData = (sender as GridView).GetRowCellDisplayText(gridHitInfo.RowHandle, gridHitInfo.Column);
  370. if (string.IsNullOrEmpty(copiedData)) return;
  371. //--复制到剪贴板
  372. Clipboard.Clear();
  373. Clipboard.SetData(DataFormats.Text, copiedData);
  374. }
  375. if (e.Button == MouseButtons.Left && e.Clicks == 2)
  376. {
  377. //if (!SysEnvironment.sign_OrderStop)//先判断是不是预约停止模式
  378. //{
  379. // DevExpress.XtraEditors.XtraMessageBox.Show($"当前非预约停止状态,禁止切换任务", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  380. // return;
  381. //}
  382. if (bNeedVerify)//判断是不是有操作权限
  383. {
  384. FormUserVerification form = new FormUserVerification();
  385. form.ShowDialog();
  386. if (form.DialogResult != DialogResult.OK)
  387. return;
  388. else
  389. bNeedVerify = false;
  390. }
  391. DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hInfo = gridView.CalcHitInfo(new Point(e.X, e.Y));
  392. if (hInfo.InRow)//判断光标是否在行范围内
  393. {
  394. //获取这个行的vin
  395. object dr = gridView.GetRow(hInfo.RowHandle);
  396. if (dr == null) return;
  397. string svin = ((MoMtocData)dr).Vin.ToString();
  398. if (DevExpress.XtraEditors.XtraMessageBox.Show($"{svin}\n\n设置为扫码工位指针?\n\n", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  399. {
  400. LogHelper.log.Info($"【双击调整指针】按钮按下: {SysEnvironment.Global_Scanning_Pointer} -> {svin}");
  401. SysEnvironment.Global_Scanning_Pointer = svin;
  402. redis.Publish(SysEnvironment.redis_Scanning_Pointer, SysEnvironment.Global_Scanning_Pointer);
  403. }
  404. }
  405. }
  406. }
  407. private void txt_VIN_KeyDown(object sender, KeyEventArgs e)
  408. {
  409. if (e.KeyValue == 13)
  410. {
  411. btn_Check_RecoverProduce_Click(sender, e);
  412. }
  413. }
  414. private void btn_Check_RecoverProduce_Click(object sender, EventArgs e)
  415. {
  416. if (lookUp_TaskState.EditValue.ToString() == "")
  417. {
  418. return;
  419. }
  420. txt_VINInput.Text = txt_VINInput.Text.Trim();
  421. if (!SysEnvironment.CheckVINRule(txt_VINInput.Text))
  422. {
  423. DevExpress.XtraEditors.XtraMessageBox.Show($"当前输入车号不符合规则校验!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  424. return;
  425. }
  426. try
  427. {
  428. Cursor = Cursors.WaitCursor;
  429. LogHelper.log.Info($"【{lookUp_TaskState.Text.Trim()}--操作确认】按钮按下: 当前指针{SysEnvironment.Global_Scanning_Pointer}");
  430. if (lookUp_TaskState.EditValue.ToString() == "1")
  431. {
  432. SysEnvironment.LastPostResult = new string[10] { "", "", "", "", "", "", "", "", "", "" };//初始化POST结果缓存
  433. BLLFactory<BlMtocData>.Instance.TruncateTable(); //清空本地数据表
  434. this.btn_Check_RecoverProduce.Text = "远程读取中...";
  435. GetAS400DataJob getAS400DataJob = new GetAS400DataJob();
  436. bool bres = getAS400DataJob.GetAS400(txt_VINInput.Text);
  437. if (!bres)
  438. {
  439. DevExpress.XtraEditors.XtraMessageBox.Show($"无法查询到车号 {txt_VINInput.Text},请确认AS400数据库是否存在此数据", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  440. return;
  441. }
  442. DevExpress.XtraEditors.XtraMessageBox.Show($"下载完成!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  443. BindData_SetPointer(txt_VINInput.Text);
  444. }
  445. else if (lookUp_TaskState.EditValue.ToString() == "5")
  446. {
  447. MoMtocData moMtocData = BLLFactory<BlMtocData>.Instance.FindPointerModel(txt_VINInput.Text);
  448. if (moMtocData == null)
  449. {
  450. DevExpress.XtraEditors.XtraMessageBox.Show($"当前输入车号 {txt_VINInput.Text} 未下载AS400数据,请先下载数据!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  451. return;
  452. }
  453. SysEnvironment.Global_Scanning_Pointer = txt_VINInput.Text;
  454. redis.Publish(SysEnvironment.redis_Scanning_Pointer, SysEnvironment.Global_Scanning_Pointer);
  455. }
  456. else if (lookUp_TaskState.EditValue.ToString() == "6")
  457. {
  458. if (lookUp_Color.EditValue.ToString() == "")
  459. {
  460. DevExpress.XtraEditors.XtraMessageBox.Show($"请选择颜色", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  461. return;
  462. }
  463. short model = Convert.ToInt16(txt_ModelInput.Text);
  464. short color = Convert.ToInt16(lookUp_Color.Text);
  465. btn_Check_RecoverProduce.Text = "写入PLC...";
  466. manualForceWrite2Tighting(model, color, txt_VINInput.Text);
  467. }
  468. }
  469. catch (Exception ex)
  470. {
  471. DevExpress.XtraEditors.XtraMessageBox.Show($"操作失败:\n{ex.Message}", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
  472. }
  473. finally
  474. {
  475. Cursor = Cursors.Default;
  476. btn_Check_RecoverProduce.Text = "操作确认";
  477. txt_VINInput.Focus();
  478. }
  479. }
  480. private void lbl_headCode_MouseDown(object sender, MouseEventArgs e)
  481. {
  482. if (e.Button == MouseButtons.Right)
  483. {
  484. //--复制到剪贴板
  485. Clipboard.Clear();
  486. Clipboard.SetData(DataFormats.Text, lbl_Scanning_HeadCode.Text);
  487. }
  488. if (e.Button == MouseButtons.Left && e.Clicks == 2)
  489. {
  490. DevExpress.XtraEditors.XtraMessageBox.Show($"当前车头扫码结果队列:\n{PrintQueue(MXComponent_FEM02.SuperQueueScanner.HeadScanQueue)}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  491. }
  492. }
  493. private void lbl_femCode_MouseDown(object sender, MouseEventArgs e)
  494. {
  495. if (e.Button == MouseButtons.Right)
  496. {
  497. //--复制到剪贴板
  498. Clipboard.Clear();
  499. Clipboard.SetData(DataFormats.Text, lbl_ScanningFEMCode.Text);
  500. }
  501. if (e.Button == MouseButtons.Left && e.Clicks == 2)
  502. {
  503. DevExpress.XtraEditors.XtraMessageBox.Show($"当前FEM扫码结果队列:\n{PrintQueue(MXComponent_FEM02.SuperQueueScanner.FEMScanQueue)}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  504. }
  505. }
  506. private void lbl_vincode_MouseDown(object sender, MouseEventArgs e)
  507. {
  508. if (e.Button == MouseButtons.Right)
  509. {
  510. //--复制到剪贴板
  511. Clipboard.Clear();
  512. Clipboard.SetData(DataFormats.Text, lbl_Scanning_Pointer.Text);
  513. }
  514. }
  515. private void labelControl2_MouseDown(object sender, MouseEventArgs e)
  516. {
  517. if (e.Button == MouseButtons.Left && e.Clicks == 2)
  518. {
  519. if (!CheckIdentify()) return;
  520. if (MXComponent_FEM02.SkipHeadScan)
  521. {
  522. if (DevExpress.XtraEditors.XtraMessageBox.Show($"开启车头扫码", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
  523. return;
  524. }
  525. else
  526. {
  527. if (DevExpress.XtraEditors.XtraMessageBox.Show($"关闭车头扫码", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
  528. return;
  529. }
  530. MXComponent_FEM02.SkipHeadScan = !MXComponent_FEM02.SkipHeadScan;
  531. SetHeadScannerlabel();
  532. string message = MXComponent_FEM02.SkipHeadScan ? "关闭" : "开启";
  533. DevExpress.XtraEditors.XtraMessageBox.Show($"车头扫码已{message}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  534. }
  535. }
  536. private void labelControl3_MouseDown(object sender, MouseEventArgs e)
  537. {
  538. if (e.Button == MouseButtons.Left && e.Clicks == 2)
  539. {
  540. if (!CheckIdentify()) return;
  541. if (MXComponent_FEM02.SkipFEMScan)
  542. {
  543. if (DevExpress.XtraEditors.XtraMessageBox.Show($"开启FEM扫码", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
  544. return;
  545. }
  546. else
  547. {
  548. if (DevExpress.XtraEditors.XtraMessageBox.Show($"关闭FEM扫码", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
  549. return;
  550. }
  551. MXComponent_FEM02.SkipFEMScan = !MXComponent_FEM02.SkipFEMScan;
  552. SetFEMScannerlabel();
  553. string message = MXComponent_FEM02.SkipFEMScan ? "关闭" : "开启";
  554. DevExpress.XtraEditors.XtraMessageBox.Show($"FEM扫码已{message}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  555. }
  556. }
  557. private void SetHeadScannerlabel()
  558. {
  559. lbl_HeadScanner.BackColor = MXComponent_FEM02.SkipHeadScan ? Color.LightGray : Color.White;
  560. }
  561. private void SetFEMScannerlabel()
  562. {
  563. lbl_FEMScanner.BackColor = MXComponent_FEM02.SkipFEMScan ? Color.LightGray : Color.White;
  564. }
  565. private void gridView_PLC_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
  566. {
  567. if (e.Column.FieldName == "Model")
  568. {
  569. e.DisplayText = SmProject.ModelDisplayFieldText(e.Value.ToString().Trim());
  570. }
  571. if (e.Column.FieldName == "Color")
  572. {
  573. e.DisplayText = SmProject.ColorDisplayFieldText(e.Value.ToString().Trim());
  574. }
  575. }
  576. #endregion
  577. #region 私有方法
  578. private string PrintQueue(Queue<string> list)
  579. {
  580. //Console.WriteLine("开始打印队列");
  581. string ss = "";
  582. foreach (string str in list)
  583. {
  584. ss += str + "\n";
  585. }
  586. return ss;
  587. }
  588. #endregion
  589. private void btn_ForceMatch_Click(object sender, EventArgs e)
  590. {
  591. if (string.IsNullOrEmpty(SysEnvironment.Global_Scanning_Pointer))
  592. {
  593. DevExpress.XtraEditors.XtraMessageBox.Show($"当前扫码指针为空,请先调整指针", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  594. return;
  595. }
  596. MoMtocData task = BLLFactory<BlMtocData>.Instance.FindPointerModel(SysEnvironment.Global_Scanning_Pointer);
  597. if (task == null)
  598. {
  599. DevExpress.XtraEditors.XtraMessageBox.Show($"当前指针 {SysEnvironment.Global_Scanning_Pointer}未下载数据,请先下载数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
  600. return;
  601. }
  602. if (DevExpress.XtraEditors.XtraMessageBox.Show($"是否确认当前扫码工位来车为\n\n{SysEnvironment.Global_Scanning_Pointer}", "强制匹配", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  603. {
  604. LogHelper.log.Info($"【匹配指针】按钮按下: 当前指针{SysEnvironment.Global_Scanning_Pointer}");
  605. manualForceMatchSuccess();
  606. }
  607. }
  608. public delegate void delegateResetVertify2();
  609. public static event delegateResetVertify2 manualForceMatchSuccess;
  610. public static event delegateResetVertify2 manualForceReleaseEmpty;
  611. public delegate void delegateResetVertify3(short model, short color, string vin);
  612. public static event delegateResetVertify3 manualForceWrite2Tighting;
  613. private void btn_ReleaseEmpty_Click(object sender, EventArgs e)
  614. {
  615. if (DevExpress.XtraEditors.XtraMessageBox.Show($"是否强制放行?\n\n当前车头扫码结果:{SysEnvironment.Global_Scanning_HeadCode}", "强制放行", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
  616. {
  617. LogHelper.log.Info($"【强制放行】按钮按下: 当前指针{SysEnvironment.Global_Scanning_Pointer}");
  618. manualForceReleaseEmpty();
  619. }
  620. }
  621. private void txt_VINInput_EditValueChanged(object sender, EventArgs e)
  622. {
  623. if (SysEnvironment.CheckVINRule(txt_VINInput.Text))
  624. {
  625. string model = txt_VINInput.Text.Substring(3, 2);
  626. txt_ModelInput.Text = SmProject.ListModelContrast.Find(p => p.Model_Code.ToString() == model).PLC_Code.ToString();
  627. }
  628. }
  629. private void txt_VINInput_Click(object sender, EventArgs e)
  630. {
  631. txt_VINInput.SelectAll();
  632. }
  633. private bool CheckIdentify()
  634. {
  635. if (bNeedVerify)
  636. {
  637. FormUserVerification form = new FormUserVerification();
  638. form.ShowDialog();
  639. if (form.DialogResult != DialogResult.OK)
  640. {
  641. lookUp_TaskState.EditValue = "";
  642. return false;
  643. }
  644. else
  645. bNeedVerify = false;
  646. }
  647. return true;
  648. }
  649. }
  650. }