From 82de67c48acaf472a6f8bb8b53f3f4feec9f5e54 Mon Sep 17 00:00:00 2001
From: zrg <z1873@LAPTOP-EAVL132E>
Date: 星期五, 17 十月 2025 10:42:18 +0800
Subject: [PATCH] 1

---
 WebAPI/Controllers/仓存管理/验收入库/Kf_ProductInBillController.cs |  147 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 147 insertions(+), 0 deletions(-)

diff --git "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_ProductInBillController.cs" "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_ProductInBillController.cs"
index 3673ad0..420fb66 100644
--- "a/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_ProductInBillController.cs"
+++ "b/WebAPI/Controllers/\344\273\223\345\255\230\347\256\241\347\220\206/\351\252\214\346\224\266\345\205\245\345\272\223/Kf_ProductInBillController.cs"
@@ -1652,5 +1652,152 @@
             }
         }
         #endregion
+
+        #region 鐢熶骇鍏ュ簱鍗� 瀹℃牳鍚屾鎻掍欢 璋冪敤鎺ュ彛
+        [Route("Kf_ProductInBill/Kf_ProductInBillSaveApi")]
+        [HttpPost]
+        public object Kf_ProductInBillSaveApi([FromBody] JObject sMainSub)
+        {
+            try
+            {
+                oCn.BeginTran();
+                LogService.Write("鐢熶骇鍏ュ簱鍗曞悓姝�,淇濆瓨鏂规硶鎵ц锛�" + sMainSub.ToString());
+
+                var model = sMainSub["model"].ToString();
+                var entry = sMainSub["model"]["HENTRY"].ToString();
+
+                model = "[" + model.ToString() + "]";
+                List<ClsKf_ProductInBillMain> mainList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ProductInBillMain>>(model);
+                List<ClsKf_ProductInBillSub> subList = Newtonsoft.Json.JsonConvert.DeserializeObject<List<ClsKf_ProductInBillSub>>(entry);
+
+
+                // 鍒ゆ柇 鏁版嵁搴撲腑鏄惁瀛樺湪id鍜屽崟鎹彿鐩哥瓑鐨勬墦鍗曟嵁锛屽瓨鍦紝鍒欓噸寤猴紝鍙湁id鍙风浉绛夛紝鍒欑敵璇锋柊鐨刬d鍙�
+                var ds1 = oCn.RunProcReturn($@"
+                select hmainid HInterID, 鍗曟嵁鍙� HBillNO from h_v_Kf_ProductInBillList where hmainid = {mainList[0].HInterID}
+                ", "h_v_Kf_ProductInBillList");
+
+                if (ds1.Tables[0].Rows.Count > 0 && ds1.Tables[0].Rows[0]["HInterID"] != null)
+                {
+                    if (string.Equals(ds1.Tables[0].Rows[0]["HBillNo"].ToString(), mainList[0].HBillNo, StringComparison.OrdinalIgnoreCase))
+                    {
+                        string sql = string.Empty;
+                        sql = $"delete Kf_ICStockBillMain where HinterID = {mainList[0].HInterID}";
+                        oCn.RunProc(sql);
+                        sql = $"delete Kf_ICStockBillSub where HinterID = {mainList[0].HInterID}";
+                        oCn.RunProc(sql);
+                    }
+                    else
+                    {
+                        // 閲嶆柊鐢宠HInterID
+                        var HInterID_Exch = DBUtility.ClsPub.CreateBillID("1202", ref DBUtility.ClsPub.sExeReturnInfo);
+                        mainList[0].HInterID = HInterID_Exch;
+
+                        foreach (var oSub in subList)
+                        {
+                            oSub.HInterID = HInterID_Exch;
+                        }
+
+                    }
+                }
+
+               
+
+                // 涓昏〃
+                oCn.RunProc($@"Insert Into Kf_ICStockBillMain    
+                    (HInterID,HYear,HPeriod,HBillType,HBillSubType,HDate
+	                ,HBillNo,HBillStatus,HSupID,HManagerID,HEmpID,HDeptID,HSecManagerID,HKeeperID,HRemark,HMaker,HMakeDate,HCurID,HExRate,HWHID,HInnerBillNo,HExplanation
+                    ,HChecker, HCheckDate, HSTOCKORGID)
+                    values(
+                    '{mainList[0].HInterID}',
+                    '{mainList[0].HYear}',
+                    '{mainList[0].HPeriod}',
+                    '{mainList[0].HBillType}',
+                    '{mainList[0].HBillSubType}',
+                    '{mainList[0].HDate}',
+                    '{mainList[0].HBillNo}',
+                    {mainList[0].HBillStatus},
+                    '{mainList[0].HSupID}',
+                    '{mainList[0].HManagerID}',
+                    '{mainList[0].HEmpID}',
+                    '{mainList[0].HDeptID}',
+                    '{mainList[0].HSecManagerID}',
+                    '{mainList[0].HKeeperID}',
+                    '{mainList[0].HRemark}',
+                    '{mainList[0].HMaker}',
+                    '{mainList[0].HMakeDate}',
+                    '{mainList[0].HCurID}',  
+                    '{mainList[0].HExRate}',  
+                    '{mainList[0].HWHID}',
+                    '{mainList[0].HInnerBillNo}',
+                    '{mainList[0].HExplanation}',
+                    '{mainList[0].HChecker}',
+                    '{mainList[0].HCheckDate}',
+                    {mainList[0].HSTOCKORGID}
+                    )
+                ");
+                // 瀛愯〃
+                foreach (var osub in subList)
+                {
+
+                    oCn.RunProc($@"Insert into Kf_ICStockBillSub 
+                    (HInterID,HEntryID,HMaterID,HUnitID,HQtyMust,HQty,HPrice
+	                ,HMoney,HWHID,HSPID,HRemark,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HPOOrderInterID
+                    ,HPOOrderEntryID,HPOORderBillNo,HSecUnitID,HSeOrderInterID,HSeOrderEntryID,HSeOrderBillNo,HRelationQty,HSecUnitRate,HPropertyID) 
+                    values (
+                        '{osub.HInterID}', 
+                        '{osub.HEntryID}', 
+                        '{osub.HMaterID}',
+                        '{osub.HUnitID}', 
+                        '{osub.HQtyMust}', 
+                        '{osub.HQty}',
+                        '{osub.HPrice}',
+                        '{osub.HMoney}',
+                        '{osub.HWHID}',
+                        '{osub.HSPID}',
+                        '{osub.HRemark}',
+                        '{osub.HSourceInterID}',
+                        '{osub.HSourceEntryID}',
+                        '{osub.HSourceBillNo}',
+                        '{osub.HSourceBillType}',
+                        '{osub.HPOOrderInterID}',
+                        '{osub.HPOOrderEntryID}',
+                        '{osub.HPOOrderBillNo}',
+                        '{osub.HSecUnitID}',
+                        '{osub.HSeOrderInterID}',
+                        '{osub.HSeOrderEntryID}',
+                        '{osub.HSeOrderBillNo}',
+                        '{osub.HRelationQty}',
+                        '{osub.HSecUnitRate}',
+                        '{osub.HPropertyID}'
+                    )
+                    ");
+                }
+
+                //鐢熶骇鍏ュ簱鍗曟柊澧炲洖濉敓浜ц鍗曞叧鑱旀暟閲�
+                oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMO_Add " + mainList[0].HInterID);
+                 
+                //鐢熶骇鍏ュ簱鍗曟柊澧炲洖濉敓浜ф眹鎶ュ崟鍏宠仈鏁伴噺
+                oCn.RunProc("exec h_p_Kf_UpDateRelation_ProductInToICMOReport_Add " + mainList[0].HInterID);
+
+                oCn.Commit();
+                objJsonResult.code = "1";
+                objJsonResult.count = 1;
+                objJsonResult.Message = "鍗曟嵁淇濆瓨鎴愬姛锛�";
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+            catch (Exception e)
+            {
+                LogService.Write("鐢熶骇鍏ュ簱鍗曞悓姝ュ紓甯�,淇濆瓨鏂规硶鎵ц瀹屾垚寮傚父锛�" + e.Message.ToString());
+
+                oCn.RollBack();
+                objJsonResult.code = "0";
+                objJsonResult.count = 0;
+                objJsonResult.Message = "淇濆瓨澶辫触锛�" + e.ToString();
+                objJsonResult.data = null;
+                return objJsonResult;
+            }
+        }
+        #endregion
     }
 }
\ No newline at end of file

--
Gitblit v1.9.1