|
|
@@ -589,19 +589,21 @@ namespace UAS_MES.PublicMethod
|
|
|
if (nextstepcode != "")
|
|
|
{
|
|
|
sql.Clear();
|
|
|
- sql.Append("update makeserial set ms_stepcode='" + CurrentStep + "',ms_stepname='" + CurrentStepName + "',ms_nextstepcode=");
|
|
|
- sql.Append("'" + nextstepcode + "',ms_sccode='" + iSourceCode + "',ms_paststep=ms_paststep|| case when " + ifpast + ">0 then ','||'" + CurrentStep + "' end ");
|
|
|
- sql.Append("where exists (select 1 from mes_package_view where ms_sncode=v_barcode and ");
|
|
|
- sql.Append("ms_makecode=v_makecode and v_outboxcode='" + iOutBoxCode + "')");
|
|
|
- ExeSQL.Add(sql.ToString());
|
|
|
+ sql.Append("merge into makeserial using mes_package_view on (v_outboxcode='" + iOutBoxCode + "' ");
|
|
|
+ sql.Append("and ms_sncode=v_barcode and ms_makecode=v_makecode) when matched then update ");
|
|
|
+ sql.Append(" set ms_stepcode='" + CurrentStep + "',ms_stepname='" + CurrentStepName + "',");
|
|
|
+ sql.Append("ms_nextstepcode='"+ nextstepcode + "', ms_sccode = '"+ iSourceCode + "',ms_paststep = ");
|
|
|
+ sql.Append("ms_paststep || case when " + ifpast + " > 0 then ',' || '" + ifpast + "' end");
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
//更新下一执行步骤
|
|
|
sql.Clear();
|
|
|
- sql.Append("update makeserial set ms_stepcode='" + CurrentStep + "',ms_stepname='" + CurrentStepName + "',ms_nextstepcode='',MS_STATUS=2,");
|
|
|
- sql.Append("ms_sccode='" + iSourceCode + "',ms_paststep=ms_paststep|| case when " + ifpast + ">0 then ','||'" + CurrentStep + "' end ");
|
|
|
- sql.Append("where exists (select 1 from mes_package_view where ms_sncode=v_barcode and ms_makecode=v_makecode and v_outboxcode='" + iOutBoxCode + "')");
|
|
|
+ sql.Append("merge into makeserial using mes_package_view on (v_outboxcode='" + iOutBoxCode + "' ");
|
|
|
+ sql.Append("and ms_sncode=v_barcode and ms_makecode=v_makecode) when matched then update ");
|
|
|
+ sql.Append(" set ms_stepcode='',ms_stepname='" + CurrentStepName + "',ms_status=2,");
|
|
|
+ sql.Append("ms_nextstepcode='" + nextstepcode + "', ms_sccode = '" + iSourceCode + "',ms_paststep = ");
|
|
|
+ sql.Append("ms_paststep || case when " + ifpast + " > 0 then ',' || '" + ifpast + "' end");
|
|
|
ExeSQL.Add(sql.ToString());
|
|
|
//更新完工数量
|
|
|
ExeSQL.Add("update make set ma_madeqty=nvl(ma_madeqty,0)+" + totalcount + " where ma_code='" + iMakeCode + "'");
|