|
|
@@ -302,26 +302,7 @@ namespace UAS_MES_NEW.Make
|
|
|
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 + "' and ms_makecode='" + macode + "'),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();
|
|
|
- // }
|
|
|
- //}
|
|
|
- }
|
|
|
- else
|
|
|
+ if (dt.Rows.Count == 0)
|
|
|
{
|
|
|
sql.Clear();
|
|
|
sql.Append("select cm_craftcode,cm_stepcode,cm_soncode,min(cm_indate)cm_indate,sum(case when cm_status=-1 ");
|
|
|
@@ -335,9 +316,26 @@ namespace UAS_MES_NEW.Make
|
|
|
cdstepcode = dt.Rows[0]["cm_stepcode"].ToString();
|
|
|
}
|
|
|
}
|
|
|
- if (cdstepcode == "")
|
|
|
+ //如果通过上料工序已经取到了回流工序
|
|
|
+ if (cdstepcode != "")
|
|
|
{
|
|
|
- //序号小于等于当前不良的序号
|
|
|
+ string currentdetno = dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_detno,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + ms_stepcode + "'").ToString();
|
|
|
+ string materialdetno = dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "nvl(cd_detno,0)", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + cdstepcode + "'").ToString();
|
|
|
+ //如果是自动拆解,回流工序在当前工序之后的
|
|
|
+ if (double.Parse(currentdetno) < double.Parse(materialdetno))
|
|
|
+ {
|
|
|
+ sql.Clear();
|
|
|
+ sql.Append("select cd_stepcode from craft left join craftdetail on cr_id =cd_crid where ");
|
|
|
+ sql.Append("cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and ");
|
|
|
+ sql.Append("nvl(cd_ifspc,0)<>0 and cd_detno <='" + currentdetno + "' order by cd_detno desc");
|
|
|
+ dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
+ if (dt.Rows.Count > 0)
|
|
|
+ {
|
|
|
+ cdstepcode = dt.Rows[0][0].ToString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
string currentdetno = dh.getFieldDataByCondition("craft left join craftdetail on cr_id=cd_crid", "cd_detno", "cr_code='" + cr_code.Text + "' and cr_prodcode='" + ms_prodcode.Text + "' and cd_stepcode='" + ms_stepcode + "'").ToString();
|
|
|
sql.Clear();
|
|
|
sql.Append("select cd_stepcode from craft left join craftdetail on cr_id =cd_crid where ");
|
|
|
@@ -588,7 +586,7 @@ namespace UAS_MES_NEW.Make
|
|
|
sql.Append("spr_regex,max(pr_detail)pr_detail,max(substr(pr_detail,0,20))pr_spec from stepproductrep left join product on pr_code=spr_fsoncode where ");
|
|
|
sql.Append("spr_bomversion='" + ma_bomversion + "' and spr_craftcode='" + cr_code.Text + "' and instr('" + ms_paststep + "',spr_stepcode)>0 ");
|
|
|
sql.Append("And spr_mothercode ='" + ms_prodcode.Text + "' and spr_tracekind=1 and nvl(pr_prodtype,' ')<>'包装物料' group by spr_fsoncode,spr_id,spr_spid ");
|
|
|
- sql.Append(") group by case when spr_isreplace=-1 then to_char(spr_isreplace) else sp_fsoncode end,sp_id order by sp_id) where not exists(select 1 from craftmaterial where cm_sncode in (select '"+firstsn+"' from dual union select sn from makesnrelation where firstsn='"+ firstsn + "') and cm_makecode='"+ms_makecode.Text+ "'and instr(sp_fsoncode,cm_fsoncode)>0 and cm_status=0)");
|
|
|
+ sql.Append(") group by case when spr_isreplace=-1 then to_char(spr_isreplace) else sp_fsoncode end,sp_id order by sp_id) where not exists(select 1 from craftmaterial where cm_sncode in (select '" + firstsn + "' from dual union select sn from makesnrelation where firstsn='" + firstsn + "') and cm_makecode='" + ms_makecode.Text + "'and instr(sp_fsoncode,cm_fsoncode)>0 and cm_status=0)");
|
|
|
dt = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
////如果含有序列号物料有被拆解过
|
|
|
if (dt.Rows.Count > 0)
|
|
|
@@ -626,9 +624,9 @@ namespace UAS_MES_NEW.Make
|
|
|
return;
|
|
|
}
|
|
|
if (ms_ifrework == "0")
|
|
|
- SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftname='"+ cr_name + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_status=1,ms_qccheck=-1 where ms_id='" + msid + "'");
|
|
|
+ SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftname='" + cr_name + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_status=1,ms_qccheck=-1 where ms_id='" + msid + "'");
|
|
|
else
|
|
|
- SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftname='"+ cr_name + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_reworkstatus=1,ms_qccheck=-1 where ms_id='" + msid + "'");
|
|
|
+ SQLS.Add("update makeserial set ms_checkno='',ms_paststep = ms_paststep || case when instr(','||ms_paststep||',','" + User.CurrentStepCode + "')=0 then ','||'" + User.CurrentStepCode + "' end , ms_nextstepcode ='" + cd_stepcode.Text + "',ms_craftname='" + cr_name + "',ms_craftcode='" + cr_code.Text + "',ms_stepcode='" + User.CurrentStepCode + "',ms_reworkstatus=1,ms_qccheck=-1 where ms_id='" + msid + "'");
|
|
|
}
|
|
|
SQLS.Add("update makebad set mb_status=-1 where (mb_sncode='" + ms_sncode.Text + "' or mb_mscode='" + ms_sncode.Text + "') and mb_makecode='" + ms_makecode.Text + "'");
|
|
|
//取消最近拆解部件
|