Преглед на файлове

修改取上料数据慢的SQL

章政 преди 8 години
родител
ревизия
b581074f50
променени са 2 файла, в които са добавени 4 реда и са изтрити 4 реда
  1. 2 2
      UAS-MES/FunctionCode/Make/Make_ColorBoxLoadPrint.cs
  2. 2 2
      UAS-MES/FunctionCode/Make/Make_FeedingCollection.cs

+ 2 - 2
UAS-MES/FunctionCode/Make/Make_ColorBoxLoadPrint.cs

@@ -140,8 +140,8 @@ namespace UAS_MES.Make
                             sql.Append("sp_ifforsn,max(sp_length)sp_length,max(sp_type)sp_type,max(sp_prefix)sp_prefix,max(sp_regex)");
                             sql.Append("sp_regex,max(pr_detail)pr_detail from stepproduct left join product on pr_code=sp_fsoncode where ");
                             sql.Append("sp_bomversion='" + ma_bomversion.Text + "' and sp_craftcode='" + ms_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' ");
-                            sql.Append("And sp_mothercode ='" + pr_code.Text + "' and sp_tracekind=1 and not exists(select 1 from craftmaterial where (cm_sncode='" + ms_firstsn + "' or ");
-                            sql.Append("cm_sncode in (select sn from makesnrelation where firstsn='" + ms_firstsn + "')) and cm_makecode='" + ma_code.Text + "' and cm_soncode=");
+                            sql.Append("And sp_mothercode ='" + pr_code.Text + "' and sp_tracekind=1 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_soncode=");
                             sql.Append("sp_soncode and cm_status=0) group by sp_fsoncode order by SP_DETNO asc");
                             ListA = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
                             //获取对应 产品的机身标的打印模板

+ 2 - 2
UAS-MES/FunctionCode/Make/Make_FeedingCollection.cs

@@ -331,8 +331,8 @@ namespace UAS_MES.Make
             sql.Append("sp_ifforsn,max(sp_length)sp_length,max(sp_type)sp_type,max(sp_prefix)sp_prefix,max(sp_regex)");
             sql.Append("sp_regex,max(pr_detail)pr_detail from stepproduct left join product on pr_code=sp_fsoncode where ");
             sql.Append("sp_bomversion='" + ma_bomversion.Text + "' and sp_craftcode='" + ms_craftcode.Text + "' and sp_stepcode='" + User.CurrentStepCode + "' ");
-            sql.Append("And sp_mothercode ='" + ma_prodcode.Text + "' and sp_tracekind=1 and not exists(select 1 from craftmaterial where (cm_sncode='" + ms_firstsn + "' or ");
-            sql.Append("cm_sncode in (select sn from makesnrelation where firstsn='" + ms_firstsn + "')) and cm_makecode='" + ma_code.Text + "' and cm_fsoncode=");
+            sql.Append("And sp_mothercode ='" + ma_prodcode.Text + "' and sp_tracekind=1 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) group by sp_fsoncode order by SP_DETNO asc");
             dt1 = (DataTable)dh.ExecuteSql(sql.GetString(), "select");
             code.Clear();