|
|
@@ -37,9 +37,9 @@ namespace UAS_MES.Packing
|
|
|
|
|
|
int samplesCount = 0;
|
|
|
|
|
|
- string maxValue = "";//存储最大值
|
|
|
+ //string maxValue = "";//存储最大值
|
|
|
|
|
|
- string minValue = "";//存储最小值
|
|
|
+ //string minValue = "";//存储最小值
|
|
|
|
|
|
List<string> sncodes = new List<string>();//存序列号
|
|
|
List<string> indates = new List<string>();//存时间
|
|
|
@@ -47,8 +47,6 @@ namespace UAS_MES.Packing
|
|
|
|
|
|
string recordSW = ""; //存标准重量
|
|
|
string recordEV = "";//存误差值
|
|
|
-
|
|
|
- bool isKg = false;//记录单位是否KG
|
|
|
public Packing_ProdWeightSet()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
@@ -84,20 +82,20 @@ namespace UAS_MES.Packing
|
|
|
//分条赋值
|
|
|
lvi.SubItems.Add(index+"");
|
|
|
lvi.SubItems.Add(palletcode);
|
|
|
- lvi.SubItems.Add(weigh+pr_cartonunit.Text);
|
|
|
+ lvi.SubItems.Add(weigh);
|
|
|
lvi.SubItems.Add(time.ToString());
|
|
|
//添加结果的信息进去
|
|
|
showResult.Items.Add(lvi);
|
|
|
//更新已称重量最大值最小值
|
|
|
if (index > 1)
|
|
|
{
|
|
|
- maxValue = double.Parse(weigh) > double.Parse(maxValue) ? weigh : maxValue;
|
|
|
- minValue = double.Parse(weigh) < double.Parse(minValue) ? weigh : minValue;
|
|
|
+ //maxValue = double.Parse(weigh) > double.Parse(maxValue) ? weigh : maxValue;
|
|
|
+ //minValue = double.Parse(weigh) < double.Parse(minValue) ? weigh : minValue;
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- maxValue = weigh;
|
|
|
- minValue = weigh;
|
|
|
+ //maxValue = weigh;
|
|
|
+ //minValue = weigh;
|
|
|
//每次添加第一条数据的时候清空list的值
|
|
|
sncodes.Clear();
|
|
|
indates.Clear();
|
|
|
@@ -177,24 +175,16 @@ namespace UAS_MES.Packing
|
|
|
OperateResult.AppendText("<<采样个数不足\n", Color.Red);
|
|
|
return;
|
|
|
}
|
|
|
- double sum = 0;
|
|
|
- //点击取平均值
|
|
|
- foreach (string s in weights)
|
|
|
- {
|
|
|
- sum += double.Parse(s);
|
|
|
- }
|
|
|
- sum = sum / weights.Count;
|
|
|
+ //double sum = 0;
|
|
|
+ ////点击取平均值
|
|
|
+ //foreach (string s in weights)
|
|
|
+ //{
|
|
|
+ // sum += double.Parse(s);
|
|
|
+ //}
|
|
|
+ //sum = sum / weights.Count;
|
|
|
//更新彩盒重量最大值最小值
|
|
|
- if (isKg)
|
|
|
- {
|
|
|
- dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" +Math.Round( (sum + double.Parse(errorValue.Text))/1000) + "', PR_COLORBOXMINW = '" +Math.Round( (sum - double.Parse(errorValue.Text))/1000) + "',PR_COLORBOXUNIT='" + pr_cartonunit.Text + "' where pr_code='" + pr_code.Text + "'", "update");
|
|
|
- OperateResult.AppendText("<<重量设置成功,最大值" +Math.Round( (sum + double.Parse(errorValue.Text))/1000 )+ "kg,最小值" +Math.Round( (sum - double.Parse(errorValue.Text))/1000 ) + "kg\n", Color.Green);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" +Math.Round( (sum + double.Parse(errorValue.Text)) ) + "', PR_COLORBOXMINW = '" + Math.Round((sum - double.Parse(errorValue.Text))) + "',PR_COLORBOXUNIT='" + pr_cartonunit.Text + "' where pr_code='" + pr_code.Text + "'", "update");
|
|
|
- OperateResult.AppendText("<<重量设置成功,最大值"+ Math.Round( (sum + double.Parse(errorValue.Text)) ) + "g,最小值"+ Math.Round((sum - double.Parse(errorValue.Text))) + "g\n", Color.Green);
|
|
|
- }
|
|
|
+ dh.ExecuteSql("update product set PR_COLORBOXMAXW ='" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) + "', PR_COLORBOXMINW = '" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + "' where pr_code='" + pr_code.Text + "'", "update");
|
|
|
+ OperateResult.AppendText("<<重量设置成功,最大值" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) + ",最小值" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + "g\n", Color.Green);
|
|
|
//更新采样记录表
|
|
|
string serialNum = dh.GetSerialNumberByCaller("ProdWeightSample");
|
|
|
sql.Clear();
|
|
|
@@ -242,7 +232,8 @@ namespace UAS_MES.Packing
|
|
|
return;
|
|
|
}
|
|
|
//判断称重记录是否满足标准重量+-误差值
|
|
|
- if (double.Parse(weight.Text)<(double.Parse(standardWeight.Text)- double.Parse(errorValue.Text))|| double.Parse(weight.Text) >(double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)))
|
|
|
+ double ActualWeight = double.Parse(weight.Text == "" ? "0" : weight.Text.Replace("kg", "").Trim());
|
|
|
+ if (ActualWeight < (double.Parse(standardWeight.Text)- double.Parse(errorValue.Text))|| ActualWeight > (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)))
|
|
|
{
|
|
|
OperateResult.AppendText("<<序列号" + sncode.Text + "重量不在预设范围内\n", Color.Red, sncode);
|
|
|
return;
|
|
|
@@ -339,7 +330,6 @@ namespace UAS_MES.Packing
|
|
|
{
|
|
|
//产品更换的时候
|
|
|
DataTable d = (DataTable)dh.ExecuteSql("select PR_COLORBOXMAXW,PR_COLORBOXMINW,PR_COLORBOXUNIT from product where pr_code='" + pr_code.Text + "'", "select");
|
|
|
- isKg = false;
|
|
|
//给标准重量赋值
|
|
|
if (d.Rows[0]["PR_COLORBOXMAXW"].ToString() == "" || d.Rows[0]["PR_COLORBOXMINW"].ToString() == "")
|
|
|
{
|
|
|
@@ -349,12 +339,8 @@ namespace UAS_MES.Packing
|
|
|
{
|
|
|
//取二者平均值来
|
|
|
standardWeight.Text = (double.Parse(d.Rows[0]["PR_COLORBOXMAXW"].ToString()) + double.Parse(d.Rows[0]["PR_COLORBOXMINW"].ToString())) / 2 + "";
|
|
|
- if (d.Rows[0]["PR_COLORBOXUNIT"].ToString()=="kg")
|
|
|
- {
|
|
|
- isKg = true;
|
|
|
- standardWeight.Text = double.Parse(standardWeight.Text) * 1000 + "";
|
|
|
- }
|
|
|
}
|
|
|
+ unit.Text = d.Rows[0]["PR_COLORBOXUNIT"].ToString();
|
|
|
//取误差值
|
|
|
errorValue.Text = dh.GetConfig("prodWeightErrorValue", "MESSetting").ToString();
|
|
|
//查询重量设置采样个数
|