|
|
@@ -63,7 +63,7 @@ namespace UAS_MES_NEW.Packing
|
|
|
ma_code.TableName = "make left join product on ma_prodcode=pr_code";
|
|
|
ma_code.SelectField = "ma_code # 工单号,pr_code # 产品编号,pr_detail # 产品名称,pr_spec # 规格,ma_qty # 工单数量";
|
|
|
ma_code.FormName = Name;
|
|
|
- ma_code.SetValueField = new string[] { "ma_code","pr_code","pr_detail","pr_spec" };
|
|
|
+ ma_code.SetValueField = new string[] { "ma_code", "pr_code", "pr_detail", "pr_spec" };
|
|
|
ma_code.DbChange += Ma_code_DbChange;
|
|
|
|
|
|
dh = SystemInf.dh;
|
|
|
@@ -77,12 +77,12 @@ namespace UAS_MES_NEW.Packing
|
|
|
//取误差值
|
|
|
errorValue.Text = dh.GetConfig("prodWeightErrorValue", "MESSetting").ToString();
|
|
|
}
|
|
|
- private void recordResult(int index,string palletcode, string weigh, DateTime time)
|
|
|
+ private void recordResult(int index, string palletcode, string weigh, DateTime time)
|
|
|
{
|
|
|
//创建一个item
|
|
|
ListViewItem lvi = new ListViewItem();
|
|
|
//分条赋值
|
|
|
- lvi.SubItems.Add(index+"");
|
|
|
+ lvi.SubItems.Add(index + "");
|
|
|
lvi.SubItems.Add(palletcode);
|
|
|
lvi.SubItems.Add(weigh);
|
|
|
lvi.SubItems.Add(time.ToString());
|
|
|
@@ -171,13 +171,13 @@ namespace UAS_MES_NEW.Packing
|
|
|
private void confirm_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
//按确认更新产品重量
|
|
|
- if (ma_code.Text=="")
|
|
|
+ if (ma_code.Text == "")
|
|
|
{
|
|
|
OperateResult.AppendText("<<请先选择工单\n", Color.Red);
|
|
|
return;
|
|
|
}
|
|
|
//判断是否达到已称数量
|
|
|
- if (showResult.Items.Count<samplesCount)
|
|
|
+ if (showResult.Items.Count < samplesCount)
|
|
|
{
|
|
|
OperateResult.AppendText("<<采样个数不足\n", Color.Red);
|
|
|
return;
|
|
|
@@ -190,17 +190,25 @@ namespace UAS_MES_NEW.Packing
|
|
|
//}
|
|
|
//sum = sum / weights.Count;
|
|
|
//更新彩盒重量最大值最小值
|
|
|
+ double totalweight = 0;
|
|
|
+ foreach (string w in weights)
|
|
|
+ {
|
|
|
+ totalweight += double.Parse(w);
|
|
|
+ }
|
|
|
+ standardWeight.Text = (totalweight / weights.Count).ToString();
|
|
|
dh.ExecuteSql("update product set pr_midboxmaxweight ='" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) + "', pr_midboxminweight = '" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + "' where pr_code='" + pr_code.Text + "'", "update");
|
|
|
//更新此产品需要检测彩盒重量
|
|
|
//dh.ExecuteSql("update product set pr_checkcolorboxw = 1 where pr_code='" + pr_code.Text + "'", "update");
|
|
|
- OperateResult.AppendText("<<重量设置成功,最大值" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) +unit.Text+ ",最小值" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + unit.Text+"\n", Color.Green);
|
|
|
- LogicHandler.DoCommandLog(Tag.ToString(),User.UserCode,"",User.UserLineCode,User.UserSourceCode,"产品重量设置","产品编号"+pr_code.Text+",最大"+ (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text))+unit.Text+"最小"+ (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text))+unit.Text,"","");
|
|
|
+ OperateResult.AppendText("<<重量设置成功,最大值" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) + unit.Text + ",最小值" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + unit.Text + "\n", Color.Green);
|
|
|
+ LogicHandler.DoCommandLog(Tag.ToString(), User.UserCode, "", User.UserLineCode, User.UserSourceCode, "产品重量设置", "产品编号" + pr_code.Text + ",最大" + (double.Parse(standardWeight.Text) + double.Parse(errorValue.Text)) + unit.Text + "最小" + (double.Parse(standardWeight.Text) - double.Parse(errorValue.Text)) + unit.Text, "", "");
|
|
|
//更新采样记录表
|
|
|
string serialNum = dh.GetSerialNumberByCaller("ProdWeightSample");
|
|
|
sql.Clear();
|
|
|
sql.Append("insert into PRODWEIGHTSAMPLE(PWS_CODE,PWS_SNCODE,PWS_MAKECODE,PWS_PRODCODE,PWS_INDATE,PWS_WEIGHT,PWS_UNIT) ");
|
|
|
- sql.Append("values ('"+serialNum+"',:sncode,'"+ma_code.Text+"','"+pr_code.Text+ "',TO_Date(:indate,'YYYY-MM-dd HH24:mi:ss'),:weight,'" + unit.Text+"')");
|
|
|
- dh.BatchInsert(sql.GetString(), new string[] { "sncode", "indate" , "weight" },sncodes.ToArray(),indates.ToArray(),weights.ToArray());
|
|
|
+ sql.Append("values ('" + serialNum + "',:sncode,'" + ma_code.Text + "','" + pr_code.Text + "',TO_Date(:indate,'YYYY-MM-dd HH24:mi:ss'),:weight,'" + unit.Text + "')");
|
|
|
+ dh.BatchInsert(sql.GetString(), new string[] { "sncode", "indate", "weight" }, sncodes.ToArray(), indates.ToArray(), weights.ToArray());
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
private void sncode_KeyDown(object sender, KeyEventArgs e)
|
|
|
@@ -230,9 +238,9 @@ namespace UAS_MES_NEW.Packing
|
|
|
return;
|
|
|
}
|
|
|
//验证彩盒是否与产品对应
|
|
|
- if (!dh.CheckExist("makeserial","ms_prodcode='"+pr_code.Text+"' and ms_sncode = '"+sncode.Text+"'"))
|
|
|
+ if (!dh.CheckExist("makeserial", "ms_prodcode='" + pr_code.Text + "' and ms_sncode = '" + sncode.Text + "'"))
|
|
|
{
|
|
|
- OperateResult.AppendText("<<序列号"+sncode.Text+"对应产品编号不是"+pr_code.Text+"\n", Color.Red, sncode);
|
|
|
+ OperateResult.AppendText("<<序列号" + sncode.Text + "对应产品编号不是" + pr_code.Text + "\n", Color.Red, sncode);
|
|
|
return;
|
|
|
}
|
|
|
//验证所称彩盒是否重复
|
|
|
@@ -243,13 +251,13 @@ namespace UAS_MES_NEW.Packing
|
|
|
}
|
|
|
//判断称重记录是否满足标准重量+-误差值
|
|
|
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)))
|
|
|
+ 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;
|
|
|
}
|
|
|
//记录重量
|
|
|
- recordResult(showResult.Items.Count+1,sncode.Text, weight.Text, System.DateTime.Now);
|
|
|
+ recordResult(showResult.Items.Count + 1, sncode.Text, weight.Text, System.DateTime.Now);
|
|
|
sncode.Text = "";
|
|
|
}
|
|
|
}
|
|
|
@@ -306,11 +314,11 @@ namespace UAS_MES_NEW.Packing
|
|
|
//在采样的时候不能更改
|
|
|
if (showResult.Items.Count > 0)
|
|
|
{
|
|
|
- if ((sender as TextBox).Name == "standardWeight"&& standardWeight.Text == recordSW)
|
|
|
+ if ((sender as TextBox).Name == "standardWeight" && standardWeight.Text == recordSW)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
- else if((sender as TextBox).Name == "errorValue" && errorValue.Text == recordEV)
|
|
|
+ else if ((sender as TextBox).Name == "errorValue" && errorValue.Text == recordEV)
|
|
|
{
|
|
|
return;
|
|
|
}
|
|
|
@@ -369,7 +377,7 @@ namespace UAS_MES_NEW.Packing
|
|
|
catch (Exception ess)
|
|
|
{
|
|
|
//如果没维护的话默认是10
|
|
|
- samplesCount = 10;
|
|
|
+ samplesCount = 5;
|
|
|
}
|
|
|
OperateResult.AppendText("<<重量设置需采样个数为" + samplesCount + "\n", Color.Black);
|
|
|
//清空称量记录
|