|
|
@@ -37,6 +37,10 @@ namespace UAS_AutoPass
|
|
|
/// </summary>
|
|
|
string ilinecode;
|
|
|
/// <summary>
|
|
|
+ /// 不良代码组
|
|
|
+ /// </summary>
|
|
|
+ string ibadgroup;
|
|
|
+ /// <summary>
|
|
|
/// 当前工序
|
|
|
/// </summary>
|
|
|
string istepcode;
|
|
|
@@ -88,12 +92,21 @@ namespace UAS_AutoPass
|
|
|
AutoStart.Checked = (bool)BaseUtil.GetCacheData("AutoStart");
|
|
|
}
|
|
|
catch (Exception ex) { Console.WriteLine(ex.Message); }
|
|
|
+ for (int i = 0; i < DB.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (Master.Text == DB.Rows[i]["ma_user"].ToString())
|
|
|
+ {
|
|
|
+ DataHelper.DBConnectionString = "Data Source=" + DB.Rows[i]["ma_address"] + ";User ID=" + DB.Rows[i]["ma_user"] + ";PassWord=" + DB.Rows[i]["ms_pwd"]; ;
|
|
|
+ dh = new DataHelper();
|
|
|
+ }
|
|
|
+ }
|
|
|
//获取岗位资源相关信息
|
|
|
- dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode from source where sc_code='" + isource + "'", "select");
|
|
|
+ DataTable dt = (DataTable)dh.ExecuteSql("select sc_linecode,sc_stepcode,st_badgroupcode from source left join step on sc_stepcode=st_code where sc_code='" + isource + "'", "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
ilinecode = dt.Rows[0]["sc_linecode"].ToString();
|
|
|
istepcode = dt.Rows[0]["sc_stepcode"].ToString();
|
|
|
+ ibadgroup = dt.Rows[0]["st_badgroupcode"].ToString();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -135,12 +148,12 @@ namespace UAS_AutoPass
|
|
|
dh = new DataHelper();
|
|
|
}
|
|
|
}
|
|
|
- //暂时不用归属工单
|
|
|
- //if (!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + MakeCode.Text + "'"))
|
|
|
- //{
|
|
|
- // OperateResult.AppendText("工单不存在或者未下放\n");
|
|
|
- // return;
|
|
|
- //}
|
|
|
+ //存在工单必须是已下放状态
|
|
|
+ if (!dh.CheckExist("make", "ma_statuscode='STARTED' and ma_code='" + ma_code.Text + "'") && ma_code.Text != "")
|
|
|
+ {
|
|
|
+ OperateResult.AppendText("工单不存在或者未下放\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
XmlWatcher.Path = FolderPath.Text;
|
|
|
XmlWatcher.Filter = "*.xml";
|
|
|
XmlWatcher.EnableRaisingEvents = true;
|
|
|
@@ -152,7 +165,7 @@ namespace UAS_AutoPass
|
|
|
//设置按钮不可点击
|
|
|
StartWatch.Enabled = false;
|
|
|
ChooseFolder.Enabled = false;
|
|
|
- MakeCode.Enabled = false;
|
|
|
+ ma_code.Enabled = false;
|
|
|
ChooseBackUpFolder.Enabled = false;
|
|
|
StopWatch.Enabled = true;
|
|
|
OperateResult.AppendText("开始执行监控\n");
|
|
|
@@ -223,9 +236,8 @@ namespace UAS_AutoPass
|
|
|
//获取文件名的序列号,如SA123456.xml,如果开头为-表示无条码需要自动获取
|
|
|
string sncode = e.Name.Substring(0, 1) == "-" ? "" : e.Name.Split('.')[0];
|
|
|
string makecode = "";
|
|
|
- string ErrMessage = "";
|
|
|
- //获取序列号ID最大的工单号,测试良品时才进行分配
|
|
|
- if (sncode == "" && test_result == "OK")
|
|
|
+ //获取序列号ID最大的工单号,所有序列号都测试为良品
|
|
|
+ if (sncode == "")
|
|
|
{
|
|
|
//获取资源,线别,工序相等,并且状态在线的序列号进行分配
|
|
|
sql.Clear();
|
|
|
@@ -239,82 +251,63 @@ namespace UAS_AutoPass
|
|
|
}
|
|
|
//-2-NG2017/10/2514:46:29.xml取第二位版号
|
|
|
string combinecode = e.Name.Substring(1, 1);
|
|
|
- if (LogicHandler.CheckStepSNAndMacode(makecode, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
|
|
|
+ if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
|
|
|
{
|
|
|
- LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, "0");
|
|
|
- if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out ErrMessage))
|
|
|
+ //插入日志
|
|
|
+ LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, test_result == "NG" ? "1" : "0");
|
|
|
+ //如果是不良品记录日志,用于测试采集判负
|
|
|
+ if (test_result == "NG")
|
|
|
+ {
|
|
|
+ RecordBadInfo(sncode, makecode, e.Name, combinecode, badcode.ToArray(), badlocation.ToArray());
|
|
|
+ }
|
|
|
+ if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
|
|
|
{
|
|
|
- OperateResult.AppendText(ErrMessage + "\n");
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- OperateResult.AppendText(ErrMessage + "\n");
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
- //没有条码并且不良进行记录
|
|
|
- else if (sncode == "" && test_result == "NG")
|
|
|
- {
|
|
|
- LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, "1");
|
|
|
- }
|
|
|
- else if (sncode != "")
|
|
|
+ else
|
|
|
{
|
|
|
- if (LogicHandler.CheckStepSNAndMacode(makecode, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
|
|
|
+ if (LogicHandler.CheckStepSNAndMacode(ma_code.Text == "" ? makecode : ma_code.Text, isource, sncode, iusercode, out oMakeCode, out oMSID, out oErrMessage))
|
|
|
{
|
|
|
//获取序列号ID最大的工单
|
|
|
- string msid = "";
|
|
|
dt = (DataTable)dh.ExecuteSql("select ms_makecode,ms_id from makeserial where ms_sncode='" + sncode + "' order by ms_id desc", "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
- msid = dt.Rows[0]["ms_id"].ToString();
|
|
|
makecode = dt.Rows[0]["ms_makecode"].ToString();
|
|
|
switch (test_result)
|
|
|
{
|
|
|
case "OK":
|
|
|
- if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out ErrMessage))
|
|
|
+ if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out oErrMessage))
|
|
|
{
|
|
|
- OperateResult.AppendText(ErrMessage + "\n");
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
return;
|
|
|
}
|
|
|
break;
|
|
|
case "NG":
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
|
|
|
- sql.Append(",mb_sourcecode,mb_badcode,mb_badtable,mb_soncode,mb_status) select makebad_seq.nextval");
|
|
|
- sql.Append(",ma_code,ms_code,ms_sncode,'" + iusercode + "',sysdate,'" + istepcode + "','" + isource + "',:bc_code,'',");
|
|
|
- sql.Append("sp_soncode,'0' from make left join makeSerial on ms_makecode=ma_code left join stepProduct on sp_mothercode");
|
|
|
- sql.Append("=ma_prodcode and sp_stepcode=ms_nextstepcode where ms_sncode='" + sncode + "' and ms_makecode='" + makecode + "'");
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "bc_code" }, badcode.ToArray());
|
|
|
- //更新序列号不良状态
|
|
|
- dh.UpdateByCondition("makeserial", "ms_status=3", "ms_id='" + msid + "'");
|
|
|
- for (int i = 0; i < badcode.Count; i++)
|
|
|
+ RecordBadInfo(sncode, makecode, e.Name, "", badcode.ToArray(), badlocation.ToArray());
|
|
|
+ //所有的序列号均采集为良品
|
|
|
+ if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", "OK", iusercode, out oErrMessage))
|
|
|
{
|
|
|
- //保存不良位置
|
|
|
- string[] location = badlocation[i].Split(',');
|
|
|
- sql.Clear();
|
|
|
- sql.Append("insert into makebadrsloc(mbl_id,mbl_loc,mbl_badcode,mbl_sncode,mbl_makecode,");
|
|
|
- sql.Append("mbl_indate ,mbl_inman) select makebadrsloc_seq.nextval,");
|
|
|
- sql.Append(":location,'" + badcode[i] + "','" + sncode + "','" + makecode + "',");
|
|
|
- sql.Append("sysdate,'" + iusercode + "' from dual");
|
|
|
- dh.BatchInsert(sql.ToString(), new string[] { "location" }, location);
|
|
|
- }
|
|
|
- if (!LogicHandler.SetStepResult(makecode, isource, sncode, "自动过站采集", test_result, iusercode, out ErrMessage))
|
|
|
- {
|
|
|
- OperateResult.AppendText(ErrMessage + "\n");
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
return;
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
- LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, "0");
|
|
|
+ LogicHandler.AutoPassLog(sncode, isource, makecode, test_date, istepcode, ilinecode, e.Name, test_result == "NG" ? "1" : "0");
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- OperateResult.AppendText(ErrMessage + "\n");
|
|
|
+ OperateResult.AppendText(oErrMessage + "\n");
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
@@ -346,11 +339,24 @@ namespace UAS_AutoPass
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void RecordBadInfo(string sncode, string makecode, string filename, string combine, string[] badcode, string[] badlocation)
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("insert into makebad(mb_id,mb_makecode,mb_mscode,mb_sncode,mb_inman,mb_indate,mb_stepcode");
|
|
|
+ sql.Append(",mb_sourcecode,mb_badcode,mb_bgcode,mb_badtable,mb_status,mb_badremark) select makebad_seq.nextval");
|
|
|
+ sql.Append(",ma_code,ms_code,ms_sncode,'" + iusercode + "',sysdate,'" + istepcode + "','" + isource + "',");
|
|
|
+ sql.Append(":bc_code,'" + ibadgroup + "','','0',:location from make left join makeSerial on ms_makecode=ma_code ");
|
|
|
+ sql.Append("where ms_sncode='" + sncode + "' and ms_makecode='" + makecode + "'");
|
|
|
+ dh.BatchInsert(sql.ToString(), new string[] { "bc_code", "location" }, badcode, badlocation);
|
|
|
+ //记录判断日志
|
|
|
+ LogicHandler.AutoPassJudge(sncode, makecode, isource, filename, ilinecode, combine);
|
|
|
+ }
|
|
|
+
|
|
|
private void StopWatch_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
XmlWatcher.EnableRaisingEvents = false;
|
|
|
StartWatch.Enabled = true;
|
|
|
- MakeCode.Enabled = true;
|
|
|
+ ma_code.Enabled = true;
|
|
|
ChooseFolder.Enabled = true;
|
|
|
ChooseBackUpFolder.Enabled = true;
|
|
|
StopWatch.Enabled = false;
|