修改已知问题
This commit is contained in:
@@ -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