|
|
@@ -27,6 +27,7 @@ namespace UAS_MES_NEW.Make
|
|
|
StringBuilder SQL = new StringBuilder();
|
|
|
DataTable dt, data;
|
|
|
DataHelper dh;
|
|
|
+ bool qaSwitching;
|
|
|
|
|
|
private void Make_HandFeedQualityConfirm_Load(object sender, EventArgs e)
|
|
|
{
|
|
|
@@ -47,6 +48,10 @@ namespace UAS_MES_NEW.Make
|
|
|
data.Columns.Add("reelnum", typeof(string));
|
|
|
data.Columns.Add("qa_emp", typeof(string));
|
|
|
data.Columns.Add("qa_date", typeof(string));
|
|
|
+ data.Columns.Add("qa_type", typeof(string));
|
|
|
+ data.Columns.Add("qa_result", typeof(string));
|
|
|
+ data.Columns.Add("update_time", typeof(string));
|
|
|
+ data.Columns.Add("handreel_id", typeof(string));
|
|
|
dgv.DataSource = data;
|
|
|
|
|
|
submit.Enabled = false;
|
|
|
@@ -76,14 +81,24 @@ namespace UAS_MES_NEW.Make
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- string makeSql = makeCode.Replace("'", "''");
|
|
|
SQL.Clear();
|
|
|
- SQL.Append($@"SELECT m.ms_sncode, h.line_name, h.side,
|
|
|
+ /*SQL.Append($@"SELECT m.ms_sncode, h.line_name, h.side,
|
|
|
h.position, h.reel_position, h.part_no, h.reel_qty, h.reelremark, h.reelnum,
|
|
|
- h.qa_emp, to_char(h.qa_date,'yyyy-mm-dd hh24:mi:ss') qa_date
|
|
|
+ h.qa_emp, to_char(h.qa_date,'yyyy-mm-dd hh24:mi:ss') qa_date, h.qa_type,
|
|
|
+ to_char(h.update_time,'yyyy-mm-dd hh24:mi:ss') update_time, h.handreel_id
|
|
|
FROM makeserial m, smt_handreel_log h
|
|
|
- WHERE h.serial_number = m.ms_sncode AND m.ms_makecode = '{makeSql}'
|
|
|
- ORDER BY m.ms_sncode, h.handreel_id");
|
|
|
+ WHERE h.serial_number = m.ms_sncode AND m.ms_makecode = '{makeCode}'
|
|
|
+ ORDER BY m.ms_sncode, h.handreel_id");*/
|
|
|
+
|
|
|
+ SQL.Append($@"SELECT m.ms_sncode, h.line_name, h.side, h.position,
|
|
|
+ h.reel_position, h.part_no, h.reel_qty, h.reelremark, h.reelnum,
|
|
|
+ h.qa_emp, to_char(h.qa_date, 'yyyy-mm-dd hh24:mi:ss') qa_date,
|
|
|
+ h.qa_type, to_char(h.update_time, 'yyyy-mm-dd hh24:mi:ss') update_time, h.handreel_id
|
|
|
+ FROM makeserial m, smt_handreel_log h WHERE h.serial_number = m.ms_sncode
|
|
|
+ AND m.ms_makecode = '{makeCode}' AND h.update_time IN(SELECT MAX(t2.update_time) update_time
|
|
|
+ FROM makeserial t1, smt_handreel_log t2 WHERE t2.serial_number = t1.ms_sncode
|
|
|
+ AND t1.ms_makecode = '{makeCode}' GROUP BY t2.serial_number)
|
|
|
+ ORDER BY m.ms_sncode, h.handreel_id");
|
|
|
dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
|
|
|
|
|
|
data.Rows.Clear();
|
|
|
@@ -98,6 +113,7 @@ namespace UAS_MES_NEW.Make
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
DataRow src = dt.Rows[i];
|
|
|
+ string qaType = NormalizeQaType(src["qa_type"]);
|
|
|
data.Rows.Add(false, i + 1,
|
|
|
src["ms_sncode"].ToString(),
|
|
|
src["line_name"].ToString(),
|
|
|
@@ -109,9 +125,15 @@ namespace UAS_MES_NEW.Make
|
|
|
src["reelremark"].ToString(),
|
|
|
src["reelnum"].ToString(),
|
|
|
src["qa_emp"].ToString(),
|
|
|
- src["qa_date"].ToString());
|
|
|
+ src["qa_date"].ToString(),
|
|
|
+ qaType,
|
|
|
+ QaTypeText(qaType),
|
|
|
+ src["update_time"].ToString(),
|
|
|
+ src["handreel_id"].ToString());
|
|
|
}
|
|
|
|
|
|
+ ApplyLoadedStyle();
|
|
|
+
|
|
|
submit.Enabled = true;
|
|
|
snVal.Text = "";
|
|
|
snVal.Focus();
|
|
|
@@ -140,6 +162,13 @@ namespace UAS_MES_NEW.Make
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
+ string qaType = SelectedQaType();
|
|
|
+ if (qaType == "")
|
|
|
+ {
|
|
|
+ MessageBox.Show("请先选择合格或不合格", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
bool found = false;
|
|
|
bool already = true;
|
|
|
int firstRow = -1;
|
|
|
@@ -151,13 +180,10 @@ namespace UAS_MES_NEW.Make
|
|
|
found = true;
|
|
|
if (firstRow < 0)
|
|
|
firstRow = i;
|
|
|
- if (data.Rows[i]["isScan"] == DBNull.Value || !Convert.ToBoolean(data.Rows[i]["isScan"]))
|
|
|
- {
|
|
|
- data.Rows[i]["isScan"] = true;
|
|
|
+ bool scanned = data.Rows[i]["isScan"] != DBNull.Value && Convert.ToBoolean(data.Rows[i]["isScan"]);
|
|
|
+ if (!scanned || data.Rows[i]["qa_type"].ToString() != qaType)
|
|
|
already = false;
|
|
|
- }
|
|
|
- dgv.Rows[i].DefaultCellStyle.BackColor = Color.Green;
|
|
|
- dgv.Rows[i].DefaultCellStyle.ForeColor = Color.Black;
|
|
|
+ MarkScanRow(i, qaType);
|
|
|
}
|
|
|
|
|
|
if (!found)
|
|
|
@@ -187,16 +213,31 @@ namespace UAS_MES_NEW.Make
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- List<string> snList = new List<string>();
|
|
|
+ List<DataRow> scanRows = new List<DataRow>();
|
|
|
+ List<string> missing = new List<string>();
|
|
|
foreach (DataRow row in data.Rows)
|
|
|
{
|
|
|
bool scanned = row["isScan"] != DBNull.Value && Convert.ToBoolean(row["isScan"]);
|
|
|
+ if (!scanned)
|
|
|
+ continue;
|
|
|
string sn = row["ms_sncode"].ToString();
|
|
|
- if (scanned && !snList.Contains(sn))
|
|
|
- snList.Add(sn);
|
|
|
+ string position = row["position"].ToString();
|
|
|
+ string qaType = NormalizeQaType(row["qa_type"]);
|
|
|
+ if (qaType == "")
|
|
|
+ {
|
|
|
+ missing.Add("序列号" + sn + "当前站位" + position);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ scanRows.Add(row);
|
|
|
}
|
|
|
|
|
|
- if (snList.Count == 0)
|
|
|
+ if (missing.Count > 0)
|
|
|
+ {
|
|
|
+ MessageBox.Show(string.Join("、", missing) + "未选择合格或不合格", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (scanRows.Count == 0)
|
|
|
{
|
|
|
MessageBox.Show("请先扫描序列号", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
|
|
snVal.Focus();
|
|
|
@@ -206,19 +247,17 @@ namespace UAS_MES_NEW.Make
|
|
|
string emp = User.UserName ?? "";
|
|
|
if (emp.Length > 20)
|
|
|
emp = emp.Substring(0, 20);
|
|
|
- string empSql = emp.Replace("'", "''");
|
|
|
- string makeSql = ma_code.Text.Trim().Replace("'", "''");
|
|
|
string confirmTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
|
try
|
|
|
{
|
|
|
- foreach (string sn in snList)
|
|
|
+ foreach (DataRow row in scanRows)
|
|
|
{
|
|
|
- string snSql = sn.Replace("'", "''");
|
|
|
+ string idSql = row["handreel_id"].ToString();
|
|
|
+ string qaType = NormalizeQaType(row["qa_type"]);
|
|
|
SQL.Clear();
|
|
|
- SQL.Append($@"UPDATE smt_handreel_log SET qa_emp = '{empSql}', qa_date = sysdate
|
|
|
- WHERE serial_number = '{snSql}'
|
|
|
- AND serial_number IN (SELECT ms_sncode FROM makeserial WHERE ms_makecode = '{makeSql}' AND ms_sncode = '{snSql}')");
|
|
|
+ SQL.Append($@"UPDATE smt_handreel_log SET qa_emp = '{emp}', qa_date = sysdate, qa_type = '{qaType}'
|
|
|
+ WHERE handreel_id = '{idSql}'");
|
|
|
dh.ExecuteSql(SQL.ToString(), "update");
|
|
|
}
|
|
|
}
|
|
|
@@ -228,20 +267,106 @@ namespace UAS_MES_NEW.Make
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- foreach (DataRow row in data.Rows)
|
|
|
+ List<string> snList = new List<string>();
|
|
|
+ foreach (DataRow row in scanRows)
|
|
|
{
|
|
|
- if (row["isScan"] == DBNull.Value || !Convert.ToBoolean(row["isScan"]))
|
|
|
- continue;
|
|
|
row["qa_emp"] = emp;
|
|
|
row["qa_date"] = confirmTime;
|
|
|
+ string sn = row["ms_sncode"].ToString();
|
|
|
+ if (!snList.Contains(sn))
|
|
|
+ snList.Add(sn);
|
|
|
}
|
|
|
|
|
|
- MessageBox.Show($"已确认{snList.Count}个序列号:{string.Join("、", snList)}", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
+ MessageBox.Show($"序列号:{string.Join("、", snList)},数量{snList.Count},品质确认完成", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
|
|
snVal.Focus();
|
|
|
snVal.SelectAll();
|
|
|
snVal.Text = "";
|
|
|
}
|
|
|
|
|
|
+ private void qaPass_CheckedChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (qaSwitching || !qaPass.Checked)
|
|
|
+ return;
|
|
|
+ qaSwitching = true;
|
|
|
+ qaFail.Checked = false;
|
|
|
+ qaSwitching = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void qaFail_CheckedChanged(object sender, EventArgs e)
|
|
|
+ {
|
|
|
+ if (qaSwitching || !qaFail.Checked)
|
|
|
+ return;
|
|
|
+ qaSwitching = true;
|
|
|
+ qaPass.Checked = false;
|
|
|
+ qaSwitching = false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private string SelectedQaType()
|
|
|
+ {
|
|
|
+ if (qaPass.Checked)
|
|
|
+ return "1";
|
|
|
+ if (qaFail.Checked)
|
|
|
+ return "0";
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ private string NormalizeQaType(object value)
|
|
|
+ {
|
|
|
+ string text = value == null || value == DBNull.Value ? "" : value.ToString().Trim();
|
|
|
+ decimal number;
|
|
|
+ if (decimal.TryParse(text, out number))
|
|
|
+ {
|
|
|
+ if (number == 1)
|
|
|
+ return "1";
|
|
|
+ if (number == 0 && text != "")
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ private string QaTypeText(string qaType)
|
|
|
+ {
|
|
|
+ if (qaType == "1")
|
|
|
+ return "合格";
|
|
|
+ if (qaType == "0")
|
|
|
+ return "不合格";
|
|
|
+ return "";
|
|
|
+ }
|
|
|
+
|
|
|
+ private void MarkScanRow(int rowIndex, string qaType)
|
|
|
+ {
|
|
|
+ data.Rows[rowIndex]["isScan"] = true;
|
|
|
+ data.Rows[rowIndex]["qa_type"] = qaType;
|
|
|
+ data.Rows[rowIndex]["qa_result"] = QaTypeText(qaType);
|
|
|
+ PaintRow(rowIndex, qaType);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void ApplyLoadedStyle()
|
|
|
+ {
|
|
|
+ int count = Math.Min(data.Rows.Count, dgv.Rows.Count);
|
|
|
+ for (int i = 0; i < count; i++)
|
|
|
+ PaintRow(i, NormalizeQaType(data.Rows[i]["qa_type"]));
|
|
|
+ }
|
|
|
+
|
|
|
+ private void PaintRow(int rowIndex, string qaType)
|
|
|
+ {
|
|
|
+ if (qaType == "1")
|
|
|
+ {
|
|
|
+ dgv.Rows[rowIndex].DefaultCellStyle.BackColor = Color.Green;
|
|
|
+ dgv.Rows[rowIndex].DefaultCellStyle.ForeColor = Color.Black;
|
|
|
+ }
|
|
|
+ else if (qaType == "0")
|
|
|
+ {
|
|
|
+ dgv.Rows[rowIndex].DefaultCellStyle.BackColor = Color.DarkRed;
|
|
|
+ dgv.Rows[rowIndex].DefaultCellStyle.ForeColor = Color.White;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ dgv.Rows[rowIndex].DefaultCellStyle.BackColor = dgv.DefaultCellStyle.BackColor;
|
|
|
+ dgv.Rows[rowIndex].DefaultCellStyle.ForeColor = dgv.DefaultCellStyle.ForeColor;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private void UpdateSN(string type, string sn = "")
|
|
|
{
|
|
|
if (type == "C")
|
|
|
@@ -253,10 +378,9 @@ namespace UAS_MES_NEW.Make
|
|
|
}
|
|
|
else if (type == "L")
|
|
|
{
|
|
|
- string snSql = sn.Replace("'", "''");
|
|
|
SQL.Clear();
|
|
|
SQL.Append($@"SELECT ms_sncode,ma_code,pr_code,pr_spec FROM makeserial,make,product
|
|
|
- WHERE ms_sncode = '{snSql}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
|
|
|
+ WHERE ms_sncode = '{sn}' AND ms_makecode = ma_code AND ms_prodcode = pr_code");
|
|
|
dt = (DataTable)dh.ExecuteSql(SQL.ToString(), "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|