|
|
@@ -443,16 +443,16 @@ namespace UAS_MES_NEW.Make
|
|
|
sql.Append("sp_regex,max(pr_detail)pr_detail,max(substr(pr_detail,0,20))pr_spec from stepproduct left join product on pr_code=sp_fsoncode where ");
|
|
|
sql.Append("sp_bomversion='" + ms_bomversion.Text + "' and sp_craftcode='" + ms_craftcode.Text + "' and instr('" + ms_paststep + "',sp_stepcode)>0 ");
|
|
|
sql.Append("And sp_mothercode ='" + ma_prodcode.Text + "' and sp_tracekind=1 and nvl(pr_prodtype,' ')<>'包装物料' and not exists(select 1 from craftmaterial where ");
|
|
|
- sql.Append("cm_sncode in (select '" + ms_firstsn + "' from dual union select sn from makesnrelation where firstsn='" + ms_firstsn + "') and cm_makecode='" + ma_code.Text + "' and cm_fsoncode=");
|
|
|
- sql.Append("sp_fsoncode and cm_status=0 and cm_stepcode=sp_stepcode ) group by sp_fsoncode,sp_id union ");
|
|
|
+ sql.Append("cm_sncode in (select '" + ms_firstsn + "' from dual union select sn from makesnrelation where firstsn='" + ms_firstsn + "') and cm_makecode='" + ma_code.Text + "' and ");
|
|
|
+ sql.Append("(cm_fsoncode = sp_fsoncode OR EXISTS (SELECT 1 FROM stepproductrep r WHERE r.spr_spid = sp_id AND r.spr_stepcode = cm_stepcode AND r.spr_fsoncode = cm_fsoncode) ) and cm_status=0 and cm_stepcode=sp_stepcode ) group by sp_fsoncode,sp_id union ");
|
|
|
sql.Append("select '替代' sptype,spr_id,max(spr_isreplace),max(spr_rate)spr_rate,max(pr_lightbox)pr_lightbox,spr_spid,max(nvl(spr_subnum,0))spr_subnum,max(nvl(spr_subnumlength,0))spr_subnumlength,max(spr_detno)spr_detno,min(spr_ifrepeat)spr_ifrepeat,max(spr_checkbarcode)spr_checkbarcode,min(spr_checksalecode)spr_checksalecode,");
|
|
|
sql.Append("spr_fsoncode,max(spr_barcoderule)spr_barcoderule,max(nvl(spr_sntype,'原厂'))spr_sntype,wm_concat(spr_soncode) spr_soncode,max(spr_ifuseregex)spr_ifuseregex,max(spr_ifforsn)");
|
|
|
sql.Append("spr_ifforsn,max(spr_length)spr_length,max(spr_type)spr_type,replace(wm_concat(spr_prefix),',','|')spr_prefix,max(spr_regex)");
|
|
|
- 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_regex,max(pr_detail)pr_detail,max(substr(pr_detail,0,20))pr_spec from stepproductrep left join product on pr_code=spr_fsoncode left join stepproduct on spr_spid=sp_id where ");
|
|
|
sql.Append("spr_bomversion='" + ms_bomversion.Text + "' and spr_craftcode='" + ms_craftcode.Text + "' and instr('" + ms_paststep + "',spr_stepcode)>0 ");
|
|
|
sql.Append("And spr_mothercode ='" + ma_prodcode.Text + "' and spr_tracekind=1 and nvl(pr_prodtype,' ')<>'包装物料' and not exists(select 1 from craftmaterial where ");
|
|
|
- sql.Append("cm_sncode in (select '" + ms_firstsn + "' from dual union select sn from makesnrelation where firstsn='" + ms_firstsn + "') and cm_makecode='" + ma_code.Text + "' and cm_fsoncode=");
|
|
|
- sql.Append("spr_fsoncode and cm_status=0 and cm_stepcode=spr_stepcode) group by spr_fsoncode,spr_id,spr_spid ");
|
|
|
+ sql.Append("cm_sncode in (select '" + ms_firstsn + "' from dual union select sn from makesnrelation where firstsn='" + ms_firstsn + "') and cm_makecode='" + ma_code.Text + "' ");
|
|
|
+ sql.Append("and (cm_fsoncode=spr_fsoncode or cm_fsoncode=sp_fsoncode) and cm_status=0 and cm_stepcode=spr_stepcode) 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");
|
|
|
dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
|
|
|
code.Clear();
|