You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

179 lines
5.8 KiB
C#

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
{
/// <summary>
/// 写入页面
/// </summary>
public partial class WriteInfo : Window
{
private string processId = "";
private int position = 0;
private IBaseServices<ProShaftInfo> baseServices = new BaseServices<ProShaftInfo>();
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";
}
}
/// <summary>
/// 写入方法
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click(object sender, RoutedEventArgs e)
{
1 month ago
int roleId = Convert.ToInt32(ConfigHelper.GetConfig("roleId"));
if (roleId > 2 || roleId == 0)
{
1 month ago
System.Windows.MessageBox.Show($"请登录系统管理账号进行操作当前用户角色ID{roleId}");
return;
}
string rfidCode = this.rfidCode.Text.ToString();
LogHelperBusiness.LogInfo("手动写入RFID条码信息"+ rfidCode);
1 month ago
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();
}
/// <summary>
/// 清除
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
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<Func<ProShaftInfo, bool>> exp = s1 => true;
exp = exp.And(x => x.processId == this.processId && x.positionId == this.position.ToString());
Expression<Func<ProShaftInfo, object>> 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);
}
}
}
}