From 377fa7f01680feb02a5e1305acac68eb79b124b3 Mon Sep 17 00:00:00 2001
From: zrg <z18737863051@163.com>
Date: 星期五, 20 十二月 2024 13:51:46 +0800
Subject: [PATCH] 开完工增加班次字段 报工台根据源单查询数据增加工序查出

---
 WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs |  322 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 316 insertions(+), 6 deletions(-)

diff --git a/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs b/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs
index 8a23c05..da2b8e2 100644
--- a/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs
+++ b/WebAPI/Controllers/Sb_CheckEqpRepairWorkBillController.cs
@@ -83,6 +83,60 @@
         }
         #endregion
 
+        #region 璁惧缁翠慨宸ュ崟鍒嗛〉鏌ヨ
+        [Route("Sb_EqpRepairWorkBill/GetEqpRepairWorkBillListPage")]
+        [HttpGet]
+        public object GetEqpRepairWorkBillListPage(string sWhere, string user, int page, int size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipRepairWorkBillList", 3, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairWorkBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipRepairWorkBillListPage");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairWorkBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipRepairWorkBillListPage");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                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 璁惧缁翠慨璁板綍缁熻鍒嗘瀽 
         /// <summary>
         /// 杩斿洖璁惧缁翠慨璁板綍缁熻鍒嗘瀽 鍒楄〃
@@ -195,6 +249,59 @@
         }
         #endregion
 
+        #region 璁惧缁翠慨楠屾敹鍗曞垎椤垫煡璇�
+        [Route("Sb_EqpRepairWorkBill/GetEqpRepairCheckWorkBillListPage")]
+        [HttpGet]
+        public object GetEqpRepairCheckWorkBillListPage(string sWhere, string user, int page, int size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipRepairCheckBillList", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairCheckBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipRepairCheckBillListPage");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairCheckBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipRepairCheckBillListPage");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                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 璁惧缁翠慨楠屾敹鍗曞垪琛╯ql璇彞
         public static DataSet Sb_EquipRepairCheckWorkBill_s(string sWhere)
         {
@@ -211,8 +318,6 @@
             
         }
         #endregion
-
-
 
         #region 璁惧鏁呴殰鐧昏鍗曞垪琛�
         /// <summary>
@@ -264,6 +369,58 @@
         }
         #endregion
 
+        #region 璁惧鏁呴殰鐧昏鍗曞垎椤垫煡璇�
+        [Route("Sb_EqpRepairWorkBill/GetEqpConkBookBillListPage")]
+        [HttpGet]
+        public object GetEqpConkBookBillListPage(string sWhere, string user, int page, int size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipConkBookBillList", 3, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipConkBookBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipConkBookBillListPage");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipConkBookBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipConkBookBillListPage");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                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 璁惧鏁呴殰璁板綍缁熻鍒嗘瀽 
         /// <summary>
@@ -477,7 +634,7 @@
                 if (oBill.omodel.HInterID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);                  
                     //閮ㄩ棬,鍙戠幇浜�,璐熻矗浜�,璁惧
                     _ = SendDingDingAsync(oBill.omodel.HDeptID, oBill.omodel.HEmpID, oBill.omodel.HManagerID, oBill.omodel.HEquipID,2);
                 }
@@ -819,7 +976,10 @@
                 if (oBill.omodel.HInterID == 0)
                 {
                     // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
-                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);    
+                    //鍙嶅啓缁翠慨璁板綍鍗曞叧闂�
+                    string sql = "Update Sb_EquipRepairWorkBillMain set HCloseMan='鍏宠仈楠屾敹鍗曡嚜鍔ㄥ叧闂�',HCloseDate=GETDATE(),HBillStatus=3,HCloseType = 1 Where HInterID=" + oBill.omodel.HMainSourceInterID.ToString();
+                    ds = oCN.RunProcReturn(sql, "Sb_EquipRepairWorkBillMain");
                     //閮ㄩ棬,鍙戠幇浜�,璐熻矗浜�,璁惧
                     _ = SendDingDingAsync(oBill.omodel.HDeptID, oBill.omodel.HEmpID, oBill.omodel.HManagerID, oBill.omodel.HEquipID, 3);
                 }
@@ -1323,8 +1483,8 @@
                     objJsonResult.data = null;
                     return objJsonResult;
                 }
-                //寰楀埌淇℃伅
-                ds = oCN.RunProcReturn("select top 1 * from h_v_Gy_EquipFileBillList where HBarCode= '" + HBarCode + "'", "Gy_EquipFileBillMain");
+                //寰楀埌淇℃伅鏈�鏂扮殑
+                ds = oCN.RunProcReturn("select  * from h_v_Gy_EquipFileBillList where HBarCode= '" + HBarCode + "'  order by 鏁呴殰鐧昏鍗旾D desc", "Gy_EquipFileBillMain");
                 //鍐欏叆淇℃伅
                 if (ds == null || ds.Tables[0].Rows.Count == 0)
                 {
@@ -1332,6 +1492,14 @@
                     objJsonResult.count = 0;
                     objJsonResult.Message = "1.鏈煡璇㈠埌璁惧淇℃伅锛� 2.璁惧娌℃湁缁存姢鏁呴殰鐧昏鍗�  3.璁惧鏁呴殰鐧昏鍗曟病鏈夊鏍�";
                     objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                if ( ds.Tables[0].Rows.Count > 1)
+                {
+                    objJsonResult.code = "1";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "璇ヨ澶囧嚭鐜板涓晠闅滅櫥璁板崟,璇锋墜鍔ㄩ�夌潃";
+                    objJsonResult.data = ds.Tables[0];
                     return objJsonResult;
                 }
                 objJsonResult.code = "1";
@@ -2104,6 +2272,59 @@
                 objJsonResult.Message = "Sucess锛�";
                 objJsonResult.data = ds.Tables[0];
                 objJsonResult.list = columnNameList;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "Exception锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
+
+        #region 璁惧绛惧埌鍗曞垎椤垫煡璇�
+        [Route("Sb_CheckEqpRepairWorkBill/Sb_EquipRepairSignBillListPage")]
+        [HttpGet]
+        public object Sb_EquipRepairSignBillListPage(string sWhere, string user, int page, int size)
+        {
+            try
+            {
+                List<object> columnNameList = new List<object>();
+                //缂栬緫鏉冮檺
+                if (!DBUtility.ClsPub.Security_Log_second("Sb_EquipRepairSignBillMain_Query", 1, false, user))
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "鏃犳煡鐪嬫潈闄愶紒";
+                    objJsonResult.data = null;
+                    return objJsonResult;
+                }
+                sWhere = sWhere.Replace("'", "''");
+                if (sWhere == null || sWhere.Equals(""))
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairSignBillListPage " + page + "," + size + ",''", "h_p_Sb_EquipRepairSignBillListPage");
+                }
+                else
+                {
+                    ds = oCN.RunProcReturn("exec h_p_Sb_EquipRepairSignBillListPage " + page + "," + size + ",'" + sWhere + "'", "h_p_Sb_EquipRepairSignBillListPage");
+                }
+
+                //娣诲姞鍒楀悕
+                foreach (DataColumn col in ds.Tables[0].Columns)
+                {
+                    Type dataType = col.DataType;
+                    string ColmString = "{\"ColmCols\":\"" + col.ColumnName + "\",\"ColmType\":\"" + dataType.Name + "\"}";
+                    columnNameList.Add(JsonConvert.DeserializeObject(ColmString));//鑾峰彇鍒癉ataColumn鍒楀璞$殑鍒楀悕
+                }
+
+                objJsonResult.code = "1";
+                objJsonResult.count = int.Parse(ds.Tables[1].Rows[0]["count"].ToString());
+                objJsonResult.Message = "Sucess锛�";
+                objJsonResult.list = columnNameList;
+                objJsonResult.data = ds.Tables[0];
                 return objJsonResult;
             }
             catch (Exception e)
@@ -2945,8 +3166,97 @@
             }
         }
         #endregion
+    
+        #region 璁惧绛惧埌鍗曟彁浜DA
 
+        [Route("Sb_CheckEqpRepairWorkBill/SaveSb_EquipRepairSignBill_PDA")]
+        [HttpPost]
+        public object SaveSb_EquipRepairSignBill_PDA([FromBody] JObject msg)
+        {
+            var _value = msg["msg"].ToString();
+            string msg1 = _value.ToString();
+            string[] sArray = msg1.Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries);
+            string msg2 = sArray[0].ToString();
+            string msg3 = sArray[1].ToString();
 
+            string UserName = "";
+
+            ListModels oListModels = new ListModels();
+            try
+            {
+                DLL.ClsSb_EquipRepairSignBill oBill = new DLL.ClsSb_EquipRepairSignBill();
+                List<Models.ClsSb_EquipRepairSignBillMain> lsmain = new List<Models.ClsSb_EquipRepairSignBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  
+                lsmain = oListModels.getObjectByJson_Sb_EquipRepairSignBill_PDA(msg2);
+                foreach (Models.ClsSb_EquipRepairSignBillMain oItem in lsmain)
+                {
+                    //鍗曟嵁鍙锋槸鍚﹂噸澶�
+                    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;
+                    }
+                 
+                    UserName = oItem.HMaker;  //鍒跺崟浜�
+                    oItem.HBillType = "3920";
+                    oItem.HBillSubType = "3920";                  
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HMakeDate = DBUtility.ClsPub.isStrNull(DateTime.Now.ToString("yyyy-MM-dd"));             
+                 
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }             
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                else
+                {
+                    bResult = oBill.ModifyBill(oBill.omodel.HInterID, ref DBUtility.ClsPub.sExeReturnInfo);
+                }
+                if (bResult)
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 1;
+                    objJsonResult.Message = "淇濆瓨鎴愬姛锛�";
+                    //WebAPIController.Add_Log("閫佽揣鍗曚笅鎺�", UserName, "鐢熸垚閫佽揣鍗�");
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+                else
+                {
+                    objJsonResult.code = "0";
+                    objJsonResult.count = 0;
+                    objJsonResult.Message = "淇濆瓨澶辫触锛�" + DBUtility.ClsPub.sExeReturnInfo;
+                    objJsonResult.data = 1;
+                    return objJsonResult;
+                }
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = 1;
+                return objJsonResult;
+            }
+        }
+        #endregion
+             
         #region 璁惧鏁呴殰 鐧昏/璁板綍/楠屾敹  鍙戦�佹秷鎭�
         /// <summary>
         /// 寮傚父鍙嶉 鎺ユ敹,澶勭悊,楠屾敹鍗曚繚瀛樺彂閫佹秷鎭�

--
Gitblit v1.9.1