|
|
@@ -44,6 +44,8 @@ namespace UAS_MES.Make
|
|
|
|
|
|
string reworkstatus = "";
|
|
|
|
|
|
+ string firstsn = "";
|
|
|
+
|
|
|
DataTable Dbfind;
|
|
|
|
|
|
public Make_Repair()
|
|
|
@@ -200,13 +202,14 @@ namespace UAS_MES.Make
|
|
|
{
|
|
|
msid = dt.Rows[0]["ms_id"].ToString();
|
|
|
BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
- //判断是否存在上料记录
|
|
|
- string firstsn = dt.Rows[0]["ms_firstsn"].ToString();
|
|
|
+ //判断是否当前工单途程的上料记录
|
|
|
+ firstsn = dt.Rows[0]["ms_firstsn"].ToString();
|
|
|
sql.Clear();
|
|
|
- sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case ");
|
|
|
- sql.Append("when cm_status=-1 then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode ");
|
|
|
- sql.Append("where(cm_sncode in (select sn from makesnrelation where firstsn='" + firstsn + "') or cm_sncode='" + firstsn + "')");
|
|
|
- sql.Append("group by cm_craftcode,cm_stepcode,cm_soncode having sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
|
|
|
+ sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
|
|
|
+ sql.Append("then 0 else 1 end)qty from craftmaterial left join product on pr_code=cm_soncode where(cm_sncode ");
|
|
|
+ sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "') or cm_sncode='" + firstsn + "') ");
|
|
|
+ sql.Append("and cm_craftcode='" + cr_code.Text + "' group by cm_craftcode,cm_stepcode,cm_soncode having ");
|
|
|
+ sql.Append("sum(case when cm_status=-1 then 0 else 1 end)=0 order by cm_indate");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
@@ -352,7 +355,7 @@ namespace UAS_MES.Make
|
|
|
}
|
|
|
if (ifrework != "0" && reworkstatus == "0")
|
|
|
{
|
|
|
- if (dh.getRowCount("Makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='"+ms_makecode.Text+"' and mb_status=0") == 0)
|
|
|
+ if (dh.getRowCount("Makebad", "mb_sncode='" + ms_sncode.Text + "' and mb_makecode='" + ms_makecode.Text + "' and mb_status=0") == 0)
|
|
|
{
|
|
|
OperatResult.AppendText(">>维修必须维护不良代码\n", Color.Red);
|
|
|
return;
|
|
|
@@ -380,6 +383,38 @@ namespace UAS_MES.Make
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
+ //查询拆解的物料
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select cm_soncode from craftmaterial where (cm_sncode='" + firstsn + "' or cm_sncode ");
|
|
|
+ sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "')) and cm_status=-1");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ //如果含有序列号物料有被拆解过
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ string soncode = "";
|
|
|
+ for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ soncode += "'" + dt.Rows[i][0].ToString() + "',";
|
|
|
+ }
|
|
|
+ //查询对应的上料记录
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select cm_soncode from craftmaterial where (cm_sncode='" + firstsn + "' or cm_sncode ");
|
|
|
+ sql.Append("in (select sn from makesnrelation where firstsn='" + firstsn + "')) and cm_status=0 and cm_soncode in (" + soncode.Substring(0, soncode.Length - 1) + ")");
|
|
|
+ DataTable dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ //查询的结果不相等表示未完成上料
|
|
|
+ if (dt.Rows.Count != dt1.Rows.Count)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < dt1.Rows.Count; i++)
|
|
|
+ {
|
|
|
+ if (soncode.Contains(dt.Rows[i][0].ToString()))
|
|
|
+ {
|
|
|
+ soncode = soncode.Replace(dt.Rows[i][0].ToString(),"");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ OperatResult.AppendText(">>" + soncode.Replace("'","") + "物料尚未备料,不允许回流\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
dt = (DataTable)dh.ExecuteSql("select cr_id from craft where cr_statuscode='AUDITED' and cr_code='" + cr_code.Text + "'", "select");
|
|
|
if (dt.Rows.Count == 0)
|
|
|
OperatResult.AppendText(">>回流工序不存在\n", Color.Red);
|
|
|
@@ -402,7 +437,7 @@ namespace UAS_MES.Make
|
|
|
return;
|
|
|
}
|
|
|
if (ms_ifrework == "0")
|
|
|
- dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_nextstepcode='" + cd_stepcode.Text + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_status=1", "ms_id='" +msid + "'");
|
|
|
+ dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_nextstepcode='" + cd_stepcode.Text + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_status=1", "ms_id='" + msid + "'");
|
|
|
else
|
|
|
dh.UpdateByCondition("makeserial", "ms_paststep = ms_paststep ||'," + User.CurrentStepCode + "',ms_nextstepcode='" + cd_stepcode.Text + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_reworkstatus=1", "ms_id='" + msid + "'");
|
|
|
}
|