修改已知问题
This commit is contained in:
@@ -8,6 +8,8 @@
|
||||
<add key="PLCIP" value="127.0.0.1" />
|
||||
<add key="PLCPort" value="6000" />
|
||||
<add key="PLCScan" value="600" />
|
||||
<add key="WeightUp" value="105.25" />
|
||||
<add key="WeightDown" value="180.23" />
|
||||
</appSettings>
|
||||
|
||||
</configuration>
|
||||
@@ -16,7 +16,7 @@ namespace FATrace.App
|
||||
{
|
||||
return new FreeSql.FreeSqlBuilder()
|
||||
.UseConnectionString(FreeSql.DataType.SqlServer, connectionString)
|
||||
.UseAutoSyncStructure(true)
|
||||
.UseAutoSyncStructure(false)
|
||||
.Build();
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
140
FATrace.App/frmMain.Designer.cs
generated
140
FATrace.App/frmMain.Designer.cs
generated
@@ -48,7 +48,16 @@ namespace FATrace.App
|
||||
btnHistoryData = new Button();
|
||||
TabControlMain = new TabControl();
|
||||
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();
|
||||
btnReprint = new Button();
|
||||
pictureBox4 = new PictureBox();
|
||||
btnWeightPrint = new Button();
|
||||
txtCode = new TextBox();
|
||||
@@ -105,7 +114,6 @@ namespace FATrace.App
|
||||
dtpSearchStartTime = new DateTimePicker();
|
||||
dataGridView1 = new DataGridView();
|
||||
label22 = new Label();
|
||||
btnReprint = new Button();
|
||||
statusStrip1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
|
||||
splitContainer1.Panel1.SuspendLayout();
|
||||
@@ -114,6 +122,8 @@ namespace FATrace.App
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
TabControlMain.SuspendLayout();
|
||||
tabPage2.SuspendLayout();
|
||||
panel4.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox5).BeginInit();
|
||||
panel3.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox4).BeginInit();
|
||||
panel2.SuspendLayout();
|
||||
@@ -333,6 +343,7 @@ namespace FATrace.App
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
tabPage2.Controls.Add(panel4);
|
||||
tabPage2.Controls.Add(panel3);
|
||||
tabPage2.Controls.Add(panel2);
|
||||
tabPage2.Controls.Add(panel1);
|
||||
@@ -344,6 +355,96 @@ namespace FATrace.App
|
||||
tabPage2.TabIndex = 1;
|
||||
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.BorderStyle = BorderStyle.FixedSingle;
|
||||
@@ -362,6 +463,18 @@ namespace FATrace.App
|
||||
panel3.Size = new Size(878, 176);
|
||||
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.BackgroundImageLayout = ImageLayout.None;
|
||||
@@ -488,7 +601,7 @@ namespace FATrace.App
|
||||
lblRawUseStateTip.BackColor = Color.LightSalmon;
|
||||
lblRawUseStateTip.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
|
||||
lblRawUseStateTip.ForeColor = SystemColors.ButtonHighlight;
|
||||
lblRawUseStateTip.Location = new Point(159, 102);
|
||||
lblRawUseStateTip.Location = new Point(168, 106);
|
||||
lblRawUseStateTip.Name = "lblRawUseStateTip";
|
||||
lblRawUseStateTip.Size = new Size(247, 34);
|
||||
lblRawUseStateTip.TabIndex = 11;
|
||||
@@ -984,18 +1097,6 @@ namespace FATrace.App
|
||||
label22.Text = "历史数据";
|
||||
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
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
@@ -1020,6 +1121,9 @@ namespace FATrace.App
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).EndInit();
|
||||
TabControlMain.ResumeLayout(false);
|
||||
tabPage2.ResumeLayout(false);
|
||||
panel4.ResumeLayout(false);
|
||||
panel4.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox5).EndInit();
|
||||
panel3.ResumeLayout(false);
|
||||
panel3.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox4).EndInit();
|
||||
@@ -1119,5 +1223,13 @@ namespace FATrace.App
|
||||
private TextBox txtOpName;
|
||||
private Label label28;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,9 @@
|
||||
using FATrace.App.Model;
|
||||
using FATrace.Com;
|
||||
using FATrace.Model;
|
||||
using NLog;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.Net.NetworkInformation;
|
||||
using System.Text;
|
||||
|
||||
@@ -193,6 +195,16 @@ namespace FATrace.App
|
||||
|
||||
public string CurrentOperationNoUserLevel { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// 称重上限
|
||||
/// </summary>
|
||||
private double WeightUp { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 称重下限
|
||||
/// </summary>
|
||||
private double WeightDown { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 计算扫描 Task
|
||||
/// </summary>
|
||||
@@ -220,6 +232,18 @@ namespace FATrace.App
|
||||
var scaleIp = "192.168.0.80"; // 仪表的 TCP Server IP(示例值,实际请替换)
|
||||
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();
|
||||
|
||||
@@ -324,6 +348,8 @@ namespace FATrace.App
|
||||
}
|
||||
}
|
||||
|
||||
CurDaySgl.CurDay = DateTime.Now.ToString("yyyy-MM-dd");
|
||||
|
||||
// 每30秒检测一次服务器与打印机
|
||||
loop = (loop + 1) % 1000000;
|
||||
if (loop % 10 == 0)
|
||||
@@ -662,6 +688,22 @@ namespace FATrace.App
|
||||
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);
|
||||
@@ -670,16 +712,16 @@ namespace FATrace.App
|
||||
return;
|
||||
}
|
||||
|
||||
if (CurWeight < 2.0)
|
||||
{
|
||||
//确认数据
|
||||
// 显示消息框,并等待用户响应
|
||||
DialogResult resultWeightCheck = frmMessage.ShowConfirm("检测到当前的重量小于2g,确定要【打印】操作吗?", "确认操作", this);
|
||||
if (resultWeightCheck == DialogResult.Cancel)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
//if (CurWeight < 2.0)
|
||||
//{
|
||||
// //确认数据
|
||||
// // 显示消息框,并等待用户响应
|
||||
// DialogResult resultWeightCheck = frmMessage.ShowConfirm("检测到当前的重量小于2g,确定要【打印】操作吗?", "确认操作", this);
|
||||
// if (resultWeightCheck == DialogResult.Cancel)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//新的剩余重量 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();
|
||||
if (CurDayCountInfo == null)
|
||||
{
|
||||
logger.Info($"日产量信息不存在,新建日产量信息");
|
||||
//当日的日产量信息不存在,第一次的话就新建信息
|
||||
var ReturnData = FSqlContext.FDb.Insert<DayCount>(new DayCount()
|
||||
{
|
||||
@@ -1337,8 +1380,68 @@ namespace FATrace.App
|
||||
{
|
||||
logger.Error(String.Format("ErrSource : {0} ErrMsg : {1}", ex.StackTrace.ToString(), ex.Message.ToString()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user