123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762 |
- using System;
- using System.Collections.Generic;
- using ProjectBase.Controls;
- using SIMDP.BLL;
- using ProjectBase.Data.Pager;
- using SIMDP.Model;
- using ProjectBase.Util;
- using ProjectBase.Data.BaseDAL;
- using ProjectBase.Data.Logs;
- using ProjectBase.Data.Redis;
- using StackExchange.Redis;
- using System.Windows.Forms;
- using System.Drawing;
- using System.Data;
- using SIMDP.View;
- using DevExpress.XtraGrid.Views.Grid;
- namespace SIMDP.Project
- {
- public partial class FormCurrentTask : BaseDock
- {
- #region 变量声明
- private RedisHelper redis = new RedisHelper(0);
- private bool bNeedVerify = true;
- public FormCurrentTask()
- {
- InitializeComponent();
- //当前任务功能 初始化
- BindData();
- SubScribeEnent();
- //条码录入功能 初始化
- InitLookUpCtrl();
- MainForm.eventUserIdle += new MainForm.delegateResetVertify(ResetVervity);//订阅权限超时事件
- SetHeadScannerlabel();
- SetFEMScannerlabel();
- lookUp_TaskState.EditValueChanged += new System.EventHandler(this.lookUp_TaskState_EditValueChanged);
- }
- private void InitLookUpCtrl()
- {
- Dictionary<string, string> linkType2 = new Dictionary<string, string>();
- linkType2.Add("1", "下载AS400数据");
- linkType2.Add("5", "调整扫码工位指针");
- linkType2.Add("6", "强制写入安装工位");
- lookUp_TaskState.Properties.DataSource = linkType2;
- lookUp_TaskState.Properties.ValueMember = "Key";
- lookUp_TaskState.Properties.DisplayMember = "Value";
- lookUp_TaskState.EditValue = "";
- SmProject.InitColorList();
- lookUp_Color.Properties.DataSource = SmProject.ColorList;
- lookUp_Color.Properties.ValueMember = "Value";
- lookUp_Color.Properties.DisplayMember = "Key";
- lookUp_Color.EditValue = "";
- }
- private void lookUp_TaskState_EditValueChanged(object sender, EventArgs e)
- {
- txt_VINInput.Text = "";
- txt_ModelInput.Text = "";
- lookUp_Color.Text = "";
- txt_VINInput.Enabled = false;
- txt_ModelInput.Enabled = false;
- lookUp_Color.Enabled = false;
- txt_VINInput.EditValueChanged -= txt_VINInput_EditValueChanged;
- if (lookUp_TaskState.EditValue.ToString() == "") return;
- if (bNeedVerify)
- {
- FormUserVerification form = new FormUserVerification();
- form.ShowDialog();
- if (form.DialogResult != DialogResult.OK)
- {
- lookUp_TaskState.EditValue = "";
- return;
- }
- else
- bNeedVerify = false;
- }
- //判断是什么模式,给什么输入框
- if (lookUp_TaskState.EditValue.ToString() == "1")
- {
- lookUp_Color.EditValue = "";
- txt_VINInput.Enabled = true;
- txt_VINInput.Focus();
- //this.txt_VINInput.EditValueChanged += new System.EventHandler(InputValueChanged);
- }
- else if (lookUp_TaskState.EditValue.ToString() == "5")
- {
- lookUp_Color.EditValue = "";
- txt_VINInput.Enabled = true;
- txt_VINInput.Focus();
- }
- else if (lookUp_TaskState.EditValue.ToString() == "6")
- {
- txt_VINInput.Enabled = true;
- txt_VINInput.Focus();
- // txt_ModelInput.Enabled = true;
- lookUp_Color.Enabled = true;
- txt_VINInput.EditValueChanged += txt_VINInput_EditValueChanged;
- }
- else
- {
- return;
- }
- }
- private void ResetVervity()
- {
- bNeedVerify = true;
- lookUp_TaskState.EditValue = "";
- }
- #endregion
- #region 控件方法
- private void BindData()
- {
- List<MoMtocData> list = BLLFactory<BlMtocData>.Instance.GetAll();
- gridControl.DataSource = list;
- label_PageInfo.Text = string.Format("共 {0} 条记录", list.Count);
- }
- private void BindData_SetPointer(string vinInput)
- {
- List<MoMtocData> list = BLLFactory<BlMtocData>.Instance.GetAll();
- gridControl.DataSource = list;
- label_PageInfo.Text = string.Format("共 {0} 条记录", list.Count);
- MoMtocData moMtocData = BLLFactory<BlMtocData>.Instance.FindPointerModel(txt_VINInput.Text);
- if (moMtocData == null)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"当前输入车号 {txt_VINInput.Text} 未下载AS400数据,请先下载数据!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- SysEnvironment.Global_Scanning_Pointer = vinInput;
- redis.Publish(SysEnvironment.redis_Scanning_Pointer, SysEnvironment.Global_Scanning_Pointer);
- }
- private void timerRefresh_Tick(object sender, EventArgs e)
- {
- // if (!IsActive) return;
- BindData();
- }
- private void SubScribeEnent()
- {
- //扫码工位标签值
- redis.Subscribe(SysEnvironment.redis_Scanning_Pointer, new Action<RedisChannel, RedisValue>(ScanningPointerChange));
- redis.Subscribe(SysEnvironment.redis_Scanning_HeadCode, new Action<RedisChannel, RedisValue>(ScanningHeadcodeChange));
- redis.Subscribe(SysEnvironment.redis_Scanning_FEMCode, new Action<RedisChannel, RedisValue>(ScanningFEMCodeChange));
- redis.Subscribe(SysEnvironment.redis_ScanningMatchRes, new Action<RedisChannel, RedisValue>(ShowMatchResult));
- //拧紧工位标签值
- redis.Subscribe(SysEnvironment.redis_Tighting_Pointer, new Action<RedisChannel, RedisValue>(TightingPointerChange));
- redis.Subscribe(SysEnvironment.redis_Tighting_Model, new Action<RedisChannel, RedisValue>(TightingModelChange));
- redis.Subscribe(SysEnvironment.redis_Tighting_Color, new Action<RedisChannel, RedisValue>(TightingColorChange));
- redis.Subscribe(SysEnvironment.redis_ScannerBlock, new Action<RedisChannel, RedisValue>(ScannerBlockChange));
- // redis.Subscribe(SysEnvironment.redis_Tighting_HeadCode, new Action<RedisChannel, RedisValue>(TightingHeadCodeChange));
- // redis.Subscribe(SysEnvironment.redis_Tighting_FEMCode, new Action<RedisChannel, RedisValue>(TightingFEMCodeChange));
- }
- private void ScanningPointerChange(RedisChannel channel, RedisValue message)
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(() =>
- {
- ScanningPointerChange(channel, message);
- }));
- return;
- }
- lbl_Scanning_Pointer.Text = message.ToString();
- }
- catch (Exception ex)
- {
- LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
- }
- }
- private void ShowMatchResult(RedisChannel channel, RedisValue message)
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(() =>
- {
- ShowMatchResult(channel, message);
- }));
- return;
- }
- if (message.ToString() == "1")
- {
- lbl_Scanning_MatchRes.Text = "匹配成功";
- lbl_Scanning_MatchRes.ForeColor = Color.Green;
- }
- else if (message.ToString() == "0")
- {
- lbl_Scanning_MatchRes.Text = "匹配失败";
- lbl_Scanning_MatchRes.ForeColor = Color.Red;
- }
- else if (message.ToString() == "-1")
- {
- lbl_Scanning_MatchRes.Text = "空车架/插车";
- lbl_Scanning_MatchRes.ForeColor = Color.Orange;
- }
- else if (message.ToString() == "-2")
- {
- lbl_Scanning_MatchRes.Text = "匹配中···";//扫码未完成状态
- lbl_Scanning_MatchRes.ForeColor = Color.Black;
- }
- else if (message.ToString() == "-3")
- {
- lbl_Scanning_MatchRes.Text = "";//未连锁状态
- lbl_Scanning_MatchRes.ForeColor = Color.Black;
- }
- else
- {
- lbl_Scanning_MatchRes.Text = "??";
- lbl_Scanning_MatchRes.ForeColor = Color.Red;
- }
- }
- catch (Exception ex)
- {
- LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
- }
- }
- private void TightingPointerChange(RedisChannel channel, RedisValue message)
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(() =>
- {
- TightingPointerChange(channel, message);
- }));
- return;
- }
- lbl_Tighting_Pointer.Text = message;
- }
- catch (Exception ex)
- {
- LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
- }
- }
- private void TightingModelChange(RedisChannel channel, RedisValue message)
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(() =>
- {
- TightingModelChange(channel, message);
- }));
- return;
- }
- lbl_TightingModel.Text = SmProject.TaskModelDisplay(message);
- }
- catch (Exception ex)
- {
- LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
- }
- }
- private void TightingColorChange(RedisChannel channel, RedisValue message)
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(() =>
- {
- TightingColorChange(channel, message);
- }));
- return;
- }
- lbl_TightingColor.Text = SmProject.TaskColorDisplay(message);
- }
- catch (Exception ex)
- {
- LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
- }
- }
- private void ScanningHeadcodeChange(RedisChannel channel, RedisValue message)
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(() =>
- {
- ScanningHeadcodeChange(channel, message);
- }));
- return;
- }
- lbl_Scanning_HeadCode.Text = message;//缓存获取
- }
- catch (Exception ex)
- {
- LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
- }
- }
- private void ScanningFEMCodeChange(RedisChannel channel, RedisValue message)
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(() =>
- {
- ScanningFEMCodeChange(channel, message);
- }));
- return;
- }
- lbl_ScanningFEMCode.Text = message;//缓存获取
- }
- catch (Exception ex)
- {
- LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
- }
- }
- private void ScannerBlockChange(RedisChannel channel, RedisValue message)
- {
- try
- {
- if (InvokeRequired)
- {
- BeginInvoke(new Action(() =>
- {
- ScannerBlockChange(channel, message);
- }));
- return;
- }
- if (bool.Parse(message.ToString()))
- lbl_ScannerBlock.Text = "扫码阻塞";
- else
- lbl_ScannerBlock.Text = "";
- }
- catch (Exception ex)
- {
- LogHelper.log.Error($"标签值订阅异常:{ex.Message}");
- }
- }
- private void GridView_RowStyle(object sender, DevExpress.XtraGrid.Views.Grid.RowStyleEventArgs e)
- {
- if (gridView.DataSource == null) return;
- Color foreColor = Color.Brown;
- Color backColor = Color.LightGreen;
- //Change the foreground and background colors of selected rows.
- if (e.RowHandle == ((List<MoMtocData>)gridView.DataSource).FindIndex(c => c.Vin == SysEnvironment.Global_Scanning_Pointer))
- {
- e.Appearance.ForeColor = foreColor;
- e.Appearance.BackColor = backColor;
- /* This property controls whether settings of the RowStyle event have a higher priority
- than the appearances specified by the GridViewAppearances.EvenRow
- and GridViewAppearances.OddRow properties. */
- e.HighPriority = true;
- // gridView.FocusedRowHandle = e.RowHandle;
- if (e.RowHandle > 23)
- BLLFactory<BlMtocData>.Instance.AutoDelete(SysEnvironment.Global_Scanning_Pointer);
- // gridView.TopRowIndex = index;//不要这行
- }
- }
- private void gridView_CustomDrawRowIndicator(object sender, DevExpress.XtraGrid.Views.Grid.RowIndicatorCustomDrawEventArgs e)
- {
- if (e.Info.IsRowIndicator && e.RowHandle >= 0)
- {
- e.Info.DisplayText = (e.RowHandle + 1).ToString();
- }
- }
- private void gridView_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo gridHitInfo = new DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo();
- Point point = new Point(e.X, e.Y);
- gridHitInfo = (sender as GridView).CalcHitInfo(point);
- if (gridHitInfo.Column == null) return;
- //--获取单元格内容
- string copiedData = (sender as GridView).GetRowCellDisplayText(gridHitInfo.RowHandle, gridHitInfo.Column);
- if (string.IsNullOrEmpty(copiedData)) return;
- //--复制到剪贴板
- Clipboard.Clear();
- Clipboard.SetData(DataFormats.Text, copiedData);
- }
- if (e.Button == MouseButtons.Left && e.Clicks == 2)
- {
- //if (!SysEnvironment.sign_OrderStop)//先判断是不是预约停止模式
- //{
- // DevExpress.XtraEditors.XtraMessageBox.Show($"当前非预约停止状态,禁止切换任务", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- // return;
- //}
- if (bNeedVerify)//判断是不是有操作权限
- {
- FormUserVerification form = new FormUserVerification();
- form.ShowDialog();
- if (form.DialogResult != DialogResult.OK)
- return;
- else
- bNeedVerify = false;
- }
- DevExpress.XtraGrid.Views.Grid.ViewInfo.GridHitInfo hInfo = gridView.CalcHitInfo(new Point(e.X, e.Y));
- if (hInfo.InRow)//判断光标是否在行范围内
- {
- //获取这个行的vin
- object dr = gridView.GetRow(hInfo.RowHandle);
- if (dr == null) return;
- string svin = ((MoMtocData)dr).Vin.ToString();
- if (DevExpress.XtraEditors.XtraMessageBox.Show($"{svin}\n\n设置为扫码工位指针?\n\n", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
- {
- LogHelper.log.Info($"【双击调整指针】按钮按下: {SysEnvironment.Global_Scanning_Pointer} -> {svin}");
- SysEnvironment.Global_Scanning_Pointer = svin;
- redis.Publish(SysEnvironment.redis_Scanning_Pointer, SysEnvironment.Global_Scanning_Pointer);
- }
- }
- }
- }
- private void txt_VIN_KeyDown(object sender, KeyEventArgs e)
- {
- if (e.KeyValue == 13)
- {
- btn_Check_RecoverProduce_Click(sender, e);
- }
- }
- private void btn_Check_RecoverProduce_Click(object sender, EventArgs e)
- {
- if (lookUp_TaskState.EditValue.ToString() == "")
- {
- return;
- }
- txt_VINInput.Text = txt_VINInput.Text.Trim();
- if (!SysEnvironment.CheckVINRule(txt_VINInput.Text))
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"当前输入车号不符合规则校验!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- try
- {
- Cursor = Cursors.WaitCursor;
- LogHelper.log.Info($"【{lookUp_TaskState.Text.Trim()}--操作确认】按钮按下: 当前指针{SysEnvironment.Global_Scanning_Pointer}");
- if (lookUp_TaskState.EditValue.ToString() == "1")
- {
- SysEnvironment.LastPostResult = new string[10] { "", "", "", "", "", "", "", "", "", "" };//初始化POST结果缓存
- BLLFactory<BlMtocData>.Instance.TruncateTable(); //清空本地数据表
- this.btn_Check_RecoverProduce.Text = "远程读取中...";
- GetAS400DataJob getAS400DataJob = new GetAS400DataJob();
- bool bres = getAS400DataJob.GetAS400(txt_VINInput.Text);
- if (!bres)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"无法查询到车号 {txt_VINInput.Text},请确认AS400数据库是否存在此数据", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- DevExpress.XtraEditors.XtraMessageBox.Show($"下载完成!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- BindData_SetPointer(txt_VINInput.Text);
- }
- else if (lookUp_TaskState.EditValue.ToString() == "5")
- {
- MoMtocData moMtocData = BLLFactory<BlMtocData>.Instance.FindPointerModel(txt_VINInput.Text);
- if (moMtocData == null)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"当前输入车号 {txt_VINInput.Text} 未下载AS400数据,请先下载数据!", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- SysEnvironment.Global_Scanning_Pointer = txt_VINInput.Text;
- redis.Publish(SysEnvironment.redis_Scanning_Pointer, SysEnvironment.Global_Scanning_Pointer);
- }
- else if (lookUp_TaskState.EditValue.ToString() == "6")
- {
- if (lookUp_Color.EditValue.ToString() == "")
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"请选择颜色", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- short model = Convert.ToInt16(txt_ModelInput.Text);
- short color = Convert.ToInt16(lookUp_Color.Text);
- btn_Check_RecoverProduce.Text = "写入PLC...";
- manualForceWrite2Tighting(model, color, txt_VINInput.Text);
- }
- }
- catch (Exception ex)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"操作失败:\n{ex.Message}", "信息", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- finally
- {
- Cursor = Cursors.Default;
- btn_Check_RecoverProduce.Text = "操作确认";
- txt_VINInput.Focus();
- }
- }
- private void lbl_headCode_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- //--复制到剪贴板
- Clipboard.Clear();
- Clipboard.SetData(DataFormats.Text, lbl_Scanning_HeadCode.Text);
- }
- if (e.Button == MouseButtons.Left && e.Clicks == 2)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"当前车头扫码结果队列:\n{PrintQueue(MXComponent_FEM02.SuperQueueScanner.HeadScanQueue)}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private void lbl_femCode_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- //--复制到剪贴板
- Clipboard.Clear();
- Clipboard.SetData(DataFormats.Text, lbl_ScanningFEMCode.Text);
- }
- if (e.Button == MouseButtons.Left && e.Clicks == 2)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"当前FEM扫码结果队列:\n{PrintQueue(MXComponent_FEM02.SuperQueueScanner.FEMScanQueue)}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private void lbl_vincode_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Right)
- {
- //--复制到剪贴板
- Clipboard.Clear();
- Clipboard.SetData(DataFormats.Text, lbl_Scanning_Pointer.Text);
- }
- }
- private void labelControl2_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left && e.Clicks == 2)
- {
- if (!CheckIdentify()) return;
- if (MXComponent_FEM02.SkipHeadScan)
- {
- if (DevExpress.XtraEditors.XtraMessageBox.Show($"开启车头扫码", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
- return;
- }
- else
- {
- if (DevExpress.XtraEditors.XtraMessageBox.Show($"关闭车头扫码", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
- return;
- }
- MXComponent_FEM02.SkipHeadScan = !MXComponent_FEM02.SkipHeadScan;
- SetHeadScannerlabel();
- string message = MXComponent_FEM02.SkipHeadScan ? "关闭" : "开启";
- DevExpress.XtraEditors.XtraMessageBox.Show($"车头扫码已{message}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private void labelControl3_MouseDown(object sender, MouseEventArgs e)
- {
- if (e.Button == MouseButtons.Left && e.Clicks == 2)
- {
- if (!CheckIdentify()) return;
- if (MXComponent_FEM02.SkipFEMScan)
- {
- if (DevExpress.XtraEditors.XtraMessageBox.Show($"开启FEM扫码", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
- return;
- }
- else
- {
- if (DevExpress.XtraEditors.XtraMessageBox.Show($"关闭FEM扫码", "操作确认", MessageBoxButtons.YesNo, MessageBoxIcon.Information) != DialogResult.Yes)
- return;
- }
- MXComponent_FEM02.SkipFEMScan = !MXComponent_FEM02.SkipFEMScan;
- SetFEMScannerlabel();
- string message = MXComponent_FEM02.SkipFEMScan ? "关闭" : "开启";
- DevExpress.XtraEditors.XtraMessageBox.Show($"FEM扫码已{message}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- }
- }
- private void SetHeadScannerlabel()
- {
- lbl_HeadScanner.BackColor = MXComponent_FEM02.SkipHeadScan ? Color.LightGray : Color.White;
- }
- private void SetFEMScannerlabel()
- {
- lbl_FEMScanner.BackColor = MXComponent_FEM02.SkipFEMScan ? Color.LightGray : Color.White;
- }
- private void gridView_PLC_CustomColumnDisplayText(object sender, DevExpress.XtraGrid.Views.Base.CustomColumnDisplayTextEventArgs e)
- {
- if (e.Column.FieldName == "Model")
- {
- e.DisplayText = SmProject.ModelDisplayFieldText(e.Value.ToString().Trim());
- }
- if (e.Column.FieldName == "Color")
- {
- e.DisplayText = SmProject.ColorDisplayFieldText(e.Value.ToString().Trim());
- }
- }
- #endregion
- #region 私有方法
- private string PrintQueue(Queue<string> list)
- {
- //Console.WriteLine("开始打印队列");
- string ss = "";
- foreach (string str in list)
- {
- ss += str + "\n";
- }
- return ss;
- }
- #endregion
- private void btn_ForceMatch_Click(object sender, EventArgs e)
- {
- if (string.IsNullOrEmpty(SysEnvironment.Global_Scanning_Pointer))
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"当前扫码指针为空,请先调整指针", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- MoMtocData task = BLLFactory<BlMtocData>.Instance.FindPointerModel(SysEnvironment.Global_Scanning_Pointer);
- if (task == null)
- {
- DevExpress.XtraEditors.XtraMessageBox.Show($"当前指针 {SysEnvironment.Global_Scanning_Pointer}未下载数据,请先下载数据", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
- return;
- }
- if (DevExpress.XtraEditors.XtraMessageBox.Show($"是否确认当前扫码工位来车为\n\n{SysEnvironment.Global_Scanning_Pointer}", "强制匹配", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
- {
- LogHelper.log.Info($"【匹配指针】按钮按下: 当前指针{SysEnvironment.Global_Scanning_Pointer}");
- manualForceMatchSuccess();
- }
- }
- public delegate void delegateResetVertify2();
- public static event delegateResetVertify2 manualForceMatchSuccess;
- public static event delegateResetVertify2 manualForceReleaseEmpty;
- public delegate void delegateResetVertify3(short model, short color, string vin);
- public static event delegateResetVertify3 manualForceWrite2Tighting;
- private void btn_ReleaseEmpty_Click(object sender, EventArgs e)
- {
- if (DevExpress.XtraEditors.XtraMessageBox.Show($"是否强制放行?\n\n当前车头扫码结果:{SysEnvironment.Global_Scanning_HeadCode}", "强制放行", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.Yes)
- {
- LogHelper.log.Info($"【强制放行】按钮按下: 当前指针{SysEnvironment.Global_Scanning_Pointer}");
- manualForceReleaseEmpty();
- }
- }
- private void txt_VINInput_EditValueChanged(object sender, EventArgs e)
- {
- if (SysEnvironment.CheckVINRule(txt_VINInput.Text))
- {
- string model = txt_VINInput.Text.Substring(3, 2);
- txt_ModelInput.Text = SmProject.ListModelContrast.Find(p => p.Model_Code.ToString() == model).PLC_Code.ToString();
- }
- }
- private void txt_VINInput_Click(object sender, EventArgs e)
- {
- txt_VINInput.SelectAll();
- }
- private bool CheckIdentify()
- {
- if (bNeedVerify)
- {
- FormUserVerification form = new FormUserVerification();
- form.ShowDialog();
- if (form.DialogResult != DialogResult.OK)
- {
- lookUp_TaskState.EditValue = "";
- return false;
- }
- else
- bNeedVerify = false;
- }
- return true;
- }
- }
- }
|