|
@@ -240,10 +240,10 @@ namespace UAS_MES_NEW.Make
|
|
|
{
|
|
|
//验证makeserial或者ms_firstsn表序列号是否存在
|
|
|
sql.Clear();
|
|
|
- sql.Append("select max(ms_id) ms_id,ms_makecode,ma_craftcode,ms_stepcode,ms_firstsn,ms_prodcode,ms_sncode,pr_detail,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno ");
|
|
|
+ sql.Append("select max(ms_id) ms_id,ms_makecode,ma_craftcode,ms_stepcode,ms_firstsn,ms_prodcode,ms_sncode,ma_bomversion,pr_detail,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno ");
|
|
|
sql.Append("from makeserial left join make on ms_makecode=ma_code left join product on pr_code=ms_prodcode where ms_makecode ='" + macode + "' and ms_sncode in(");
|
|
|
sql.Append("select '" + GetSNCode.Text + "' from dual union select firstsn from makesnrelation where ");
|
|
|
- sql.Append("sn='" + GetSNCode.Text + "') group by ms_makecode,ms_stepcode,ms_prodcode,ma_craftcode,ms_sncode,pr_detail,ms_firstsn,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno");
|
|
|
+ sql.Append("sn='" + GetSNCode.Text + "') group by ms_makecode,ms_stepcode,ms_prodcode,ma_craftcode,ms_sncode,ma_bomversion,pr_detail,ms_firstsn,ms_craftcode,ms_checkno,ms_ifrework,ms_reworkcheckno");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
@@ -252,31 +252,40 @@ namespace UAS_MES_NEW.Make
|
|
|
BaseUtil.SetFormValue(this.Controls, dt);
|
|
|
//判断是否当前工单途程的上料记录
|
|
|
firstsn = dt.Rows[0]["ms_firstsn"].ToString();
|
|
|
+ string ma_bomversion = dt.Rows[0]["ma_bomversion"].ToString();
|
|
|
string cdstepcode = "";
|
|
|
+ //sql.Clear();
|
|
|
+ //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 + "' union select '" + firstsn + "' from dual)) ");
|
|
|
+ //sql.Append("and cm_craftcode='" + cr_code.Text + "'and nvl(cm_lastdeco,0)<>0 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");
|
|
|
sql.Clear();
|
|
|
- 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 + "' union select '" + firstsn + "' from dual)) ");
|
|
|
- sql.Append("and cm_craftcode='" + cr_code.Text + "'and nvl(cm_lastdeco,0)<>0 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");
|
|
|
+ sql.Append("select sp_stepcode cm_stepcode,sp_craftcode cm_craftcode from stepproduct left join product on pr_code=sp_fsoncode where sp_bomversion='" + ma_bomversion + "' and ");
|
|
|
+ sql.Append("sp_craftcode='" + cr_code.Text + "' And sp_mothercode ='" + ms_prodcode.Text + "' and sp_tracekind=1 ");
|
|
|
+ //sql.Append("sp_craftcode=v_v_mscraftcode and sp_stepcode='' And sp_mothercode ='"+ms_prodcode.Text+"' and sp_tracekind=1");
|
|
|
+ sql.Append("and not exists(select 1 from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union ");
|
|
|
+ sql.Append("select sn from makesnrelation where firstsn='" + firstsn + "') and cm_makecode='" + macode + "' and ");
|
|
|
+ sql.Append("cm_fsoncode=sp_fsoncode and cm_status=0) and instr((select ms_paststep from makeserial where ms_firstsn='" + firstsn + "'),sp_stepcode)>0 order by SP_DETNO asc");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
if (dt.Rows.Count > 0)
|
|
|
{
|
|
|
+ cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
|
|
|
//如果本工序包含老化则默认选择本工序,否则选择上料的后一道工序
|
|
|
- if (dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_ifburnin,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + dt.Rows[0]["cm_stepcode"].ToString() + "'").ToString() != "0")
|
|
|
- cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
|
|
|
- else
|
|
|
- {
|
|
|
- string nextstep = LogicHandler.GetNextStep(dt.Rows[0]["cm_craftcode"].ToString(), dt.Rows[0]["cm_stepcode"].ToString(), ms_prodcode.Text);
|
|
|
- if (ms_paststep.Contains(nextstep))
|
|
|
- {
|
|
|
- cdstepcode = nextstep;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
|
|
|
- }
|
|
|
- }
|
|
|
+ //if (dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_ifburnin,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + dt.Rows[0]["cm_stepcode"].ToString() + "'").ToString() != "0")
|
|
|
+ // cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ //string nextstep = LogicHandler.GetNextStep(dt.Rows[0]["cm_craftcode"].ToString(), dt.Rows[0]["cm_stepcode"].ToString(), ms_prodcode.Text);
|
|
|
+ // if (ms_paststep.Contains(nextstep))
|
|
|
+ // {
|
|
|
+ // cdstepcode = nextstep;
|
|
|
+ // }
|
|
|
+ // else
|
|
|
+ // {
|
|
|
+ // cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -309,7 +318,15 @@ namespace UAS_MES_NEW.Make
|
|
|
//如果ms_stepcode和扣料工序均没有查到返修的工序
|
|
|
if (cdstepcode == "")
|
|
|
{
|
|
|
- cdstepcode = ms_stepcode;
|
|
|
+ string flowback = dh.getFieldDataByCondition("craftdetail left JOIN craft on cr_id = cd_crid", "cd_stepcode", "cr_code= '" + cr_code.Text + "' and cr_prodcode = '" + ms_prodcode.Text + "' and nvl(cd_ifflowback,0)=-1").ToString();
|
|
|
+ if (flowback != "")
|
|
|
+ {
|
|
|
+ cdstepcode = flowback;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ cdstepcode = ms_stepcode;
|
|
|
+ }
|
|
|
}
|
|
|
cd_stepcode.Text = cdstepcode;
|
|
|
//if (dh.getFieldDataByCondition("craftdetail left JOIN craft on cr_id = cd_crid", "nvl(cd_ifinput,0)cd_ifinput", "cr_code= '" + cr_code.Text + "' and cr_prodcode = '" + ms_prodcode.Text + "' and cd_stepcode = '" + cd_stepcode.Text + "'").ToString() == "-1")
|
|
@@ -584,6 +601,7 @@ namespace UAS_MES_NEW.Make
|
|
|
BaseUtil.CleanForm(this);
|
|
|
BadCodeTree.Nodes.Clear();
|
|
|
GetSNCode.Clear();
|
|
|
+ GetSNCode.Focus();
|
|
|
}
|
|
|
}
|
|
|
}
|