You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
312 lines
10 KiB
C#
312 lines
10 KiB
C#
using Estsh.Client.Base;
|
|
|
|
|
|
namespace Estsh.Client.StepLibrary
|
|
{
|
|
public partial class OffLineCheck : StepBase
|
|
{
|
|
private StepLibraryAPP app = null;
|
|
int _terminalID = 0;
|
|
private string _sn = string.Empty;
|
|
private string inputSN = string.Empty;
|
|
|
|
public OffLineCheck()
|
|
{
|
|
InitializeComponent();
|
|
|
|
// 有用户界面的工步在初始化时需要设置为不可见
|
|
// 开始执行此工步后再置为可见
|
|
this.Visible = false;
|
|
}
|
|
|
|
public override bool Do()
|
|
{
|
|
try
|
|
{
|
|
ShowMessage(this, "green|请选择产品检查结果!");
|
|
|
|
// 置为可见并加载到最前端
|
|
this.Visible = true;
|
|
this.BringToFront();
|
|
|
|
// 从配置文件中加载工位编号
|
|
_terminalID = Convert.ToInt32(Context["terminal_id"].ToString());
|
|
_sn = Context["serial_number"].ToString();
|
|
|
|
app = new StepLibraryAPP(httpClient);
|
|
|
|
checkData();
|
|
|
|
// 执行父类的 Do 方法并返回
|
|
return base.Do();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
// 记录日志
|
|
using (StreamWriter sw = new StreamWriter("Error_Log_" + DateTime.Now.ToString("yyyyMM") + ".txt", true))
|
|
{
|
|
sw.WriteLine(string.Format("{0} {1}", "["
|
|
+ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")
|
|
+ "] ", ex.ToString()));
|
|
sw.Flush();
|
|
sw.Close();
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
|
|
public int _failCount = 0;
|
|
public int checkData()
|
|
{
|
|
_failCount = 0;
|
|
string Mesage = string.Empty;
|
|
|
|
//是否校验电功能检测
|
|
if (app.IsValidata("IsValidateFuncData"))
|
|
{
|
|
//校验电检数据的工位集合
|
|
if (app.getBaseParamValue("validatePowerTestLimit").IndexOf(Context["terminal_id"].ToString() + ",") >= 0)
|
|
{
|
|
if (!app.GetTestData(_sn))
|
|
{
|
|
//ShowMessage(this, "red|此产品电检结果不合格");
|
|
lblFunTestResult.Text = "NG";
|
|
lblFunTestResult.ForeColor = Color.Red;
|
|
_failCount++;
|
|
}
|
|
else
|
|
{
|
|
lblFunTestResult.Text = "OK";
|
|
lblFunTestResult.ForeColor = Color.Green;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblFunTestResult.Text = "校验功能未开启";
|
|
lblFunTestResult.ForeColor = Color.Orange;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblFunTestResult.Text = "校验功能未开启";
|
|
lblFunTestResult.ForeColor = Color.Orange;
|
|
}
|
|
|
|
|
|
//是否校验扭矩数量
|
|
if (app.IsValidata("IsValidateKeyData"))
|
|
{
|
|
//校验扭矩数量的工位集合
|
|
if (app.getBaseParamValue("validateKeydataLimit").IndexOf(Context["terminal_id"].ToString() + ",") >= 0)
|
|
{
|
|
//校验扭矩数量
|
|
int torqueQty = app.torqueQty(_sn);
|
|
int factTorqueQty = app.factTorqueQty(_sn);
|
|
if (torqueQty > factTorqueQty)
|
|
{
|
|
//ShowMessage(this, "red|扭矩信息缺失!");
|
|
lblKeyDataResult.Text = "NG";
|
|
lblKeyDataResult.ForeColor = Color.Red;
|
|
_failCount++;
|
|
}
|
|
else
|
|
{
|
|
lblKeyDataResult.Text = "OK";
|
|
lblKeyDataResult.ForeColor = Color.Green;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblKeyDataResult.Text = "校验功能未开启";
|
|
lblKeyDataResult.ForeColor = Color.Orange;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
lblKeyDataResult.Text = "校验功能未开启";
|
|
lblKeyDataResult.ForeColor = Color.Orange;
|
|
}
|
|
|
|
//是否检测关键零件条码绑定
|
|
if (app.IsValidata("IsValidateKeyPart"))
|
|
{
|
|
//校验关键零部件的工位集合
|
|
if (app.getBaseParamValue("validateKeyPartLimit").IndexOf(Context["terminal_id"].ToString() + ",") >= 0)
|
|
{
|
|
string part_no = app.GetPartNo(_sn);
|
|
//应该绑定的零件数量
|
|
List<dynamic> BindQty1 = app.GetBindQty(part_no);
|
|
//实际绑定的零件数量
|
|
List<dynamic> BindQty2 = app.GetKeyParts(_sn);
|
|
|
|
for (int i = 0; i < BindQty1.Count; i++)
|
|
{
|
|
string part_no1 = BindQty1[i]["part_no"].ToString();
|
|
string part_spec = BindQty1[i]["part_spec"].ToString();
|
|
string part_no2 = "";
|
|
|
|
for (int j = 0; j < BindQty2.Count; j++)
|
|
{
|
|
part_no2 = BindQty2[j]["part_no"].ToString();
|
|
if (part_no2 != part_no1)
|
|
{
|
|
continue;
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
if (part_no2 != part_no1)
|
|
{
|
|
Mesage += "[" + part_no1 + "-" + part_spec + "]绑定未完成!" + Environment.NewLine;
|
|
_failCount++;
|
|
}
|
|
else
|
|
{
|
|
continue;
|
|
}
|
|
}
|
|
if (string.IsNullOrEmpty(Mesage))
|
|
{
|
|
lblKeyPartResult.Text = "OK";
|
|
lblKeyPartResult.ForeColor = Color.Green;
|
|
}
|
|
else
|
|
{
|
|
lblKeyPartResult.Text = "NG";
|
|
lblKeyPartResult.ForeColor = Color.Red;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
lblKeyPartResult.Text = "校验功能未开启";
|
|
lblKeyPartResult.ForeColor = Color.Orange;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
|
|
lblKeyPartResult.Text = "校验功能未开启";
|
|
lblKeyPartResult.ForeColor = Color.Orange;
|
|
}
|
|
|
|
Context.Add("btnOK_enabled", "True");
|
|
if (_failCount > 0)
|
|
{
|
|
btnOK.Enabled = false;
|
|
Context["btnOK_enabled"] = "False";
|
|
|
|
if (string.IsNullOrEmpty(Mesage))
|
|
{
|
|
ShowMessage(this, "red|数据检查未通过!");
|
|
}
|
|
else
|
|
{
|
|
ShowMessage(this, "red|数据检查未通过!");
|
|
lblKpsnList.Text = Mesage;
|
|
}
|
|
}
|
|
return _failCount;
|
|
}
|
|
|
|
private void OffLineCheck_Load(object sender, EventArgs e)
|
|
{
|
|
lblKpsnList.Text = string.Empty;
|
|
}
|
|
|
|
private void btnOK_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btn1_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btn2_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
private void btn3_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
|
|
////下线外观检查界面中的按钮使用扫描条码代替
|
|
//private void checkInput()
|
|
//{
|
|
// if (inputSN == "KEY000")
|
|
// {
|
|
// if (Context["btnOK_enabled"].ToString().ToUpper() == "TRUE")
|
|
// {
|
|
// //更新条码状态为下线
|
|
// app.updateStatus(_sn);
|
|
// Complate(this, new EventArgs());
|
|
// return;
|
|
// }
|
|
// else
|
|
// {
|
|
// ShowMessage(this, "red|此产品数据校验不合格,请选择不良类别!");
|
|
// txtSN.Focus();
|
|
// return;
|
|
// }
|
|
// }
|
|
// bool result = false;
|
|
// if (inputSN == "KEY001")
|
|
// {
|
|
// result = app.UpdateCurrentStatus(_sn);
|
|
// app.instertFailItem(_sn, "外观检查工位", "1", "外观不良", "外观不良");
|
|
// Complate(this, new EventArgs());
|
|
// return;
|
|
// }
|
|
// if (inputSN == "KEY002")
|
|
// {
|
|
// result = app.UpdateCurrentStatus(_sn);
|
|
// app.instertFailItem(_sn, "外观检查工位", "2", "操作功能不良", "操作功能不良");
|
|
// Complate(this, new EventArgs());
|
|
// return;
|
|
// }
|
|
// if (inputSN == "KEY003")
|
|
// {
|
|
// result = app.UpdateCurrentStatus(_sn);
|
|
// app.instertFailItem(_sn, "外观检查工位", "3", "错漏装", "错漏装");
|
|
// Complate(this, new EventArgs());
|
|
// return;
|
|
// }
|
|
//}
|
|
|
|
//private void OffLineCheck_VisibleChanged(object sender, EventArgs e)
|
|
//{
|
|
// txtSN.Focus();
|
|
//}
|
|
//private void txtSN_Enter(object sender, EventArgs e)
|
|
//{
|
|
// txtSN.SelectAll();
|
|
// txtSN.BackColor = Color.PeachPuff;
|
|
//}
|
|
|
|
//private void txtSN_Leave(object sender, EventArgs e)
|
|
//{
|
|
// txtSN.BackColor = Color.White;
|
|
//}
|
|
|
|
//private void txtSN_KeyPress(object sender, KeyPressEventArgs e)
|
|
//{
|
|
// if (e.KeyChar != (char)13)
|
|
// {
|
|
// return;
|
|
// }
|
|
// if (string.IsNullOrEmpty(txtSN.Text))
|
|
// {
|
|
// return;
|
|
// }
|
|
// inputSN = txtSN.Text.Trim().ToUpper();
|
|
// checkInput();
|
|
//}
|
|
}
|
|
}
|