From 32d83cd49fb13b621a35354c08f6ee82b4dbdb1c Mon Sep 17 00:00:00 2001
From: duhe <226547893@qq.com>
Date: 星期二, 14 十一月 2023 18:31:03 +0800
Subject: [PATCH] 销售订单:下推生产订单,保存后反写销售订单关联数量

---
 WebAPI/Controllers/生产管理/生产任务单/Sc_ICMOBillController.cs |   28 ++++++++++++++++++++++------
 1 files changed, 22 insertions(+), 6 deletions(-)

diff --git "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs" "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
index 41cadcd..775940d 100644
--- "a/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
+++ "b/WebAPI/Controllers/\347\224\237\344\272\247\347\256\241\347\220\206/\347\224\237\344\272\247\344\273\273\345\212\241\345\215\225/Sc_ICMOBillController.cs"
@@ -446,10 +446,11 @@
                 string HMaker = user;//鍒跺崟浜�
                 string HIsStockQty = mainList[0].HIsStockQty;
                 string HRemark3 = mainList[0].HRemark3;
+              
 
                 ds = oCN.RunProcReturn("select * from h_v_IF_ICMOBillList where hmainid=" + HInterID + " and 鍗曟嵁鍙�='" + HBillNo + "'", "h_v_IF_ICMOBillList");
 
-                if ((OperationType == 1 || OperationType == 2) && ds.Tables[0].Rows.Count == 0)//鏂板
+                if ((OperationType == 1 || OperationType == 2 || OperationType == 4) && ds.Tables[0].Rows.Count == 0)//鏂板
                 {
                     //涓昏〃
                     oCN.RunProc(@"Insert Into Sc_ICMOBillMain   
@@ -463,6 +464,12 @@
                     ",'" + HSeOrderBillNo + "'," + HSeOrderInterID + "," + HSeOrderEntryID + "," + HEmpID + "," + HCusID +
                     "," + HCenterID + ",0,0,0,0," + HBomID + ",'',''" +
                     ",'"+ HIsStockQty + "','"+ HRemark3 + "') ");
+
+
+                    //鍙嶅啓閿�鍞鍗曟暟鎹�
+                    ClsSc_ICMOBillSub oSub = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSc_ICMOBillSub>(msg3);
+                    string sql = "update Xs_SeOrderBillSub set HRelationQty_ICMO = ISNULL(HRelationQty_ICMO,0) + " + (oSub.HQty == null ? 0 : oSub.HQty) + " where HInterID = " + mainList[0].HSeOrderInterID + " and HEntryID = "+ mainList[0].HSeOrderEntryID;
+                    oCN.RunProc(sql);
 
                     LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",鏂板鐢熶骇璁㈠崟鍗曟嵁:" + HBillNo);
                     oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "鏂板鐢熶骇璁㈠崟鍗曟嵁锛�" + HBillNo + "','LMES-鐢熶骇璁㈠崟妯″潡','" + DBUtility.ClsPub.IPAddress + "','鏂板鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
@@ -487,6 +494,16 @@
 
                     //鍒犻櫎瀛愯〃
                     oCN.RunProc("delete from Sc_ICMOBillSub where HInterID='" + HInterID + "' and HEntryID='" + HEntryID + "'");
+
+
+                    //鍙嶅啓閿�鍞鍗曟暟鎹�
+                    ClsSc_ICMOBillSub oSub = Newtonsoft.Json.JsonConvert.DeserializeObject<ClsSc_ICMOBillSub>(msg3);
+                    string sql = "update Xs_SeOrderBillSub set " +
+                        "HRelationQty_ICMO = ISNULL(HRelationQty_ICMO,0) - " + ds.Tables[0].Rows[0]["閿�鍞暟閲�"] + " +  " + (oSub.HQty == null ? 0 : oSub.HQty) + "" +
+                        " where HInterID = " + mainList[0].HSeOrderInterID + " and HEntryID = " + mainList[0].HSeOrderEntryID;
+                    oCN.RunProc(sql);
+
+
 
                     LogService.Write("鐢ㄦ埛:" + user + ",鏃ユ湡:" + DateTime.Now + ",淇敼鐢熶骇璁㈠崟鍗曟嵁:" + HBillNo);
                     oCN.RunProc("Insert into System_log (GeginDate, userid, WorkstationName, WorkList, SystemName, NetuserName, State) select GETDATE(),'" + user + "','" + HComputerName + "','" + "淇敼鐢熶骇璁㈠崟鍗曟嵁锛�" + HBillNo + "','LMES-鐢熶骇璁㈠崟妯″潡','" + DBUtility.ClsPub.IPAddress + "','淇敼鍗曟嵁'", ref DBUtility.ClsPub.sExeReturnInfo);
@@ -569,15 +586,14 @@
                 ,HMaterID,HUnitID,HRemark,HSourceID,HDeptID,HSTATUS
                 ,HBomID,HEntryCusID,HSTOCKINORGID
 				,HSourceInterID,HSourceEntryID,HSourceBillNo,HSourceBillType,HRelationQty,HRelationMoney
-                ,HAuxQty,HAuxUnit,HWidth,HWeight,HColorRemark) 
+                ,HAuxQty,HAuxUnit,HWidth,HWeight,HColorRemark,HCusMaterName,HCusModel) 
                  values({HInterID},{HEntryID},{(oSub.HQty == null ? 0 : oSub.HQty)}
                 ,'{(oSub.HPlanBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HPlanBeginDate.ToString())}','{(oSub.HPlanEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HPlanEndDate.ToString())}'
                 ,'{(oSub.HBeginDate == null ? DateTime.Now.ToString("yyyy-MM-dd") : oSub.HBeginDate.ToString())}','{(oSub.HEndDate == null ? DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") : oSub.HEndDate.ToString())}'
                 ,{oSub.HMaterID},{oSub.HUnitID},'{oSub.HRemark}',{oSub.HSourceID},{oSub.HDeptID},{oSub.HSTATUS}
                  ,{oSub.HBomID}  ,{oSub.HCusID} ,{oSub.HSTOCKINORGID}
 	                    ,0,0,'','',0,0
-                ,{oSub.HAuxQty},{oSub.HAuxUnit},{oSub.HWidth},{oSub.HWeight},'{oSub.HColorRemark}')");
-
+                ,{oSub.HAuxQty},{oSub.HAuxUnit},{oSub.HWidth},{oSub.HWeight},'{oSub.HColorRemark}','{oSub.HCusMaterName}','{oSub.HCusModel}')");
 
             objJsonResult.code = "1";
             objJsonResult.count = 1;
@@ -1146,13 +1162,13 @@
         #region 鐢熶骇浠诲姟鍗曡幏鍙栬溅闂�
         [Route("Sc_ICMOBill/GetHDeptList")]
         [HttpGet]
-        public object GetHDeptList()
+        public object GetHDeptList(string HOrgID)
         {
             try
             {
                 DataSet oDs = new DataSet();
                 //==========
-                oDs = oCN.RunProcReturn("select HItemID,HName from Gy_Department", "Gy_Department");
+                oDs = oCN.RunProcReturn("select HItemID,HName from Gy_Department where HUSEORGID="+ HOrgID, "Gy_Department");
                 objJsonResult.code = "1";
                 objJsonResult.count = 1;
                 objJsonResult.Message = "鑾峰彇鎴愬姛锛�";

--
Gitblit v1.9.1