修改已知问题

This commit is contained in:
2026-01-29 22:15:34 +08:00
parent b940170607
commit 88483b38ad
13 changed files with 860 additions and 378 deletions

View File

@@ -8,6 +8,8 @@
<add key="PLCIP" value="127.0.0.1" /> <add key="PLCIP" value="127.0.0.1" />
<add key="PLCPort" value="6000" /> <add key="PLCPort" value="6000" />
<add key="PLCScan" value="600" /> <add key="PLCScan" value="600" />
<add key="WeightUp" value="105.25" />
<add key="WeightDown" value="180.23" />
</appSettings> </appSettings>
</configuration> </configuration>

View File

@@ -16,7 +16,7 @@ namespace FATrace.App
{ {
return new FreeSql.FreeSqlBuilder() return new FreeSql.FreeSqlBuilder()
.UseConnectionString(FreeSql.DataType.SqlServer, connectionString) .UseConnectionString(FreeSql.DataType.SqlServer, connectionString)
.UseAutoSyncStructure(true) .UseAutoSyncStructure(false)
.Build(); .Build();
} }
catch (Exception ex) catch (Exception ex)

View File

@@ -48,7 +48,16 @@ namespace FATrace.App
btnHistoryData = new Button(); btnHistoryData = new Button();
TabControlMain = new TabControl(); TabControlMain = new TabControl();
tabPage2 = new TabPage(); tabPage2 = new TabPage();
panel4 = new Panel();
btnConfigSave = new Button();
label30 = new Label();
pictureBox5 = new PictureBox();
txtWeightDown = new TextBox();
label29 = new Label();
label31 = new Label();
txtWeightUp = new TextBox();
panel3 = new Panel(); panel3 = new Panel();
btnReprint = new Button();
pictureBox4 = new PictureBox(); pictureBox4 = new PictureBox();
btnWeightPrint = new Button(); btnWeightPrint = new Button();
txtCode = new TextBox(); txtCode = new TextBox();
@@ -105,7 +114,6 @@ namespace FATrace.App
dtpSearchStartTime = new DateTimePicker(); dtpSearchStartTime = new DateTimePicker();
dataGridView1 = new DataGridView(); dataGridView1 = new DataGridView();
label22 = new Label(); label22 = new Label();
btnReprint = new Button();
statusStrip1.SuspendLayout(); statusStrip1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit(); ((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout(); splitContainer1.Panel1.SuspendLayout();
@@ -114,6 +122,8 @@ namespace FATrace.App
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
TabControlMain.SuspendLayout(); TabControlMain.SuspendLayout();
tabPage2.SuspendLayout(); tabPage2.SuspendLayout();
panel4.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox5).BeginInit();
panel3.SuspendLayout(); panel3.SuspendLayout();
((System.ComponentModel.ISupportInitialize)pictureBox4).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox4).BeginInit();
panel2.SuspendLayout(); panel2.SuspendLayout();
@@ -333,6 +343,7 @@ namespace FATrace.App
// //
// tabPage2 // tabPage2
// //
tabPage2.Controls.Add(panel4);
tabPage2.Controls.Add(panel3); tabPage2.Controls.Add(panel3);
tabPage2.Controls.Add(panel2); tabPage2.Controls.Add(panel2);
tabPage2.Controls.Add(panel1); tabPage2.Controls.Add(panel1);
@@ -344,6 +355,96 @@ namespace FATrace.App
tabPage2.TabIndex = 1; tabPage2.TabIndex = 1;
tabPage2.UseVisualStyleBackColor = true; tabPage2.UseVisualStyleBackColor = true;
// //
// panel4
//
panel4.BorderStyle = BorderStyle.FixedSingle;
panel4.Controls.Add(btnConfigSave);
panel4.Controls.Add(label30);
panel4.Controls.Add(pictureBox5);
panel4.Controls.Add(txtWeightDown);
panel4.Controls.Add(label29);
panel4.Controls.Add(label31);
panel4.Controls.Add(txtWeightUp);
panel4.Dock = DockStyle.Bottom;
panel4.Location = new Point(3, 559);
panel4.Name = "panel4";
panel4.Size = new Size(878, 131);
panel4.TabIndex = 4;
//
// btnConfigSave
//
btnConfigSave.Font = new Font("微软雅黑", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
btnConfigSave.ForeColor = SystemColors.ControlDarkDark;
btnConfigSave.Location = new Point(670, 70);
btnConfigSave.Name = "btnConfigSave";
btnConfigSave.Size = new Size(190, 44);
btnConfigSave.TabIndex = 18;
btnConfigSave.Text = "保存并使用";
btnConfigSave.UseVisualStyleBackColor = true;
btnConfigSave.Click += btnConfigSave_Click;
//
// label30
//
label30.AutoSize = true;
label30.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
label30.ForeColor = SystemColors.WindowFrame;
label30.Location = new Point(149, 64);
label30.Name = "label30";
label30.Size = new Size(82, 26);
label30.TabIndex = 19;
label30.Text = "下限(g):";
//
// pictureBox5
//
pictureBox5.BackgroundImageLayout = ImageLayout.None;
pictureBox5.Image = Properties.Resources.;
pictureBox5.Location = new Point(5, 7);
pictureBox5.Name = "pictureBox5";
pictureBox5.Size = new Size(35, 35);
pictureBox5.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox5.TabIndex = 21;
pictureBox5.TabStop = false;
//
// txtWeightDown
//
txtWeightDown.Font = new Font("Microsoft YaHei UI", 12F);
txtWeightDown.Location = new Point(231, 63);
txtWeightDown.Name = "txtWeightDown";
txtWeightDown.Size = new Size(76, 28);
txtWeightDown.TabIndex = 18;
txtWeightDown.Text = "0";
//
// label29
//
label29.AutoSize = true;
label29.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
label29.ForeColor = SystemColors.WindowFrame;
label29.Location = new Point(329, 64);
label29.Name = "label29";
label29.Size = new Size(82, 26);
label29.TabIndex = 16;
label29.Text = "上限(g):";
//
// label31
//
label31.AutoSize = true;
label31.Font = new Font("Microsoft YaHei UI", 18F, FontStyle.Bold);
label31.ForeColor = SystemColors.ControlDarkDark;
label31.Location = new Point(42, 9);
label31.Name = "label31";
label31.Size = new Size(110, 31);
label31.TabIndex = 20;
label31.Text = "称重配置";
//
// txtWeightUp
//
txtWeightUp.Font = new Font("Microsoft YaHei UI", 12F);
txtWeightUp.Location = new Point(414, 63);
txtWeightUp.Name = "txtWeightUp";
txtWeightUp.Size = new Size(76, 28);
txtWeightUp.TabIndex = 15;
txtWeightUp.Text = "200";
//
// panel3 // panel3
// //
panel3.BorderStyle = BorderStyle.FixedSingle; panel3.BorderStyle = BorderStyle.FixedSingle;
@@ -362,6 +463,18 @@ namespace FATrace.App
panel3.Size = new Size(878, 176); panel3.Size = new Size(878, 176);
panel3.TabIndex = 3; panel3.TabIndex = 3;
// //
// btnReprint
//
btnReprint.Font = new Font("微软雅黑", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
btnReprint.ForeColor = SystemColors.ControlDarkDark;
btnReprint.Location = new Point(670, 5);
btnReprint.Name = "btnReprint";
btnReprint.Size = new Size(190, 44);
btnReprint.TabIndex = 17;
btnReprint.Text = "重新打印当前";
btnReprint.UseVisualStyleBackColor = true;
btnReprint.Click += btnReprint_Click;
//
// pictureBox4 // pictureBox4
// //
pictureBox4.BackgroundImageLayout = ImageLayout.None; pictureBox4.BackgroundImageLayout = ImageLayout.None;
@@ -488,7 +601,7 @@ namespace FATrace.App
lblRawUseStateTip.BackColor = Color.LightSalmon; lblRawUseStateTip.BackColor = Color.LightSalmon;
lblRawUseStateTip.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134); lblRawUseStateTip.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
lblRawUseStateTip.ForeColor = SystemColors.ButtonHighlight; lblRawUseStateTip.ForeColor = SystemColors.ButtonHighlight;
lblRawUseStateTip.Location = new Point(159, 102); lblRawUseStateTip.Location = new Point(168, 106);
lblRawUseStateTip.Name = "lblRawUseStateTip"; lblRawUseStateTip.Name = "lblRawUseStateTip";
lblRawUseStateTip.Size = new Size(247, 34); lblRawUseStateTip.Size = new Size(247, 34);
lblRawUseStateTip.TabIndex = 11; lblRawUseStateTip.TabIndex = 11;
@@ -984,18 +1097,6 @@ namespace FATrace.App
label22.Text = "历史数据"; label22.Text = "历史数据";
label22.TextAlign = ContentAlignment.MiddleCenter; label22.TextAlign = ContentAlignment.MiddleCenter;
// //
// btnReprint
//
btnReprint.Font = new Font("微软雅黑", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
btnReprint.ForeColor = SystemColors.ControlDarkDark;
btnReprint.Location = new Point(670, 5);
btnReprint.Name = "btnReprint";
btnReprint.Size = new Size(190, 44);
btnReprint.TabIndex = 17;
btnReprint.Text = "重新打印当前";
btnReprint.UseVisualStyleBackColor = true;
btnReprint.Click += btnReprint_Click;
//
// frmMain // frmMain
// //
AutoScaleDimensions = new SizeF(7F, 17F); AutoScaleDimensions = new SizeF(7F, 17F);
@@ -1020,6 +1121,9 @@ namespace FATrace.App
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
TabControlMain.ResumeLayout(false); TabControlMain.ResumeLayout(false);
tabPage2.ResumeLayout(false); tabPage2.ResumeLayout(false);
panel4.ResumeLayout(false);
panel4.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox5).EndInit();
panel3.ResumeLayout(false); panel3.ResumeLayout(false);
panel3.PerformLayout(); panel3.PerformLayout();
((System.ComponentModel.ISupportInitialize)pictureBox4).EndInit(); ((System.ComponentModel.ISupportInitialize)pictureBox4).EndInit();
@@ -1119,5 +1223,13 @@ namespace FATrace.App
private TextBox txtOpName; private TextBox txtOpName;
private Label label28; private Label label28;
private Button btnReprint; private Button btnReprint;
private Label label29;
private TextBox txtWeightUp;
private Label label30;
private TextBox txtWeightDown;
private Panel panel4;
private PictureBox pictureBox5;
private Label label31;
private Button btnConfigSave;
} }
} }

View File

@@ -1,7 +1,9 @@
using FATrace.App.Model; using FATrace.App.Model;
using FATrace.Com;
using FATrace.Model; using FATrace.Model;
using NLog; using NLog;
using System.Data; using System.Data;
using System.Globalization;
using System.Net.NetworkInformation; using System.Net.NetworkInformation;
using System.Text; using System.Text;
@@ -193,6 +195,16 @@ namespace FATrace.App
public string CurrentOperationNoUserLevel { get; set; } = string.Empty; public string CurrentOperationNoUserLevel { get; set; } = string.Empty;
/// <summary>
/// 称重上限
/// </summary>
private double WeightUp { get; set; }
/// <summary>
/// 称重下限
/// </summary>
private double WeightDown { get; set; }
/// <summary> /// <summary>
/// 计算扫描 Task /// 计算扫描 Task
/// </summary> /// </summary>
@@ -220,6 +232,18 @@ namespace FATrace.App
var scaleIp = "192.168.0.80"; // 仪表的 TCP Server IP示例值实际请替换 var scaleIp = "192.168.0.80"; // 仪表的 TCP Server IP示例值实际请替换
var scalePort = 10251; // 仪表的 TCP Server 端口(示例值,实际请替换) var scalePort = 10251; // 仪表的 TCP Server 端口(示例值,实际请替换)
if (double.TryParse(ConfigHelper.GetStringOrDefault("WeightUp", "10"), out var weightUp))
{
WeightUp = weightUp;
}
if (double.TryParse(ConfigHelper.GetStringOrDefault("WeightDown", "200"), out var weightDown))
{
WeightDown = weightDown;
}
txtWeightUp.Text = weightUp.ToString();
txtWeightDown.Text = weightDown.ToString();
//日产量初始获取信息 //日产量初始获取信息
CurDayCount = GetDayCount(); CurDayCount = GetDayCount();
@@ -324,6 +348,8 @@ namespace FATrace.App
} }
} }
CurDaySgl.CurDay = DateTime.Now.ToString("yyyy-MM-dd");
// 每30秒检测一次服务器与打印机 // 每30秒检测一次服务器与打印机
loop = (loop + 1) % 1000000; loop = (loop + 1) % 1000000;
if (loop % 10 == 0) if (loop % 10 == 0)
@@ -662,6 +688,22 @@ namespace FATrace.App
return; return;
} }
if (WeightDown > 0 && WeightUp > 0)
{
if (CurWeight < WeightDown || CurWeight > WeightUp)
{
DialogResult resultRangeCheck = frmMessage.ShowConfirm($"检测到当前重量 {CurWeight:0.###}g 不在配置范围 [{WeightDown:0.###}g, {WeightUp:0.###}g] 内,确定要【打印】操作吗?", "确认操作", this);
if (resultRangeCheck == DialogResult.Cancel)
{
return;
}
else
{
logger.Info("你打印了一个不在配置范围内的重量!!!");
}
}
}
//确认数据 //确认数据
// 显示消息框,并等待用户响应 // 显示消息框,并等待用户响应
DialogResult result = frmMessage.ShowConfirm("确定要【打印】操作吗?", "确认操作", this); DialogResult result = frmMessage.ShowConfirm("确定要【打印】操作吗?", "确认操作", this);
@@ -670,16 +712,16 @@ namespace FATrace.App
return; return;
} }
if (CurWeight < 2.0) //if (CurWeight < 2.0)
{ //{
//确认数据 // //确认数据
// 显示消息框,并等待用户响应 // // 显示消息框,并等待用户响应
DialogResult resultWeightCheck = frmMessage.ShowConfirm("检测到当前的重量小于2g确定要【打印】操作吗", "确认操作", this); // DialogResult resultWeightCheck = frmMessage.ShowConfirm("检测到当前的重量小于2g确定要【打印】操作吗", "确认操作", this);
if (resultWeightCheck == DialogResult.Cancel) // if (resultWeightCheck == DialogResult.Cancel)
{ // {
return; // return;
} // }
} //}
//新的剩余重量 Kg //新的剩余重量 Kg
@@ -811,6 +853,7 @@ namespace FATrace.App
var CurDayCountInfo = FSqlContext.FDb.Select<DayCount>().Where(a => a.DayInfo == DateTime.Now.ToString("yyyy-MM-dd")).First(); var CurDayCountInfo = FSqlContext.FDb.Select<DayCount>().Where(a => a.DayInfo == DateTime.Now.ToString("yyyy-MM-dd")).First();
if (CurDayCountInfo == null) if (CurDayCountInfo == null)
{ {
logger.Info($"日产量信息不存在,新建日产量信息");
//当日的日产量信息不存在,第一次的话就新建信息 //当日的日产量信息不存在,第一次的话就新建信息
var ReturnData = FSqlContext.FDb.Insert<DayCount>(new DayCount() var ReturnData = FSqlContext.FDb.Insert<DayCount>(new DayCount()
{ {
@@ -1340,5 +1383,65 @@ namespace FATrace.App
} }
/// <summary>
/// 保存配置到Config并使用
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void btnConfigSave_Click(object sender, EventArgs e)
{
try
{
var downText = (txtWeightDown.Text ?? string.Empty).Trim();
var upText = (txtWeightUp.Text ?? string.Empty).Trim();
if (string.IsNullOrWhiteSpace(downText) ||
!double.TryParse(downText.Replace('', '.').Replace('。', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var down) || down <= 0)
{
MessageBox.Show("请输入有效的下限(g),必须为正数。", "校验失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtWeightDown.Focus();
txtWeightDown.SelectAll();
return;
}
if (string.IsNullOrWhiteSpace(upText) ||
!double.TryParse(upText.Replace('', '.').Replace('。', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out var up) || up <= 0)
{
MessageBox.Show("请输入有效的上限(g),必须为正数。", "校验失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtWeightUp.Focus();
txtWeightUp.SelectAll();
return;
}
if (down >= up)
{
MessageBox.Show("下限(g)必须小于上限(g)。", "校验失败", MessageBoxButtons.OK, MessageBoxIcon.Warning);
txtWeightDown.Focus();
txtWeightDown.SelectAll();
return;
}
var downStr = down.ToString("0.###", CultureInfo.InvariantCulture);
var upStr = up.ToString("0.###", CultureInfo.InvariantCulture);
ConfigHelper.SetValue("WeightDown", downStr);
ConfigHelper.SetValue("WeightUp", upStr);
WeightDown = down;
WeightUp = up;
txtWeightDown.Text = downStr;
txtWeightUp.Text = upStr;
logger.Info($"称重配置已更新WeightDown={downStr}g, WeightUp={upStr}g");
MessageBox.Show("配置已保存并立即生效。", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
catch (Exception ex)
{
logger.Error(ex, "保存称重配置失败");
MessageBox.Show($"保存配置失败:{ex.Message}", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
} }
} }

View File

@@ -11,6 +11,7 @@ namespace FATrace.Model
/// 原料生产 使用信息 /// 原料生产 使用信息
/// </summary> /// </summary>
[Table(Name = "RawProUse")] [Table(Name = "RawProUse")]
[Index("idx_RawProUse_WeightTime", "WeightTime")]
public class RawProUse public class RawProUse
{ {
/// <summary> /// <summary>

View File

@@ -50,13 +50,40 @@ namespace FATrace.WPLApp.Services
private void LineSglModel_BoxSprayCodeReqHandle(object? sender, string e) private void LineSglModel_BoxSprayCodeReqHandle(object? sender, string e)
{ {
//首先复位PLC信号 //首先复位PLC信号
var SetValueResult = KeyencePlcMcNet!.Write("D1100", (Int16)0);
if (!SetValueResult.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("外箱喷码-复位PLC信号失败-执行两次写入0");
KeyencePlcMcNet!.Write("D1100", (Int16)0); KeyencePlcMcNet!.Write("D1100", (Int16)0);
KeyencePlcMcNet!.Write("D1100", (Int16)0);
}
//获取箱子喷码的数据+A //获取箱子喷码的数据+A
var ReqData = FreeSql.Select<LineTempCode>() var ReqData = FreeSql.Select<LineTempCode>()
.OrderBy(a => a.Id) .OrderByDescending(a => a.Id)
.Limit(1) .Limit(1)
.ToList(); .ToList();
//无数据再重试一次
if (ReqData.Count <= 0)
{
try
{
Thread.Sleep(50);
}
catch
{
}
ReqData = FreeSql.Select<LineTempCode>()
.OrderByDescending(a => a.Id)
.Limit(1)
.ToList();
LogService.Warn("外箱喷码-不存在请求的数据-重试一次");
}
if (ReqData.Count > 0) if (ReqData.Count > 0)
{ {
var CodeItem = ReqData.FirstOrDefault(); var CodeItem = ReqData.FirstOrDefault();
@@ -65,12 +92,15 @@ namespace FATrace.WPLApp.Services
var BoxSprayCodeRev = RevData(BoxSprayCodeSource); var BoxSprayCodeRev = RevData(BoxSprayCodeSource);
BoxSprayCode = BoxSprayCodeSource; BoxSprayCode = BoxSprayCodeSource;
var Result = KeyencePlcMcNet.Write("D1150", BoxSprayCodeRev);
if (!Result.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("外箱喷码-写入条码 D1150 PLC信号失败-执行两次写入条码");
KeyencePlcMcNet.Write("D1150", BoxSprayCodeRev); KeyencePlcMcNet.Write("D1150", BoxSprayCodeRev);
}
Console.WriteLine($"外箱喷码:{BoxSprayCodeSource}-发送OK"); Console.WriteLine($"外箱喷码:{BoxSprayCodeSource}-发送OK");
//这里需要删除数据吗?还是等扫码后删除,会不会过来新的箱子
} }
else else
{ {
@@ -78,13 +108,22 @@ namespace FATrace.WPLApp.Services
KeyencePlcMcNet.Write("D1102", (Int16)1); KeyencePlcMcNet.Write("D1102", (Int16)1);
Console.WriteLine($"外箱喷码:不存在请求的数据"); Console.WriteLine($"外箱喷码:不存在请求的数据");
AddAlarm("外箱喷码", "不存在请求的数据"); AddAlarm("外箱喷码", "不存在请求的数据");
LogService.Warn("外箱喷码-不存在请求的数据");
} }
Task.Run(async () => Task.Run(async () =>
{ {
await Task.Delay(1000).ConfigureAwait(false); await Task.Delay(1000).ConfigureAwait(false);
var Data = KeyencePlcMcNet!.Write("D1102", (Int16)0);
if (!Data.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("外箱喷码-复位D1102PLC信号失败-执行两次写入0");
KeyencePlcMcNet!.Write("D1102", (Int16)0); KeyencePlcMcNet!.Write("D1102", (Int16)0);
KeyencePlcMcNet!.Write("D1102", (Int16)0);
}
//KeyencePlcMcNet.Write("D1150", new Int16[30]); //KeyencePlcMcNet.Write("D1150", new Int16[30]);
}); });
@@ -99,7 +138,14 @@ namespace FATrace.WPLApp.Services
private void LineSglModel_BoxScanCodeReqHandle(object? sender, string e) private void LineSglModel_BoxScanCodeReqHandle(object? sender, string e)
{ {
//首先复位PLC信号 //首先复位PLC信号
var SetValueResult = KeyencePlcMcNet!.Write("D1200", (Int16)0);
if (!SetValueResult.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("外箱扫描码请求-复位PLC信号失败-执行两次写入0");
KeyencePlcMcNet!.Write("D1200", (Int16)0); KeyencePlcMcNet!.Write("D1200", (Int16)0);
KeyencePlcMcNet!.Write("D1200", (Int16)0);
}
string BoxScanCode = string.Empty; string BoxScanCode = string.Empty;
BoxScanCode = this.BoxScanCode; BoxScanCode = this.BoxScanCode;
@@ -111,7 +157,14 @@ namespace FATrace.WPLApp.Services
if (IsExist.Count() > 0) if (IsExist.Count() > 0)
{ {
//存在条码数据 OK返回PLC结果 //存在条码数据 OK返回PLC结果
var DataResult = KeyencePlcMcNet!.Write("D1210", (Int16)1);
if (!DataResult.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("外箱扫描码请求-置位D1210PLC信号失败-执行两次写入1");
KeyencePlcMcNet!.Write("D1210", (Int16)1); KeyencePlcMcNet!.Write("D1210", (Int16)1);
KeyencePlcMcNet!.Write("D1210", (Int16)1);
}
Console.WriteLine($"外箱扫描码:{BoxScanCode}-存在找到"); Console.WriteLine($"外箱扫描码:{BoxScanCode}-存在找到");
// 加入队列 // 加入队列
@@ -181,8 +234,15 @@ namespace FATrace.WPLApp.Services
Task.Run(async () => Task.Run(async () =>
{ {
await Task.Delay(1000).ConfigureAwait(false); await Task.Delay(1200).ConfigureAwait(false);
var DataResult = KeyencePlcMcNet!.Write("D1210", (Int16)0);
if (!DataResult.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("外箱扫描码请求-复位D1210PLC信号失败-执行两次写入0");
KeyencePlcMcNet!.Write("D1210", (Int16)0); KeyencePlcMcNet!.Write("D1210", (Int16)0);
KeyencePlcMcNet!.Write("D1210", (Int16)0);
}
KeyencePlcMcNet.Write("D1250", new Int16[30]); KeyencePlcMcNet.Write("D1250", new Int16[30]);
}); });
@@ -198,7 +258,14 @@ namespace FATrace.WPLApp.Services
private void LineSglModel_WeightScanCodeHandle(object? sender, string e) private void LineSglModel_WeightScanCodeHandle(object? sender, string e)
{ {
//首先复位PLC信号 //首先复位PLC信号
var SetValueResult = KeyencePlcMcNet!.Write("D1000", (Int16)0);
if (!SetValueResult.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("称重扫描码-复位PLC信号失败-执行两次写入0");
KeyencePlcMcNet!.Write("D1000", (Int16)0); KeyencePlcMcNet!.Write("D1000", (Int16)0);
KeyencePlcMcNet!.Write("D1000", (Int16)0);
}
if (!string.IsNullOrEmpty(WeightScanCode)) if (!string.IsNullOrEmpty(WeightScanCode))
{ {
@@ -206,17 +273,40 @@ namespace FATrace.WPLApp.Services
if (IsExist.Count() > 0) if (IsExist.Count() > 0)
{ {
//存在条码数据 OK返回PLC结果 //存在条码数据 OK返回PLC结果
var SetValueResult1 = KeyencePlcMcNet!.Write("D1010", (Int16)1);
if (!SetValueResult1.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("称重扫描码-置位数据D1010 PLC信号失败-执行两次写入1");
KeyencePlcMcNet!.Write("D1010", (Int16)1); KeyencePlcMcNet!.Write("D1010", (Int16)1);
KeyencePlcMcNet!.Write("D1010", (Int16)1);
}
Console.WriteLine($"称重扫描码:{WeightScanCode}"); Console.WriteLine($"称重扫描码:{WeightScanCode}");
//// 加入队列 //// 加入队列
//EnqueueMessage(WeightScanCode); //EnqueueMessage(WeightScanCode);
LogService.Info($"称重扫描码:{WeightScanCode}"); LogService.Info($"称重扫描码:{WeightScanCode}");
var TempData = FreeSql.Insert<LineTempCode>(new LineTempCode() try
{
var delAff = FreeSql.Delete<LineTempCode>()
.Where(p => p.Id > 0)
.ExecuteAffrows();
var insAff = FreeSql.Insert<LineTempCode>(new LineTempCode()
{ {
Code = WeightScanCode Code = WeightScanCode
}).ExecuteAffrows(); }).ExecuteAffrows();
if (insAff <= 0)
{
LogService.Warn($"称重扫描码:{WeightScanCode} 写入临时表 LineTempCode 失败(affrows={insAff})delAff={delAff}");
}
}
catch (Exception ex)
{
LogService.Error($"称重扫描码:{WeightScanCode} 写入临时表 LineTempCode 异常: {ex}");
}
try try
{ {
EventAggregator?.GetEvent<DashboardRefreshEvent>()?.Publish(true); EventAggregator?.GetEvent<DashboardRefreshEvent>()?.Publish(true);
@@ -254,8 +344,16 @@ namespace FATrace.WPLApp.Services
Task.Run(async () => Task.Run(async () =>
{ {
await Task.Delay(1000).ConfigureAwait(false); await Task.Delay(1200).ConfigureAwait(false);
//KeyencePlcMcNet!.Write("D1010", (Int16)0);
var SetValueResult2 = KeyencePlcMcNet!.Write("D1010", (Int16)0);
if (!SetValueResult2.IsSuccess)
{
//写入失败,重新写入
LogService.Warn("称重扫描码-复位数据D1010 PLC信号失败-执行两次写入0");
KeyencePlcMcNet!.Write("D1010", (Int16)0); KeyencePlcMcNet!.Write("D1010", (Int16)0);
}
KeyencePlcMcNet.Write("D1050", new Int16[30]); KeyencePlcMcNet.Write("D1050", new Int16[30]);
}); });
@@ -323,7 +421,6 @@ namespace FATrace.WPLApp.Services
} }
// 扫描控制 // 扫描控制
private CancellationTokenSource? _plcScanCts; private CancellationTokenSource? _plcScanCts;
private Task? _plcScanTask; private Task? _plcScanTask;
@@ -331,10 +428,6 @@ namespace FATrace.WPLApp.Services
public bool IsScanning => _isScanning; public bool IsScanning => _isScanning;
private bool _disposed = false; private bool _disposed = false;
/// <summary>
/// 简单字符串队列FIFO
/// </summary>
private readonly ConcurrentQueue<string> _messageQueue = new();
/// <summary> /// <summary>
/// 产线信号模型 /// 产线信号模型
@@ -366,6 +459,7 @@ namespace FATrace.WPLApp.Services
if (connect.IsSuccess)//初始连接状态的显示判断 if (connect.IsSuccess)//初始连接状态的显示判断
{ {
Console.WriteLine($"PLC-连接 OK"); Console.WriteLine($"PLC-连接 OK");
LogService.Error($"PLC-连接 OK");
PlcConnected = true; PlcConnected = true;
try { SysRunService.PlcLinkState = true; SysRunService.SysRunState.ComState = 1; SysRunService.SysRunState.ComMsg = "正常"; } catch { } try { SysRunService.PlcLinkState = true; SysRunService.SysRunState.ComState = 1; SysRunService.SysRunState.ComMsg = "正常"; } catch { }
} }
@@ -400,7 +494,31 @@ namespace FATrace.WPLApp.Services
var token = _plcScanCts.Token; var token = _plcScanCts.Token;
_isScanning = true; _isScanning = true;
try { SysRunService.PlcScanState = 1; } catch { }
_plcScanTask = Task.Run(() => PlcScanLoopAsync(period, token), token); _plcScanTask = Task.Run(() => PlcScanLoopAsync(period, token), token);
_plcScanTask.ContinueWith(t =>
{
try
{
if (t.IsFaulted)
{
try { SysRunService.PlcScanState = 2; } catch { }
try { LogService.Error($"PLC扫描任务异常退出: {t.Exception}"); } catch { }
}
else if (t.IsCanceled)
{
try { SysRunService.PlcScanState = 0; } catch { }
}
else
{
try { SysRunService.PlcScanState = 0; } catch { }
}
}
catch
{
}
}, TaskScheduler.Default);
} }
/// <summary> /// <summary>
@@ -425,6 +543,8 @@ namespace FATrace.WPLApp.Services
_plcScanTask = null; _plcScanTask = null;
_plcScanCts?.Dispose(); _plcScanCts?.Dispose();
_plcScanCts = null; _plcScanCts = null;
try { SysRunService.PlcScanState = 0; } catch { }
} }
} }
@@ -513,13 +633,12 @@ namespace FATrace.WPLApp.Services
} }
} }
catch (OperationCanceledException)
{
break;
}
catch (Exception ex) catch (Exception ex)
{ {
LogService.Error($"PLC 扫描异常: {ex}"); LogService.Error($"PLC 扫描异常 Exception: {ex.ToString()}");
// 这里属于循环内部异常:循环仍会继续;
// 但若后续由于未捕获异常导致扫描任务退出StartPlcScan 的 ContinueWith 也会做最终状态处理。
} }
finally finally
{ {
@@ -527,14 +646,23 @@ namespace FATrace.WPLApp.Services
{ {
await Task.Delay(period, token).ConfigureAwait(false); await Task.Delay(period, token).ConfigureAwait(false);
} }
catch (OperationCanceledException) catch (OperationCanceledException ex)
{ {
// 正常停止扫描时会触发取消,这里不应记录为错误。
// 不允许从 finally 中 break/return // 不允许从 finally 中 break/return
// 这里吞掉异常,循环将在下一次 while 判断时依据 token 自动退出 // 这里吞掉异常,循环将在下一次 while 判断时依据 token 自动退出
} }
} }
} }
_isScanning = false; _isScanning = false;
// 退出循环:如果是正常取消,则 StopPlcScanAsync 会把状态置为停止;
// 若是外部未走 StopPlcScanAsync而 token 已取消,也归为停止。
try
{
if (token.IsCancellationRequested) SysRunService.PlcScanState = 0;
}
catch { }
} }
/// <summary> /// <summary>

View File

@@ -14,6 +14,14 @@ namespace FATrace.WPLApp.Services
{ {
private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); // 初始化日志类 private static readonly Logger Logger = LogManager.GetCurrentClassLogger(); // 初始化日志类
private static bool IsQueryNoise(string msg)
{
if (string.IsNullOrWhiteSpace(msg)) return false;
return msg.IndexOf("查询开始", StringComparison.OrdinalIgnoreCase) >= 0
|| msg.IndexOf("查询完成", StringComparison.OrdinalIgnoreCase) >= 0
|| msg.IndexOf("记录数", StringComparison.OrdinalIgnoreCase) >= 0;
}
/// <summary> /// <summary>
/// 调试日志 /// 调试日志
/// </summary> /// </summary>
@@ -29,8 +37,16 @@ namespace FATrace.WPLApp.Services
/// 适用大部分场景 /// 适用大部分场景
/// 1.记录日志文件 /// 1.记录日志文件
/// </remarks> /// </remarks>
public void Info(string msg) => Logger.Info(msg); public void Info(string msg)
public void Info(string msg, Exception ex) => Logger.Info(ex, msg); {
if (IsQueryNoise(msg)) return;
Logger.Info(msg);
}
public void Info(string msg, Exception ex)
{
if (IsQueryNoise(msg)) return;
Logger.Info(ex, msg);
}
/// <summary> /// <summary>
/// 错误日志 /// 错误日志

View File

@@ -68,6 +68,46 @@ namespace FATrace.WPLApp.Services
set { _PlcLinkState = value;RaisePropertyChanged(); } set { _PlcLinkState = value;RaisePropertyChanged(); }
} }
private int _PlcScanState = 0;
/// <summary>
/// PLC扫描循环状态
/// 0=已停止1=运行中2=异常退出
/// </summary>
public int PlcScanState
{
get { return _PlcScanState; }
set
{
if (_PlcScanState != value)
{
_PlcScanState = value;
switch (value)
{
case 1:
PlcScanMsg = "扫描运行";
break;
case 2:
PlcScanMsg = "扫描异常";
break;
default:
PlcScanMsg = "扫描停止";
break;
}
RaisePropertyChanged();
}
}
}
private string? _PlcScanMsg = "扫描停止";
/// <summary>
/// PLC扫描循环状态消息
/// </summary>
public string? PlcScanMsg
{
get { return _PlcScanMsg; }
set { _PlcScanMsg = value; RaisePropertyChanged(); }
}
private string? _CurUser; private string? _CurUser;
/// <summary> /// <summary>

View File

@@ -41,7 +41,6 @@ namespace FATrace.WPLApp.ViewModels
_ea = ea; _ea = ea;
LiveMessages = new ObservableCollection<string>(); LiveMessages = new ObservableCollection<string>();
LineTempCodes = new ObservableCollection<LineTempCode>();
RefreshCommand = new DelegateCommand(async () => await RefreshStatsAsync()); RefreshCommand = new DelegateCommand(async () => await RefreshStatsAsync());
ClearLogsCommand = new DelegateCommand(() => LiveMessages.Clear()); ClearLogsCommand = new DelegateCommand(() => LiveMessages.Clear());
@@ -168,7 +167,6 @@ namespace FATrace.WPLApp.ViewModels
try try
{ {
await RefreshStatsAsync(); await RefreshStatsAsync();
await RefreshLineTempCodesAsync();
} }
catch (Exception ex) catch (Exception ex)
{ {
@@ -206,11 +204,6 @@ namespace FATrace.WPLApp.ViewModels
public bool PlcConnected { get => _plcConnected; set { _plcConnected = value; RaisePropertyChanged(); } } public bool PlcConnected { get => _plcConnected; set { _plcConnected = value; RaisePropertyChanged(); } }
public ObservableCollection<string> LiveMessages { get; } public ObservableCollection<string> LiveMessages { get; }
/// <summary>
/// 产线临时条码队列(内包扫码入队,外箱扫码确认后出队)
/// </summary>
public ObservableCollection<LineTempCode> LineTempCodes { get; }
#endregion #endregion
#region Commands #region Commands
@@ -285,52 +278,6 @@ namespace FATrace.WPLApp.ViewModels
} }
} }
/// <summary>
/// 从数据库刷新产线临时队列LineTempCode 表)并同步到 UI。
/// </summary>
private async Task RefreshLineTempCodesAsync()
{
try
{
var list = await Task.Run(() =>
{
return _fsql.Select<LineTempCode>()
.OrderBy(a => a.Id)
.Limit(200)
.ToList();
});
void apply()
{
LineTempCodes.Clear();
foreach (var item in list)
{
LineTempCodes.Add(item);
}
}
var dispatcher = Application.Current?.Dispatcher;
if (dispatcher == null)
{
apply();
return;
}
if (dispatcher.CheckAccess())
{
apply();
}
else
{
await dispatcher.InvokeAsync(apply).Task.ConfigureAwait(false);
}
}
catch (Exception ex)
{
_log.Error($"刷新 LineTempCode 队列失败: {ex}");
}
}
public override async void OnNavigatedTo(Prism.Regions.NavigationContext navigationContext) public override async void OnNavigatedTo(Prism.Regions.NavigationContext navigationContext)
{ {
try try
@@ -351,7 +298,6 @@ namespace FATrace.WPLApp.ViewModels
LatestWeightScanCode = _data.WeightScanCode; LatestWeightScanCode = _data.WeightScanCode;
LatestBoxScanCode = _data.BoxScanCode; LatestBoxScanCode = _data.BoxScanCode;
LatestBoxSprayCode = _data.BoxSprayCode; LatestBoxSprayCode = _data.BoxSprayCode;
await RefreshLineTempCodesAsync();
TryHookConsole(); TryHookConsole();
} }
} }

View File

@@ -7,7 +7,7 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:prism="http://prismlibrary.com/" xmlns:prism="http://prismlibrary.com/"
d:DesignHeight="720" d:DesignHeight="720"
d:DesignWidth="1280" d:DesignWidth="1580"
prism:ViewModelLocator.AutoWireViewModel="True" prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"> mc:Ignorable="d">
<Grid Margin="12"> <Grid Margin="12">
@@ -227,92 +227,100 @@
</Border> </Border>
</Grid> </Grid>
<!-- 底部:预留区域 --> <Grid Grid.Row="2">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="3*" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- 工艺图区域 -->
<Border <Border
Grid.Row="2" Grid.ColumnSpan="2"
Margin="0,10,0,0" Margin="0,10,0,0"
Padding="12" Padding="12"
Background="#F9FAFB" Background="#F9FAFB"
BorderBrush="#DDE3EB" BorderBrush="#DDE3EB"
BorderThickness="1" BorderThickness="1"
CornerRadius="6"> CornerRadius="6" />
<Canvas Margin="-3,0,0,0">
<Canvas Margin="0,0,0,0">
<Rectangle <Rectangle
Canvas.Top="136.567" Canvas.Left="53"
Canvas.Top="136"
Width="62" Width="62"
Height="97" Height="97"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Center" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="181" Canvas.Left="181.5"
Canvas.Top="276.816" Canvas.Top="321.709"
Width="62" Width="62"
Height="11" Height="11"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="181" Canvas.Left="181.5"
Canvas.Top="286.817" Canvas.Top="331.71"
Width="62" Width="62"
Height="11" Height="11"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="181" Canvas.Left="181.5"
Canvas.Top="296.818" Canvas.Top="341.711"
Width="62" Width="62"
Height="11" Height="11"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="181" Canvas.Left="181.5"
Canvas.Top="306.902" Canvas.Top="351.795"
Width="62" Width="62"
Height="11" Height="11"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="181" Canvas.Left="181.5"
Canvas.Top="316.82" Canvas.Top="361.713"
Width="62" Width="62"
Height="11" Height="11"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="174.5" Canvas.Left="175"
Canvas.Top="218.816" Canvas.Top="263.709"
Width="75" Width="75"
Height="57" Height="57"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="248.5" Canvas.Left="249"
Canvas.Top="234.066" Canvas.Top="278.959"
Width="10" Width="10"
Height="26" Height="26"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Label <Label
Canvas.Left="185.13" Canvas.Left="185.63"
Canvas.Top="234.826" Canvas.Top="279.719"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Content="X光机器" /> Content="X光机器" />
<Rectangle <Rectangle
Canvas.Left="165.5" Canvas.Left="166"
Canvas.Top="234.066" Canvas.Top="278.959"
Width="10" Width="10"
Height="26" Height="26"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Path <Path
@@ -328,370 +336,372 @@
</Path.Data> </Path.Data>
</Path> </Path>
<Rectangle <Rectangle
Canvas.Left="281.25" Canvas.Left="281.75"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="144" Width="144"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="289.5" Canvas.Left="290"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="298.501" Canvas.Left="299.001"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="307.502" Canvas.Left="308.002"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="316.503" Canvas.Left="317.003"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="325.504" Canvas.Left="326.004"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="334.51" Canvas.Left="335.01"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="343.511" Canvas.Left="344.011"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="352.503" Canvas.Left="353.003"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="361.504" Canvas.Left="362.004"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="370.505" Canvas.Left="371.005"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="379.506" Canvas.Left="380.006"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="388.507" Canvas.Left="389.007"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="397.513" Canvas.Left="398.013"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="406.514" Canvas.Left="407.014"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="424.251" Canvas.Left="424.751"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="70" Width="70"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="556.251" Canvas.Left="556.751"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="297" Width="297"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="493.242" Canvas.Left="493.742"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="502.243" Canvas.Left="502.743"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="511.244" Canvas.Left="511.744"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="520.25" Canvas.Left="520.75"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="529.251" Canvas.Left="529.751"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="538.244" Canvas.Left="538.744"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="547.25" Canvas.Left="547.75"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="564.492" Canvas.Left="564.992"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="573.493" Canvas.Left="573.993"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="582.494" Canvas.Left="582.994"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="591.5" Canvas.Left="592"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="600.501" Canvas.Left="601.001"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="609.494" Canvas.Left="609.994"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="618.5" Canvas.Left="619"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="627.493" Canvas.Left="627.993"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="636" Canvas.Left="636.5"
Canvas.Top="88" Canvas.Top="132.893"
Width="54" Width="54"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Center"
Stroke="Black" />
<Rectangle
Canvas.Left="771.84"
Canvas.Top="88.066"
Width="10"
Height="62"
HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="780.833" Canvas.Left="772.34"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="789.839" Canvas.Left="781.333"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="798.832" Canvas.Left="790.339"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="807.833" Canvas.Left="799.332"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="816.839" Canvas.Left="808.333"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="825.84" Canvas.Left="817.339"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="834.833" Canvas.Left="826.34"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="10" Width="10"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="511.244" Canvas.Left="835.333"
Canvas.Top="149.4" Canvas.Top="132.959"
Width="10"
Height="62"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Stroke="Black" />
<Rectangle
Canvas.Left="511.744"
Canvas.Top="194.293"
Width="70" Width="70"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="852.251" Canvas.Left="852.751"
Canvas.Top="88.066" Canvas.Top="132.959"
Width="70" Width="70"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="852.251" Canvas.Left="852.751"
Canvas.Top="149.4" Canvas.Top="194.293"
Width="70" Width="70"
Height="98" Height="98"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Rectangle <Rectangle
Canvas.Left="929" Canvas.Left="929.5"
Canvas.Top="288" Canvas.Top="332.893"
Width="70" Width="70"
Height="62" Height="62"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Center" VerticalAlignment="Top"
Stroke="Black" /> Stroke="Black" />
<Path <Path
Canvas.Left="174.496" Canvas.Left="174.996"
Canvas.Top="87.882" Canvas.Top="132.775"
Width="107" Width="107"
Height="132" Height="132"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Fill="#FFF4F4F5" Fill="#FFF4F4F5"
Stretch="Fill" Stretch="Fill"
Stroke="Black"> Stroke="Black">
@@ -700,10 +710,12 @@
</Path.Data> </Path.Data>
</Path> </Path>
<Path <Path
Canvas.Left="247.74" Canvas.Left="248.24"
Canvas.Top="148.882" Canvas.Top="193.775"
Width="34" Width="34"
Height="71" Height="71"
HorizontalAlignment="Center"
VerticalAlignment="Top"
Fill="#FFF4F4F5" Fill="#FFF4F4F5"
Stretch="Fill" Stretch="Fill"
Stroke="Black"> Stroke="Black">
@@ -712,45 +724,45 @@
</Path.Data> </Path.Data>
</Path> </Path>
<Label <Label
Canvas.Left="437" Canvas.Left="437.5"
Canvas.Top="105" Canvas.Top="149.893"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Content="称重机" /> Content="称重机" />
<Label <Label
Canvas.Left="525.25" Canvas.Left="525.75"
Canvas.Top="171.762" Canvas.Top="216.655"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Content="控制柜" /> Content="控制柜" />
<Label <Label
Canvas.Left="704.751" Canvas.Left="705.251"
Canvas.Top="106.446" Canvas.Top="151.339"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Content="封箱机" /> Content="封箱机" />
<Label <Label
Canvas.Left="852" Canvas.Left="852.5"
Canvas.Top="189" Canvas.Top="233.893"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Content="喷码和扫码" /> Content="喷码和扫码" />
<Label <Label
Canvas.Left="8" Canvas.Left="61"
Canvas.Top="171.762" Canvas.Top="171"
HorizontalAlignment="Left" HorizontalAlignment="Left"
VerticalAlignment="Top" VerticalAlignment="Top"
Content="称重侧" /> Content="称重侧" />
<Label <Label
Canvas.Left="943.244" Canvas.Left="943.744"
Canvas.Top="305.133" Canvas.Top="350.026"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Content="工作站" /> Content="工作站" />
<Label <Label
Canvas.Left="927" Canvas.Left="927.5"
Canvas.Top="147" Canvas.Top="191.893"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Background="SkyBlue" Background="SkyBlue"
Content="喷码数据" Content="喷码数据"
@@ -758,8 +770,8 @@
FontWeight="Bold" /> FontWeight="Bold" />
<TextBlock <TextBlock
x:Name="喷码数据" x:Name="喷码数据"
Canvas.Left="927" Canvas.Left="927.5"
Canvas.Top="178" Canvas.Top="222.893"
Padding="2" Padding="2"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
@@ -768,9 +780,9 @@
Text="{Binding LatestBoxSprayCode}" Text="{Binding LatestBoxSprayCode}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<Label <Label
Canvas.Left="928" Canvas.Left="928.5"
Canvas.Top="207" Canvas.Top="251.893"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Background="SkyBlue" Background="SkyBlue"
Content="外箱扫码数据" Content="外箱扫码数据"
@@ -778,8 +790,8 @@
FontWeight="Bold" /> FontWeight="Bold" />
<TextBlock <TextBlock
x:Name="外箱扫码数据" x:Name="外箱扫码数据"
Canvas.Left="929" Canvas.Left="929.5"
Canvas.Top="238" Canvas.Top="282.893"
Padding="2" Padding="2"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
@@ -788,15 +800,15 @@
Text="{Binding LatestBoxScanCode}" Text="{Binding LatestBoxScanCode}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<Label <Label
Canvas.Left="634" Canvas.Left="634.5"
Canvas.Top="105" Canvas.Top="149.893"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Content="内包扫码" /> Content="内包扫码" />
<Label <Label
Canvas.Left="639" Canvas.Left="639.5"
Canvas.Top="27" Canvas.Top="71.893"
HorizontalAlignment="Left" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
Background="SkyBlue" Background="SkyBlue"
Content="内包扫码数据" Content="内包扫码数据"
@@ -804,8 +816,8 @@
FontWeight="Bold" /> FontWeight="Bold" />
<TextBlock <TextBlock
x:Name="内包扫码数据" x:Name="内包扫码数据"
Canvas.Left="639" Canvas.Left="639.5"
Canvas.Top="59" Canvas.Top="103.893"
Padding="2" Padding="2"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
@@ -813,40 +825,67 @@
FontSize="12" FontSize="12"
Text="{Binding LatestWeightScanCode}" Text="{Binding LatestWeightScanCode}"
TextWrapping="Wrap" /> TextWrapping="Wrap" />
<ListView
x:Name="LineTempCodeList" <TextBlock
Canvas.Left="1138" Canvas.Left="33"
Canvas.Top="5" Canvas.Top="37"
Width="420"
Height="425"
HorizontalAlignment="Center" HorizontalAlignment="Center"
VerticalAlignment="Top" VerticalAlignment="Top"
d:ItemsSource="{d:SampleData ItemCount=5}" FontFamily="/Assets/Fonts/#iconfont"
BorderBrush="Gray" FontSize="40"
BorderThickness="1" Foreground="DeepSkyBlue"
ItemsSource="{Binding LineTempCodes}"> Text="&#xe9f4;" />
<ListView.View> <Label
<GridView> Canvas.Left="83"
<GridViewColumn Canvas.Top="32"
Width="50" HorizontalAlignment="Center"
DisplayMemberBinding="{Binding Id}" VerticalAlignment="Top"
Header="序号" /> Content="布局概要图"
<GridViewColumn FontSize="32"
Width="200" FontWeight="Bold"
DisplayMemberBinding="{Binding Code}" Foreground="Gray" />
Header="条码" />
<GridViewColumn
Width="150"
DisplayMemberBinding="{Binding CreateTime, StringFormat='MM-dd HH:mm:ss'}"
Header="时间" />
</GridView>
</ListView.View>
</ListView>
</Canvas> </Canvas>
</Border> <Grid Grid.Column="1">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="3*" />
</Grid.RowDefinitions>
<StackPanel Margin="10" Orientation="Horizontal">
<TextBlock
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontFamily="/Assets/Fonts/#iconfont"
FontSize="40"
Foreground="DeepSkyBlue"
Text="&#xe636;" />
<Label
Margin="10,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="提示"
FontSize="32"
FontWeight="Bold"
Foreground="Gray" />
</StackPanel>
<StackPanel Grid.Row="1">
<TextBlock>
<Run
FontSize="30"
FontWeight="Bold"
Foreground="DeepSkyBlue">
常见检查事项:
</Run><LineBreak /><LineBreak />
<Run FontSize="24">1.检查产线电气柜上电</Run><LineBreak />
<Run FontSize="24">2.检查软件是否打开</Run><LineBreak />
<Run FontSize="24">3.检查软件底部的状态</Run><LineBreak />
<Run FontSize="24">4.检查喷码器状态</Run><LineBreak />
</TextBlock>
</StackPanel>
</Grid>
</Grid>
</Grid> </Grid>

View File

@@ -13,7 +13,7 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="2*" /> <ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="2*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
@@ -137,5 +137,43 @@
</StackPanel> </StackPanel>
</Border> </Border>
<Border Grid.Column="3">
<Border.Style>
<Style BasedOn="{StaticResource BoardStyle}" TargetType="Border">
<Style.Triggers>
<DataTrigger Binding="{Binding SysRunService.PlcScanState}" Value="1">
<Setter Property="Background" Value="LimeGreen" />
</DataTrigger>
<DataTrigger Binding="{Binding SysRunService.PlcScanState}" Value="2">
<Setter Property="Background" Value="OrangeRed" />
</DataTrigger>
</Style.Triggers>
</Style>
</Border.Style>
<StackPanel Style="{StaticResource StackPanelStyle}">
<Ellipse
Width="10"
Height="10"
Margin="0,0,6,0">
<Ellipse.Style>
<Style TargetType="Ellipse">
<Setter Property="Fill" Value="Red" />
<Style.Triggers>
<DataTrigger Binding="{Binding SysRunService.PlcScanState}" Value="1">
<Setter Property="Fill" Value="Lime" />
</DataTrigger>
<DataTrigger Binding="{Binding SysRunService.PlcScanState}" Value="2">
<Setter Property="Fill" Value="Orange" />
</DataTrigger>
</Style.Triggers>
</Style>
</Ellipse.Style>
</Ellipse>
<TextBlock Style="{StaticResource TextBlockIcon}" Text="&#xe776;" />
<TextBlock Style="{StaticResource TextBlockStyle}" Text="PLC扫描:" />
<TextBlock Style="{StaticResource TextBlockStyle}" Text="{Binding SysRunService.PlcScanMsg}" />
</StackPanel>
</Border>
</Grid> </Grid>
</UserControl> </UserControl>

View File

@@ -207,19 +207,53 @@
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="100"
Binding="{Binding ShelfLife}" Binding="{Binding ShelfLife}"
Header="保质期()" /> Header="保质期()" />
<DataGridTextColumn <DataGridTextColumn
Width="120" Width="120"
Binding="{Binding RawSource}" Binding="{Binding RawSource}"
Header="原料来源" /> Header="原料来源" />
<DataGridTextColumn <DataGridTextColumn
Width="120" Width="120"
Binding="{Binding RemainWeight}" Binding="{Binding RemainWeight, StringFormat=F5}"
Header="剩余重量(kg)" /> Header="剩余重量(kg)" />
<DataGridTextColumn <DataGridTemplateColumn Width="120" Header="分拆状态">
Width="120" <DataGridTemplateColumn.CellStyle>
Binding="{Binding RawState}" <Style TargetType="DataGridCell">
Header="分拆状态" /> <Setter Property="HorizontalContentAlignment" Value="Center" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="Black" />
<Style.Triggers>
<DataTrigger Binding="{Binding RawState}" Value="2">
<Setter Property="Background" Value="LimeGreen" />
<Setter Property="Foreground" Value="White" />
</DataTrigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FF3399FF" />
<Setter Property="Foreground" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</DataGridTemplateColumn.CellStyle>
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock HorizontalAlignment="Center">
<TextBlock.Style>
<Style TargetType="TextBlock">
<Setter Property="Text" Value="{Binding RawState}" />
<Style.Triggers>
<DataTrigger Binding="{Binding RawState}" Value="0">
<Setter Property="Text" Value="分拆中" />
</DataTrigger>
<DataTrigger Binding="{Binding RawState}" Value="2">
<Setter Property="Text" Value="分拆完成" />
</DataTrigger>
</Style.Triggers>
</Style>
</TextBlock.Style>
</TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn <DataGridTextColumn
Width="160" Width="160"
Binding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" Binding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}"

View File

@@ -181,10 +181,33 @@
Margin="0,10,0,10" Margin="0,10,0,10"
AutoGenerateColumns="False" AutoGenerateColumns="False"
CanUserAddRows="False" CanUserAddRows="False"
FontSize="15" FontSize="16"
IsReadOnly="True" IsReadOnly="True"
ItemsSource="{Binding Items}" ItemsSource="{Binding Items}"
RowHeight="34"> RowHeight="34">
<DataGrid.RowStyle>
<Style BasedOn="{StaticResource {x:Type DataGridRow}}" TargetType="DataGridRow">
<Setter Property="Background" Value="LimeGreen" />
<Style.Triggers>
<DataTrigger Binding="{Binding OutTime.Year}" Value="1970">
<Setter Property="Background" Value="White" />
</DataTrigger>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFBEE6FD" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.RowStyle>
<DataGrid.CellStyle>
<Style BasedOn="{StaticResource {x:Type DataGridCell}}" TargetType="DataGridCell">
<Setter Property="Background" Value="{Binding RelativeSource={RelativeSource AncestorType=DataGridRow}, Path=Background}" />
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="#FFBEE6FD" />
</Trigger>
</Style.Triggers>
</Style>
</DataGrid.CellStyle>
<DataGrid.ColumnHeaderStyle> <DataGrid.ColumnHeaderStyle>
<Style TargetType="DataGridColumnHeader"> <Style TargetType="DataGridColumnHeader">
<Setter Property="FontSize" Value="18" /> <Setter Property="FontSize" Value="18" />
@@ -202,11 +225,11 @@
Binding="{Binding RawName}" Binding="{Binding RawName}"
Header="原料名称" /> Header="原料名称" />
<DataGridTextColumn <DataGridTextColumn
Width="260" Width="280"
Binding="{Binding InBagCode}" Binding="{Binding InBagCode}"
Header="内袋二维码" /> Header="内袋二维码" />
<DataGridTextColumn <DataGridTextColumn
Width="260" Width="300"
Binding="{Binding BoxCode}" Binding="{Binding BoxCode}"
Header="外箱二维码" /> Header="外箱二维码" />
<DataGridTextColumn <DataGridTextColumn
@@ -216,19 +239,19 @@
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="100"
Binding="{Binding ShelfLife}" Binding="{Binding ShelfLife}"
Header="保质期()" /> Header="保质期()" />
<DataGridTextColumn <DataGridTextColumn
Width="100" Width="120"
Binding="{Binding Weight}" Binding="{Binding Weight}"
Header="称重重量(g)" /> Header="称重重量(g)" />
<DataGridTextColumn
Width="100"
Binding="{Binding RemainWeight}"
Header="剩余重量(g)" />
<DataGridTextColumn <DataGridTextColumn
Width="120" Width="120"
Binding="{Binding RemainWeight, StringFormat=F5}"
Header="剩余重量(Kg)" />
<DataGridTextColumn
Width="140"
Binding="{Binding StockWeight}" Binding="{Binding StockWeight}"
Header="入库总重量(g)" /> Header="入库总重量(Kg)" />
<DataGridTextColumn <DataGridTextColumn
Width="160" Width="160"
Binding="{Binding WeightTime, StringFormat=yyyy-MM-dd HH:mm:ss}" Binding="{Binding WeightTime, StringFormat=yyyy-MM-dd HH:mm:ss}"
@@ -245,10 +268,10 @@
Width="160" Width="160"
Binding="{Binding OutTime, StringFormat=yyyy-MM-dd HH:mm:ss}" Binding="{Binding OutTime, StringFormat=yyyy-MM-dd HH:mm:ss}"
Header="出库时间" /> Header="出库时间" />
<DataGridTextColumn <!--<DataGridTextColumn
Width="160" Width="160"
Binding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}" Binding="{Binding CreateTime, StringFormat=yyyy-MM-dd HH:mm:ss}"
Header="创建时间" /> Header="创建时间" />-->
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>