From a985e6ba578b4ec28a25932f871c4df76ce092f2 Mon Sep 17 00:00:00 2001
From: chenhaozhe <cgz@hz-kingdee.com>
Date: 星期二, 12 五月 2026 15:02:39 +0800
Subject: [PATCH] 模块添加自定义标签鉴权 在Token启用的情况下。通过自定义标签定义的modname和Operate 判断用户是否有访问模块的权限

---
 WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs |  264 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 251 insertions(+), 13 deletions(-)

diff --git a/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs b/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs
index dc8bfd5..23fbc3c 100644
--- a/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs
+++ b/WebAPI/Controllers/XSGL/Xs_ExceptiveCheckRequestBillController.cs
@@ -8,10 +8,12 @@
 using System.Data.SqlClient;
 using System.Web.Http;
 using WebAPI.Models;
+using WebAPI.Utility;
 
 namespace WebAPI.Controllers
 {
     //鐗规壒鐢宠鍗旵ontroller
+    [Permission(HModName = "Xs_ExceptiveCheckRequestBill")]
     public class Xs_ExceptiveCheckRequestBillController : ApiController
     {
         //鑾峰彇绯荤粺鍙傛暟
@@ -31,29 +33,30 @@
         /// </summary>
         [Route("Xs_ExceptiveCheckRequestBill/list")]
         [HttpGet]
+        [Permission(HModName = "Xs_ExceptiveCheckRequestBill", Operate = "_Query")]
         public object getXs_ExceptiveCheckRequestBill(string sWhere, string user)
         {
             try
             {
                 List<object> columnNameList = new List<object>();
                 //鏌ョ湅鏉冮檺
-                //if (!DBUtility.ClsPub.Security_Log("Gy_ProjectStage_Query", 1, false, user))
-                //{
-                //    objJsonResult.code = "0";
-                //    objJsonResult.count = 0;
-                //    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
-                //    objJsonResult.data = null;
-                //    return objJsonResult;
-                //}
+                if (!DBUtility.ClsPub.Security_Log("Xs_ExceptiveCheckRequestBill_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
 
                 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");
                 }
 
@@ -86,6 +89,7 @@
         #region 鐗规壒鐢宠鍗曚繚瀛� 鏂板/缂栬緫
         [Route("Xs_ExceptiveCheckRequestBill/SaveXs_ExceptiveCheckRequestBill")]
         [HttpPost]
+        [Permission(HModName = "Xs_ExceptiveCheckRequestBill", Operate = "_Edit")]
         public object SaveXs_ExceptiveCheckRequestBill([FromBody] JObject msg)
         {
             var _value = msg["msg"].ToString();
@@ -217,7 +221,15 @@
 
                 }
 
-
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                int sYear = 0;
+                int sPeriod = 0;
+                DateTime HDate = DateTime.Now;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.Message = s;
+                    return objJsonResult;
+                }
 
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
@@ -307,6 +319,7 @@
         /// </summary>
         [Route("Xs_ExceptiveCheckRequestBill/delete")]
         [HttpGet]
+        [Permission(HModName = "Xs_ExceptiveCheckRequestBill", Operate = "_Drop")]
         public object deleteXs_ExceptiveCheckRequestBill(string HInterID, string user)
         {
             try
@@ -350,6 +363,16 @@
                     return objJsonResult;
                 }
 
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                int sYear = 0;
+                int sPeriod = 0;
+                DateTime HDate = DateTime.Now;
+                if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                {
+                    objJsonResult.Message = s;
+                    return objJsonResult;
+                }
+
                 oCN.BeginTran();
 
                 oCN.RunProc("delete from Xs_ExceptiveCheckRequestBillMain where HInterID = " + HInterID);
@@ -359,7 +382,7 @@
 
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
-                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.Message = "鎮ㄥ凡鍒犻櫎鍗曟嵁鍙蜂负" + BillOld.omodel.HBillNo + "鐨勭壒鎵圭敵璇峰崟锛�";
                 objJsonResult.data = null;
                 return objJsonResult;
             }
@@ -383,6 +406,7 @@
         /// <returns></returns>
         [Route("Xs_ExceptiveCheckRequestBill/AuditXs_ExceptiveCheckRequestBill")]
         [HttpGet]
+        [Permission(HModName = "Xs_ExceptiveCheckRequestBill", Operate = "_Check")]
         public object AuditXs_ExceptiveCheckRequestBill(int HInterID, int IsAudit, string CurUserName)
         {
             string ModRightNameCheck = "Xs_ExceptiveCheckRequestBill_Check";
@@ -468,9 +492,96 @@
                 //杩涜闇�瑕佽繘琛岀殑瀹℃牳/鍙嶅鏍告搷浣�
                 if (IsAudit == 0) //瀹℃牳鎻愪氦
                 {
-                    //瀹℃牳鎻愪氦
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.Message = s;
+                        return objJsonResult;
+                    }
+
+                    oCN.BeginTran();
+
+                    //妫�楠屾簮鍗曟槸鍚﹀瓨鍦�
+                    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 (int.Parse(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 (int.Parse(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 == "1425")
+                    {
+                        objJsonResult = AuditXs_ExceptiveCheckRequestBill_CheckSeOrderChangeBill(oBill.omodel.HMainSourceInterID);
+                        if (objJsonResult.code != "1")
+                        {
+                            return objJsonResult;
+                        }
+
+                        //鍙嶅啓閿�鍞鍗曟暟鎹�
+                        sql = "exec h_p_IF_SeOrderBill_ReWriteBySeOrderChangeBill " + oBill.omodel.HMainSourceInterID;
+                        oCN.RunProc(sql);
+                    }
+                    else
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟涓嶆槑纭紒!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //鍙嶅啓婧愬崟鍗曟嵁鐘舵��
+                    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 +590,8 @@
                     }
                     else
                     {
+                        oCN.RollBack();
+
                         objJsonResult.code = "0";
                         objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
@@ -488,6 +601,18 @@
                 }
                 if (IsAudit == 1) //鍙嶅鏍告彁浜�
                 {
+
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    string s = "";
+                    int sYear = 0;
+                    int sPeriod = 0;
+                    DateTime HDate = DateTime.Now;
+                    if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(HDate, ref sYear, ref sPeriod, ref s) == false)
+                    {
+                        objJsonResult.Message = s;
+                        return objJsonResult;
+                    }
+
                     //鍙嶅鏍告彁浜bandonCheck
                     if (oBill.AbandonCheck(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
@@ -510,6 +635,8 @@
             }
             catch (Exception e)
             {
+                oCN.RollBack();
+
                 objJsonResult.code = "0";
                 objJsonResult.count = 0;
                 objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
@@ -517,6 +644,115 @@
                 return objJsonResult;
             }
         }
+
+        #region 瀹℃牳鐗规壒鐢宠鍗曞弽鍐欓攢鍞鍗曞彉鏇村崟鐘舵�佹暟鎹楠�
+        public json AuditXs_ExceptiveCheckRequestBill_CheckSeOrderChangeBill(long HInterID)
+        {
+
+            try
+            {
+                Int64 lngBillKey = 0;
+                lngBillKey = DBUtility.ClsPub.isLong(HInterID);                                         //瀵笻InterID杩涜绫诲瀷鐨勮浆鎹�
+                DAL.ClsXs_SeOrderChangeBill oBill = new DAL.ClsXs_SeOrderChangeBill();                  //閿�鍞鍗曞彉鏇村崟瀹炰緥鍖栧崟鎹搷浣滅被锛岀敤浜庤繘琛岀浉鍏虫搷浣�
+                DAL.ClsXs_SeOrderBill oBillSource = new DAL.ClsXs_SeOrderBill();                        //閿�鍞鍗曞疄渚嬪寲鍗曟嵁鎿嶄綔绫伙紝鐢ㄤ簬杩涜鐩稿叧鎿嶄綔
+
+                //閽堝闇�瑕佽繘琛岀殑鎿嶄綔锛屾楠屽綋鍓嶅崟鎹殑鐘舵�佹槸鍚︽敮鎸侀渶瑕佽繘琛岀殑鎿嶄綔
+                if (oBill.ShowBill(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo))                    //鏍规嵁HInterID鑾峰彇閿�鍞鍗曞彉鏇村崟鍗曟嵁鐨勬暟鎹�
+                {
+                    if (!oBillSource.ShowBill(oBill.DetailColl[0].HSourceInterID, ref DBUtility.ClsPub.sExeReturnInfo))  //鍒ゆ柇閿�鍞鍗曞彉鏇村崟鐨勬簮鍗�-閿�鍞鍗曟槸鍚﹀瓨鍦ㄥ苟鑾峰彇鏁版嵁
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曞彉鏇村崟鐨勬簮鍗�-閿�鍞鍗曚笉瀛樺湪!";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+
+                    if (oBill.omodel.HBillStatus > 1)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曞彉鏇村崟涓嶄负鈥樺垱寤衡�欑姸鎬侊紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    if (oBillSource.omodel.HBillStatus != 2)
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曞彉鏇村崟鐨勬簮鍗�-閿�鍞鍗曚笉涓衡�樺凡瀹℃牳鈥欑姸鎬侊紒";
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    //妫�楠屽瓙琛ㄦ暟鎹�
+                    string errorMessage = "";
+                    DateTime today = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd"));                   //褰撴棩鏃ユ湡
+                    double HRelationQty = 0;                                                                //婧愬崟-閿�鍞鍗曞叧鑱旀暟閲�(閿�鍞嚭搴撴暟閲�)
+                    foreach (Model.ClsXs_SeOrderChangeBillSub oSub in oBill.DetailColl)
+                    {
+                        string sql = "select * from Xs_SeOrderBillSub where HInterID = " + oSub.HSourceInterID + " and HEntryID = " + oSub.HSourceEntryID;
+                        ds = oCN.RunProcReturn(sql, "Xs_SeOrderBillSub");
+                        if (ds.Tables[0].Rows.Count == 0)
+                        {
+                            errorMessage += "婧愬崟-閿�鍞鍗曞彉鏇村崟锛氱" + oSub.HEntryID + "琛岀墿鏂欏湪婧愬崟-閿�鍞鍗曚腑涓嶅瓨鍦�!";
+                        }
+                        else
+                        {
+                            //鑾峰彇閿�鍞鍗曞彉鏇村崟涓搴旂墿鏂欏湪婧愬崟-閿�鍞鍗曚腑鐨勫叧鑱旀暟閲�
+                            HRelationQty = double.Parse(ds.Tables[0].Rows[0]["HRelationQty"].ToString());
+
+                            //鍒ゆ柇鐗╂枡鏂版暟閲忔槸鍚﹀皬浜庢簮鍗曞崟鎹腑瀵瑰簲鐗╂枡鐨勫叧鑱旀暟閲�
+                            if (oSub.HQty_New < HRelationQty)
+                            {
+                                errorMessage += "婧愬崟-閿�鍞鍗曞彉鏇村崟锛氱" + oSub.HEntryID + "琛岀墿鏂欐柊鏁伴噺灏忎簬婧愬崟-閿�鍞鍗曡鍏宠仈鏁伴噺!";
+                            }
+                            //鍒ゆ柇鏂颁氦璐ф棩鏈熸槸鍚︽棭浜庡綋鏃�
+                            if (oSub.HDate_New.CompareTo(today) < 0)
+                            {
+                                errorMessage += "婧愬崟-閿�鍞鍗曞彉鏇村崟锛氱" + oSub.HEntryID + "琛屾柊浜よ揣鏃ユ湡鏃╀簬褰撴棩!";
+                            }
+
+                        }
+                    }
+                    if (errorMessage != "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + errorMessage;
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
+
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = null;
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:婧愬崟-閿�鍞鍗曞彉鏇村崟涓嶅瓨鍦�!";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                oCN.RollBack();
+
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "瀹℃牳澶辫触鎴栬�呭弽瀹℃牳澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
         #endregion
 
         #region 鐗规壒鐢宠鍗� 鍏抽棴/鍙嶅叧闂�
@@ -528,6 +764,7 @@
         /// <returns></returns>
         [Route("Xs_ExceptiveCheckRequestBill/CloseXs_ExceptiveCheckRequestBill")]
         [HttpGet]
+        [Permission(HModName = "Xs_ExceptiveCheckRequestBill", Operate = "_Close")]
         public object CloseXs_ExceptiveCheckRequestBill(int HInterID, int IsAudit, string CurUserName)
         {
             string ModRightNameCheck = "Xs_ExceptiveCheckRequestBill_Close";
@@ -673,6 +910,7 @@
         /// <returns></returns>
         [Route("Xs_ExceptiveCheckRequestBill/DeleteXs_ExceptiveCheckRequestBill")]
         [HttpGet]
+        [Permission(HModName = "Xs_ExceptiveCheckRequestBill", Operate = "_Delete")]
         public object DeleteXs_ExceptiveCheckRequestBill(int HInterID, int IsAudit, string CurUserName)
         {
             string ModRightNameCheck = "Xs_ExceptiveCheckRequestBill_Delete";

--
Gitblit v1.9.1