using MaterialTraceability.Business; using MaterialTraceability.Business.Impl; using MaterialTraceability.Entity.DAO; using MaterialTraceability.SqlSugar; using MaterialTraceability.SqlSugar.ServiceImpl; using MaterialTraceabilityUI.Common; using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Shapes; namespace MaterialTraceabilityUI { /// /// 写入页面 /// public partial class WriteInfo : Window { private string processId = ""; private int position = 0; private IBaseServices baseServices = new BaseServices(); private TBSignalReadBusiness tBSignalRead = new TBSignalReadBusiness(); private LYSignalReadBusiness lYSignalRead = new LYSignalReadBusiness(); private MQSignalReadBusiness mQSignalRead = new MQSignalReadBusiness(); private ABSignalReadBusiness ABSignalRead = new ABSignalReadBusiness(); public WriteInfo() { InitializeComponent(); } public WriteInfo(string processId,int position) { this.processId = processId; this.position = position; InitializeComponent(); if (processId == "AB") { if (position == 0) { //this.rfidCode.Text = ""; } else { this.rfidCode.Text = "JSLY5RD"; } } else { this.rfidCode.Text = "JSLY5RD"; } } /// /// 写入方法 /// /// /// private void Button_Click(object sender, RoutedEventArgs e) { int roleId = Convert.ToInt32(ConfigHelper.GetConfig("roleId")); if (roleId > 2 || roleId == 0) { System.Windows.MessageBox.Show($"请登录系统管理账号进行操作,当前用户角色ID:{roleId}"); return; } string rfidCode = this.rfidCode.Text.ToString(); LogHelperBusiness.LogInfo("手动写入RFID条码信息:"+ rfidCode); if (StringExtension.IsBlank(rfidCode)) { MessageBox.Show("请输入正确的RFID条码信息"); return; } if(processId == "TB") { if(position < 3) { tBSignalRead.MesBegin(position, rfidCode, false); } else { tBSignalRead.FJMesBegin(position, rfidCode, false); } MessageBox.Show("涂布RFID条码信息写入成功"); }else if(processId == "MQ_A") { if(position > 4) { mQSignalRead.UpMaterialBeginByMes(position, rfidCode, false); } else { mQSignalRead.DownMaterialBeginByMes(position, rfidCode, false); } MessageBox.Show("模切RFID条码信息写入成功"); }else if(processId == "LY_A") { lYSignalRead.MesBegin(position, rfidCode, false); MessageBox.Show("冷压RFID条码信息写入成功"); } else if (processId == "AB") { if (position == 0) { ABSignalRead.FJMesBegin(position, rfidCode, false); } else { ABSignalRead.SJMesBegin(position, rfidCode, false); } MessageBox.Show("凹版RFID条码信息写入成功"); } this.Close(); } /// /// 清除 /// /// /// private void Button_Click_1(object sender, RoutedEventArgs e) { if (!"1".Equals(ConfigHelper.GetConfig("roleId")) && !"2".Equals(ConfigHelper.GetConfig("roleId"))) { System.Windows.MessageBox.Show("请登录系统管理账号进行操作"); return; } try { LogHelperBusiness.LogInfo("手动清除卷轴绑定信息"); Expression> exp = s1 => true; exp = exp.And(x => x.processId == this.processId && x.positionId == this.position.ToString()); Expression> order = s1 => s1.bindTime; ProShaftInfo shaftInfo = baseServices.QueryFirst(exp, order, false).Result; if (shaftInfo == null) { LogHelperBusiness.LogInfo("清除卷轴绑定数据,获取绑定数据为空"); MessageBox.Show("清除卷轴绑定数据,获取绑定数据为空"); return; } shaftInfo.bindRfid = ""; shaftInfo.bindSfc = ""; shaftInfo.bindEaValue = ""; baseServices.Update(shaftInfo); MessageBox.Show("清除成功"); LogHelperBusiness.LogInfo("清除成功"); this.Close(); }catch(Exception ex) { LogHelperBusiness.LogError("清除卷轴绑定数据异常", ex); } } } }