From 015997e4efd5e5189498c9af00b7805919a676b2 Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期三, 15 十一月 2023 19:44:17 +0800
Subject: [PATCH] 特批申请单:审核时判断源单是否处于创建状态,不是则审核失败

---
 WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs |   75 +++++++++++++++++++++++++++++++++++--
 1 files changed, 71 insertions(+), 4 deletions(-)

diff --git a/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs b/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs
index dc8bfd5..9fe4a0b 100644
--- a/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs
+++ b/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs
@@ -48,12 +48,12 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_Xs_ExceptiveCheckRequestBillList_Query order by 鍗曟嵁鍙� ", "h_v_Xs_ExceptiveCheckRequestBillList_Query");
+                    ds = oCN.RunProcReturn("select * from h_v_Xs_ExceptiveCheckRequestBillList_Query order by 鍗曟嵁鍙� desc", "h_v_Xs_ExceptiveCheckRequestBillList_Query");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_Xs_ExceptiveCheckRequestBillList_Query where 1 = 1 ";
-                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� ";
+                    string sql = sql1 + sWhere + " order by 鍗曟嵁鍙� desc";
                     ds = oCN.RunProcReturn(sql, "h_v_Xs_ExceptiveCheckRequestBillList_Query");
                 }
 
@@ -468,9 +468,72 @@
                 //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣�
                 if (IsAudit == 0) //瀹℃牳鎻愪氦
                 {
-                    //瀹℃牳鎻愪氦
-                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    //妫�楠屾簮鍗曟槸鍚﹀瓨鍦�
+                    string sql = "";
+                    if(oBill.omodel.HMainSourceBillType == "1401")
                     {
+                        sql = "select * from Xs_SeOrderBillMain as a " +
+                        "inner join Xs_SeOrderBillSub as b on a.HInterID = b.HInterID " +
+                        "where a.HInterID = " + oBill.omodel.HMainSourceInterID;
+                        ds = oCN.RunProcReturn(sql, "Xs_SeOrderBill");
+                        if (ds == null || ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曚笉瀛樺湪!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else if (ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "1")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曟湭澶勪簬鍒涘缓鐘舵��!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    else if(oBill.omodel.HMainSourceBillType == "1205")
+                    {
+                        sql = "select * from Kf_ICStockBillMain as a " +
+                        "inner join Kf_ICStockBillSub as b on a.HInterID = b.HInterID " +
+                        "where a.HInterID = " + oBill.omodel.HMainSourceInterID;
+                        ds = oCN.RunProcReturn(sql, "Kf_ICStockBill");
+                        if (ds == null || ds.Tables[0].Rows.Count == 0)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞嚭搴撳崟涓嶅瓨鍦�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                        else if (ds.Tables[0].Rows[0]["HBillStatus"].ToString() != "1")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞嚭搴撳崟鏈浜庡垱寤虹姸鎬�!";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟涓嶆槑纭紒!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    oCN.BeginTran();
+                    //鍙嶅啓婧愬崟鍗曟嵁鐘舵��
+                    sql = "exec h_p_Xs_ExceptiveCheckRequestBill_ReWriteSourceStatus " + oBill.omodel.HMainSourceInterID + ",'" + oBill.omodel.HMainSourceBillType + "','" + CurUserName + "'";
+                    oCN.RunProc(sql);
+
+                    if (oBill.CheckBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
+                    {                        
+                        oCN.Commit();
+                       
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
                         objJsonResult.Message = "瀹℃牳鎴愬姛";
@@ -479,6 +542,8 @@
                     }
                     else
                     {
+                        oCN.RollBack();
+
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
@@ -510,6 +575,8 @@
             }
             catch (Exception e)
             {
+                oCN.RollBack();
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();

--
Gitblit v1.9.1