From db25c944428a0f857097aa05b7be1716e7a3751b Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期五, 31 五月 2024 17:32:06 +0800
Subject: [PATCH] 1.采购入库单,生产入库单,委外加工入库单,其他入库单,分步式调入单,生产退料单,销售退货单 审核时 增加库存, 反审核时 减少库存; 2.销售出库单,生产领料单,分步式调出单,委外加工出库单,其他出库单,采购退料单,生产退库单 审核时 减少库存, 反审核时 增加 库存; (写在通用的方法中了,只有符合条件的才会进行更新,对原有审核/反审核无影响)

---
 WebAPI/Controllers/XSGL/Xs_SeOrderBillController.cs |  240 +++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 198 insertions(+), 42 deletions(-)

diff --git a/WebAPI/Controllers/XSGL/Xs_SeOrderBillController.cs b/WebAPI/Controllers/XSGL/Xs_SeOrderBillController.cs
index c195f24..4c3302f 100644
--- a/WebAPI/Controllers/XSGL/Xs_SeOrderBillController.cs
+++ b/WebAPI/Controllers/XSGL/Xs_SeOrderBillController.cs
@@ -87,12 +87,12 @@
 
                 if (sWhere == null || sWhere.Equals(""))
                 {
-                    ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList order by hmainid desc", "h_v_IF_SeOrderBillList");
+                    ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList order by hmainid desc,hsubid asc", "h_v_IF_SeOrderBillList");
                 }
                 else
                 {
                     string sql1 = "select * from h_v_IF_SeOrderBillList where 1 = 1 ";
-                    string sql = sql1 + sWhere+ " order by hmainid desc";
+                    string sql = sql1 + sWhere+ " order by hmainid desc,hsubid asc";
                     ds = oCN.RunProcReturn(sql, "h_v_IF_SeOrderBillList");
                 }
 
@@ -1167,7 +1167,7 @@
                     }
                     UserName = oItem.HMaker;  //鍒跺崟浜�
                     oItem.HBillType = "1401";
-                    oItem.HBillSubType = "1401";
+                    //oItem.HBillSubType = "1401";
                     oItem.HSALEORGID = oItem.HOrgID;
 
                     oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
@@ -1209,9 +1209,23 @@
                     //oItemSub.HSourceBillType = ""; //婧愬崟绫诲瀷
                     //oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
                     //oItemSub.HRelationMoney = 0;   //鍏宠仈閲戦 
-                    oBill.DetailColl.Add(oItemSub);
 
+                    if (oItemSub.HMaterID != 0)
+                    {
+                        oBill.DetailColl.Add(oItemSub);
+                    }
                 }
+
+                //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                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;
+                }
+
                 //淇濆瓨
                 //淇濆瓨瀹屾瘯鍚庡鐞�
                 bool bResult;
@@ -1265,7 +1279,7 @@
             try
             {
 
-                ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList where hmainid =" + HInterID, "h_v_IF_SeOrderBillList");
+                ds = oCN.RunProcReturn("select * from h_v_IF_SeOrderBillList where hmainid =" + HInterID + " order by hsubid asc", "h_v_IF_SeOrderBillList");
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
                     objJsonResult.code = "0";
@@ -1361,6 +1375,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();
 
@@ -1492,6 +1516,18 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+
+                        foreach(Model.ClsXs_SeOrderBillSub oSub in oBill.DetailColl)
+                        {
+                            if (oSub.HCloseMan != "")
+                            {
+                                objJsonResult.code = "0";
+                                objJsonResult.count = 0;
+                                objJsonResult.Message = "鍗曟嵁涓瓨鍦ㄨ鍏抽棴鐨勮褰�!鍙嶅鏍稿け璐ワ紒";
+                                objJsonResult.data = null;
+                                return objJsonResult;
+                            }
+                        }
                     }
                 }
                 else
@@ -1539,6 +1575,17 @@
                     }
                     //==================================================================================      
 
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    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;
+                    }
+
                     //瀹℃牳鎻愪氦
                     if (oBill.CheckBill(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Xs_SeOrderBill_AfterCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
@@ -1578,6 +1625,17 @@
                         return objJsonResult;
                     }
                     //=========================================================
+
+                    //杩涜 浼氳鏈熼棿 缁撹处 鐨勫垽鏂拰鎺у埗
+                    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(oBill.omodel.HInterID, oBill.omodel.HBillNo, "h_p_Xs_SeOrderBill_AfterUnCheckCtrl", CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
@@ -1623,6 +1681,7 @@
         {
             string ModRightNameCheck = "Xs_SeOrderBill_Close";
             DBUtility.ClsPub.CurUserName = CurUserName;
+            string sql = "";
             try
             {
                 //妫�鏌ユ潈闄�
@@ -1689,6 +1748,18 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+
+                        //鍒ゆ柇鍗曟嵁鏄惁涓鸿嚜鍔ㄥ叧闂�
+                        sql = "select * from Xs_SeOrderBillMain where HInterID = " + HInterID;
+                        ds = oCN.RunProcReturn(sql, "Xs_SeOrderBillMain");
+                        if (ds.Tables[0].Rows[0]["HCloseType"].ToString() == "False")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍙嶅叧闂け璐�!鍗曟嵁涓鸿嚜鍔ㄥ叧闂紝涓嶈兘杩涜鎵嬪姩鍙嶅叧闂紒";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
                 else
@@ -1724,22 +1795,18 @@
                 }
                 if (IsAudit == 1) //鍙嶅叧闂彁浜�
                 {
-                    oBill.oCn.BeginTran();
+                    ds = oCN.RunProcReturn("exec h_p_Kf_CheckSeOrderBill_CrediControl " + oBill.omodel.HInterID, "h_p_Kf_CheckSeOrderBill_CrediControl");
+                    if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
+                        objJsonResult.data = null;
+                        return objJsonResult;
+                    }
                     //鍙嶅叧闂彁浜�
                     if (oBill.CancelClose(lngBillKey, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
-                        ds = oCN.RunProcReturn("exec h_p_Kf_CheckSeOrderBill_CrediControl " + oBill.omodel.HInterID, "h_p_Kf_CheckSeOrderBill_CrediControl");
-                        if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
-                        {
-                            objJsonResult.code = "0";
-                            objJsonResult.count = 0;
-                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
-                            objJsonResult.data = null;
-                            oBill.oCn.RollBack();
-                            return objJsonResult;
-                        }
-
-                        oBill.oCn.Commit();
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
                         objJsonResult.Message = "鍙嶅叧闂垚鍔�";
@@ -1752,7 +1819,6 @@
                         objJsonResult.count = 0;
                         objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                         objJsonResult.data = null;
-                        oBill.oCn.RollBack();
                         return objJsonResult;
                     }
                 }
@@ -1868,6 +1934,17 @@
                             objJsonResult.data = null;
                             return objJsonResult;
                         }
+
+                        //鍒ゆ柇琛屾槸鍚︿负鑷姩鍏抽棴
+                        string temp = ds.Tables[0].Rows[0]["HCloseType"].ToString();
+                        if (ds.Tables[0].Rows[0]["HCloseType"].ToString() == "False")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "琛屽弽鍏抽棴澶辫触!琛屼负鑷姩鍏抽棴锛屼笉鑳借繘琛屾墜鍔ㄥ弽鍏抽棴锛�";
+                            objJsonResult.data = null;
+                            return objJsonResult;
+                        }
                     }
                 }
                 else
@@ -1903,13 +1980,25 @@
                 }
                 if (IsAudit == 1) //琛屽弽鍏抽棴鎻愪氦
                 {
+                    oBill.oCn.BeginTran();
                     //琛屽弽鍏抽棴鎻愪氦
                     if (oBill.CancelRow(lngBillKey, HEntryID, oBill.omodel.HBillNo, CurUserName, ref DBUtility.ClsPub.sExeReturnInfo) == true)
                     {
+                        ds = oCN.RunProcReturn("exec h_p_Kf_CheckSeOrderBill_CrediControl " + oBill.omodel.HInterID, "h_p_Kf_CheckSeOrderBill_CrediControl");
+                        if (ds.Tables[0].Rows[0]["HBack"].ToString() == "1")
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + ds.Tables[0].Rows[0]["HRemark"].ToString();
+                            objJsonResult.data = null;
+                            oBill.oCn.RollBack();
+                            return objJsonResult;
+                        }
                         objJsonResult.code = "1";
                         objJsonResult.count = 1;
                         objJsonResult.Message = "鍙嶅叧闂垚鍔�";
                         objJsonResult.data = null;
+                        oBill.oCn.Commit();
                         return objJsonResult;
                     }
                     else
@@ -1918,6 +2007,7 @@
                         objJsonResult.count = 0;
                         objJsonResult.Message = "鍙嶅叧闂け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                         objJsonResult.data = null;
+                        oBill.oCn.RollBack();
                         return objJsonResult;
                     }
                 }
@@ -2194,29 +2284,7 @@
                 }
                 else
                 {
-                    string sql = "select * from Gy_UserCustomerRelation where HUserID = '" + CurUserID + "'";
-                    ds = oCN.RunProcReturn(sql, "Gy_UserCustomerRelation");
-                    if (ds == null || ds.Tables[0].Rows.Count == 0)
-                    {
-                        sWhere = " and 1 = 0";
-                    }
-                    else
-                    {
-                        sWhere = " and HCusID in (";
-                        for (var i = 0; i < ds.Tables[0].Rows.Count; i++)
-                        {
-                            if (i < ds.Tables[0].Rows.Count - 1)
-                            {
-                                sWhere += ds.Tables[0].Rows[i]["HCusID"].ToString() + ",";
-                            }
-                            else
-                            {
-                                sWhere += ds.Tables[0].Rows[i]["HCusID"].ToString() + ")";
-                            }
-                        }
-                    }
-
-                    //sWhere = " and 1=1 ";
+                    sWhere = " and HCusID in (select hcusid from Gy_UserCustomerRelation Where HUserID = '" + CurUserID + "' union all select 166351 hcusid)";
                 }
 
                 objJsonResult.code = "1";
@@ -2450,5 +2518,93 @@
             }
         }
         #endregion
+
+        #region 閿�鍞鍗� 鏍规嵁鑱屽憳鑾峰彇閮ㄩ棬銆佷富绠�
+        [Route("Xs_SeOrderBill/getEmpInfoByHEmpID")]
+        [HttpGet]
+        public object getEmpInfoByHEmpID(long HEmpID)
+        {
+            try
+            {
+                string sql = "select a.HItemID HEmpID,a.HName HEmpName,ISNULL(a.HDeptID,0) HDeptID,b.HName HDeptName,ISNULL(b.HEmpID,0) HManagerID,c.HName HManagerName " +
+                    " from Gy_Employee as a " +
+                    " left join Gy_Department as b on a.HDeptID = b.HItemID " +
+                    " left join Gy_Employee as c on b.HEmpID = c.HItemID " +
+                    " where a.HItemID = " + HEmpID;
+                ds = oCN.RunProcReturn(sql, "Gy_Employee");
+
+
+                if (ds == null || ds.Tables[0].Rows.Count == 0)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏈煡璇㈠埌璇ヨ亴鍛樹俊鎭紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "Sucess锛�";
+                    objJsonResult.data = ds.Tables[0];
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 閿�鍞鍗� 鑾峰彇鎺掑簭鍚庣殑鏁版嵁
+        [Route("Xs_SeOrderBill/sortList")]
+        [HttpGet]
+        public object sortList(string sWhere, string user)
+        {
+            try
+            {
+                //鍒ゆ柇鏌ヨ鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log("Xs_SeOrderBillQuery", 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_IF_SeOrderBillList order by hmainid desc", "h_v_IF_SeOrderBillList");
+                }
+                else
+                {
+                    string sql1 = "select * from h_v_IF_SeOrderBillList where 1 = 1 ";
+                    string sql = sql1 + sWhere;
+                    ds = oCN.RunProcReturn(sql, "h_v_IF_SeOrderBillList");
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.data = ds.Tables[0];
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1