Browse Source

修改解除更新慢的SQL

章政 8 years ago
parent
commit
625efa411a
1 changed files with 33 additions and 1 deletions
  1. 33 1
      UAS-MES/PublicMethod/LogicHandler.cs

+ 33 - 1
UAS-MES/PublicMethod/LogicHandler.cs

@@ -592,7 +592,7 @@ namespace UAS_MES.PublicMethod
                     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_nextstepcode='" + nextstepcode + "', ms_sccode = '" + iSourceCode + "',ms_paststep = ");
                     sql.Append("ms_paststep || case when " + ifpast + " > 0 then ',' || '" + ifpast + "' end");
                 }
                 else
@@ -626,6 +626,38 @@ namespace UAS_MES.PublicMethod
         /// 大箱栈板解除装箱
         /// </summary>
         public static void OutBoxDrawStepPass(string iOutBoxCode, string iMakeCode, string iSourceCode)
+        {
+            string CurrentStep = "";
+            string LineCode = "";
+            string CurrentStepName = "";
+            List<string> ExeSQL = new List<string>();
+            GetStepCodeAndNameAndLineBySource(iSourceCode, ref CurrentStep, ref CurrentStepName, ref LineCode);
+            //更新工序会上一执行步骤
+            sql.Clear();
+            sql.Append("merge into makeserial using mes_package_view on (v_outboxcode='"+ iOutBoxCode + "' and ms_sncode=");
+            sql.Append("v_barcode and ms_makecode=v_makecode) when matched then update set ms_nextstepcode=ms_stepcode, ");
+            sql.Append(" ,ms_status=1,ms_sccode='" + iSourceCode + "' ");
+            ExeSQL.Add(sql.ToString());
+            //更新完工数量
+            ExeSQL.Add("update make set ma_madeqty=(select count(1) from makeserial where ms_makecode='" + iMakeCode + "' and ms_status=2) where ma_code='" + iMakeCode + "'");
+            //删除StepPassed数据
+            sql.Clear();
+            sql.Append("delete from steppassed where sp_sncode in (select v_barcode from mes_package_view where v_outboxcode='" + iOutBoxCode + "') ");
+            sql.Append("and sp_makecode='" + iMakeCode + "' and sp_stepcode='" + CurrentStep + "'");
+            ExeSQL.Add(sql.ToString());
+            //更新大箱或栈板的母箱编号为空
+            ExeSQL.Add("update package set pa_mothercode='' where pa_outboxcode in(select PD_INNERBOXCODE from package left join packagedetail on pa_id=pd_paid where pa_outboxcode='" + iOutBoxCode + "')");
+            //删除从表明细
+            ExeSQL.Add("delete from packagedetail where pd_paid=(select pa_id from package where pa_outboxcode='" + iOutBoxCode + "')");
+            //设置大箱或栈板的已装数量为0
+            ExeSQL.Add("update package set pa_totalqty=0,pa_status=0,pa_currentqty=0,pa_packageqty=0 where pa_outboxcode='" + iOutBoxCode + "'");
+            dh.ExecuteSQLTran(ExeSQL.ToArray());
+        }
+
+        /// <summary>
+        /// 大箱栈板解除装箱
+        /// </summary>
+        public static void OutBoxDrawStepPass(string iOutBoxCode, string iInnerBoxCode, string iMakeCode, string iSourceCode)
         {
             string CurrentStep = "";
             string LineCode = "";