From af56ce9aaaebf2ea7b03c7096388ec8abf34d92c Mon Sep 17 00:00:00 2001
From: zzr99 <1940172413@qq.com>
Date: 星期五, 03 十二月 2021 17:21:50 +0800
Subject: [PATCH] 出入库单保存后,更新器具档案 状态字段

---
 WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs |  202 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 201 insertions(+), 1 deletions(-)

diff --git a/WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs b/WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs
index 3939dd1..3a37cea 100644
--- a/WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs
+++ b/WebAPI/Controllers/SBGL/Sb_EquipMaintainRuleBillController.cs
@@ -1,4 +1,5 @@
-锘縰sing System;
+锘縰sing Newtonsoft.Json.Linq;
+using System;
 using System.Collections.Generic;
 using System.Data;
 using System.Linq;
@@ -171,5 +172,204 @@
             return objJsonResult;
         }
         #endregion
+
+        #region[璁惧淇濆吇瑙勭▼缂栬緫鏃惰幏鍙栬〃澶存暟鎹甝
+        [Route("Sb_EquipMaintainRuleBill/Sb_EquipMaintainRuleBillListCheckDetai")]
+        [HttpGet]
+        public ApiResult<DataSet> Sb_EquipMaintainRuleBillListCheckDetai(string HID)
+        {
+            if (string.IsNullOrEmpty(HID))
+                return new ApiResult<DataSet> { code = -1, msg = "ID涓嶈兘涓虹┖" };
+            SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+            var dataSet = oCN.RunProcReturn("select top 1 * from Sb_EquipMaintainRuleBillMain  where HInterID= " + HID + " ", "Sb_EquipMaintainRuleBillMain");
+            if (dataSet == null || dataSet.Tables[0].Rows.Count == 0)
+                return new ApiResult<DataSet> { code = -1, msg = "涓嶅瓨鍦ㄧ偣妫�璁″垝琛�" };
+            return new ApiResult<DataSet> { code = 1, msg = "鏌ヨ鎴愬姛", data = dataSet };
+        }
+        #endregion
+
+        # region 璁惧淇濆吇瑙勭▼缂栬緫鏃惰幏鍙栬〃浣撴暟鎹柊(淇濆吇椤瑰垪琛ㄣ�侀厤浠堕」鍒楄〃)
+        [Route("Sb_EquipMaintainRuleBill/Sb_EquipMaintainRuleBillSubAndSubItem")]
+        [HttpGet]
+        public object Sb_EquipMaintainRuleBillSubAndSubItem(string HInterID)
+        {
+
+            DataSet ds, ds1;
+            List<object> list = new List<object>();
+            string Swhere = "";
+            try
+            {
+                if (HInterID != "" || HInterID != null)
+                {
+                    Swhere = " and hmainid='" + HInterID + "'";
+                }
+                else
+                {
+                    Swhere = HInterID;
+                }
+                SQLHelper.ClsCN oCN = new SQLHelper.ClsCN();
+                //鑾峰彇淇濆吇椤圭洰缂栬緫鏁版嵁
+                string sql = "select 淇濆吇椤圭洰ID HMaintainItemID,淇濆吇椤圭洰浠g爜 HMaintainItemNumber,淇濆吇椤圭洰 HMaintainItem,淇濆吇閮ㄤ綅 HMaintainPart,鍏蜂綋瑕佹眰 HClaim,璐熻矗浜篒D HManagerID,璐熻矗浜轰唬鐮� HManagerNumber,璐熻矗浜哄悕绉� HManagerName,瀛愬娉�2 HRemark from h_v_Sb_EquipMaintainRuleList where 1 = 1 " + Swhere + "";
+                ds = oCN.RunProcReturn(sql, "h_v_Sb_EquipMaintainRuleList");
+                //鑾峰彇閰嶄欢椤圭洰缂栬緫鏁版嵁
+                string sql1 = "select 閰嶄欢ID HMaterID,閰嶄欢浠g爜 HMaterNumber,閰嶄欢鍚嶇О HMaterName,鍗曚綅ID HUnitID,璁¢噺鍗曚綅浠g爜 HUnitNumber,璁¢噺鍗曚綅鍚嶇О HUnitName,鐢ㄩ噺 HQty,瀛愬娉�1 HRemark from h_v_Sb_EquipMaintainRuleList where 1 = 1 " + Swhere + "";
+                ds1 = oCN.RunProcReturn(sql1, "h_v_Sb_EquipMaintainRuleList");
+
+                list.Add(ds.Tables[0]);
+                list.Add(ds1.Tables[0]);
+                objJsonResult.code = "0";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鑾峰彇淇℃伅鎴愬姛锛�";
+                objJsonResult.list = list;
+            }
+            catch (Exception e)
+            {
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "娌℃湁杩斿洖浠讳綍璁板綍锛�" + e.ToString();
+                objJsonResult.data = null;
+            }
+            return objJsonResult;
+        }
+        #endregion
+
+        #region 璁惧淇濆吇瑙勭▼琛� 淇濆瓨/缂栬緫
+        /// <summary>
+        /// 淇濆瓨妯″叿缁翠慨鍗�
+        /// </summary>
+        /// <param name="msg"></param>
+        /// <returns></returns>
+        [Route("Sb_EquipMaintainRuleBill/SaveEquipMaintainRuleBillList")]
+        [HttpPost]
+        public object SaveEquipMaintainRuleBillList([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 msg4 = sArray[2].ToString();
+
+            string UserName = "";
+            ListModels oListModels = new ListModels();
+            try
+            {
+                DLL.ClsSb_EquipMaintainRuleBill oBill = new DLL.ClsSb_EquipMaintainRuleBill();
+                List<Models.ClsSb_EquipMaintainRuleBillMain> lsmain = new List<Models.ClsSb_EquipMaintainRuleBillMain>();
+                msg2 = msg2.Replace("\\", "");
+                msg2 = msg2.Replace("\n", "");  //\n
+                //涓昏〃
+                lsmain = oListModels.getObjectByJson_Sb_EquipMaintainRuleBillMain(msg2);
+                foreach (Models.ClsSb_EquipMaintainRuleBillMain oItem in lsmain)
+                {
+                    UserName = oItem.HMaker;  //鍒跺崟浜�
+                    oItem.HBillType = "3912";
+                    oItem.HBillSubType = "3912";
+
+                    oItem.HDate = DBUtility.ClsPub.isDate(DateTime.Now.ToString("yyyy-MM-dd"));//  --鏃ユ湡
+                    oItem.HYear = DBUtility.ClsPub.isLong(DateTime.Now.Year);
+                    oItem.HPeriod= DBUtility.ClsPub.isLong(DateTime.Now.Month);
+
+                    if (DBUtility.ClsPub.isStrNull(oItem.HDate) == "")
+                    {
+                        objJsonResult.code = "0";
+                        objJsonResult.count = 0;
+                        objJsonResult.Message = "淇濆瓨澶辫触锛佹病鏈夊崟鎹棩鏈燂紝鏃犳硶淇濆瓨锛�";
+                        objJsonResult.data = 1;
+                        return objJsonResult;
+                    }
+                    oBill.omodel = oItem;
+                }
+
+                //淇濆吇椤硅〃浣撴暟鎹�
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg3 = msg3.Substring(1, msg3.Length - 2);
+                msg3 = msg3.Replace("\\", "");
+                msg3 = msg3.Replace("\n", "");  //\n
+                //msg2 = msg2.Replace("'", "鈥�");
+                List<Models.ClsSb_EquipMaintainRuleBillSub_Item> ls = new List<Models.ClsSb_EquipMaintainRuleBillSub_Item>();
+                ls = oListModels.getObjectByJson_Sc_EquipMaintainRuleBillSub_Item(msg3);
+                int i = 0;
+                foreach (Models.ClsSb_EquipMaintainRuleBillSub_Item item in ls)
+                {
+
+                    i++;
+                    item.HEntryID = i;
+                    item.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    item.HCloseType = false;   //鍏抽棴绫诲瀷
+                    item.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                    item.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+                    item.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                    oBill.DetailColl_Pay.Add(item);
+
+                }
+                
+                
+                //閰嶄欢椤硅〃浣撴暟鎹�
+                //鎸� },{鏉ユ媶鍒嗘暟缁� //鍘绘帀銆愬拰銆�
+                msg4 = msg4.Substring(1, msg4.Length - 2);
+                msg4 = msg4.Replace("\\", "");
+                msg4 = msg4.Replace("\n", "");  //\n
+                                                //msg2 = msg2.Replace("'", "鈥�");
+                List<Models.ClsSb_EquipMaintainRuleBillSub> ls1 = new List<Models.ClsSb_EquipMaintainRuleBillSub>();
+                ls1 = oListModels.getObjectByJson_Sb_EquipMaintainRuleBillSub(msg4);
+                int j = 0;
+                foreach (Models.ClsSb_EquipMaintainRuleBillSub oItemSub in ls1)
+                {
+
+                    j++;
+                    oItemSub.HEntryID = j;
+                    //oItemSub.HCloseMan = "";       //琛屽叧闂�
+                    oItemSub.HEntryCloseDate = DBUtility.ClsPub.isDate(DateTime.Now);
+                    oItemSub.HCloseType = false;   //鍏抽棴绫诲瀷
+                                                  
+                    oItemSub.HSourceInterID = 0;     // 婧愬崟涓诲唴鐮�
+                    oItemSub.HSourceEntryID = 0;   //婧愬崟瀛愬唴鐮�
+                                                   
+                    oItemSub.HRelationQty = 0;     //鍏宠仈鏁伴噺
+                    oBill.DetailColl_Mater.Add(oItemSub);
+                }
+
+
+                //淇濆瓨
+                //淇濆瓨瀹屾瘯鍚庡鐞�
+                bool bResult;
+                if (oBill.omodel.HInterID == 0)
+                {
+                    // bResult = oBill.AddBill(ref DBUtility.ClsPub.sExeReturnInfo);
+                    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
     }
 }

--
Gitblit v1.9.1