From 4ce845ec79f717ac4669ce3e39eaa0cb7323b1ad Mon Sep 17 00:00:00 2001
From: 沈泽 <211959439@qq.com>
Date: 星期二, 12 十月 2021 16:56:28 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/SCGL/Sc_MESStopWorkBillController.cs |  132 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 115 insertions(+), 17 deletions(-)

diff --git a/WebAPI/Controllers/SCGL/Sc_MESStopWorkBillController.cs b/WebAPI/Controllers/SCGL/Sc_MESStopWorkBillController.cs
index c0eb485..1d74b02 100644
--- a/WebAPI/Controllers/SCGL/Sc_MESStopWorkBillController.cs
+++ b/WebAPI/Controllers/SCGL/Sc_MESStopWorkBillController.cs
@@ -13,11 +13,17 @@
     //鐢熶骇鍋滃伐鍗旵ontroller
     public class Sc_MESStopWorkBillController : ApiController
     {
-        public DBUtility.ClsPub.Enum_BillStatus BillStatus;
+
+        public DBUtility.ClsPub.Enum_BillStatus BillStatus;//鍗曟嵁鐘舵�侊紙鏂板锛屼慨鏀癸紝娴忚锛屾洿鏂板崟浠凤紝鍙樻洿锛�
 
         private json objJsonResult = new json();
         SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
         DataSet ds;
+        //鑾峰彇绯荤粺鍙傛暟
+        Pub_Class.ClsXt_SystemParameter oSystemParameter = new Pub_Class.ClsXt_SystemParameter();
+
+        public DAL.ClsSc_MESStopWorkBill BillNew = new DAL.ClsSc_MESStopWorkBill();   //瀵瑰簲鍗曟嵁绫�
+        public DAL.ClsSc_MESStopWorkBill BillOld = new DAL.ClsSc_MESStopWorkBill();   //瀵瑰簲鍗曟嵁绫�
 
         #region 鍋滃伐鍗�
 
@@ -182,17 +188,18 @@
         /// <returns></returns>
         [Route("Sc_MESStopWorkBill/DeltetMESStopWorkBill")]
         [HttpGet]
-        public object DeltetMESStopWorkBill(string HInterID)
+        public object DeltetMESStopWorkBill(string HInterID,string UserName)
         {
+            DBUtility.ClsPub.CurUserName = UserName;
             //缂栬緫鏉冮檺
-            //if (!DBUtility.ClsPub.Security_Log("Sc_MESStopWorkBill_Delete", 1, true, DBUtility.ClsPub.CurUserName))
-            //{
-            //    objJsonResult.code = "0";
-            //    objJsonResult.count = 0;
-            //    objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
-            //    objJsonResult.data = null;
-            //    return objJsonResult;
-            //}
+            if (!DBUtility.ClsPub.Security_Log("MES_MESStopWorkBill_Delete", 1, true, DBUtility.ClsPub.CurUserName))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犲垹闄ゆ潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
             Int64 lngBillKey = 0;
@@ -355,8 +362,8 @@
                     }
                     else
                     {
-                        objJsonResult.code = "1";
-                        objJsonResult.count = 1;
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "瀹℃牳澶辫触!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                         objJsonResult.data = null;
                         return objJsonResult;
@@ -375,8 +382,8 @@
                     }
                     else
                     {
-                        objJsonResult.code = "1";
-                        objJsonResult.count = 1;
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
                         objJsonResult.Message = "鍙嶅鏍稿け璐�!鍘熷洜:" + DBUtility.ClsPub.sExeReturnInfo;
                         objJsonResult.data = null;
                         return objJsonResult;
@@ -413,10 +420,34 @@
             string msg1 = _value.ToString();
             string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
             string msg2 = sArray[0].ToString();
+            string UserName = sArray[1].ToString();
+            string refSav = sArray[2].ToString();
+            DBUtility.ClsPub.CurUserName = UserName;
+
+            //淇濆瓨鏉冮檺
+            if (!DBUtility.ClsPub.Security_Log("MES_MESStopWorkBill_Edit", 1, true, DBUtility.ClsPub.CurUserName))
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "鏃犱繚瀛樻潈闄愶紒";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            //鍒ゆ柇浼氳鏈熸槸鍚﹀悎鐞�
+            string s = "";
+            int sYear = 0;
+            int sPeriod = 0;
+            if (DBUtility.Xt_BaseBillFun.Fun_AllowYearPeriod(DateTime.Now, ref sYear, ref sPeriod, ref s) == false)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = s;
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
 
 
 
-            string UserName = "";
             ListModels oListModels = new ListModels();
             try
             {
@@ -427,7 +458,57 @@
                 lsmain = oListModels.getObjectByJson_Gy_MESStopWorkBillMain(msg2);
                 foreach (Models.ClsSc_MESStopWorkBillMain oItem in lsmain)
                 {
+                    if (refSav == "Add")
+                    {
+                        //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                        if (BillNew.IsExistBillNo(ref ClsPub.sExeReturnInfo, oItem.HBillNo, BillStatus, BillOld.omodel.HInterID))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "鍗曟嵁鍙烽噸澶嶏紒涓嶅厑璁镐繚瀛橈紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+                    if (refSav == "Update")
+                    {
+                        if (BillOld.ShowBill(oItem.HInterID, ref s) == false)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹湁璇紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        //鍒ゆ柇鏄惁鍙紪杈�
+                        if (BillOld.omodel.HChecker != "" && BillOld.omodel.HChecker != null)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹凡缁忚瀹℃牳锛屼笉鍏佽淇敼锛�";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (BillOld.omodel.HBillStatus > 1)
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = "姝ゅ崟鎹浜庝笉鍙紪杈戠姸鎬侊紝涓嶅厑璁镐慨鏀癸紒";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                        if (!DBUtility.Xt_BaseBillFun.Fun_AllowEditBill(BillOld, ref s))
+                        {
+                            objJsonResult.code = "0";
+                            objJsonResult.count = 0;
+                            objJsonResult.Message = s + "锛屼笉鍏佽淇敼";
+                            objJsonResult.data = 1;
+                            return objJsonResult;
+                        }
+                    }
+
                     //oItem.HMaker = "";
+                    DBUtility.ClsPub.CurUserName = oItem.HMaker;
                     UserName = oItem.HMaker;  //鍒跺崟浜�
                     oItem.HBillType = "3789";
                     oItem.HBillSubType = "3789";
@@ -452,16 +533,33 @@
                 bool bResult;
                 if (oBill.omodel.HInterID == 0)
                 {
-                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
                     bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    if (bResult)
+                    {
+                        objJsonResult.HInterID = DBUtility.ClsPub.sExeReturnInfo; //杩斿洖涓籌D
+                        //绯荤粺鍙傛暟  鑷姩瀹℃牳
+                        string sReturn = "";
+                        if (oSystemParameter.ShowBill(ref sReturn) == true)
+                        {
+                            if (oSystemParameter.omodel.Sc_MESStopWorkBill_AutoCheck == "Y") //绯荤粺鍙傛暟  鑷姩瀹℃牳 
+                            {
+                                objJsonResult.Verify = "Y";
+                            }
+                            else
+                            {
+                                objJsonResult.Verify = "N";
+                            }
+                        }
+                    }
                 }
                 else
                 {
                     bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                    objJsonResult.Verify = "N";
                 }
                 if (bResult)
                 {
-                    objJsonResult.code = "0";
+                    objJsonResult.code = "1";
                     objJsonResult.count = 1;
                     objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
                     //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");

--
Gitblit v1.9.1